avformat/bit: only accept the g729 codec and 1 channel
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Thu, 26 Feb 2015 20:42:02 +0000 (21:42 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 26 Feb 2015 22:28:01 +0000 (23:28 +0100)
Other codecs/channel numbers are not supported by this muxer.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit d0b8640f75ff7569c98d6fdb03d83451104e088c)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/bit.c

index 42df0c2..f5112c2 100644 (file)
@@ -119,8 +119,12 @@ static int write_header(AVFormatContext *s)
 {
     AVCodecContext *enc = s->streams[0]->codec;
 
-    enc->codec_id = AV_CODEC_ID_G729;
-    enc->channels = 1;
+    if ((enc->codec_id != AV_CODEC_ID_G729) || enc->channels != 1) {
+        av_log(s, AV_LOG_ERROR,
+               "only codec g729 with 1 channel is supported by this format\n");
+        return AVERROR(EINVAL);
+    }
+
     enc->bits_per_coded_sample = 16;
     enc->block_align = (enc->bits_per_coded_sample * enc->channels) >> 3;