From patchwork Thu Aug 24 05:32:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 43295 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a6:b0:149:dfde:5c0a with SMTP id m38csp1089230pzd; Wed, 23 Aug 2023 22:32:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF+TmIc+NeLhTdYBLw6hiRzvyOuI3UdgTJu27bopF8aPcBHT4s0rACWqXXll9hpjat812VT X-Received: by 2002:a05:6512:3045:b0:4fb:89b3:3374 with SMTP id b5-20020a056512304500b004fb89b33374mr12826845lfb.54.1692855176845; Wed, 23 Aug 2023 22:32:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692855176; cv=none; d=google.com; s=arc-20160816; b=MQ8CtAEbisz9rq5PGyUN0Q+EQ5RFyNr3jKvn+spPle9ROSiNyovBXXOxHqhIfi3vwF 3cBqvQFgSa+2wB8nzY1Urq++kbapn2PmtnfxIgiOeFfwHOLjLU0+asMY97xJX/RIuVAM //IAFuY8fCkXrHEfiXeYYPeE1NK1gzp11Z3/4eDsXQzyiVpEHZPidf1x7BoiuRG1yFu7 IyfeHhv3gewEbocFQLlk2FYpf/Lohy+AvVbdFksSVb7/H09CIdbT7q47MvOIxAgPmnPf tof939+iBaU1KUhZ5fbbrIjn4bl9iwGhhPDrArmnejhDrBOdNt6OYEs6nnMa4CllLrak F7Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:feedback-id:mime-version:references :in-reply-to:message-id:date:to:from:delivered-to; bh=8EomGCXYSHXErwD7yRjZUAz8m1p91xkzfaBHeiQegSQ=; fh=UbKzVxiKqWMRVKHrgyn1mg7tw/nuokz5Lr8G3ZXebqo=; b=LfAlf32ihVLr54Ym/Y+eo4jKRJ0MR42y0YouWQJWl/OC4lj81vE4ensvcHp/sygqcd p6M9O4VgLMRNdMmFcP3l5TlSOpyLOa7c2IzUcHz+Qps3O3U/LpQP+zUjvAyWzjyBeQjT jvuLsQKvbZ9uHWwfXzu9ZX2Ub0MpZxCwi9ty7kECd5SjUT3lBY1qcpno49xq0dKC45/0 h89WcqM8Xp7W1t3/gqbPHW44ZlBDvtDayn3qdhZ70vxvUwfKreVs+za69Jo66goUYbHP IbFTMdTxL6m2214eEf539j2jaovFJolM/j/yUKinNQ3/ggkVyfg7O2khL4wdhUReUNFc Y1BA== ARC-Authentication-Results: i=1; mx.google.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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id f12-20020a05640214cc00b0052a021db02dsi7032789edx.563.2023.08.23.22.32.56; Wed, 23 Aug 2023 22:32:56 -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; 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 C181468C5F8; Thu, 24 Aug 2023 08:32:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from bg2.exmail.qq.com (bg2.exmail.qq.com [114.132.63.24]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 649A568C534 for ; Thu, 24 Aug 2023 08:32:34 +0300 (EEST) X-QQ-mid: bizesmtp63t1692855142tcih1do5 Received: from localhost ( [103.102.203.194]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 24 Aug 2023 13:32:21 +0800 (CST) X-QQ-SSF: 01100000000000Z0Z000000A0000000 X-QQ-FEAT: 7jw2iSiCazpJCA7v0aLdclSDYorhw4joYnrv+Geswj3Qb6XmIjvyBQS7s//As FqGoCo+90U+UHw6OBe5VCW6ZZGeBC8fs8JRQnBN2vCDiqbJJWRIKhfsP/8Uic9dHoFmatqA 0P1EIrjYhZMWl3EJI2elIz37mNyZhiElbFY23FFpI06yecoCS6r4nGsNB5h+hmaqXaaA3Oz 88v1v+wEfBoOgn5VpHMlLiIHAJcXDjT1eEd31NiUtAU8GCX9nKKm79s0/f2kaXdYarggUUf 9bvaey9xlobv93+4LvQulB9nLCJ+y4sI7R+tqghWKKt1StvwJEScV1dQx71BsDfwQMXaldt fua8WNb+ywOnyV9FXddJ3HLzO/JHyL0GoYHi/UFy13X1DwSyac= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 955745464454442052 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Thu, 24 Aug 2023 13:32:13 +0800 Message-Id: <20230824053213.982-2-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230824053213.982-1-lq@chinaffmpeg.org> References: <20230824053213.982-1-lq@chinaffmpeg.org> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybglogicsvrsz:qybglogicsvrsz3a-0 Subject: [FFmpeg-devel] [PATCH v1 2/2] avformat/rtmpproto: support enhanced rtmp X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Steven Liu Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: tMWwlxC3y/tM add option named rtmp_enhanced_codec, it would support hvc1,av01,vp09 now, the fourcc is using Array of strings. Signed-off-by: Steven Liu --- doc/protocols.texi | 6 ++++++ libavformat/rtmpproto.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/doc/protocols.texi b/doc/protocols.texi index b3fad55591..f2930fb3a2 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -896,6 +896,12 @@ be named, by prefixing the type with 'N' and specifying the name before the value (i.e. @code{NB:myFlag:1}). This option may be used multiple times to construct arbitrary AMF sequences. +@item rtmp_enhanced_codec +Specify that the media is an enhanced rtmp live stream. This option should +set a sting like @code{hvc1,av01,vp09} for multiple codecs, or @code{hvc1} +for only one codec, set codec fourcc into fourCcLive property into +Connect Command Message, + @item rtmp_flashver Version of the Flash plugin used to run the SWF player. The default is LNX 9,0,124,2. (When publishing, the default is FMLE/3.0 (compatible; diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index f0ef223f05..f7ce04244f 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -127,6 +127,7 @@ typedef struct RTMPContext { int nb_streamid; ///< The next stream id to return on createStream calls double duration; ///< Duration of the stream in seconds as returned by the server (only valid if non-zero) int tcp_nodelay; ///< Use TCP_NODELAY to disable Nagle's algorithm if set to 1 + char *enhanced; ///< codecs list in enhanced rtmp char username[50]; char password[50]; char auth_params[500]; @@ -336,6 +337,42 @@ static int gen_connect(URLContext *s, RTMPContext *rt) ff_amf_write_field_name(&p, "app"); ff_amf_write_string2(&p, rt->app, rt->auth_params); + if (rt->enhanced) { + uint32_t list_len = 0; + char *fourcc_data = rt->enhanced; + int fourcc_str_len = fourcc_data ? strlen(fourcc_data) : 0; + + // check the string, fourcc + ',' + ... + end fourcc correct length should be (4+1)*n+4 + if ((fourcc_str_len + 1) % 5 != 0) + return AVERROR(EINVAL); + + list_len = (fourcc_str_len + 1) / 5; + // write the fourCcList field name + ff_amf_write_field_name(&p, "fourCcList"); + + // write the fourcc array length + ff_amf_write_array(&p, list_len); + + while(fourcc_data) { + unsigned char fourcc[5]; + switch (*(uint32_t *)fourcc_data) { + case MKTAG('h', 'v', 'c', '1'): + case MKTAG('a', 'v', '0', '1'): + case MKTAG('v', 'p', '0', '9'): + strncpy(fourcc, fourcc_data, 4); + fourcc[4] = '\0'; + ff_amf_write_string(&p, fourcc); + break; + default: + return AVERROR(EINVAL); + } + + fourcc_data += (fourcc_str_len - (fourcc_data - rt->enhanced)) > 4 ? 5 : 4; + if (fourcc_data - rt->enhanced >= fourcc_str_len) + break; + } + } + if (!rt->is_input) { ff_amf_write_field_name(&p, "type"); ff_amf_write_string(&p, "nonprivate"); @@ -3104,6 +3141,7 @@ static const AVOption rtmp_options[] = { {"rtmp_conn", "Append arbitrary AMF data to the Connect message", OFFSET(conn), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC}, {"rtmp_flashver", "Version of the Flash plugin used to run the SWF player.", OFFSET(flashver), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC}, {"rtmp_flush_interval", "Number of packets flushed in the same request (RTMPT only).", OFFSET(flush_interval), AV_OPT_TYPE_INT, {.i64 = 10}, 0, INT_MAX, ENC}, + {"rtmp_enhanced_codec", "Specify that the codec in enhanced rtmp live stream", OFFSET(enhanced), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, ENC}, {"rtmp_live", "Specify that the media is a live stream.", OFFSET(live), AV_OPT_TYPE_INT, {.i64 = -2}, INT_MIN, INT_MAX, DEC, "rtmp_live"}, {"any", "both", 0, AV_OPT_TYPE_CONST, {.i64 = -2}, 0, 0, DEC, "rtmp_live"}, {"live", "live stream", 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, DEC, "rtmp_live"},