summaryrefslogtreecommitdiff
path: root/libavformat/rtpenc.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2010-09-15 17:35:39 +0000
committerMartin Storsjö <martin@martin.st>2010-09-15 17:35:39 +0000
commit0048a2a8d347c9a81a781f4126023018f1b29527 (patch)
treeeb9e71c1e3edaa6eface988067c0fac44bd5656b /libavformat/rtpenc.c
parent82eac2f3216534c065c5023e5599720bd17bed26 (diff)
Handle G.722 in RTP, and all the exceptions mandated in RFC 3551
Originally committed as revision 25125 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/rtpenc.c')
-rw-r--r--libavformat/rtpenc.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index f5e1e3bbd3..0a2959dfcf 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -56,6 +56,7 @@ static int is_supported(enum CodecID id)
case CODEC_ID_VORBIS:
case CODEC_ID_THEORA:
case CODEC_ID_VP8:
+ case CODEC_ID_ADPCM_G722:
return 1;
default:
return 0;
@@ -148,6 +149,11 @@ static int rtp_write_header(AVFormatContext *s1)
case CODEC_ID_VP8:
av_log(s1, AV_LOG_WARNING, "RTP VP8 payload is still experimental\n");
break;
+ case CODEC_ID_ADPCM_G722:
+ /* Due to a historical error, the clock rate for G722 in RTP is
+ * 8000, even if the sample rate is 16000. See RFC 3551. */
+ av_set_pts_info(st, 32, 1, 8000);
+ break;
case CODEC_ID_AMR_NB:
case CODEC_ID_AMR_WB:
if (!s->max_frames_per_packet)
@@ -382,6 +388,12 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt)
case CODEC_ID_PCM_S16LE:
rtp_send_samples(s1, pkt->data, size, 2 * st->codec->channels);
break;
+ case CODEC_ID_ADPCM_G722:
+ /* The actual sample size is half a byte per sample, but since the
+ * stream clock rate is 8000 Hz while the sample rate is 16000 Hz,
+ * the correct parameter for send_samples is 1 byte per stream clock. */
+ rtp_send_samples(s1, pkt->data, size, 1 * st->codec->channels);
+ break;
case CODEC_ID_MP2:
case CODEC_ID_MP3:
rtp_send_mpegaudio(s1, pkt->data, size);