diff --git a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/Chapter.java b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/Chapter.java index bf726ae..1c34991 100644 --- a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/Chapter.java +++ b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/Chapter.java @@ -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); } /** diff --git a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/MediaInformation.java b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/MediaInformation.java index 61d2e46..4576fc5 100644 --- a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/MediaInformation.java +++ b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/MediaInformation.java @@ -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); } /** diff --git a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/StreamInformation.java b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/StreamInformation.java index 45bd329..9a5bc5e 100644 --- a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/StreamInformation.java +++ b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/StreamInformation.java @@ -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); } /** diff --git a/apple/src/Chapter.h b/apple/src/Chapter.h index f85e2b7..7cf1194 100644 --- a/apple/src/Chapter.h +++ b/apple/src/Chapter.h @@ -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. diff --git a/apple/src/Chapter.m b/apple/src/Chapter.m index 30baf06..b037b40 100644 --- a/apple/src/Chapter.m +++ b/apple/src/Chapter.m @@ -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; diff --git a/apple/src/MediaInformation.h b/apple/src/MediaInformation.h index 1483311..d13810c 100644 --- a/apple/src/MediaInformation.h +++ b/apple/src/MediaInformation.h @@ -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. diff --git a/apple/src/MediaInformation.m b/apple/src/MediaInformation.m index a9211db..8f3a108 100644 --- a/apple/src/MediaInformation.m +++ b/apple/src/MediaInformation.m @@ -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 { diff --git a/apple/src/StreamInformation.h b/apple/src/StreamInformation.h index 9a14e3e..6e98f99 100644 --- a/apple/src/StreamInformation.h +++ b/apple/src/StreamInformation.h @@ -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. diff --git a/apple/src/StreamInformation.m b/apple/src/StreamInformation.m index 04a19e3..0a0d312 100644 --- a/apple/src/StreamInformation.m +++ b/apple/src/StreamInformation.m @@ -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; diff --git a/linux/src/Chapter.cpp b/linux/src/Chapter.cpp index be32ef1..544bac4 100644 --- a/linux/src/Chapter.cpp +++ b/linux/src/Chapter.cpp @@ -47,7 +47,7 @@ std::shared_ptr ffmpegkit::Chapter::getEndTime() { } std::shared_ptr ffmpegkit::Chapter::getTags() { - return getProperties(KeyTags); + return getProperty(KeyTags); } std::shared_ptr ffmpegkit::Chapter::getStringProperty(const char* key) { @@ -66,7 +66,7 @@ std::shared_ptr ffmpegkit::Chapter::getNumberProperty(const char* key) } } -std::shared_ptr ffmpegkit::Chapter::getProperties(const char* key) { +std::shared_ptr ffmpegkit::Chapter::getProperty(const char* key) { if (_chapterValue->HasMember(key)) { auto value = std::make_shared(); *value = (*_chapterValue)[key]; diff --git a/linux/src/Chapter.h b/linux/src/Chapter.h index 3365a8c..e711d20 100644 --- a/linux/src/Chapter.h +++ b/linux/src/Chapter.h @@ -73,11 +73,11 @@ namespace ffmpegkit { std::shared_ptr 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 getProperties(const char* key); + std::shared_ptr getProperty(const char* key); /** * Returns all chapter properties defined. diff --git a/linux/src/MediaInformation.cpp b/linux/src/MediaInformation.cpp index 6173bcf..caded5a 100644 --- a/linux/src/MediaInformation.cpp +++ b/linux/src/MediaInformation.cpp @@ -24,38 +24,38 @@ ffmpegkit::MediaInformation::MediaInformation(std::shared_ptr } std::shared_ptr ffmpegkit::MediaInformation::getFilename() { - return getStringProperty(KeyFilename); + return getStringFormatProperty(KeyFilename); } std::shared_ptr ffmpegkit::MediaInformation::getFormat() { - return getStringProperty(KeyFormat); + return getStringFormatProperty(KeyFormat); } std::shared_ptr ffmpegkit::MediaInformation::getLongFormat() { - return getStringProperty(KeyFormatLong); + return getStringFormatProperty(KeyFormatLong); } std::shared_ptr ffmpegkit::MediaInformation::getStartTime() { - return getStringProperty(KeyStartTime); + return getStringFormatProperty(KeyStartTime); } std::shared_ptr ffmpegkit::MediaInformation::getDuration() { - return getStringProperty(KeyDuration); + return getStringFormatProperty(KeyDuration); } std::shared_ptr ffmpegkit::MediaInformation::getSize() { - return getStringProperty(KeySize); + return getStringFormatProperty(KeySize); } std::shared_ptr ffmpegkit::MediaInformation::getBitrate() { - return getStringProperty(KeyBitRate); + return getStringFormatProperty(KeyBitRate); } std::shared_ptr ffmpegkit::MediaInformation::getTags() { - auto mediaProperties = getMediaProperties(); - if (mediaProperties->HasMember(KeyTags)) { + auto formatProperties = getFormatProperties(); + if (formatProperties->HasMember(KeyTags)) { auto tags = std::make_shared(); - *tags = (*mediaProperties)[KeyTags]; + *tags = (*formatProperties)[KeyTags]; return tags; } else { return nullptr; @@ -71,37 +71,67 @@ std::shared_ptr>> ffmpegkit::Med } std::shared_ptr ffmpegkit::MediaInformation::getStringProperty(const char* key) { - auto mediaProperties = getMediaProperties(); - if (mediaProperties->HasMember(key)) { - return std::make_shared((*mediaProperties)[key].GetString()); + auto allProperties = getAllProperties(); + if (allProperties->HasMember(key)) { + return std::make_shared((*allProperties)[key].GetString()); } else { return nullptr; } } std::shared_ptr ffmpegkit::MediaInformation::getNumberProperty(const char* key) { - auto mediaProperties = getMediaProperties(); - if (mediaProperties->HasMember(key)) { - return std::make_shared((*mediaProperties)[key].GetInt64()); + auto allProperties = getAllProperties(); + if (allProperties->HasMember(key)) { + return std::make_shared((*allProperties)[key].GetInt64()); } else { return nullptr; } } -std::shared_ptr ffmpegkit::MediaInformation::getProperties(const char* key) { - if (_mediaInformationValue->HasMember(key)) { +std::shared_ptr ffmpegkit::MediaInformation::getProperty(const char* key) { + auto allProperties = getAllProperties(); + if (allProperties->HasMember(key)) { auto value = std::make_shared(); - *value = (*_mediaInformationValue)[key]; + *value = (*allProperties)[key]; return value; } else { return nullptr; } } -std::shared_ptr ffmpegkit::MediaInformation::getMediaProperties() { - if (_mediaInformationValue->HasMember(KeyMediaProperties)) { +std::shared_ptr ffmpegkit::MediaInformation::getStringFormatProperty(const char* key) { + auto formatProperties = getFormatProperties(); + if (formatProperties->HasMember(key)) { + return std::make_shared((*formatProperties)[key].GetString()); + } else { + return nullptr; + } +} + +std::shared_ptr ffmpegkit::MediaInformation::getNumberFormatProperty(const char* key) { + auto formatProperties = getFormatProperties(); + if (formatProperties->HasMember(key)) { + return std::make_shared((*formatProperties)[key].GetInt64()); + } else { + return nullptr; + } +} + +std::shared_ptr ffmpegkit::MediaInformation::getFormatProperty(const char* key) { + auto formatProperties = getFormatProperties(); + if (formatProperties->HasMember(key)) { + auto value = std::make_shared(); + *value = (*formatProperties)[key]; + return value; + } else { + return nullptr; + } +} + +std::shared_ptr ffmpegkit::MediaInformation::getFormatProperties() { + if (_mediaInformationValue->HasMember(KeyFormatProperties)) { auto mediaProperties = std::make_shared(); - *mediaProperties = (*_mediaInformationValue)[KeyMediaProperties]; + *mediaProperties = (*_mediaInformationValue)[KeyFormatProperties]; return mediaProperties; } else { return nullptr; diff --git a/linux/src/MediaInformation.h b/linux/src/MediaInformation.h index cf17844..928e412 100644 --- a/linux/src/MediaInformation.h +++ b/linux/src/MediaInformation.h @@ -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>> 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 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 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 getProperties(const char* key); + std::shared_ptr 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 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 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 getMediaProperties(); + std::shared_ptr 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 getFormatProperties(); /** * Returns all properties defined. diff --git a/linux/src/StreamInformation.cpp b/linux/src/StreamInformation.cpp index cb9b31a..502018f 100644 --- a/linux/src/StreamInformation.cpp +++ b/linux/src/StreamInformation.cpp @@ -91,7 +91,7 @@ std::shared_ptr ffmpegkit::StreamInformation::getCodecTimeBase() { } std::shared_ptr ffmpegkit::StreamInformation::getTags() { - return getProperties(KeyTags); + return getProperty(KeyTags); } std::shared_ptr ffmpegkit::StreamInformation::getStringProperty(const char* key) { @@ -110,7 +110,7 @@ std::shared_ptr ffmpegkit::StreamInformation::getNumberProperty(const c } } -std::shared_ptr ffmpegkit::StreamInformation::getProperties(const char* key) { +std::shared_ptr ffmpegkit::StreamInformation::getProperty(const char* key) { if (_streamInformationValue->HasMember(key)) { auto value = std::make_shared(); *value = (*_streamInformationValue)[key]; diff --git a/linux/src/StreamInformation.h b/linux/src/StreamInformation.h index d1ec105..b547556 100644 --- a/linux/src/StreamInformation.h +++ b/linux/src/StreamInformation.h @@ -195,11 +195,11 @@ namespace ffmpegkit { std::shared_ptr 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 getProperties(const char* key); + std::shared_ptr getProperty(const char* key); /** * Returns all stream properties defined.