OSDN Git Service

auenc: strict check for supported codec
authorPaul B Mahol <onemda@gmail.com>
Tue, 29 Jan 2013 10:54:02 +0000 (10:54 +0000)
committerPaul B Mahol <onemda@gmail.com>
Wed, 30 Jan 2013 22:17:52 +0000 (22:17 +0000)
Also check number of streams and give error message why muxing failed.
This prevents muxing unsupported codec with known and supported tag.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
libavformat/au.c

index f887162..db2ab27 100644 (file)
@@ -156,8 +156,16 @@ static int au_write_header(AVFormatContext *s)
     AVIOContext *pb = s->pb;
     AVCodecContext *enc = s->streams[0]->codec;
 
-    if (!enc->codec_tag)
+    if (s->nb_streams != 1) {
+        av_log(s, AV_LOG_ERROR, "only one stream is supported\n");
         return AVERROR(EINVAL);
+    }
+
+    enc->codec_tag = ff_codec_get_tag(codec_au_tags, enc->codec_id);
+    if (!enc->codec_tag) {
+        av_log(s, AV_LOG_ERROR, "unsupported codec\n");
+        return AVERROR(EINVAL);
+    }
 
     ffio_wfourcc(pb, ".snd");                   /* magic number */
     avio_wb32(pb, AU_HEADER_SIZE);              /* header size */