generic: minimal libav adjustments
authorLeandro Dorileo <leandro.maciel.dorileo@intel.com>
Tue, 11 Feb 2014 17:26:51 +0000 (15:26 -0200)
committerLeandro Dorileo <leandro.maciel.dorileo@intel.com>
Tue, 11 Feb 2014 17:30:21 +0000 (15:30 -0200)
Since libav doesn't implement the avcodec_get_name() util function we
need to implement the AVCodecDescriptor handling in our side.

Libav will also need the AV_OPT_SEARCH_FAKE_OBJ flag to retrieve the
ts_packetsize.

src/plugins/generic/generic.c

index a7bd7e1..e453b67 100644 (file)
@@ -172,11 +172,12 @@ _mp4_get_video_codec(AVStream *stream, struct lms_string_size *value)
 static void
 _mpeg2_get_video_codec(AVStream *stream, struct lms_string_size *value)
 {
-    const char *codec_name, *str_profile, *str_level;
+    const char *str_profile, *str_level;
+    const AVCodecDescriptor *codec;
     char buf[256];
 
-    codec_name = avcodec_get_name(stream->codec->codec_id);
-    if (!codec_name) return;
+    codec = avcodec_descriptor_get(stream->codec->codec_id);
+    if (!codec || !codec->name) return;
 
     str_profile = NULL;
     str_level = NULL;
@@ -204,7 +205,8 @@ _mpeg2_get_video_codec(AVStream *stream, struct lms_string_size *value)
         break;
     }
 
-    snprintf(buf, sizeof(buf), "%s-p%s-l%s", codec_name, str_profile, str_level);
+    snprintf(buf, sizeof(buf), "%s-p%s-l%s", codec->name, str_profile,
+             str_level);
     lms_string_size_strndup(value, buf, -1);
 }
 
@@ -459,7 +461,8 @@ _parse(struct plugin *plugin, struct lms_context *ctxt, const struct lms_file_in
     if (metadata)
         lms_string_size_strndup(&info.genre, metadata, -1);
 
-    av_opt_get_int(fmt_ctx, "ts_packetsize", AV_OPT_SEARCH_CHILDREN,
+    av_opt_get_int(fmt_ctx, "ts_packetsize",
+                   AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ,
                    &packet_size);
 
     language = _get_dict_value(fmt_ctx->metadata, "language");