Signed-off-by: Martin Storsjö <martin@martin.st>
Martin Storsjö authored on 2013/10/31 02:12:27... | ... |
@@ -259,7 +259,7 @@ fail: |
259 | 259 |
} |
260 | 260 |
|
261 | 261 |
/* send an rtcp sender report packet */ |
262 |
-static void rtcp_send_sr(AVFormatContext *s1, int64_t ntp_time) |
|
262 |
+static void rtcp_send_sr(AVFormatContext *s1, int64_t ntp_time, int bye) |
|
263 | 263 |
{ |
264 | 264 |
RTPMuxContext *s = s1->priv_data; |
265 | 265 |
uint32_t rtp_ts; |
... | ... |
@@ -293,6 +293,13 @@ static void rtcp_send_sr(AVFormatContext *s1, int64_t ntp_time) |
293 | 293 |
avio_w8(s1->pb, 0); |
294 | 294 |
} |
295 | 295 |
|
296 |
+ if (bye) { |
|
297 |
+ avio_w8(s1->pb, (RTP_VERSION << 6) | 1); |
|
298 |
+ avio_w8(s1->pb, RTCP_BYE); |
|
299 |
+ avio_wb16(s1->pb, 1); /* length in words - 1 */ |
|
300 |
+ avio_wb32(s1->pb, s->ssrc); |
|
301 |
+ } |
|
302 |
+ |
|
296 | 303 |
avio_flush(s1->pb); |
297 | 304 |
} |
298 | 305 |
|
... | ... |
@@ -491,7 +498,7 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt) |
491 | 491 |
if ((s->first_packet || ((rtcp_bytes >= RTCP_SR_SIZE) && |
492 | 492 |
(ff_ntp_time() - s->last_rtcp_ntp_time > 5000000))) && |
493 | 493 |
!(s->flags & FF_RTP_FLAG_SKIP_RTCP)) { |
494 |
- rtcp_send_sr(s1, ff_ntp_time()); |
|
494 |
+ rtcp_send_sr(s1, ff_ntp_time(), 0); |
|
495 | 495 |
s->last_octet_count = s->octet_count; |
496 | 496 |
s->first_packet = 0; |
497 | 497 |
} |
... | ... |
@@ -587,6 +594,10 @@ static int rtp_write_trailer(AVFormatContext *s1) |
587 | 587 |
{ |
588 | 588 |
RTPMuxContext *s = s1->priv_data; |
589 | 589 |
|
590 |
+ /* If the caller closes and recreates ->pb, this might actually |
|
591 |
+ * be NULL here even if it was successfully allocated at the start. */ |
|
592 |
+ if (s1->pb && (s->flags & FF_RTP_FLAG_SEND_BYE)) |
|
593 |
+ rtcp_send_sr(s1, ff_ntp_time(), 1); |
|
590 | 594 |
av_freep(&s->buf); |
591 | 595 |
|
592 | 596 |
return 0; |
... | ... |
@@ -68,13 +68,15 @@ typedef struct RTPMuxContext RTPMuxContext; |
68 | 68 |
#define FF_RTP_FLAG_RFC2190 2 |
69 | 69 |
#define FF_RTP_FLAG_SKIP_RTCP 4 |
70 | 70 |
#define FF_RTP_FLAG_H264_MODE0 8 |
71 |
+#define FF_RTP_FLAG_SEND_BYE 16 |
|
71 | 72 |
|
72 | 73 |
#define FF_RTP_FLAG_OPTS(ctx, fieldname) \ |
73 | 74 |
{ "rtpflags", "RTP muxer flags", offsetof(ctx, fieldname), AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "rtpflags" }, \ |
74 | 75 |
{ "latm", "Use MP4A-LATM packetization instead of MPEG4-GENERIC for AAC", 0, AV_OPT_TYPE_CONST, {.i64 = FF_RTP_FLAG_MP4A_LATM}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "rtpflags" }, \ |
75 | 76 |
{ "rfc2190", "Use RFC 2190 packetization instead of RFC 4629 for H.263", 0, AV_OPT_TYPE_CONST, {.i64 = FF_RTP_FLAG_RFC2190}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "rtpflags" }, \ |
76 | 77 |
{ "skip_rtcp", "Don't send RTCP sender reports", 0, AV_OPT_TYPE_CONST, {.i64 = FF_RTP_FLAG_SKIP_RTCP}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "rtpflags" }, \ |
77 |
- { "h264_mode0", "Use mode 0 for H264 in RTP", 0, AV_OPT_TYPE_CONST, {.i64 = FF_RTP_FLAG_H264_MODE0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "rtpflags" } \ |
|
78 |
+ { "h264_mode0", "Use mode 0 for H264 in RTP", 0, AV_OPT_TYPE_CONST, {.i64 = FF_RTP_FLAG_H264_MODE0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "rtpflags" }, \ |
|
79 |
+ { "send_bye", "Send RTCP BYE packets when finishing", 0, AV_OPT_TYPE_CONST, {.i64 = FF_RTP_FLAG_SEND_BYE}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "rtpflags" } \ |
|
78 | 80 |
|
79 | 81 |
void ff_rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len, int m); |
80 | 82 |
|
... | ... |
@@ -31,7 +31,7 @@ |
31 | 31 |
|
32 | 32 |
#define LIBAVFORMAT_VERSION_MAJOR 55 |
33 | 33 |
#define LIBAVFORMAT_VERSION_MINOR 9 |
34 |
-#define LIBAVFORMAT_VERSION_MICRO 3 |
|
34 |
+#define LIBAVFORMAT_VERSION_MICRO 4 |
|
35 | 35 |
|
36 | 36 |
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ |
37 | 37 |
LIBAVFORMAT_VERSION_MINOR, \ |