aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/rtpenc.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2009-04-08 07:16:14 +0000
committerLuca Abeni <lucabe72@email.it>2009-04-08 07:16:14 +0000
commit08e696c0b28e58797b4b77310e07a93ab3267369 (patch)
tree054415f25763b7323aad26488f7a5dbcd66321af /libavformat/rtpenc.c
parent17ad7b24c890a9816bd3e7b737c44ba7505aea67 (diff)
downloadffmpeg-08e696c0b28e58797b4b77310e07a93ab3267369.tar.gz
Add support for AMR audio in the RTP muxer
patch by Martin Storsjö (martin AT martin DOT st) Originally committed as revision 18375 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/rtpenc.c')
-rw-r--r--libavformat/rtpenc.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index 511c0bd5bc..c5df85961b 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -60,6 +60,8 @@ static int is_supported(enum CodecID id)
case CODEC_ID_PCM_U16LE:
case CODEC_ID_PCM_U8:
case CODEC_ID_MPEG2TS:
+ case CODEC_ID_AMR_NB:
+ case CODEC_ID_AMR_WB:
return 1;
default:
return 0;
@@ -134,6 +136,23 @@ static int rtp_write_header(AVFormatContext *s1)
s->max_payload_size = n * TS_PACKET_SIZE;
s->buf_ptr = s->buf;
break;
+ case CODEC_ID_AMR_NB:
+ case CODEC_ID_AMR_WB:
+ if (!s->max_frames_per_packet)
+ s->max_frames_per_packet = 12;
+ if (st->codec->codec_id == CODEC_ID_AMR_NB)
+ n = 31;
+ else
+ n = 61;
+ /* max_header_toc_size + the largest AMR payload must fit */
+ if (1 + s->max_frames_per_packet + n > s->max_payload_size) {
+ av_log(s1, AV_LOG_ERROR, "RTP max payload size too small for AMR\n");
+ return -1;
+ }
+ if (st->codec->channels != 1) {
+ av_log(s1, AV_LOG_ERROR, "Only mono is supported\n");
+ return -1;
+ }
case CODEC_ID_AAC:
s->num_frames = 0;
default:
@@ -366,6 +385,10 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt)
case CODEC_ID_AAC:
ff_rtp_send_aac(s1, buf1, size);
break;
+ case CODEC_ID_AMR_NB:
+ case CODEC_ID_AMR_WB:
+ ff_rtp_send_amr(s1, buf1, size);
+ break;
case CODEC_ID_MPEG2TS:
rtp_send_mpegts_raw(s1, buf1, size);
break;