[FFmpeg-devel] [PATCH v1] avformat/rtmpproto: support fourCcList property in enhanced rtmp

Steven Liu lq at chinaffmpeg.org
Sun Aug 20 07:10:10 EEST 2023


As the enhanced rtmp Extending NetConnection connect Command section
said, the rtmp should add a property named fourCcLive, but there should
only one codec can be set for the video stream in rtmp+flv, so user can
use the option rtmp_enhanced_flags to set the enhanced rtmp with av1,
hevc or vp9.

Signed-off-by: Steven Liu <lq at chinaffmpeg.org>
---
 doc/protocols.texi      | 17 +++++++++++++++++
 libavformat/rtmpproto.c | 22 ++++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/doc/protocols.texi b/doc/protocols.texi
index b3fad55591..b5ab023066 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -896,6 +896,23 @@ 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.
 
+ at item rtmp_enhanced_flags @var{flags}
+Specify that the media is an enhanced rtmp live stream. This option have
+three flags, set one of them into fourCcLive property into Connect Command Message,
+The default is @{none}.
+
+ at table @samp
+ at item av1
+If the rtmp_enhanced_flags set av1, the video stream in enhanced rtmp is av1.
+
+ at item hevc
+If the rtmp_enhanced_flags set hevc, the video stream in enhanced rtmp is hevc.
+
+ at item vp9
+If the rtmp_enhanced_flags set vp9, the video stream in enhanced rtmp is vp9.
+
+ at end table
+
 @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..9dcc4bdc3a 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -69,6 +69,13 @@ typedef enum {
     STATE_STOPPED,    ///< the broadcast has been stopped
 } ClientState;
 
+typedef enum {
+    ENHANCED_NONE,
+    ENHANCED_AV1,
+    ENHANCED_HEVC,
+    ENHANCED_VP9,
+} EnhancedFlags;
+
 typedef struct TrackedMethod {
     char *name;
     int id;
@@ -123,6 +130,7 @@ typedef struct RTMPContext {
     int           nb_tracked_methods;         ///< number of tracked methods
     int           tracked_methods_size;       ///< size of the tracked methods buffer
     int           listen;                     ///< listen mode flag
+    int           enhanced_flags;             ///< 0: none, 1: av1, 2: hevc, 3: vp9
     int           listen_timeout;             ///< listen timeout to wait for new connections
     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)
@@ -336,6 +344,16 @@ 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_flags > 0)
+        ff_amf_write_field_name(&p, "fourCcList");
+
+    if (rt->enhanced_flags == ENHANCED_AV1)
+        ff_amf_write_string(&p, "av01");
+    else if (rt->enhanced_flags == ENHANCED_HEVC)
+        ff_amf_write_string(&p, "hevc");
+    else if (rt->enhanced_flags == ENHANCED_VP9)
+        ff_amf_write_string(&p, "vp9");
+
     if (!rt->is_input) {
         ff_amf_write_field_name(&p, "type");
         ff_amf_write_string(&p, "nonprivate");
@@ -3104,6 +3122,10 @@ 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_flags", "Specify that the media is an enhanced rtmp live stream", OFFSET(enhanced_flags), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 3, ENC, "rtmp_enhanced_flags"},
+    {"av1", "enhanced rtmp with av1 codec", 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, ENC, "rtmp_enhanced_flags"},
+    {"hevc", "enhanced rtmp with hevc codec", 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, ENC, "rtmp_enhanced_flags"},
+    {"vp9", "enhanced rtmp with vp9 codec", 0, AV_OPT_TYPE_CONST, {.i64 = 3}, 0, 0, ENC, "rtmp_enhanced_flags"},
     {"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.39.2 (Apple Git-143)



More information about the ffmpeg-devel mailing list