From patchwork Fri Oct 21 19:43:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ahmed Ammar X-Patchwork-Id: 1118 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.133 with SMTP id o127csp1350380vsd; Fri, 21 Oct 2016 22:08:59 -0700 (PDT) X-Received: by 10.194.153.66 with SMTP id ve2mr3236015wjb.82.1477112939370; Fri, 21 Oct 2016 22:08:59 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id v77si1519157wmd.111.2016.10.21.22.08.57; Fri, 21 Oct 2016 22:08:59 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@genesi-usa-com.20150623.gappssmtp.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3C60B689930; Sat, 22 Oct 2016 08:08:52 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EEFB1680C92 for ; Fri, 21 Oct 2016 22:48:55 +0300 (EEST) Received: by mail-wm0-f52.google.com with SMTP id c78so3753135wme.1 for ; Fri, 21 Oct 2016 12:48:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=genesi-usa-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=9ALN5yaP06yWAp8k2WA32skCGA8BarWtFM1DnzHZlPw=; b=JZO3L8iu35DVKtuGspWgWJAhv5vg0iaFDZKdDaM2uJrP2gUZUcdpuH/rfB5i3YJuc3 9w92rfAyQgcU2XbGwF10SCUBZCB7rEV1Pp9wm3q/ejaB5QG29K8sAV2IOdZZq9oRLTrj AAldb5kMzjgCc2s5FyW/Zpw72LMQEoVkBsfmEyqaaFtRc9Nq85luV2JPuzwvHZK0oly+ MPi5zyVelHbTlDjhzxX/x2Ooa3TwZgqDCjH1qOpVu6I1Mi43IdG93eD7+P/pMtqd+ujV ctktx63owsj/vhSac9VNKw6Vci4+0zqOY7L5G7N07enfkYRvSkH6R0m9dYrj58+cvSz9 zVSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=9ALN5yaP06yWAp8k2WA32skCGA8BarWtFM1DnzHZlPw=; b=UQLJxjJtB8vFG2FRClZsOSg1rt94IMh9/rsZkC/p0NIpTycImTMQ1M7/yCZU09N5se rinEEtEBlFNkgICrsQ7RcuwpCP1w16fgzvA0jQ8YksDAuzJGxoAsPYHrgSOI4EzI0ixy J/MoYgsgow3X36EXHh8V9/y2PnhmltwOJY7sVHu+RQ0GX6a8JrFLp9an6ZmSVuSI/1kF kYJbzQLaPUnjj0ls+gp/2nb0IwgR4U1iQIztxsn7Gbsm6J6xnSAKUoHKkxEWBsQzz/zk 0YZvf35QbjX8fZ5UZ4ZcXiC7ON4c08ZPa8lwTJDEax+JkE6VjXSGW3Csoy9ld7qDCFc0 u9bw== X-Gm-Message-State: ABUngvd1Le5yT4j2nSdY8P9fGofJq5zqDDKOH3SwasdVwnqguFSt5dyg0SwUuOlkj6s2qg== X-Received: by 10.194.205.1 with SMTP id lc1mr2028594wjc.192.1477079027923; Fri, 21 Oct 2016 12:43:47 -0700 (PDT) Received: from localhost.localdomain ([41.69.172.94]) by smtp.gmail.com with ESMTPSA id n72sm5765113wmd.11.2016.10.21.12.43.46 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 21 Oct 2016 12:43:47 -0700 (PDT) From: Ahmed Ammar To: ffmpeg-devel@ffmpeg.org Date: Fri, 21 Oct 2016 21:43:37 +0200 Message-Id: <20161021194337.6563-1-aammar@genesi-usa.com> X-Mailer: git-send-email 2.8.4 (Apple Git-73) X-Mailman-Approved-At: Sat, 22 Oct 2016 08:08:50 +0300 Subject: [FFmpeg-devel] [PATCH] avformat/rtmpproto: Handle NetStream.Play.PublishNotify by re-creating stream. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Ahmed Ammar MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavformat/rtmpproto.c | 49 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index 95d1c1d..8a32222 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -227,6 +227,11 @@ static int rtmp_send_packet(RTMPContext *rt, RTMPPacket *pkt, int track) { int ret; +#ifdef DEBUG + av_log(rt, AV_LOG_DEBUG, "Sending packet:\n"); + ff_rtmp_packet_dump(rt, pkt); +#endif + if (pkt->type == RTMP_PT_INVOKE && track) { GetByteContext gbc; char name[128]; @@ -2032,6 +2037,29 @@ static int read_number_result(RTMPPacket *pkt, double *number) return 0; } +static int subscribe_stream(URLContext *s, RTMPContext *rt) +{ + int ret = 0; + + if ((ret = gen_create_stream(s, rt)) < 0) + goto fail; + + if (rt->is_input) { + /* Send the FCSubscribe command when the name of live + * stream 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) + goto fail; + } else if (rt->live == -1) { + if ((ret = gen_fcsubscribe_stream(s, rt, rt->playpath)) < 0) + goto fail; + } + } + +fail: + return ret; +} + static int handle_invoke_result(URLContext *s, RTMPPacket *pkt) { RTMPContext *rt = s->priv_data; @@ -2058,20 +2086,9 @@ static int handle_invoke_result(URLContext *s, RTMPPacket *pkt) goto fail; } - if ((ret = gen_create_stream(s, rt)) < 0) + if ((ret = subscribe_stream(s, rt)) < 0) goto fail; - if (rt->is_input) { - /* Send the FCSubscribe command when the name of live - * stream 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) - goto fail; - } else if (rt->live == -1) { - if ((ret = gen_fcsubscribe_stream(s, rt, rt->playpath)) < 0) - goto fail; - } - } } else if (!strcmp(tracked_method, "createStream")) { double stream_id; if (read_number_result(pkt, &stream_id)) { @@ -2137,6 +2154,13 @@ static int handle_invoke_status(URLContext *s, RTMPPacket *pkt) if (!t && !strcmp(tmpstr, "NetStream.Play.UnpublishNotify")) rt->state = STATE_STOPPED; if (!t && !strcmp(tmpstr, "NetStream.Publish.Start")) rt->state = STATE_PUBLISHING; if (!t && !strcmp(tmpstr, "NetStream.Seek.Notify")) rt->state = STATE_PLAYING; + if (!t && !strcmp(tmpstr, "NetStream.Play.PublishNotify")) { + if (gen_delete_stream(s, rt) < 0) + return -1; + + if (subscribe_stream(s, rt) < 0) + return -1; + } return 0; } @@ -2292,6 +2316,7 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) int ret; #ifdef DEBUG + av_log(rt, AV_LOG_DEBUG, "Received packet:\n"); ff_rtmp_packet_dump(s, pkt); #endif