aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/rtmpproto.c
diff options
context:
space:
mode:
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>2012-05-09 00:58:09 +0200
committerMartin Storsjö <martin@martin.st>2012-05-10 13:55:32 +0300
commitd55961fa82d34c1783f525b05608694d2b2dea1c (patch)
treef77873e2bc979765032eff39bfc7148629159608 /libavformat/rtmpproto.c
parent05945db9ce3c6708e62d05bfb040db10d73eade0 (diff)
downloadffmpeg-d55961fa82d34c1783f525b05608694d2b2dea1c.tar.gz
rtmp: Implement check bandwidth notification.
According to the behaviour of librtmp, it is recommended to send this message to the server after receiving the 'onBWDone' callback in order to do bandwidth checking and improve compatibility with some servers.
Diffstat (limited to 'libavformat/rtmpproto.c')
-rw-r--r--libavformat/rtmpproto.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index 13ef719ab2..427655c27e 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -373,6 +373,25 @@ static void gen_server_bw(URLContext *s, RTMPContext *rt)
}
/**
+ * Generate check bandwidth message and send it to the server.
+ */
+static void gen_check_bw(URLContext *s, RTMPContext *rt)
+{
+ RTMPPacket pkt;
+ uint8_t *p;
+
+ ff_rtmp_packet_create(&pkt, RTMP_SYSTEM_CHANNEL, RTMP_PT_INVOKE, 0, 21);
+
+ p = pkt.data;
+ ff_amf_write_string(&p, "_checkbw");
+ ff_amf_write_number(&p, ++rt->nb_invokes);
+ ff_amf_write_null(&p);
+
+ ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
+ ff_rtmp_packet_destroy(&pkt);
+}
+
+/**
* Generate report on bytes read so far and send it to the server.
*/
static void gen_bytes_read(URLContext *s, RTMPContext *rt, uint32_t ts)
@@ -691,6 +710,8 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt)
if (!t && !strcmp(tmpstr, "NetStream.Play.Stop")) rt->state = STATE_STOPPED;
if (!t && !strcmp(tmpstr, "NetStream.Play.UnpublishNotify")) rt->state = STATE_STOPPED;
if (!t && !strcmp(tmpstr, "NetStream.Publish.Start")) rt->state = STATE_PUBLISHING;
+ } else if (!memcmp(pkt->data, "\002\000\010onBWDone", 11)) {
+ gen_check_bw(s, rt);
}
break;
}