diff options
author | Adriano Pallavicino <adrianopallavicino@gmail.com> | 2012-07-17 09:51:13 +0200 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2012-07-24 00:42:58 +0300 |
commit | 999c63e4ca1b0500da73227d0b48591a0e695928 (patch) | |
tree | e8d2467f09c0efb30764644f07ee01d4388ba22e /libavformat/rtp.c | |
parent | d04c5293ce88927ad359ca276e287bfa63c2329d (diff) | |
download | ffmpeg-999c63e4ca1b0500da73227d0b48591a0e695928.tar.gz |
rtp: Only choose static payload types if the sample rate and channels are right
If using a different sample rate or number of channels, use a dynamic
payload type instead, where the parameters are passed in the SDP.
G722 is a special case where the normal rules don't apply.
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/rtp.c')
-rw-r--r-- | libavformat/rtp.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/libavformat/rtp.c b/libavformat/rtp.c index efc84ab249..b7ebed129f 100644 --- a/libavformat/rtp.c +++ b/libavformat/rtp.c @@ -110,9 +110,17 @@ int ff_rtp_get_payload_type(AVFormatContext *fmt, AVCodecContext *codec) !fmt->oformat->priv_class || !av_opt_flag_is_set(fmt->priv_data, "rtpflags", "rfc2190"))) continue; - if (codec->codec_id == CODEC_ID_PCM_S16BE) - if (codec->channels != AVRtpPayloadTypes[i].audio_channels) - continue; + /* G722 has 8000 as nominal rate even if the sample rate is 16000, + * see section 4.5.2 in RFC 3551. */ + if (codec->codec_id == CODEC_ID_ADPCM_G722 && + codec->sample_rate == 16000 && codec->channels == 1) + return AVRtpPayloadTypes[i].pt; + if (codec->codec_type == AVMEDIA_TYPE_AUDIO && + ((AVRtpPayloadTypes[i].clock_rate > 0 && + codec->sample_rate != AVRtpPayloadTypes[i].clock_rate) || + (AVRtpPayloadTypes[i].audio_channels > 0 && + codec->channels != AVRtpPayloadTypes[i].audio_channels))) + continue; return AVRtpPayloadTypes[i].pt; } |