30 }
@catch (NSException *exception) {
31 NSLog(
@"MediaInformation parsing failed: %@.\n", [NSString stringWithFormat:
@"%@\n%@", [exception userInfo], [exception callStackSymbols]]);
38 NSData *jsonData = [ffprobeJsonOutput dataUsingEncoding:NSUTF8StringEncoding];
39 NSDictionary *jsonDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:kNilOptions error:&error];
41 @throw [NSException exceptionWithName:@"ParsingException" reason:[NSString stringWithFormat:@"%ld",(long)[error code]] userInfo:[error userInfo]];
43 if (jsonDictionary == nil) {
47 NSArray* jsonStreamArray = [jsonDictionary objectForKey:MediaInformationJsonParserKeyStreams];
48 NSMutableArray *
streamArray = [[NSMutableArray alloc] init];
49 for(
int i = 0; i<jsonStreamArray.count; i++) {
50 NSDictionary *streamDictionary = [jsonStreamArray objectAtIndex:i];
54 NSArray* jsonChapterArray = [jsonDictionary objectForKey:MediaInformationJsonParserKeyChapters];
55 NSMutableArray *
chapterArray = [[NSMutableArray alloc] init];
56 for(
int i = 0; i<jsonChapterArray.count; i++) {
57 NSDictionary *chapterDictionary = [jsonChapterArray objectAtIndex:i];
58 [chapterArray addObject:[[
Chapter alloc] init:chapterDictionary]];
61 return [[
MediaInformation alloc] init:jsonDictionary withStreams:streamArray withChapters:chapterArray];