FFmpegKit iOS / macOS / tvOS API  4.4
StreamInformation.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 "StreamInformation.h"
21 
22 NSString* const StreamKeyIndex = @"index";
23 NSString* const StreamKeyType = @"codec_type";
24 NSString* const StreamKeyCodec = @"codec_name";
25 NSString* const StreamKeyCodecLong = @"codec_long_name";
26 NSString* const StreamKeyFormat = @"pix_fmt";
27 NSString* const StreamKeyWidth = @"width";
28 NSString* const StreamKeyHeight = @"height";
29 NSString* const StreamKeyBitRate = @"bit_rate";
30 NSString* const StreamKeySampleRate = @"sample_rate";
31 NSString* const StreamKeySampleFormat = @"sample_fmt";
32 NSString* const StreamKeyChannelLayout = @"channel_layout";
33 NSString* const StreamKeySampleAspectRatio = @"sample_aspect_ratio";
34 NSString* const StreamKeyDisplayAspectRatio = @"display_aspect_ratio";
35 NSString* const StreamKeyAverageFrameRate = @"avg_frame_rate";
36 NSString* const StreamKeyRealFrameRate = @"r_frame_rate";
37 NSString* const StreamKeyTimeBase = @"time_base";
38 NSString* const StreamKeyCodecTimeBase = @"codec_time_base";
39 NSString* const StreamKeyTags = @"tags";
40 
41 @implementation StreamInformation {
42 
46  NSDictionary *dictionary;
47 
48 }
49 
50 - (instancetype)init:(NSDictionary*)streamDictionary {
51  self = [super init];
52  if (self) {
53  dictionary = streamDictionary;
54  }
55 
56  return self;
57 }
58 
59 - (NSNumber*)getIndex {
60  return [self getNumberProperty:StreamKeyIndex];
61 }
62 
63 - (NSString*)getType {
64  return [self getStringProperty:StreamKeyType];
65 }
66 
67 - (NSString*)getCodec {
68  return [self getStringProperty:StreamKeyCodec];
69 }
70 
71 - (NSString*)getFullCodec {
72  return [self getStringProperty:StreamKeyCodecLong];
73 }
74 
75 - (NSString*)getFormat {
76  return [self getStringProperty:StreamKeyFormat];
77 }
78 
79 - (NSNumber*)getWidth {
80  return [self getNumberProperty:StreamKeyWidth];
81 }
82 
83 - (NSNumber*)getHeight {
84  return [self getNumberProperty:StreamKeyHeight];
85 }
86 
87 - (NSString*)getBitrate {
88  return [self getStringProperty:StreamKeyBitRate];
89 }
90 
91 - (NSString*)getSampleRate {
92  return [self getStringProperty:StreamKeySampleRate];
93 }
94 
95 - (NSString*)getSampleFormat {
96  return [self getStringProperty:StreamKeySampleFormat];
97 }
98 
99 - (NSString*)getChannelLayout {
100  return [self getStringProperty:StreamKeyChannelLayout];
101 }
102 
103 - (NSString*)getSampleAspectRatio {
104  return [self getStringProperty:StreamKeySampleAspectRatio];
105 }
106 
107 - (NSString*)getDisplayAspectRatio {
108  return [self getStringProperty:StreamKeyDisplayAspectRatio];
109 }
110 
111 - (NSString*)getAverageFrameRate {
112  return [self getStringProperty:StreamKeyAverageFrameRate];
113 }
114 
115 - (NSString*)getRealFrameRate {
116  return [self getStringProperty:StreamKeyRealFrameRate];
117 }
118 
119 - (NSString*)getTimeBase {
120  return [self getStringProperty:StreamKeyTimeBase];
121 }
122 
123 - (NSString*)getCodecTimeBase {
124  return [self getStringProperty:StreamKeyCodecTimeBase];
125 }
126 
127 - (NSDictionary*)getTags {
128  return [self getProperties:StreamKeyTags];
129 }
130 
131 - (NSString*)getStringProperty:(NSString*)key {
132  NSDictionary* allProperties = [self getAllProperties];
133  if (allProperties == nil) {
134  return nil;
135  }
136 
137  return allProperties[key];
138 }
139 
140 - (NSNumber*)getNumberProperty:(NSString*)key {
141  NSDictionary* mediaProperties = [self getAllProperties];
142  if (mediaProperties == nil) {
143  return nil;
144  }
145 
146  return mediaProperties[key];
147 }
148 
149 - (NSDictionary*)getProperties:(NSString*)key {
150  NSDictionary* allProperties = [self getAllProperties];
151  if (allProperties == nil) {
152  return nil;
153  }
154 
155  return allProperties[key];
156 }
157 
158 - (NSDictionary*)getAllProperties {
159  return dictionary;
160 }
161 
162 @end
NSString *const StreamKeyTags
NSString *const StreamKeyChannelLayout
NSString *const StreamKeyFormat
NSString *const StreamKeyDisplayAspectRatio
NSString *const StreamKeyType
NSString *const StreamKeyBitRate
NSString *const StreamKeyHeight
NSString *const StreamKeySampleAspectRatio
NSString *const StreamKeyCodec
NSString *const StreamKeyCodecLong
NSString *const StreamKeyWidth
NSString *const StreamKeyTimeBase
NSString *const StreamKeyIndex
NSString *const StreamKeySampleRate
NSString *const StreamKeyRealFrameRate
NSString *const StreamKeySampleFormat
NSString *const StreamKeyCodecTimeBase
NSString *const StreamKeyAverageFrameRate