diff mbox series

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

Message ID 20230820041010.34334-1-lq@chinaffmpeg.org
State New
Headers show
Series [FFmpeg-devel,v1] avformat/rtmpproto: support fourCcList property in enhanced rtmp | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 fail Make failed
andriy/make_x86 fail Make failed

Commit Message

Liu Steven Aug. 20, 2023, 4:10 a.m. UTC
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@chinaffmpeg.org>
---
 doc/protocols.texi      | 17 +++++++++++++++++
 libavformat/rtmpproto.c | 22 ++++++++++++++++++++++
 2 files changed, 39 insertions(+)

Comments

Jean-Baptiste Kempf Aug. 20, 2023, 8:28 a.m. UTC | #1
Hello,

On Sun, 20 Aug 2023, at 06:10, Steven Liu wrote:
> 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.

Technically, the protocol allows any type of FourCC, no?

jb
Steven Liu Aug. 21, 2023, 1:35 a.m. UTC | #2
Jean-Baptiste Kempf <jb@videolan.org> 于2023年8月20日周日 16:29写道:
>
> Hello,
Hi
>
> On Sun, 20 Aug 2023, at 06:10, Steven Liu wrote:
> > 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.
>
> Technically, the protocol allows any type of FourCC, no?
The protocol should allows any type of FourCC, i saw there have three
codecs in the example["av01", "vp09", "hvc1"].
I think not all servers support fourCcList in connect command, so this
should set by user.


Thanks
Steven
Jean-Baptiste Kempf Aug. 23, 2023, 3:39 p.m. UTC | #3
Hello,

On Mon, 21 Aug 2023, at 03:35, Steven Liu wrote:
> Jean-Baptiste Kempf <jb@videolan.org> 于2023年8月20日周日 16:29写道:
>>
>> Hello,
> Hi
>>
>> On Sun, 20 Aug 2023, at 06:10, Steven Liu wrote:
>> > 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.
>>
>> Technically, the protocol allows any type of FourCC, no?
> The protocol should allows any type of FourCC, i saw there have three
> codecs in the example["av01", "vp09", "hvc1"].

My question is then why have 0,1,2,3 and not a fourcc then? Or does this question make no sense on the protocol level?
Martin Storsjö Aug. 23, 2023, 4:17 p.m. UTC | #4
On Wed, 23 Aug 2023, Jean-Baptiste Kempf wrote:

> Hello,
>
> On Mon, 21 Aug 2023, at 03:35, Steven Liu wrote:
>> Jean-Baptiste Kempf <jb@videolan.org> 于2023年8月20日周日 16:29写道:
>>>
>>> Hello,
>> Hi
>>>
>>> On Sun, 20 Aug 2023, at 06:10, Steven Liu wrote:
>>> > 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.
>>>
>>> Technically, the protocol allows any type of FourCC, no?
>> The protocol should allows any type of FourCC, i saw there have three
>> codecs in the example["av01", "vp09", "hvc1"].
>
> My question is then why have 0,1,2,3 and not a fourcc then? Or does this question make no sense on the protocol level?

Put another way, why map a string to a number and back to a string - why 
not just keep it a string throughout?

// Martin
Marton Balint Aug. 23, 2023, 5:40 p.m. UTC | #5
On Wed, 23 Aug 2023, Martin Storsjö wrote:

> On Wed, 23 Aug 2023, Jean-Baptiste Kempf wrote:
>
>>  Hello,
>>
>>  On Mon, 21 Aug 2023, at 03:35, Steven Liu wrote:
>>>  Jean-Baptiste Kempf <jb@videolan.org> 于2023年8月20日周日 16:29写道:
>>>>
>>>>  Hello,
>>>  Hi
>>>>
>>>>  On Sun, 20 Aug 2023, at 06:10, Steven Liu wrote:
>>>> >  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.
>>>>
>>>>  Technically, the protocol allows any type of FourCC, no?
>>>  The protocol should allows any type of FourCC, i saw there have three
>>>  codecs in the example["av01", "vp09", "hvc1"].
>>
>>  My question is then why have 0,1,2,3 and not a fourcc then? Or does this
>>  question make no sense on the protocol level?
>
> Put another way, why map a string to a number and back to a string - why not 
> just keep it a string throughout?

Agreed. Plus it is actually list, so you eventually you might want to 
support multiple fourcc-s by splitting the fourcc list. And the 
type is a strict array, so simply putting a string wihtout array length 
seems suspicious anyway.

Regards,
Marton
Steven Liu Aug. 24, 2023, 5:33 a.m. UTC | #6
Marton Balint <cus@passwd.hu> 于2023年8月24日周四 01:43写道:
>
>
>
> On Wed, 23 Aug 2023, Martin Storsjö wrote:
>
> > On Wed, 23 Aug 2023, Jean-Baptiste Kempf wrote:
> >
> >>  Hello,
> >>
> >>  On Mon, 21 Aug 2023, at 03:35, Steven Liu wrote:
> >>>  Jean-Baptiste Kempf <jb@videolan.org> 于2023年8月20日周日 16:29写道:
> >>>>
> >>>>  Hello,
> >>>  Hi
> >>>>
> >>>>  On Sun, 20 Aug 2023, at 06:10, Steven Liu wrote:
> >>>> >  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.
> >>>>
> >>>>  Technically, the protocol allows any type of FourCC, no?
> >>>  The protocol should allows any type of FourCC, i saw there have three
> >>>  codecs in the example["av01", "vp09", "hvc1"].
> >>
> >>  My question is then why have 0,1,2,3 and not a fourcc then? Or does this
> >>  question make no sense on the protocol level?
> >
> > Put another way, why map a string to a number and back to a string - why not
> > just keep it a string throughout?
>
> Agreed. Plus it is actually list, so you eventually you might want to
> support multiple fourcc-s by splitting the fourcc list. And the
> type is a strict array, so simply putting a string wihtout array length
> seems suspicious anyway.

new version patchset is comming:
https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2023-August/313444.html

>
> Regards,
> Marton
> _______________________________________________
> 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".
diff mbox series

Patch

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.
 
+@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}.
+
+@table @samp
+@item av1
+If the rtmp_enhanced_flags set av1, the video stream in enhanced rtmp is av1.
+
+@item hevc
+If the rtmp_enhanced_flags set hevc, the video stream in enhanced rtmp is hevc.
+
+@item vp9
+If the rtmp_enhanced_flags set vp9, the video stream in enhanced rtmp is vp9.
+
+@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"},