refactor media information classes
This commit is contained in:
parent
6b09e0dfed
commit
eac6cd5a06
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Taner Sener
|
||||
* Copyright (c) 2021-2022 Taner Sener
|
||||
*
|
||||
* This file is part of FFmpegKit.
|
||||
*
|
||||
@ -63,7 +63,7 @@ public class Chapter {
|
||||
}
|
||||
|
||||
public JSONObject getTags() {
|
||||
return getProperties(KEY_TAGS);
|
||||
return getProperty(KEY_TAGS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,13 +73,13 @@ public class Chapter {
|
||||
* @return chapter property as string or null if the key is not found
|
||||
*/
|
||||
public String getStringProperty(final String key) {
|
||||
JSONObject chapterProperties = getAllProperties();
|
||||
if (chapterProperties == null) {
|
||||
JSONObject allProperties = getAllProperties();
|
||||
if (allProperties == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (chapterProperties.has(key)) {
|
||||
return chapterProperties.optString(key);
|
||||
if (allProperties.has(key)) {
|
||||
return allProperties.optString(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -92,31 +92,31 @@ public class Chapter {
|
||||
* @return chapter property as Long or null if the key is not found
|
||||
*/
|
||||
public Long getNumberProperty(String key) {
|
||||
JSONObject chapterProperties = getAllProperties();
|
||||
if (chapterProperties == null) {
|
||||
JSONObject allProperties = getAllProperties();
|
||||
if (allProperties == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (chapterProperties.has(key)) {
|
||||
return chapterProperties.optLong(key);
|
||||
if (allProperties.has(key)) {
|
||||
return allProperties.optLong(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chapter properties associated with the key.
|
||||
* Returns the chapter property associated with the key.
|
||||
*
|
||||
* @param key properties key
|
||||
* @return chapter properties as a JSONObject or null if the key is not found
|
||||
* @param key property key
|
||||
* @return chapter property as a JSONObject or null if the key is not found
|
||||
*/
|
||||
public JSONObject getProperties(String key) {
|
||||
JSONObject chapterProperties = getAllProperties();
|
||||
if (chapterProperties == null) {
|
||||
public JSONObject getProperty(String key) {
|
||||
JSONObject allProperties = getAllProperties();
|
||||
if (allProperties == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return chapterProperties.optJSONObject(key);
|
||||
return allProperties.optJSONObject(key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2021 Taner Sener
|
||||
* Copyright (c) 2018-2022 Taner Sener
|
||||
*
|
||||
* This file is part of FFmpegKit.
|
||||
*
|
||||
@ -29,7 +29,7 @@ import java.util.List;
|
||||
public class MediaInformation {
|
||||
|
||||
/* COMMON KEYS */
|
||||
public static final String KEY_MEDIA_PROPERTIES = "format";
|
||||
public static final String KEY_FORMAT_PROPERTIES = "format";
|
||||
public static final String KEY_FILENAME = "filename";
|
||||
public static final String KEY_FORMAT = "format_name";
|
||||
public static final String KEY_FORMAT_LONG = "format_long_name";
|
||||
@ -66,7 +66,7 @@ public class MediaInformation {
|
||||
* @return media file name
|
||||
*/
|
||||
public String getFilename() {
|
||||
return getStringProperty(KEY_FILENAME);
|
||||
return getStringFormatProperty(KEY_FILENAME);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,7 +75,7 @@ public class MediaInformation {
|
||||
* @return media format
|
||||
*/
|
||||
public String getFormat() {
|
||||
return getStringProperty(KEY_FORMAT);
|
||||
return getStringFormatProperty(KEY_FORMAT);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,7 +84,7 @@ public class MediaInformation {
|
||||
* @return media long format
|
||||
*/
|
||||
public String getLongFormat() {
|
||||
return getStringProperty(KEY_FORMAT_LONG);
|
||||
return getStringFormatProperty(KEY_FORMAT_LONG);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,7 +93,7 @@ public class MediaInformation {
|
||||
* @return media duration in "seconds.microseconds" format
|
||||
*/
|
||||
public String getDuration() {
|
||||
return getStringProperty(KEY_DURATION);
|
||||
return getStringFormatProperty(KEY_DURATION);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -102,7 +102,7 @@ public class MediaInformation {
|
||||
* @return media start time in milliseconds
|
||||
*/
|
||||
public String getStartTime() {
|
||||
return getStringProperty(KEY_START_TIME);
|
||||
return getStringFormatProperty(KEY_START_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,7 +111,7 @@ public class MediaInformation {
|
||||
* @return media size in bytes
|
||||
*/
|
||||
public String getSize() {
|
||||
return getStringProperty(KEY_SIZE);
|
||||
return getStringFormatProperty(KEY_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -120,16 +120,16 @@ public class MediaInformation {
|
||||
* @return media bitrate in kb/s
|
||||
*/
|
||||
public String getBitrate() {
|
||||
return getStringProperty(KEY_BIT_RATE);
|
||||
return getStringFormatProperty(KEY_BIT_RATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all tags.
|
||||
*
|
||||
* @return tags dictionary
|
||||
* @return tags as a JSONObject
|
||||
*/
|
||||
public JSONObject getTags() {
|
||||
return getProperties(KEY_TAGS);
|
||||
return getFormatProperty(KEY_TAGS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -151,65 +151,118 @@ public class MediaInformation {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the media property associated with the key.
|
||||
* Returns the property associated with the key.
|
||||
*
|
||||
* @param key property key
|
||||
* @return media property as string or null if the key is not found
|
||||
* @return property as string or null if the key is not found
|
||||
*/
|
||||
public String getStringProperty(final String key) {
|
||||
JSONObject mediaProperties = getMediaProperties();
|
||||
if (mediaProperties == null) {
|
||||
JSONObject allProperties = getAllProperties();
|
||||
if (allProperties == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (mediaProperties.has(key)) {
|
||||
return mediaProperties.optString(key);
|
||||
if (allProperties.has(key)) {
|
||||
return allProperties.optString(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the media property associated with the key.
|
||||
* Returns the property associated with the key.
|
||||
*
|
||||
* @param key property key
|
||||
* @return media property as Long or null if the key is not found
|
||||
* @return property as Long or null if the key is not found
|
||||
*/
|
||||
public Long getNumberProperty(String key) {
|
||||
JSONObject mediaProperties = getMediaProperties();
|
||||
if (mediaProperties == null) {
|
||||
JSONObject allProperties = getAllProperties();
|
||||
if (allProperties == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (mediaProperties.has(key)) {
|
||||
return mediaProperties.optLong(key);
|
||||
if (allProperties.has(key)) {
|
||||
return allProperties.optLong(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the media properties associated with the key.
|
||||
* Returns the property associated with the key.
|
||||
*
|
||||
* @param key properties key
|
||||
* @return media properties as a JSONObject or null if the key is not found
|
||||
* @param key property key
|
||||
* @return property as a JSONObject or null if the key is not found
|
||||
*/
|
||||
public JSONObject getProperties(String key) {
|
||||
JSONObject mediaProperties = getMediaProperties();
|
||||
if (mediaProperties == null) {
|
||||
public JSONObject getProperty(String key) {
|
||||
JSONObject allProperties = getAllProperties();
|
||||
if (allProperties == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return mediaProperties.optJSONObject(key);
|
||||
return allProperties.optJSONObject(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all media properties.
|
||||
* Returns the format property associated with the key.
|
||||
*
|
||||
* @return all media properties as a JSONObject or null if no media properties are defined
|
||||
* @param key property key
|
||||
* @return format property as string or null if the key is not found
|
||||
*/
|
||||
public JSONObject getMediaProperties() {
|
||||
return jsonObject.optJSONObject(KEY_MEDIA_PROPERTIES);
|
||||
public String getStringFormatProperty(final String key) {
|
||||
JSONObject formatProperties = getFormatProperties();
|
||||
if (formatProperties == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (formatProperties.has(key)) {
|
||||
return formatProperties.optString(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the format property associated with the key.
|
||||
*
|
||||
* @param key property key
|
||||
* @return format property as Long or null if the key is not found
|
||||
*/
|
||||
public Long getNumberFormatProperty(String key) {
|
||||
JSONObject formatProperties = getFormatProperties();
|
||||
if (formatProperties == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (formatProperties.has(key)) {
|
||||
return formatProperties.optLong(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the format property associated with the key.
|
||||
*
|
||||
* @param key property key
|
||||
* @return format property as a JSONObject or null if the key is not found
|
||||
*/
|
||||
public JSONObject getFormatProperty(String key) {
|
||||
JSONObject formatProperties = getFormatProperties();
|
||||
if (formatProperties == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return formatProperties.optJSONObject(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all format properties defined.
|
||||
*
|
||||
* @return all format properties as a JSONObject or null if no format properties are defined
|
||||
*/
|
||||
public JSONObject getFormatProperties() {
|
||||
return jsonObject.optJSONObject(KEY_FORMAT_PROPERTIES);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2021 Taner Sener
|
||||
* Copyright (c) 2018-2022 Taner Sener
|
||||
*
|
||||
* This file is part of FFmpegKit.
|
||||
*
|
||||
@ -214,7 +214,7 @@ public class StreamInformation {
|
||||
* @return tags object
|
||||
*/
|
||||
public JSONObject getTags() {
|
||||
return getProperties(KEY_TAGS);
|
||||
return getProperty(KEY_TAGS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -224,13 +224,13 @@ public class StreamInformation {
|
||||
* @return stream property as string or null if the key is not found
|
||||
*/
|
||||
public String getStringProperty(final String key) {
|
||||
JSONObject mediaProperties = getAllProperties();
|
||||
if (mediaProperties == null) {
|
||||
JSONObject allProperties = getAllProperties();
|
||||
if (allProperties == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (mediaProperties.has(key)) {
|
||||
return mediaProperties.optString(key);
|
||||
if (allProperties.has(key)) {
|
||||
return allProperties.optString(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -243,31 +243,31 @@ public class StreamInformation {
|
||||
* @return stream property as Long or null if the key is not found
|
||||
*/
|
||||
public Long getNumberProperty(String key) {
|
||||
JSONObject mediaProperties = getAllProperties();
|
||||
if (mediaProperties == null) {
|
||||
JSONObject allProperties = getAllProperties();
|
||||
if (allProperties == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (mediaProperties.has(key)) {
|
||||
return mediaProperties.optLong(key);
|
||||
if (allProperties.has(key)) {
|
||||
return allProperties.optLong(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stream properties associated with the key.
|
||||
* Returns the stream property associated with the key.
|
||||
*
|
||||
* @param key properties key
|
||||
* @return stream properties as a JSONObject or null if the key is not found
|
||||
* @param key property key
|
||||
* @return stream property as a JSONObject or null if the key is not found
|
||||
*/
|
||||
public JSONObject getProperties(String key) {
|
||||
JSONObject mediaProperties = getAllProperties();
|
||||
if (mediaProperties == null) {
|
||||
public JSONObject getProperty(String key) {
|
||||
JSONObject allProperties = getAllProperties();
|
||||
if (allProperties == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return mediaProperties.optJSONObject(key);
|
||||
return allProperties.optJSONObject(key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Taner Sener
|
||||
* Copyright (c) 2021-2022 Taner Sener
|
||||
*
|
||||
* This file is part of FFmpegKit.
|
||||
*
|
||||
@ -66,11 +66,11 @@ extern NSString* const ChapterKeyTags;
|
||||
- (NSNumber*)getNumberProperty:(NSString*)key;
|
||||
|
||||
/**
|
||||
* Returns the chapter properties associated with the key.
|
||||
* Returns the chapter property associated with the key.
|
||||
*
|
||||
* @return chapter properties in a dictionary or nil if the key is not found
|
||||
* @return chapter property as id or nil if the key is not found
|
||||
*/
|
||||
- (NSDictionary*)getProperties:(NSString*)key;
|
||||
- (id)getProperty:(NSString*)key;
|
||||
|
||||
/**
|
||||
* Returns all chapter properties defined.
|
||||
|
@ -70,7 +70,7 @@ NSString* const ChapterKeyTags = @"tags";
|
||||
}
|
||||
|
||||
- (NSDictionary*)getTags {
|
||||
return [self getProperties:ChapterKeyTags];
|
||||
return [self getProperty:ChapterKeyTags];
|
||||
}
|
||||
|
||||
- (NSString*)getStringProperty:(NSString*)key {
|
||||
@ -83,15 +83,15 @@ NSString* const ChapterKeyTags = @"tags";
|
||||
}
|
||||
|
||||
- (NSNumber*)getNumberProperty:(NSString*)key {
|
||||
NSDictionary* mediaProperties = [self getAllProperties];
|
||||
if (mediaProperties == nil) {
|
||||
NSDictionary* allProperties = [self getAllProperties];
|
||||
if (allProperties == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
return mediaProperties[key];
|
||||
return allProperties[key];
|
||||
}
|
||||
|
||||
- (NSDictionary*)getProperties:(NSString*)key {
|
||||
- (id)getProperty:(NSString*)key {
|
||||
NSDictionary* allProperties = [self getAllProperties];
|
||||
if (allProperties == nil) {
|
||||
return nil;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2021 Taner Sener
|
||||
* Copyright (c) 2018-2022 Taner Sener
|
||||
*
|
||||
* This file is part of FFmpegKit.
|
||||
*
|
||||
@ -112,32 +112,53 @@ extern NSString* const MediaKeyTags;
|
||||
- (NSArray*)getChapters;
|
||||
|
||||
/**
|
||||
* Returns the media property associated with the key.
|
||||
* Returns the property associated with the key.
|
||||
*
|
||||
* @return media property as string or nil if the key is not found
|
||||
* @return property as string or nil if the key is not found
|
||||
*/
|
||||
- (NSString*)getStringProperty:(NSString*)key;
|
||||
|
||||
/**
|
||||
* Returns the media property associated with the key.
|
||||
* Returns the property associated with the key.
|
||||
*
|
||||
* @return media property as number or nil if the key is not found
|
||||
* @return property as number or nil if the key is not found
|
||||
*/
|
||||
- (NSNumber*)getNumberProperty:(NSString*)key;
|
||||
|
||||
/**
|
||||
* Returns the media properties associated with the key.
|
||||
* Returns the property associated with the key.
|
||||
*
|
||||
* @return media properties in a dictionary or nil if the key is not found
|
||||
* @return property as id or nil if the key is not found
|
||||
*/
|
||||
- (NSDictionary*)getProperties:(NSString*)key;
|
||||
- (id)getProperty:(NSString*)key;
|
||||
|
||||
/**
|
||||
* Returns all media properties.
|
||||
* Returns the format property associated with the key.
|
||||
*
|
||||
* @return all media properties in a dictionary or nil if no media properties are defined
|
||||
* @return format property as string or nil if the key is not found
|
||||
*/
|
||||
- (NSString*)getStringFormatProperty:(NSString*)key;
|
||||
|
||||
/**
|
||||
* Returns the format property associated with the key.
|
||||
*
|
||||
* @return format property as number or nil if the key is not found
|
||||
*/
|
||||
- (NSNumber*)getNumberFormatProperty:(NSString*)key;
|
||||
|
||||
/**
|
||||
* Returns the format property associated with the key.
|
||||
*
|
||||
* @return format property as id or nil if the key is not found
|
||||
*/
|
||||
- (NSDictionary*)getMediaProperties;
|
||||
- (id)getFormatProperty:(NSString*)key;
|
||||
|
||||
/**
|
||||
* Returns all format properties defined.
|
||||
*
|
||||
* @return all format properties in a dictionary or nil if no format properties are defined
|
||||
*/
|
||||
- (NSDictionary*)getFormatProperties;
|
||||
|
||||
/**
|
||||
* Returns all properties defined.
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#import "MediaInformation.h"
|
||||
|
||||
NSString* const MediaKeyMediaProperties = @"format";
|
||||
NSString* const MediaKeyFormatProperties = @"format";
|
||||
NSString* const MediaKeyFilename = @"filename";
|
||||
NSString* const MediaKeyFormat = @"format_name";
|
||||
NSString* const MediaKeyFormatLong = @"format_long_name";
|
||||
@ -60,35 +60,35 @@ NSString* const MediaKeyTags = @"tags";
|
||||
}
|
||||
|
||||
- (NSString*)getFilename {
|
||||
return [self getStringProperty:MediaKeyFilename];
|
||||
return [self getStringFormatProperty:MediaKeyFilename];
|
||||
}
|
||||
|
||||
- (NSString*)getFormat {
|
||||
return [self getStringProperty:MediaKeyFormat];
|
||||
return [self getStringFormatProperty:MediaKeyFormat];
|
||||
}
|
||||
|
||||
- (NSString*)getLongFormat {
|
||||
return [self getStringProperty:MediaKeyFormatLong];
|
||||
return [self getStringFormatProperty:MediaKeyFormatLong];
|
||||
}
|
||||
|
||||
- (NSString*)getStartTime {
|
||||
return [self getStringProperty:MediaKeyStartTime];
|
||||
return [self getStringFormatProperty:MediaKeyStartTime];
|
||||
}
|
||||
|
||||
- (NSString*)getDuration {
|
||||
return [self getStringProperty:MediaKeyDuration];
|
||||
return [self getStringFormatProperty:MediaKeyDuration];
|
||||
}
|
||||
|
||||
- (NSString*)getSize {
|
||||
return [self getStringProperty:MediaKeySize];
|
||||
return [self getStringFormatProperty:MediaKeySize];
|
||||
}
|
||||
|
||||
- (NSString*)getBitrate {
|
||||
return [self getStringProperty:MediaKeyBitRate];
|
||||
return [self getStringFormatProperty:MediaKeyBitRate];
|
||||
}
|
||||
|
||||
- (NSDictionary*)getTags {
|
||||
return [self getProperties:MediaKeyTags];
|
||||
return [self getFormatProperty:MediaKeyTags];
|
||||
}
|
||||
|
||||
- (NSArray*)getStreams {
|
||||
@ -100,34 +100,61 @@ NSString* const MediaKeyTags = @"tags";
|
||||
}
|
||||
|
||||
- (NSString*)getStringProperty:(NSString*)key {
|
||||
NSDictionary* mediaProperties = [self getMediaProperties];
|
||||
if (mediaProperties == nil) {
|
||||
NSDictionary* allProperties = [self getAllProperties];
|
||||
if (allProperties == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
return mediaProperties[key];
|
||||
return allProperties[key];
|
||||
}
|
||||
|
||||
- (NSNumber*)getNumberProperty:(NSString*)key {
|
||||
NSDictionary* mediaProperties = [self getMediaProperties];
|
||||
if (mediaProperties == nil) {
|
||||
NSDictionary* allProperties = [self getAllProperties];
|
||||
if (allProperties == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
return mediaProperties[key];
|
||||
return allProperties[key];
|
||||
}
|
||||
|
||||
- (NSDictionary*)getProperties:(NSString*)key {
|
||||
NSDictionary* mediaProperties = [self getMediaProperties];
|
||||
if (mediaProperties == nil) {
|
||||
- (id)getProperty:(NSString*)key {
|
||||
NSDictionary* allProperties = [self getAllProperties];
|
||||
if (allProperties == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
return mediaProperties[key];
|
||||
return allProperties[key];
|
||||
}
|
||||
|
||||
- (NSDictionary*)getMediaProperties {
|
||||
return dictionary[MediaKeyMediaProperties];
|
||||
- (NSString*)getStringFormatProperty:(NSString*)key {
|
||||
NSDictionary* formatProperties = [self getFormatProperties];
|
||||
if (formatProperties == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
return formatProperties[key];
|
||||
}
|
||||
|
||||
- (NSNumber*)getNumberFormatProperty:(NSString*)key {
|
||||
NSDictionary* formatProperties = [self getFormatProperties];
|
||||
if (formatProperties == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
return formatProperties[key];
|
||||
}
|
||||
|
||||
- (id)getFormatProperty:(NSString*)key {
|
||||
NSDictionary* formatProperties = [self getFormatProperties];
|
||||
if (formatProperties == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
return formatProperties[key];
|
||||
}
|
||||
|
||||
- (NSDictionary*)getFormatProperties {
|
||||
return dictionary[MediaKeyFormatProperties];
|
||||
}
|
||||
|
||||
- (NSDictionary*)getAllProperties {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2021 Taner Sener
|
||||
* Copyright (c) 2018-2022 Taner Sener
|
||||
*
|
||||
* This file is part of FFmpegKit.
|
||||
*
|
||||
@ -189,11 +189,11 @@ extern NSString* const StreamKeyTags;
|
||||
- (NSNumber*)getNumberProperty:(NSString*)key;
|
||||
|
||||
/**
|
||||
* Returns the stream properties associated with the key.
|
||||
* Returns the stream property associated with the key.
|
||||
*
|
||||
* @return stream properties in a dictionary or nil if the key is not found
|
||||
* @return stream property as id or nil if the key is not found
|
||||
*/
|
||||
- (NSDictionary*)getProperties:(NSString*)key;
|
||||
- (id)getProperty:(NSString*)key;
|
||||
|
||||
/**
|
||||
* Returns all stream properties defined.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2021 Taner Sener
|
||||
* Copyright (c) 2018-2022 Taner Sener
|
||||
*
|
||||
* This file is part of FFmpegKit.
|
||||
*
|
||||
@ -125,7 +125,7 @@ NSString* const StreamKeyTags = @"tags";
|
||||
}
|
||||
|
||||
- (NSDictionary*)getTags {
|
||||
return [self getProperties:StreamKeyTags];
|
||||
return [self getProperty:StreamKeyTags];
|
||||
}
|
||||
|
||||
- (NSString*)getStringProperty:(NSString*)key {
|
||||
@ -138,15 +138,15 @@ NSString* const StreamKeyTags = @"tags";
|
||||
}
|
||||
|
||||
- (NSNumber*)getNumberProperty:(NSString*)key {
|
||||
NSDictionary* mediaProperties = [self getAllProperties];
|
||||
if (mediaProperties == nil) {
|
||||
NSDictionary* allProperties = [self getAllProperties];
|
||||
if (allProperties == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
return mediaProperties[key];
|
||||
return allProperties[key];
|
||||
}
|
||||
|
||||
- (NSDictionary*)getProperties:(NSString*)key {
|
||||
- (id)getProperty:(NSString*)key {
|
||||
NSDictionary* allProperties = [self getAllProperties];
|
||||
if (allProperties == nil) {
|
||||
return nil;
|
||||
|
@ -47,7 +47,7 @@ std::shared_ptr<std::string> ffmpegkit::Chapter::getEndTime() {
|
||||
}
|
||||
|
||||
std::shared_ptr<rapidjson::Value> ffmpegkit::Chapter::getTags() {
|
||||
return getProperties(KeyTags);
|
||||
return getProperty(KeyTags);
|
||||
}
|
||||
|
||||
std::shared_ptr<std::string> ffmpegkit::Chapter::getStringProperty(const char* key) {
|
||||
@ -66,7 +66,7 @@ std::shared_ptr<int64_t> ffmpegkit::Chapter::getNumberProperty(const char* key)
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<rapidjson::Value> ffmpegkit::Chapter::getProperties(const char* key) {
|
||||
std::shared_ptr<rapidjson::Value> ffmpegkit::Chapter::getProperty(const char* key) {
|
||||
if (_chapterValue->HasMember(key)) {
|
||||
auto value = std::make_shared<rapidjson::Value>();
|
||||
*value = (*_chapterValue)[key];
|
||||
|
@ -73,11 +73,11 @@ namespace ffmpegkit {
|
||||
std::shared_ptr<int64_t> getNumberProperty(const char* key);
|
||||
|
||||
/**
|
||||
* Returns the chapter properties associated with the key.
|
||||
* Returns the chapter property associated with the key.
|
||||
*
|
||||
* @return chapter properties in a Value or nullptr if the key is not found
|
||||
* @return chapter property in a Value or nullptr if the key is not found
|
||||
*/
|
||||
std::shared_ptr<rapidjson::Value> getProperties(const char* key);
|
||||
std::shared_ptr<rapidjson::Value> getProperty(const char* key);
|
||||
|
||||
/**
|
||||
* Returns all chapter properties defined.
|
||||
|
@ -24,38 +24,38 @@ ffmpegkit::MediaInformation::MediaInformation(std::shared_ptr<rapidjson::Value>
|
||||
}
|
||||
|
||||
std::shared_ptr<std::string> ffmpegkit::MediaInformation::getFilename() {
|
||||
return getStringProperty(KeyFilename);
|
||||
return getStringFormatProperty(KeyFilename);
|
||||
}
|
||||
|
||||
std::shared_ptr<std::string> ffmpegkit::MediaInformation::getFormat() {
|
||||
return getStringProperty(KeyFormat);
|
||||
return getStringFormatProperty(KeyFormat);
|
||||
}
|
||||
|
||||
std::shared_ptr<std::string> ffmpegkit::MediaInformation::getLongFormat() {
|
||||
return getStringProperty(KeyFormatLong);
|
||||
return getStringFormatProperty(KeyFormatLong);
|
||||
}
|
||||
|
||||
std::shared_ptr<std::string> ffmpegkit::MediaInformation::getStartTime() {
|
||||
return getStringProperty(KeyStartTime);
|
||||
return getStringFormatProperty(KeyStartTime);
|
||||
}
|
||||
|
||||
std::shared_ptr<std::string> ffmpegkit::MediaInformation::getDuration() {
|
||||
return getStringProperty(KeyDuration);
|
||||
return getStringFormatProperty(KeyDuration);
|
||||
}
|
||||
|
||||
std::shared_ptr<std::string> ffmpegkit::MediaInformation::getSize() {
|
||||
return getStringProperty(KeySize);
|
||||
return getStringFormatProperty(KeySize);
|
||||
}
|
||||
|
||||
std::shared_ptr<std::string> ffmpegkit::MediaInformation::getBitrate() {
|
||||
return getStringProperty(KeyBitRate);
|
||||
return getStringFormatProperty(KeyBitRate);
|
||||
}
|
||||
|
||||
std::shared_ptr<rapidjson::Value> ffmpegkit::MediaInformation::getTags() {
|
||||
auto mediaProperties = getMediaProperties();
|
||||
if (mediaProperties->HasMember(KeyTags)) {
|
||||
auto formatProperties = getFormatProperties();
|
||||
if (formatProperties->HasMember(KeyTags)) {
|
||||
auto tags = std::make_shared<rapidjson::Value>();
|
||||
*tags = (*mediaProperties)[KeyTags];
|
||||
*tags = (*formatProperties)[KeyTags];
|
||||
return tags;
|
||||
} else {
|
||||
return nullptr;
|
||||
@ -71,37 +71,67 @@ std::shared_ptr<std::vector<std::shared_ptr<ffmpegkit::Chapter>>> ffmpegkit::Med
|
||||
}
|
||||
|
||||
std::shared_ptr<std::string> ffmpegkit::MediaInformation::getStringProperty(const char* key) {
|
||||
auto mediaProperties = getMediaProperties();
|
||||
if (mediaProperties->HasMember(key)) {
|
||||
return std::make_shared<std::string>((*mediaProperties)[key].GetString());
|
||||
auto allProperties = getAllProperties();
|
||||
if (allProperties->HasMember(key)) {
|
||||
return std::make_shared<std::string>((*allProperties)[key].GetString());
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<int64_t> ffmpegkit::MediaInformation::getNumberProperty(const char* key) {
|
||||
auto mediaProperties = getMediaProperties();
|
||||
if (mediaProperties->HasMember(key)) {
|
||||
return std::make_shared<int64_t>((*mediaProperties)[key].GetInt64());
|
||||
auto allProperties = getAllProperties();
|
||||
if (allProperties->HasMember(key)) {
|
||||
return std::make_shared<int64_t>((*allProperties)[key].GetInt64());
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<rapidjson::Value> ffmpegkit::MediaInformation::getProperties(const char* key) {
|
||||
if (_mediaInformationValue->HasMember(key)) {
|
||||
std::shared_ptr<rapidjson::Value> ffmpegkit::MediaInformation::getProperty(const char* key) {
|
||||
auto allProperties = getAllProperties();
|
||||
if (allProperties->HasMember(key)) {
|
||||
auto value = std::make_shared<rapidjson::Value>();
|
||||
*value = (*_mediaInformationValue)[key];
|
||||
*value = (*allProperties)[key];
|
||||
return value;
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<rapidjson::Value> ffmpegkit::MediaInformation::getMediaProperties() {
|
||||
if (_mediaInformationValue->HasMember(KeyMediaProperties)) {
|
||||
std::shared_ptr<std::string> ffmpegkit::MediaInformation::getStringFormatProperty(const char* key) {
|
||||
auto formatProperties = getFormatProperties();
|
||||
if (formatProperties->HasMember(key)) {
|
||||
return std::make_shared<std::string>((*formatProperties)[key].GetString());
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<int64_t> ffmpegkit::MediaInformation::getNumberFormatProperty(const char* key) {
|
||||
auto formatProperties = getFormatProperties();
|
||||
if (formatProperties->HasMember(key)) {
|
||||
return std::make_shared<int64_t>((*formatProperties)[key].GetInt64());
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<rapidjson::Value> ffmpegkit::MediaInformation::getFormatProperty(const char* key) {
|
||||
auto formatProperties = getFormatProperties();
|
||||
if (formatProperties->HasMember(key)) {
|
||||
auto value = std::make_shared<rapidjson::Value>();
|
||||
*value = (*formatProperties)[key];
|
||||
return value;
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<rapidjson::Value> ffmpegkit::MediaInformation::getFormatProperties() {
|
||||
if (_mediaInformationValue->HasMember(KeyFormatProperties)) {
|
||||
auto mediaProperties = std::make_shared<rapidjson::Value>();
|
||||
*mediaProperties = (*_mediaInformationValue)[KeyMediaProperties];
|
||||
*mediaProperties = (*_mediaInformationValue)[KeyFormatProperties];
|
||||
return mediaProperties;
|
||||
} else {
|
||||
return nullptr;
|
||||
|
@ -32,7 +32,7 @@ namespace ffmpegkit {
|
||||
*/
|
||||
class MediaInformation {
|
||||
public:
|
||||
static constexpr const char* KeyMediaProperties = "format";
|
||||
static constexpr const char* KeyFormatProperties = "format";
|
||||
static constexpr const char* KeyFilename = "filename";
|
||||
static constexpr const char* KeyFormat = "format_name";
|
||||
static constexpr const char* KeyFormatLong = "format_long_name";
|
||||
@ -115,32 +115,53 @@ namespace ffmpegkit {
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ffmpegkit::Chapter>>> getChapters();
|
||||
|
||||
/**
|
||||
* Returns the media property associated with the key.
|
||||
* Returns the property associated with the key.
|
||||
*
|
||||
* @return media property as string or nullptr if the key is not found
|
||||
* @return property as string or nullptr if the key is not found
|
||||
*/
|
||||
std::shared_ptr<std::string> getStringProperty(const char* key);
|
||||
|
||||
/**
|
||||
* Returns the media property associated with the key.
|
||||
* Returns the property associated with the key.
|
||||
*
|
||||
* @return media property as number or nullptr if the key is not found
|
||||
* @return property as number or nullptr if the key is not found
|
||||
*/
|
||||
std::shared_ptr<int64_t> getNumberProperty(const char* key);
|
||||
|
||||
/**
|
||||
* Returns the media properties associated with the key.
|
||||
* Returns the property associated with the key.
|
||||
*
|
||||
* @return media properties in a Value or nullptr if the key is not found
|
||||
* @return property in a Value or nullptr if the key is not found
|
||||
*/
|
||||
std::shared_ptr<rapidjson::Value> getProperties(const char* key);
|
||||
std::shared_ptr<rapidjson::Value> getProperty(const char* key);
|
||||
|
||||
/**
|
||||
* Returns all media properties.
|
||||
* Returns the format property associated with the key.
|
||||
*
|
||||
* @return all media properties in a Value or nullptr if no media properties are defined
|
||||
* @return format property as string or nullptr if the key is not found
|
||||
*/
|
||||
std::shared_ptr<std::string> getStringFormatProperty(const char* key);
|
||||
|
||||
/**
|
||||
* Returns the format property associated with the key.
|
||||
*
|
||||
* @return format property as number or nullptr if the key is not found
|
||||
*/
|
||||
std::shared_ptr<int64_t> getNumberFormatProperty(const char* key);
|
||||
|
||||
/**
|
||||
* Returns the format property associated with the key.
|
||||
*
|
||||
* @return format property in a Value or nullptr if the key is not found
|
||||
*/
|
||||
std::shared_ptr<rapidjson::Value> getMediaProperties();
|
||||
std::shared_ptr<rapidjson::Value> getFormatProperty(const char* key);
|
||||
|
||||
/**
|
||||
* Returns all format properties defined.
|
||||
*
|
||||
* @return all format properties in a Value or nullptr if no format properties are defined
|
||||
*/
|
||||
std::shared_ptr<rapidjson::Value> getFormatProperties();
|
||||
|
||||
/**
|
||||
* Returns all properties defined.
|
||||
|
@ -91,7 +91,7 @@ std::shared_ptr<std::string> ffmpegkit::StreamInformation::getCodecTimeBase() {
|
||||
}
|
||||
|
||||
std::shared_ptr<rapidjson::Value> ffmpegkit::StreamInformation::getTags() {
|
||||
return getProperties(KeyTags);
|
||||
return getProperty(KeyTags);
|
||||
}
|
||||
|
||||
std::shared_ptr<std::string> ffmpegkit::StreamInformation::getStringProperty(const char* key) {
|
||||
@ -110,7 +110,7 @@ std::shared_ptr<int64_t> ffmpegkit::StreamInformation::getNumberProperty(const c
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<rapidjson::Value> ffmpegkit::StreamInformation::getProperties(const char* key) {
|
||||
std::shared_ptr<rapidjson::Value> ffmpegkit::StreamInformation::getProperty(const char* key) {
|
||||
if (_streamInformationValue->HasMember(key)) {
|
||||
auto value = std::make_shared<rapidjson::Value>();
|
||||
*value = (*_streamInformationValue)[key];
|
||||
|
@ -195,11 +195,11 @@ namespace ffmpegkit {
|
||||
std::shared_ptr<int64_t> getNumberProperty(const char* key);
|
||||
|
||||
/**
|
||||
* Returns the stream properties associated with the key.
|
||||
* Returns the stream property associated with the key.
|
||||
*
|
||||
* @return stream properties in a Value or nullptr if the key is not found
|
||||
* @return stream property in a Value or nullptr if the key is not found
|
||||
*/
|
||||
std::shared_ptr<rapidjson::Value> getProperties(const char* key);
|
||||
std::shared_ptr<rapidjson::Value> getProperty(const char* key);
|
||||
|
||||
/**
|
||||
* Returns all stream properties defined.
|
||||
|
Loading…
Reference in New Issue
Block a user