diff options
author | Martin Storsjö <martin@martin.st> | 2009-04-03 18:08:07 +0300 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2012-12-16 21:32:58 +0200 |
commit | 3b2e8d1d216f74eae73409ecc3b48396a932d256 (patch) | |
tree | 22a882a7ba1e999924bd016777b37fda3e4d8a30 /libavformat | |
parent | 65e053271a98f7acf3ef6b412998cfcb44a8eef8 (diff) | |
download | ffmpeg-3b2e8d1d216f74eae73409ecc3b48396a932d256.tar.gz |
rtpenc: Allow including a SDES/CNAME block in RTCP SR packets
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/rtpenc.c | 17 | ||||
-rw-r--r-- | libavformat/rtpenc.h | 1 |
2 files changed, 18 insertions, 0 deletions
diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c index babb2bb45f..0f5307d719 100644 --- a/libavformat/rtpenc.c +++ b/libavformat/rtpenc.c @@ -34,6 +34,7 @@ static const AVOption options[] = { FF_RTP_FLAG_OPTS(RTPMuxContext, flags), { "payload_type", "Specify RTP payload type", offsetof(RTPMuxContext, payload_type), AV_OPT_TYPE_INT, {.i64 = -1 }, -1, 127, AV_OPT_FLAG_ENCODING_PARAM }, { "ssrc", "Stream identifier", offsetof(RTPMuxContext, ssrc), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, + { "cname", "CNAME to include in RTCP SR packets", offsetof(RTPMuxContext, cname), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, { NULL }, }; @@ -271,6 +272,22 @@ static void rtcp_send_sr(AVFormatContext *s1, int64_t ntp_time) avio_wb32(s1->pb, rtp_ts); avio_wb32(s1->pb, s->packet_count); avio_wb32(s1->pb, s->octet_count); + + if (s->cname) { + int len = FFMIN(strlen(s->cname), 255); + avio_w8(s1->pb, (RTP_VERSION << 6) + 1); + avio_w8(s1->pb, RTCP_SDES); + avio_wb16(s1->pb, (7 + len + 3) / 4); /* length in words - 1 */ + + avio_wb32(s1->pb, s->ssrc); + avio_w8(s1->pb, 0x01); /* CNAME */ + avio_w8(s1->pb, len); + avio_write(s1->pb, s->cname, len); + avio_w8(s1->pb, 0); /* END */ + for (len = (7 + len) % 4; len % 4; len++) + avio_w8(s1->pb, 0); + } + avio_flush(s1->pb); } diff --git a/libavformat/rtpenc.h b/libavformat/rtpenc.h index 5fd0b9ca64..f79734826c 100644 --- a/libavformat/rtpenc.h +++ b/libavformat/rtpenc.h @@ -30,6 +30,7 @@ struct RTPMuxContext { AVStream *st; int payload_type; uint32_t ssrc; + const char *cname; uint16_t seq; uint32_t timestamp; uint32_t base_timestamp; |