[FFmpeg-devel] [PATCH] sdp: optional 'vbr' parameter for Speex RTP payload

Dmitry Samonenko shreddingwork at gmail.com
Tue Oct 9 21:09:00 CEST 2012


Hello.

Please, take a look at the provided patch.

I'm concerned with av_opt_get_int in coditional expression. Feels like
vad option should be converted to AV_OPT_TYPE_FLAG, so condition could
benefit from simple av_opt_flag_is_set and get rid of local variable.

However, this option type is almost never used - either it's relatively
new or there are some drawbacks
(AV_OPT_TYPE_INT is used much more extensively for [0;1] range).
-------------- next part --------------
>From 5f3c54214a6ca702229b5e5f1006e114447a539e Mon Sep 17 00:00:00 2001
From: Dmitry Samonenko <shreddingwork at gmail.com>
Date: Tue, 9 Oct 2012 22:47:38 +0400
Subject: [PATCH 1/1] sdp: optional 'vbr' parameter is added for speex payload
 case

---
 libavformat/sdp.c |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/libavformat/sdp.c b/libavformat/sdp.c
index 30941b7..0beba0a 100644
--- a/libavformat/sdp.c
+++ b/libavformat/sdp.c
@@ -572,10 +572,23 @@ static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c,
                                      payload_type, c->sample_rate,
                                      payload_type, c->block_align == 38 ? 20 : 30);
             break;
-        case AV_CODEC_ID_SPEEX:
-            av_strlcatf(buff, size, "a=rtpmap:%d speex/%d\r\n",
-                                     payload_type, c->sample_rate);
+        case AV_CODEC_ID_SPEEX: {
+            const char *mode;
+            uint64_t vad_option;
+
+            if (fmt->flags & CODEC_FLAG_QSCALE)
+                mode = "on";
+            else if (!av_opt_get_int(c, "vad", AV_OPT_FLAG_ENCODING_PARAM, &vad_option) && vad_option)
+                mode = "vad";
+            else
+                mode = "off";
+
+            av_strlcatf(buff, size, "a=rtpmap:%d speex/%d\r\n"
+                                    "a=fmtp:%d vbr=%s\r\n",
+                                     payload_type, c->sample_rate,
+                                     payload_type, mode);
             break;
+        }
         default:
             /* Nothing special to do here... */
             break;
-- 
1.7.4.4



More information about the ffmpeg-devel mailing list