]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/rtp.c
Split ac3 byte swapping into a separate function.
[ffmpeg] / libavformat / rtp.c
index 14e91896350c5fbd7c019ac7b2bf88f737d590cc..a5820d717d0ec17444e68d0d1b1c1fe6f75ee2e7 100644 (file)
@@ -32,6 +32,7 @@
 
 //#define DEBUG
 
+#define RTCP_SR_SIZE 28
 
 /* TODO: - add RTCP statistics reporting (should be optional).
 
@@ -801,6 +802,7 @@ static void rtcp_send_sr(AVFormatContext *s1, int64_t ntp_time)
 #endif
 
     if (s->first_rtcp_ntp_time == AV_NOPTS_VALUE) s->first_rtcp_ntp_time = ntp_time;
+    s->last_rtcp_ntp_time = ntp_time;
     rtp_ts = av_rescale_q(ntp_time - s->first_rtcp_ntp_time, AV_TIME_BASE_Q,
                           s1->streams[0]->time_base) + s->base_timestamp;
     put_byte(&s1->pb, (RTP_VERSION << 6));
@@ -983,7 +985,8 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt)
     /* XXX: mpeg pts hardcoded. RTCP send every 0.5 seconds */
     rtcp_bytes = ((s->octet_count - s->last_octet_count) * RTCP_TX_RATIO_NUM) /
         RTCP_TX_RATIO_DEN;
-    if (s->first_packet || rtcp_bytes >= 28) {
+    if (s->first_packet || ((rtcp_bytes >= RTCP_SR_SIZE) &&
+                           (av_gettime() - s->last_rtcp_ntp_time > 5000000))) {
         rtcp_send_sr(s1, av_gettime());
         s->last_octet_count = s->octet_count;
         s->first_packet = 0;