This options is only needed for RTMPT.
---
 doc/protocols.texi      |    4 ++++
 libavformat/rtmpproto.c |    8 ++++++++
 2 files changed, 12 insertions(+)

diff --git a/doc/protocols.texi b/doc/protocols.texi
index 0b4f1b1..e90d1b4 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -217,6 +217,10 @@ times to construct arbitrary AMF sequences.
 Version of the Flash plugin used to run the SWF player. The default
 is LNX 9,0,124,2.
 
+@item rtmp_flush_interval
+Number of packets flushed in the same request (RTMPT only). The default
+is 10.
+
 @item rtmp_live
 Specify that the media is a live stream. No resuming or seeking in
 live streams is possible. The default value is @code{any}, which means the
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index b3e2a30..c82302f 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -90,6 +90,7 @@ typedef struct RTMPContext {
     char*         swfurl;                     ///< url of the swf player
     int           server_bw;                  ///< server bandwidth
     int           client_buffer_time;         ///< client buffer time in ms
+    int           flush_interval;             ///< number of packets flushed 
in the same request (RTMPT only)
 } RTMPContext;
 
 #define PLAYER_KEY_OPEN_PART_LEN 30   ///< length of partial key used for 
first client digest signing
@@ -1295,6 +1296,7 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, 
int size)
     const uint8_t *buf_temp = buf;
     uint8_t c;
     int ret;
+    static int nb_packets = 0;
 
     do {
         if (rt->skip_bytes) {
@@ -1361,9 +1363,14 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, 
int size)
             rt->flv_size = 0;
             rt->flv_off = 0;
             rt->flv_header_bytes = 0;
+            nb_packets++;
         }
     } while (buf_temp - buf < size);
 
+    if (nb_packets < rt->flush_interval)
+        return size;
+    nb_packets = 0;
+
     /* set stream into nonblocking mode */
     rt->stream->flags |= AVIO_FLAG_NONBLOCK;
 
@@ -1404,6 +1411,7 @@ static const AVOption rtmp_options[] = {
     {"rtmp_buffer", "Set buffer time in milliseconds. The default is 3000.", 
OFFSET(client_buffer_time), AV_OPT_TYPE_INT, {3000}, 0, INT_MAX, DEC|ENC},
     {"rtmp_conn", "Append arbitrary AMF data to the Connect message", 
OFFSET(conn), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
     {"rtmp_flashver", "Version of the Flash plugin used to run the SWF 
player.", OFFSET(flashver), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
+    {"rtmp_flush_interval", "Number of packets flushed in the same request 
(RTMPT only).", OFFSET(flush_interval), AV_OPT_TYPE_INT, {10}, 0, INT_MAX, 
DEC|ENC},
     {"rtmp_live", "Specify that the media is a live stream.", OFFSET(live), 
AV_OPT_TYPE_INT, {-2}, INT_MIN, INT_MAX, DEC, "rtmp_live"},
     {"any", "both", 0, AV_OPT_TYPE_CONST, {-2}, 0, 0, DEC, "rtmp_live"},
     {"live", "live stream", 0, AV_OPT_TYPE_CONST, {-1}, 0, 0, DEC, 
"rtmp_live"},
-- 
1.7.10.3

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to