浏览代码

VLCMedia: expose convienience method to ask VLC for the human-readable codec name of a given FourCC

Felix Paul Kühne 10 年之前
父节点
当前提交
1f958e2085
共有 3 个文件被更改,包括 27 次插入0 次删除
  1. 8 0
      Headers/Public/VLCMedia.h
  2. 1 0
      NEWS
  3. 18 0
      Sources/VLCMedia.m

+ 8 - 0
Headers/Public/VLCMedia.h

@@ -150,6 +150,14 @@ typedef NS_ENUM(NSInteger, VLCMediaState) {
 + (instancetype)mediaWithPath:(NSString *)aPath;
 
 /**
+ * convienience method to return a user-readable codec name for the given FourCC
+ * \param uint32_t the FourCC to process
+ * \param NSString a VLC track type if known to speed-up the name search
+ * \return a NSString containing the codec name if recognized, else an empty string
+ */
++ (NSString *)codecNameForFourCC:(uint32_t)fourcc trackType:(NSString *)trackType;
+
+/**
  * TODO
  * \param aName TODO
  * \return a new VLCMedia object, only if there were no errors.  This object

+ 1 - 0
NEWS

@@ -10,6 +10,7 @@ New APIs:
                 VLCMetaInformationSeason, VLCMetaInformationEpisode,
                 VLCMetaInformationShowName, VLCMetaInformationActors,
                 VLCMetaInformationAlbumArtist, VLCMetaInformationDiscNumber
+  - new selector: codecNameForFourCC:trackType:
 
 Deprecated APIs:
 - VLCMediaPlayer

+ 18 - 0
Sources/VLCMedia.m

@@ -176,6 +176,24 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
  */
 @implementation VLCMedia
 
++ (NSString *)codecNameForFourCC:(uint32_t)fourcc trackType:(NSString *)trackType
+{
+    libvlc_track_type_t track_type = libvlc_track_unknown;
+
+    if ([trackType isEqualToString:VLCMediaTracksInformationTypeAudio])
+        track_type = libvlc_track_audio;
+    else if ([trackType isEqualToString:VLCMediaTracksInformationTypeVideo])
+        track_type = libvlc_track_video;
+    else if ([trackType isEqualToString:VLCMediaTracksInformationTypeText])
+        track_type = libvlc_track_text;
+
+    const char *ret = libvlc_media_get_codec_description(track_type, fourcc);
+    if (ret)
+        return [NSString stringWithUTF8String:ret];
+
+    return @"";
+}
+
 + (instancetype)mediaWithURL:(NSURL *)anURL;
 {
     return [[VLCMedia alloc] initWithURL:anURL];