On Tue, 7 Aug 2012, Samuel Pitoiset wrote:
When streaming live streams using the Akamai, Edgecast or Limelight CDN, players cannot simply connect to the live stream. Instead, they have to subscribe to it, by sending an FC Subscribe call to the server. --- libavformat/rtmpproto.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index 4a35319..52b3597 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -604,6 +604,30 @@ static int gen_bytes_read(URLContext *s, RTMPContext *rt, uint32_t ts) return ret; } +static int gen_fcsubscribe_stream(URLContext *s, RTMPContext *rt, + const char *subscribe) +{ + RTMPPacket pkt; + uint8_t *p; + int ret; + + if ((ret = ff_rtmp_packet_create(&pkt, RTMP_SYSTEM_CHANNEL, RTMP_PT_INVOKE, + 0, 27 + strlen(rt->playpath))) < 0) + return ret; + + p = pkt.data; + ff_amf_write_string(&p, "FCSubscribe"); + ff_amf_write_number(&p, rt->nb_invokes); + ff_amf_write_null(&p); + ff_amf_write_string(&p, rt->playpath); + + ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, + rt->prev_pkt[1]); + ff_rtmp_packet_destroy(&pkt); + + return ret; +} + int ff_rtmp_calc_digest(const uint8_t *src, int len, int gap, const uint8_t *key, int keylen, uint8_t *dst) { @@ -1011,6 +1035,22 @@ static int handle_invoke(URLContext *s, RTMPPacket *pkt) } if ((ret = gen_create_stream(s, rt)) < 0) return ret; + + if (rt->is_input) { + /* Send the FCSubscribe command when the name of the live + * stream to subscribe is defined by the user or if it's a + * live stream. */ + if (rt->subscribe) { + if ((ret = gen_fcsubscribe_stream(s, rt, + rt->subscribe)) < 0) + return ret; + } + if (rt->live == -1) { + if ((ret = gen_fcsubscribe_stream(s, rt, + rt->playpath)) < 0) + return ret; + }
This is not good - this way, you could send two such packets when you should just send one.
Also, rt->subscribe does not exist at this point yet, since you add it only in patch 2.
// Martin _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
