From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 8F6D246FCF for ; Fri, 25 Aug 2023 10:05:54 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1F32468C67D; Fri, 25 Aug 2023 13:05:47 +0300 (EEST) Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 748CE689B46 for ; Fri, 25 Aug 2023 13:05:40 +0300 (EEST) X-QQ-mid: bizesmtp83t1692957935td59mfnd Received: from localhost ( [103.102.203.194]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 25 Aug 2023 18:05:34 +0800 (CST) X-QQ-SSF: 01100000000000Z0Z000000A0000000 X-QQ-FEAT: zT6n3Y95oi0TwkW6YXGO1in3E9yntD0iG8ixOZMGa3z+fzEVyY1SIZ9a+Zfav HM9vA/kVLoue0/lUd1nCu+HM6XuRW/5j8y5yrSUVWgPcQaPj4xZ2GwXvtzr7i0PD57EeWCu QWQSeagmZs1ZLoo0s7D8sfqNYYqQULvIj0Sx5OBrsDgUwEGZWmDa97gYi544tuU4slxsPe9 6J5a28YG6SrvSAiyBcNz2V1TI7FTF40/ZEKRD5zw2VP8HYGN7fPvae4u2+CFLJzB5gQvEsl yWmIhY5ypoPfJjwwZHDaHIdUERdN2kt02FFRP3s2jQHksSL9jV5DxW8XwL1U+gnmXCzhjmV p1miGrgkbL3rYKu4+45/nkhGugJ6SRHa0iZD8i8+OZm5X5LjQU= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 8415432384090863391 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Fri, 25 Aug 2023 18:05:27 +0800 Message-Id: <20230825100527.71471-2-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230825100527.71471-1-lq@chinaffmpeg.org> References: <49a65bba-634c-1afb-6c52-94565bd7cc9@martin.st> <20230825100527.71471-1-lq@chinaffmpeg.org> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybglogicsvrsz:qybglogicsvrsz3a-0 Subject: [FFmpeg-devel] [PATCH v3 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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 | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/doc/protocols.texi b/doc/protocols.texi index b3fad55591..bd2b25e502 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_codecs +Specify the list of codecs the client advertises to support in an +enhanced RTMP stream. This option should set a string 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..10e0aed539 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; ///< codec list in enhanced rtmp char username[50]; char password[50]; char auth_params[500]; @@ -336,6 +337,41 @@ 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_codecs) { + uint32_t list_len = 0; + char *fourcc_data = rt->enhanced_codecs; + int fourcc_str_len = strlen(fourcc_data); + + // check the string, fourcc + ',' + ... + end fourcc correct length should be (4+1)*n+4 + if ((fourcc_str_len + 1) % 5 != 0) { + av_log(s, AV_LOG_ERROR, "Malformed rtmp_enhanched_codecs, " + "should be of the form hvc1[,av01][,vp09][,...]\n"); + 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_start(&p, list_len); + + while(fourcc_data - rt->enhanced_codecs < fourcc_str_len) { + unsigned char fourcc[5]; + if (!strncasecmp(fourcc_data, "hvc1", 4) || + !strncasecmp(fourcc_data, "av01", 4) || + !strncasecmp(fourcc_data, "vp09", 4)) { + av_strlcpy(fourcc, fourcc_data, sizeof(fourcc)); + ff_amf_write_string(&p, fourcc); + } else { + av_log(s, AV_LOG_ERROR, "Unsupported codec fourcc, %.*s\n", 4, fourcc_data); + return AVERROR_PATCHWELCOME; + } + + fourcc_data += 5; + } + } + if (!rt->is_input) { ff_amf_write_field_name(&p, "type"); ff_amf_write_string(&p, "nonprivate"); @@ -3104,6 +3140,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_codecs", "Specify the codec(s) to use in an enhanced rtmp live stream", OFFSET(enhanced_codecs), 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"}, -- 2.40.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".