| FFmpegKit iOS / macOS / tvOS API 6.0

Loading...
Searching...
No Matches
StreamInformation.m
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018-2022 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
22NSString* const StreamKeyIndex = @"index";
23NSString* const StreamKeyType = @"codec_type";
24NSString* const StreamKeyCodec = @"codec_name";
25NSString* const StreamKeyCodecLong = @"codec_long_name";
26NSString* const StreamKeyFormat = @"pix_fmt";
27NSString* const StreamKeyWidth = @"width";
28NSString* const StreamKeyHeight = @"height";
29NSString* const StreamKeyBitRate = @"bit_rate";
30NSString* const StreamKeySampleRate = @"sample_rate";
31NSString* const StreamKeySampleFormat = @"sample_fmt";
32NSString* const StreamKeyChannelLayout = @"channel_layout";
33NSString* const StreamKeySampleAspectRatio = @"sample_aspect_ratio";
34NSString* const StreamKeyDisplayAspectRatio = @"display_aspect_ratio";
35NSString* const StreamKeyAverageFrameRate = @"avg_frame_rate";
36NSString* const StreamKeyRealFrameRate = @"r_frame_rate";
37NSString* const StreamKeyTimeBase = @"time_base";
38NSString* const StreamKeyCodecTimeBase = @"codec_time_base";
39NSString* 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*)getCodecLong {
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 getProperty: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* allProperties = [self getAllProperties];
142 if (allProperties == nil) {
143 return nil;
144 }
145
146 return allProperties[key];
147}
148
149- (id)getProperty:(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
StreamInformation.h
StreamKeyTags
NSString *const StreamKeyTags
Definition StreamInformation.m:39
StreamKeyChannelLayout
NSString *const StreamKeyChannelLayout
Definition StreamInformation.m:32
StreamKeyFormat
NSString *const StreamKeyFormat
Definition StreamInformation.m:26
StreamKeyDisplayAspectRatio
NSString *const StreamKeyDisplayAspectRatio
Definition StreamInformation.m:34
StreamKeyType
NSString *const StreamKeyType
Definition StreamInformation.m:23
StreamKeyBitRate
NSString *const StreamKeyBitRate
Definition StreamInformation.m:29
StreamKeyHeight
NSString *const StreamKeyHeight
Definition StreamInformation.m:28
StreamKeySampleAspectRatio
NSString *const StreamKeySampleAspectRatio
Definition StreamInformation.m:33
StreamKeyCodec
NSString *const StreamKeyCodec
Definition StreamInformation.m:24
StreamKeyCodecLong
NSString *const StreamKeyCodecLong
Definition StreamInformation.m:25
StreamKeyWidth
NSString *const StreamKeyWidth
Definition StreamInformation.m:27
StreamKeyTimeBase
NSString *const StreamKeyTimeBase
Definition StreamInformation.m:37
StreamKeyIndex
NSString *const StreamKeyIndex
Definition StreamInformation.m:22
StreamKeySampleRate
NSString *const StreamKeySampleRate
Definition StreamInformation.m:30
StreamKeyRealFrameRate
NSString *const StreamKeyRealFrameRate
Definition StreamInformation.m:36
StreamKeySampleFormat
NSString *const StreamKeySampleFormat
Definition StreamInformation.m:31
StreamKeyCodecTimeBase
NSString *const StreamKeyCodecTimeBase
Definition StreamInformation.m:38
StreamKeyAverageFrameRate
NSString *const StreamKeyAverageFrameRate
Definition StreamInformation.m:35
StreamInformation
Definition StreamInformation.h:48