diff options
author | Samuel Pitoiset <samuel.pitoiset@gmail.com> | 2012-06-13 14:48:02 +0200 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2012-06-13 16:53:32 +0300 |
commit | 9477c035a768261e54c50404c0f3746bf023f7a4 (patch) | |
tree | 1007a717c79e833a97120e7ff8796da45ed02b5b | |
parent | c2d38beab2858307f76b01070e7044f2577b8600 (diff) | |
download | ffmpeg-9477c035a768261e54c50404c0f3746bf023f7a4.tar.gz |
rtmp: Set the client buffer time to 3s instead of 0.26s
This factorizes existing code into a new function gen_buffer_time(),
which generates the client buffer time message and sends it to the
server.
Signed-off-by: Martin Storsjö <martin@martin.st>
-rw-r--r-- | libavformat/rtmpproto.c | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index 729e2d7af4..0407ad32f8 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -89,6 +89,7 @@ typedef struct RTMPContext { char* flashver; ///< version of the flash plugin char* swfurl; ///< url of the swf player int server_bw; ///< server bandwidth + int client_buffer_time; ///< client buffer time in ms } RTMPContext; #define PLAYER_KEY_OPEN_PART_LEN 30 ///< length of partial key used for first client digest signing @@ -408,6 +409,31 @@ static int gen_delete_stream(URLContext *s, RTMPContext *rt) } /** + * Generate client buffer time and send it to the server. + */ +static int gen_buffer_time(URLContext *s, RTMPContext *rt) +{ + RTMPPacket pkt; + uint8_t *p; + int ret; + + if ((ret = ff_rtmp_packet_create(&pkt, RTMP_NETWORK_CHANNEL, RTMP_PT_PING, + 1, 10)) < 0) + return ret; + + p = pkt.data; + bytestream_put_be16(&p, 3); + bytestream_put_be32(&p, rt->main_channel_id); + bytestream_put_be32(&p, rt->client_buffer_time); + + ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, + rt->prev_pkt[1]); + ff_rtmp_packet_destroy(&pkt); + + return ret; +} + +/** * Generate 'play' call and send it to the server, then ping the server * to start actual playing. */ @@ -436,23 +462,6 @@ static int gen_play(URLContext *s, RTMPContext *rt) rt->prev_pkt[1]); ff_rtmp_packet_destroy(&pkt); - if (ret < 0) - return ret; - - // set client buffer time disguised in ping packet - if ((ret = ff_rtmp_packet_create(&pkt, RTMP_NETWORK_CHANNEL, RTMP_PT_PING, - 1, 10)) < 0) - return ret; - - p = pkt.data; - bytestream_put_be16(&p, 3); - bytestream_put_be32(&p, 1); - bytestream_put_be32(&p, 256); //TODO: what is a good value here? - - ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, - rt->prev_pkt[1]); - ff_rtmp_packet_destroy(&pkt); - return ret; } @@ -910,6 +919,8 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) if (rt->is_input) { if ((ret = gen_play(s, rt)) < 0) return ret; + if ((ret = gen_buffer_time(s, rt)) < 0) + return ret; } else { if ((ret = gen_publish(s, rt)) < 0) return ret; @@ -1208,6 +1219,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags) rt->bytes_read = 0; rt->last_bytes_read = 0; rt->server_bw = 2500000; + rt->client_buffer_time = 3000; av_log(s, AV_LOG_DEBUG, "Proto = %s, path = %s, app = %s, fname = %s\n", proto, path, rt->app, rt->playpath); |