diff options
author | Martin Storsjö <martin@martin.st> | 2012-10-09 00:51:42 +0300 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2012-10-09 11:57:11 +0300 |
commit | c136a813d77ed0c8698386d140990e9003d5d38c (patch) | |
tree | a766749eddd8ad28ab3fa50c49ea8057694b9b69 /libavformat/rtpenc.c | |
parent | e04826c34e9b19cc4da60fd028334f12f84b4b2a (diff) | |
download | ffmpeg-c136a813d77ed0c8698386d140990e9003d5d38c.tar.gz |
rtp: Support packetization/depacketization of opus
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/rtpenc.c')
-rw-r--r-- | libavformat/rtpenc.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c index 36064ed610..b17c4651b6 100644 --- a/libavformat/rtpenc.c +++ b/libavformat/rtpenc.c @@ -77,6 +77,7 @@ static int is_supported(enum AVCodecID id) case AV_CODEC_ID_ILBC: case AV_CODEC_ID_MJPEG: case AV_CODEC_ID_SPEEX: + case AV_CODEC_ID_OPUS: return 1; default: return 0; @@ -186,6 +187,16 @@ static int rtp_write_header(AVFormatContext *s1) * 8000, even if the sample rate is 16000. See RFC 3551. */ avpriv_set_pts_info(st, 32, 1, 8000); break; + case AV_CODEC_ID_OPUS: + if (st->codec->channels > 2) { + av_log(s1, AV_LOG_ERROR, "Multistream opus not supported in RTP\n"); + goto fail; + } + /* The opus RTP RFC says that all opus streams should use 48000 Hz + * as clock rate, since all opus sample rates can be expressed in + * this clock rate, and sample rate changes on the fly are supported. */ + avpriv_set_pts_info(st, 32, 1, 48000); + break; case AV_CODEC_ID_ILBC: if (st->codec->block_align != 38 && st->codec->block_align != 50) { av_log(s1, AV_LOG_ERROR, "Incorrect iLBC block size specified\n"); @@ -525,6 +536,14 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt) case AV_CODEC_ID_MJPEG: ff_rtp_send_jpeg(s1, pkt->data, size); break; + case AV_CODEC_ID_OPUS: + if (size > s->max_payload_size) { + av_log(s1, AV_LOG_ERROR, + "Packet size %d too large for max RTP payload size %d\n", + size, s->max_payload_size); + return AVERROR(EINVAL); + } + /* Intentional fallthrough */ default: /* better than nothing : send the codec raw data */ rtp_send_raw(s1, pkt->data, size); |