-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathXRVideoCardRun.m
More file actions
executable file
·67 lines (57 loc) · 1.94 KB
/
XRVideoCardRun.m
File metadata and controls
executable file
·67 lines (57 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
// XRVideoCardRun.m
// InstrumentsParser
//
// Created by baidu on 14/12/8.
// Copyright (c) 2014年 ___bidu___. All rights reserved.
//
#import "XRVideoCardRun.h"
@implementation XRVideoCardRun
- (id)initWithCoder:(NSCoder *)decoder
{
if((self = [super initWithCoder:decoder]))
{
sampleData = [decoder decodeObject];
[decoder decodeObject];//id
[decoder decodeObject];//id
[decoder decodeObject];//id
[decoder decodeObject];//id
}
return self;
}
- (NSString *)description
{
NSString * baseResult = [super description];
NSMutableString *result = [NSMutableString stringWithFormat:@"XRRun:%@\n", baseResult];
[result appendFormat:@"XRVideoCardRunSampleData:%@\n", sampleData];
return result;
}
- (NSString *) toJsonString
{
NSMutableArray *newArray = [[NSMutableArray alloc] init];
for(NSUInteger i=0; i<[sampleData count]; i++){
NSDictionary *data = sampleData[i];
double relativeTimestamp = [data[@"XRVideoCardRunTimeStamp"] doubleValue];
double seconds = relativeTimestamp / 1000.0 / 1000.0;
NSTimeInterval timestamp = startTime + seconds;
int fps = [data[@"FramesPerSecond"] intValue];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
[dict setObject:[NSNumber numberWithDouble:timestamp] forKey:@"XRVideoCardRunTimeStamp"];
[dict setObject:[NSNumber numberWithInt:fps] forKey:@"FramesPerSecond"];
newArray[i] = dict;
//NSLog(@"%@", newArray[i]);
}
NSError *error = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:newArray options:NSJSONWritingPrettyPrinted error:&error];
if([jsonData length] >0 && error == nil){
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
return jsonString;
}else{
return nil;
}
}
- (double) getStartTime
{
return startTime;
}
@end