FFmpegKit iOS / macOS / tvOS API 5.1
MediaInformation.m
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018-2021 Taner Sener
3 *
4 * This file is part of FFmpegKit.
5 *
6 * FFmpegKit is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * FFmpegKit is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#import "MediaInformation.h"
21
22NSString* const MediaKeyFormatProperties = @"format";
23NSString* const MediaKeyFilename = @"filename";
24NSString* const MediaKeyFormat = @"format_name";
25NSString* const MediaKeyFormatLong = @"format_long_name";
26NSString* const MediaKeyStartTime = @"start_time";
27NSString* const MediaKeyDuration = @"duration";
28NSString* const MediaKeySize = @"size";
29NSString* const MediaKeyBitRate = @"bit_rate";
30NSString* const MediaKeyTags = @"tags";
31
32@implementation MediaInformation {
33
37 NSDictionary *dictionary;
38
42 NSArray *streamArray;
43
47 NSArray *chapterArray;
48
49}
50
51- (instancetype)init:(NSDictionary*)mediaDictionary withStreams:(NSArray*)streams withChapters:(NSArray*)chapters{
52 self = [super init];
53 if (self) {
54 dictionary = mediaDictionary;
55 streamArray = streams;
56 chapterArray = chapters;
57 }
58
59 return self;
60}
61
62- (NSString*)getFilename {
63 return [self getStringFormatProperty:MediaKeyFilename];
64}
65
66- (NSString*)getFormat {
67 return [self getStringFormatProperty:MediaKeyFormat];
68}
69
70- (NSString*)getLongFormat {
71 return [self getStringFormatProperty:MediaKeyFormatLong];
72}
73
74- (NSString*)getStartTime {
75 return [self getStringFormatProperty:MediaKeyStartTime];
76}
77
78- (NSString*)getDuration {
79 return [self getStringFormatProperty:MediaKeyDuration];
80}
81
82- (NSString*)getSize {
83 return [self getStringFormatProperty:MediaKeySize];
84}
85
86- (NSString*)getBitrate {
87 return [self getStringFormatProperty:MediaKeyBitRate];
88}
89
90- (NSDictionary*)getTags {
91 return [self getFormatProperty:MediaKeyTags];
92}
93
94- (NSArray*)getStreams {
95 return streamArray;
96}
97
98- (NSArray*)getChapters {
99 return chapterArray;
100}
101
102- (NSString*)getStringProperty:(NSString*)key {
103 NSDictionary* allProperties = [self getAllProperties];
104 if (allProperties == nil) {
105 return nil;
106 }
107
108 return allProperties[key];
109}
110
111- (NSNumber*)getNumberProperty:(NSString*)key {
112 NSDictionary* allProperties = [self getAllProperties];
113 if (allProperties == nil) {
114 return nil;
115 }
116
117 return allProperties[key];
118}
119
120- (id)getProperty:(NSString*)key {
121 NSDictionary* allProperties = [self getAllProperties];
122 if (allProperties == nil) {
123 return nil;
124 }
125
126 return allProperties[key];
127}
128
129- (NSString*)getStringFormatProperty:(NSString*)key {
130 NSDictionary* formatProperties = [self getFormatProperties];
131 if (formatProperties == nil) {
132 return nil;
133 }
134
135 return formatProperties[key];
136}
137
138- (NSNumber*)getNumberFormatProperty:(NSString*)key {
139 NSDictionary* formatProperties = [self getFormatProperties];
140 if (formatProperties == nil) {
141 return nil;
142 }
143
144 return formatProperties[key];
145}
146
147- (id)getFormatProperty:(NSString*)key {
148 NSDictionary* formatProperties = [self getFormatProperties];
149 if (formatProperties == nil) {
150 return nil;
151 }
152
153 return formatProperties[key];
154}
155
156- (NSDictionary*)getFormatProperties {
157 return dictionary[MediaKeyFormatProperties];
158}
159
160- (NSDictionary*)getAllProperties {
161 return dictionary;
162}
163
164@end
NSString *const MediaKeyBitRate
NSArray * chapterArray
NSString *const MediaKeyDuration
NSArray * streamArray
NSString *const MediaKeyTags
NSString *const MediaKeyFormatProperties
NSString *const MediaKeyFormat
NSString *const MediaKeyFormatLong
NSString *const MediaKeyStartTime
NSString *const MediaKeySize
NSString *const MediaKeyFilename