MediaInformation.m
Go to the documentation of this file.
/*
* Copyright (c) 2018-2021 Taner Sener
*
* This file is part of FFmpegKit.
*
* FFmpegKit is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FFmpegKit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/
#import "MediaInformation.h"
NSString* const MediaKeyMediaProperties = @"format";
NSString* const MediaKeyFilename = @"filename";
NSString* const MediaKeyFormat = @"format_name";
NSString* const MediaKeyFormatLong = @"format_long_name";
NSString* const MediaKeyStartTime = @"start_time";
NSString* const MediaKeyDuration = @"duration";
NSString* const MediaKeySize = @"size";
NSString* const MediaKeyBitRate = @"bit_rate";
NSString* const MediaKeyTags = @"tags";
@implementation MediaInformation {
NSDictionary *dictionary;
NSArray *streamArray;
}
- (instancetype)init:(NSDictionary*)mediaDictionary withStreams:(NSArray*)streams{
self = [super init];
if (self) {
dictionary = mediaDictionary;
streamArray = streams;
}
return self;
}
- (NSString*)getFilename {
return [self getStringProperty:MediaKeyFilename];
}
- (NSString*)getFormat {
return [self getStringProperty:MediaKeyFormat];
}
- (NSString*)getLongFormat {
return [self getStringProperty:MediaKeyFormatLong];
}
- (NSString*)getStartTime {
return [self getStringProperty:MediaKeyStartTime];
}
- (NSString*)getDuration {
return [self getStringProperty:MediaKeyDuration];
}
- (NSString*)getSize {
return [self getStringProperty:MediaKeySize];
}
- (NSString*)getBitrate {
return [self getStringProperty:MediaKeyBitRate];
}
- (NSDictionary*)getTags {
return [self getProperties:MediaKeyTags];
}
- (NSArray*)getStreams {
return streamArray;
}
- (NSString*)getStringProperty:(NSString*)key {
NSDictionary* mediaProperties = [self getMediaProperties];
if (mediaProperties == nil) {
return nil;
}
return mediaProperties[key];
}
- (NSNumber*)getNumberProperty:(NSString*)key {
NSDictionary* mediaProperties = [self getMediaProperties];
if (mediaProperties == nil) {
return nil;
}
return mediaProperties[key];
}
- (NSDictionary*)getProperties:(NSString*)key {
NSDictionary* mediaProperties = [self getMediaProperties];
if (mediaProperties == nil) {
return nil;
}
return mediaProperties[key];
}
- (NSDictionary*)getMediaProperties {
return dictionary[MediaKeyMediaProperties];
}
- (NSDictionary*)getAllProperties {
return dictionary;
}
@end
MediaInformation.h
MediaKeyBitRate
NSString *const MediaKeyBitRate
Definition: MediaInformation.m:29
MediaKeyDuration
NSString *const MediaKeyDuration
Definition: MediaInformation.m:27
streamArray
NSArray * streamArray
Definition: MediaInformation.m:32
MediaKeyTags
NSString *const MediaKeyTags
Definition: MediaInformation.m:30
MediaKeyFormat
NSString *const MediaKeyFormat
Definition: MediaInformation.m:24
MediaKeyFormatLong
NSString *const MediaKeyFormatLong
Definition: MediaInformation.m:25
MediaKeyStartTime
NSString *const MediaKeyStartTime
Definition: MediaInformation.m:26
MediaKeySize
NSString *const MediaKeySize
Definition: MediaInformation.m:28
MediaKeyFilename
NSString *const MediaKeyFilename
Definition: MediaInformation.m:23
MediaKeyMediaProperties
NSString *const MediaKeyMediaProperties
Definition: MediaInformation.m:22
MediaInformation
Definition: MediaInformation.h:40