OSDN Git Service

Merge commit 'a05f5052fef3b3743fab7846da12861d8a8098ec'
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 29 Sep 2014 18:26:12 +0000 (20:26 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 29 Sep 2014 18:26:15 +0000 (20:26 +0200)
* commit 'a05f5052fef3b3743fab7846da12861d8a8098ec':
  sdp: Make opus declaration conform to the spec

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavformat/sdp.c

@@@ -581,24 -581,20 +581,34 @@@ static char *sdp_write_media_attributes
          case AV_CODEC_ID_SPEEX:
              av_strlcatf(buff, size, "a=rtpmap:%d speex/%d\r\n",
                                       payload_type, c->sample_rate);
 +            if (c->codec) {
 +                const char *mode;
 +                uint64_t vad_option;
 +
 +                if (c->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=fmtp:%d vbr=%s\r\n",
 +                                        payload_type, mode);
 +            }
              break;
          case AV_CODEC_ID_OPUS:
-             av_strlcatf(buff, size, "a=rtpmap:%d opus/48000\r\n",
+             /* The opus RTP draft says that all opus streams MUST be declared
+                as stereo, to avoid negotiation failures. The actual number of
+                channels can change on a packet-by-packet basis. The number of
+                channels a receiver prefers to receive or a sender plans to send
+                can be declared via fmtp parameters (both default to mono), but
+                receivers MUST be able to receive and process stereo packets. */
+             av_strlcatf(buff, size, "a=rtpmap:%d opus/48000/2\r\n",
                                       payload_type);
+             if (c->channels == 2) {
+                 av_strlcatf(buff, size, "a=fmtp:%d sprop-stereo:1\r\n",
+                                          payload_type);
+             }
              break;
          default:
              /* Nothing special to do here... */