From 72b870b95b18865ea0851b0233f96a6a2159b8cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 11 Dec 2009 11:37:21 +0000 Subject: =?UTF-8?q?Do=20not=20try=20to=20interact=20with=20RTMP=20server?= =?UTF-8?q?=20after=20"stop"=20command=20was=20received.=20Patch=20by=20Ma?= =?UTF-8?q?rtin=20Storsj=C3=B6=20($name=20at=20$name=20dot=20`Sao=20Tome?= =?UTF-8?q?=20and=20Principe=20domain`)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Originally committed as revision 20797 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavformat/rtmpproto.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libavformat/rtmpproto.c') diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index 96367e5eb5..c9b177493d 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -53,6 +53,7 @@ typedef enum { STATE_READY, ///< client has sent all needed commands and waits for server reply STATE_PLAYING, ///< client has started receiving multimedia data from server STATE_PUBLISHING, ///< client has started sending multimedia data to server (for output) + STATE_STOPPED, ///< the broadcast has been stopped } ClientState; /** protocol handler context */ @@ -619,6 +620,8 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) t = ff_amf_get_field_value(ptr, data_end, "code", tmpstr, sizeof(tmpstr)); if (!t && !strcmp(tmpstr, "NetStream.Play.Start")) rt->state = STATE_PLAYING; + 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; } break; @@ -642,6 +645,9 @@ static int get_packet(URLContext *s, int for_header) RTMPContext *rt = s->priv_data; int ret; + if (rt->state == STATE_STOPPED) + return AVERROR_EOF; + for (;;) { RTMPPacket rpkt; if ((ret = ff_rtmp_packet_read(rt->stream, &rpkt, @@ -658,6 +664,10 @@ static int get_packet(URLContext *s, int for_header) ff_rtmp_packet_destroy(&rpkt); return -1; } + if (rt->state == STATE_STOPPED) { + ff_rtmp_packet_destroy(&rpkt); + return AVERROR_EOF; + } if (for_header && (rt->state == STATE_PLAYING || rt->state == STATE_PUBLISHING)) { ff_rtmp_packet_destroy(&rpkt); return 0; -- cgit v1.2.1