* [FFmpeg-devel] [PATCH v1 1/2] avformat/rtmppkt: add ff_amf_write_array for write array strings
@ 2023-08-24 5:32 Steven Liu
2023-08-24 5:32 ` [FFmpeg-devel] [PATCH v1 2/2] avformat/rtmpproto: support enhanced rtmp Steven Liu
2023-08-24 20:47 ` [FFmpeg-devel] [PATCH v1 1/2] avformat/rtmppkt: add ff_amf_write_array for write array strings Marton Balint
0 siblings, 2 replies; 24+ messages in thread
From: Steven Liu @ 2023-08-24 5:32 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Steven Liu
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
libavformat/rtmppkt.c | 6 ++++++
libavformat/rtmppkt.h | 8 ++++++++
2 files changed, 14 insertions(+)
diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
index 4b97c0833f..cd0c68ec8a 100644
--- a/libavformat/rtmppkt.c
+++ b/libavformat/rtmppkt.c
@@ -40,6 +40,12 @@ void ff_amf_write_number(uint8_t **dst, double val)
bytestream_put_be64(dst, av_double2int(val));
}
+void ff_amf_write_array(uint8_t **dst, uint32_t val)
+{
+ bytestream_put_byte(dst, AMF_DATA_TYPE_ARRAY);
+ bytestream_put_be32(dst, val);
+}
+
void ff_amf_write_string(uint8_t **dst, const char *str)
{
bytestream_put_byte(dst, AMF_DATA_TYPE_STRING);
diff --git a/libavformat/rtmppkt.h b/libavformat/rtmppkt.h
index a15d2a5773..44c3420436 100644
--- a/libavformat/rtmppkt.h
+++ b/libavformat/rtmppkt.h
@@ -244,6 +244,14 @@ void ff_amf_write_null(uint8_t **dst);
*/
void ff_amf_write_object_start(uint8_t **dst);
+/**
+ * Write marker and length for AMF array to buffer.
+ *
+ * @param dst pointer to the input buffer (will be modified)
+ * @param length value to write
+ */
+void ff_amf_write_array(uint8_t **dst, uint32_t val);
+
/**
* Write string used as field name in AMF object to buffer.
*
--
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".
^ permalink raw reply [flat|nested] 24+ messages in thread
* [FFmpeg-devel] [PATCH v1 2/2] avformat/rtmpproto: support enhanced rtmp
2023-08-24 5:32 [FFmpeg-devel] [PATCH v1 1/2] avformat/rtmppkt: add ff_amf_write_array for write array strings Steven Liu
@ 2023-08-24 5:32 ` Steven Liu
2023-08-24 20:10 ` Tristan Matthews
2023-08-24 20:47 ` [FFmpeg-devel] [PATCH v1 1/2] avformat/rtmppkt: add ff_amf_write_array for write array strings Marton Balint
1 sibling, 1 reply; 24+ messages in thread
From: Steven Liu @ 2023-08-24 5:32 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Steven Liu
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 <lq@chinaffmpeg.org>
---
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"},
--
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".
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [FFmpeg-devel] [PATCH v1 2/2] avformat/rtmpproto: support enhanced rtmp
2023-08-24 5:32 ` [FFmpeg-devel] [PATCH v1 2/2] avformat/rtmpproto: support enhanced rtmp Steven Liu
@ 2023-08-24 20:10 ` Tristan Matthews
2023-08-24 21:45 ` Marton Balint
2023-08-25 5:32 ` Steven Liu
0 siblings, 2 replies; 24+ messages in thread
From: Tristan Matthews @ 2023-08-24 20:10 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Steven Liu
Hi,
On Thu, Aug 24, 2023 at 1:32 AM Steven Liu <lq@chinaffmpeg.org> wrote:
>
> 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 <lq@chinaffmpeg.org>
> ---
> 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}
I think this should be more like "Specify the codecs to use in an
enhanced rtmp live stream", the wording here makes it sound more like
a boolean flag.
Also nit: "set a string"
> +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
nit: "codec list"
> 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},
I think this should be more like "Specify the codec(s) to use in an
enhanced rtmp live stream" ?
> {"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".
_______________________________________________
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".
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [FFmpeg-devel] [PATCH v1 1/2] avformat/rtmppkt: add ff_amf_write_array for write array strings
2023-08-24 5:32 [FFmpeg-devel] [PATCH v1 1/2] avformat/rtmppkt: add ff_amf_write_array for write array strings Steven Liu
2023-08-24 5:32 ` [FFmpeg-devel] [PATCH v1 2/2] avformat/rtmpproto: support enhanced rtmp Steven Liu
@ 2023-08-24 20:47 ` Marton Balint
1 sibling, 0 replies; 24+ messages in thread
From: Marton Balint @ 2023-08-24 20:47 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Thu, 24 Aug 2023, Steven Liu wrote:
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
> libavformat/rtmppkt.c | 6 ++++++
> libavformat/rtmppkt.h | 8 ++++++++
> 2 files changed, 14 insertions(+)
>
> diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
> index 4b97c0833f..cd0c68ec8a 100644
> --- a/libavformat/rtmppkt.c
> +++ b/libavformat/rtmppkt.c
> @@ -40,6 +40,12 @@ void ff_amf_write_number(uint8_t **dst, double val)
> bytestream_put_be64(dst, av_double2int(val));
> }
>
> +void ff_amf_write_array(uint8_t **dst, uint32_t val)
ff_amf_write_array_start() would be a better name for the function,
because it does not write the full array, only the beginning.
length would be a better name for the parameter.
Regards,
Marton
> +{
> + bytestream_put_byte(dst, AMF_DATA_TYPE_ARRAY);
> + bytestream_put_be32(dst, val);
> +}
> +
> void ff_amf_write_string(uint8_t **dst, const char *str)
> {
> bytestream_put_byte(dst, AMF_DATA_TYPE_STRING);
> diff --git a/libavformat/rtmppkt.h b/libavformat/rtmppkt.h
> index a15d2a5773..44c3420436 100644
> --- a/libavformat/rtmppkt.h
> +++ b/libavformat/rtmppkt.h
> @@ -244,6 +244,14 @@ void ff_amf_write_null(uint8_t **dst);
> */
> void ff_amf_write_object_start(uint8_t **dst);
>
> +/**
> + * Write marker and length for AMF array to buffer.
> + *
> + * @param dst pointer to the input buffer (will be modified)
> + * @param length value to write
> + */
> +void ff_amf_write_array(uint8_t **dst, uint32_t val);
> +
> /**
> * Write string used as field name in AMF object to buffer.
> *
> --
> 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".
>
_______________________________________________
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".
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [FFmpeg-devel] [PATCH v1 2/2] avformat/rtmpproto: support enhanced rtmp
2023-08-24 20:10 ` Tristan Matthews
@ 2023-08-24 21:45 ` Marton Balint
2023-08-25 5:30 ` [FFmpeg-devel] [PATCH v2 1/2] avformat/rtmppkt: add ff_amf_write_array for write array strings Steven Liu
2023-08-25 5:33 ` [FFmpeg-devel] [PATCH v1 " Steven Liu
2023-08-25 5:32 ` Steven Liu
1 sibling, 2 replies; 24+ messages in thread
From: Marton Balint @ 2023-08-24 21:45 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Thu, 24 Aug 2023, Tristan Matthews wrote:
> Hi,
>
> On Thu, Aug 24, 2023 at 1:32 AM Steven Liu <lq@chinaffmpeg.org> wrote:
>>
>> 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 <lq@chinaffmpeg.org>
>> ---
>> 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
This is a list, so make it -rtmp_enhanced_codecs
>> +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}
>
> I think this should be more like "Specify the codecs to use in an
> enhanced rtmp live stream", the wording here makes it sound more like
> a boolean flag.
Actually it is a *supported* list, not a to-be-used list. So maybe
"Specify the list of codecs the client advertises to support in an
enhanced RTMP stream" is more appropriate.
>
> Also nit: "set a string"
>
>> +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 *enhanced_codecs
>
> nit: "codec list"
>> 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;
fourcc_data is always true.
>> +
>> + // 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) {
Still always true.
>> + unsigned char fourcc[5];
>> + switch (*(uint32_t *)fourcc_data) {
AV_RN32
>> + 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';
av_strlcpy(fourcc, fourcc_data, sizeof(fourcc));
>> + ff_amf_write_string(&p, fourcc);
>> + break;
>> + default:
>> + return AVERROR(EINVAL);
>> + }
>> +
>> + fourcc_data += (fourcc_str_len - (fourcc_data - rt->enhanced)) > 4 ? 5 : 4;
Why not simply fourcc_data += 5?
>> + if (fourcc_data - rt->enhanced >= fourcc_str_len)
>> + break;
Why not check this as the loop condition instead?
Regards,
Marton
>> + }
>> + }
>> +
>> 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},
>
> I think this should be more like "Specify the codec(s) to use in an
> enhanced rtmp live stream" ?
>
>> {"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".
> _______________________________________________
> 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".
_______________________________________________
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".
^ permalink raw reply [flat|nested] 24+ messages in thread
* [FFmpeg-devel] [PATCH v2 1/2] avformat/rtmppkt: add ff_amf_write_array for write array strings
2023-08-24 21:45 ` Marton Balint
@ 2023-08-25 5:30 ` Steven Liu
2023-08-25 5:30 ` [FFmpeg-devel] [PATCH v2 2/2] avformat/rtmpproto: support enhanced rtmp Steven Liu
2023-08-25 5:33 ` [FFmpeg-devel] [PATCH v1 " Steven Liu
1 sibling, 1 reply; 24+ messages in thread
From: Steven Liu @ 2023-08-25 5:30 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Steven Liu
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
libavformat/rtmppkt.c | 6 ++++++
libavformat/rtmppkt.h | 8 ++++++++
2 files changed, 14 insertions(+)
diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
index 4b97c0833f..a602bf6a96 100644
--- a/libavformat/rtmppkt.c
+++ b/libavformat/rtmppkt.c
@@ -40,6 +40,12 @@ void ff_amf_write_number(uint8_t **dst, double val)
bytestream_put_be64(dst, av_double2int(val));
}
+void ff_amf_write_array_start(uint8_t **dst, uint32_t length)
+{
+ bytestream_put_byte(dst, AMF_DATA_TYPE_ARRAY);
+ bytestream_put_be32(dst, length);
+}
+
void ff_amf_write_string(uint8_t **dst, const char *str)
{
bytestream_put_byte(dst, AMF_DATA_TYPE_STRING);
diff --git a/libavformat/rtmppkt.h b/libavformat/rtmppkt.h
index a15d2a5773..7c580f2224 100644
--- a/libavformat/rtmppkt.h
+++ b/libavformat/rtmppkt.h
@@ -244,6 +244,14 @@ void ff_amf_write_null(uint8_t **dst);
*/
void ff_amf_write_object_start(uint8_t **dst);
+/**
+ * Write marker and length for AMF array to buffer.
+ *
+ * @param dst pointer to the input buffer (will be modified)
+ * @param length value to write
+ */
+void ff_amf_write_array_start(uint8_t **dst, uint32_t length);
+
/**
* Write string used as field name in AMF object to buffer.
*
--
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".
^ permalink raw reply [flat|nested] 24+ messages in thread
* [FFmpeg-devel] [PATCH v2 2/2] avformat/rtmpproto: support enhanced rtmp
2023-08-25 5:30 ` [FFmpeg-devel] [PATCH v2 1/2] avformat/rtmppkt: add ff_amf_write_array for write array strings Steven Liu
@ 2023-08-25 5:30 ` Steven Liu
2023-08-25 9:04 ` Martin Storsjö
0 siblings, 1 reply; 24+ messages in thread
From: Steven Liu @ 2023-08-25 5:30 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Steven Liu
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 <lq@chinaffmpeg.org>
---
doc/protocols.texi | 6 ++++++
libavformat/rtmpproto.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 41 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..ea25454362 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,39 @@ 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)
+ 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];
+ switch (AV_RN32(fourcc_data)) {
+ case MKTAG('h', 'v', 'c', '1'):
+ case MKTAG('a', 'v', '0', '1'):
+ case MKTAG('v', 'p', '0', '9'):
+ av_strlcpy(fourcc, fourcc_data, sizeof(fourcc));
+ ff_amf_write_string(&p, fourcc);
+ break;
+ default:
+ return AVERROR(EINVAL);
+ }
+
+ fourcc_data += 5;
+ }
+ }
+
if (!rt->is_input) {
ff_amf_write_field_name(&p, "type");
ff_amf_write_string(&p, "nonprivate");
@@ -3104,6 +3138,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".
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [FFmpeg-devel] [PATCH v1 2/2] avformat/rtmpproto: support enhanced rtmp
2023-08-24 20:10 ` Tristan Matthews
2023-08-24 21:45 ` Marton Balint
@ 2023-08-25 5:32 ` Steven Liu
1 sibling, 0 replies; 24+ messages in thread
From: Steven Liu @ 2023-08-25 5:32 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Tristan Matthews <tmatth@videolan.org> 于2023年8月25日周五 04:11写道:
>
> Hi,
Hi Tristan,
>
> On Thu, Aug 24, 2023 at 1:32 AM Steven Liu <lq@chinaffmpeg.org> wrote:
> >
> > 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 <lq@chinaffmpeg.org>
> > ---
> > 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}
>
> I think this should be more like "Specify the codecs to use in an
> enhanced rtmp live stream", the wording here makes it sound more like
> a boolean flag.
>
> Also nit: "set a string"
>
> > +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
>
> nit: "codec list"
> > 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},
>
> I think this should be more like "Specify the codec(s) to use in an
> enhanced rtmp live stream" ?
>
> > {"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".
> _______________________________________________
> 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".
I have submitted new version patchset fix these problem:
https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2023-August/313483.html
Thanks
Steven
_______________________________________________
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".
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [FFmpeg-devel] [PATCH v1 2/2] avformat/rtmpproto: support enhanced rtmp
2023-08-24 21:45 ` Marton Balint
2023-08-25 5:30 ` [FFmpeg-devel] [PATCH v2 1/2] avformat/rtmppkt: add ff_amf_write_array for write array strings Steven Liu
@ 2023-08-25 5:33 ` Steven Liu
1 sibling, 0 replies; 24+ messages in thread
From: Steven Liu @ 2023-08-25 5:33 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Marton Balint <cus@passwd.hu> 于2023年8月25日周五 05:48写道:
Hi Marton,
>
>
>
> On Thu, 24 Aug 2023, Tristan Matthews wrote:
>
> > Hi,
> >
> > On Thu, Aug 24, 2023 at 1:32 AM Steven Liu <lq@chinaffmpeg.org> wrote:
> >>
> >> 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 <lq@chinaffmpeg.org>
> >> ---
> >> 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
>
> This is a list, so make it -rtmp_enhanced_codecs
>
> >> +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}
> >
> > I think this should be more like "Specify the codecs to use in an
> > enhanced rtmp live stream", the wording here makes it sound more like
> > a boolean flag.
>
> Actually it is a *supported* list, not a to-be-used list. So maybe
> "Specify the list of codecs the client advertises to support in an
> enhanced RTMP stream" is more appropriate.
>
> >
> > Also nit: "set a string"
> >
> >> +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 *enhanced_codecs
>
> >
> > nit: "codec list"
> >> 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;
>
> fourcc_data is always true.
>
> >> +
> >> + // 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) {
>
> Still always true.
>
> >> + unsigned char fourcc[5];
> >> + switch (*(uint32_t *)fourcc_data) {
>
> AV_RN32
>
> >> + 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';
>
> av_strlcpy(fourcc, fourcc_data, sizeof(fourcc));
>
> >> + ff_amf_write_string(&p, fourcc);
> >> + break;
> >> + default:
> >> + return AVERROR(EINVAL);
> >> + }
> >> +
> >> + fourcc_data += (fourcc_str_len - (fourcc_data - rt->enhanced)) > 4 ? 5 : 4;
>
> Why not simply fourcc_data += 5?
>
> >> + if (fourcc_data - rt->enhanced >= fourcc_str_len)
> >> + break;
>
> Why not check this as the loop condition instead?
>
> Regards,
> Marton
>
> >> + }
> >> + }
> >> +
> >> 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},
> >
> > I think this should be more like "Specify the codec(s) to use in an
> > enhanced rtmp live stream" ?
> >
> >> {"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".
> > _______________________________________________
> > 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".
> _______________________________________________
> 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".
New patchset is
coming:https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2023-August/313483.html
Thanks
Steven
_______________________________________________
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".
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 2/2] avformat/rtmpproto: support enhanced rtmp
2023-08-25 5:30 ` [FFmpeg-devel] [PATCH v2 2/2] avformat/rtmpproto: support enhanced rtmp Steven Liu
@ 2023-08-25 9:04 ` Martin Storsjö
2023-08-25 9:11 ` Steven Liu
0 siblings, 1 reply; 24+ messages in thread
From: Martin Storsjö @ 2023-08-25 9:04 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Steven Liu
On Fri, 25 Aug 2023, Steven Liu wrote:
> 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 <lq@chinaffmpeg.org>
> ---
> doc/protocols.texi | 6 ++++++
> libavformat/rtmpproto.c | 35 +++++++++++++++++++++++++++++++++++
> 2 files changed, 41 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..ea25454362 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,39 @@ 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)
> + return AVERROR(EINVAL);
If we trigger this error, we definitely should tell the user what was
wrong. 'Malformed rtmp_enhanched_codecs, should be of the form
"fourcc[,fourcc..]"' or something like that? (Would it be better to use
"frcc" or just "hvc1" or something else there, to show that it needs to be
exactly a four char string for each element?)
> +
> + 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];
> + switch (AV_RN32(fourcc_data)) {
> + case MKTAG('h', 'v', 'c', '1'):
This feels a bit convoluted to use AV_RN32 + MKTAG on data that is already
just a string - just using strncmp(fourcc_data, "hvc1", 4) would work just
as well. That doesn't fit quite as neatly into a switch, but would be a
more unwieldy if statement though.
> + case MKTAG('a', 'v', '0', '1'):
> + case MKTAG('v', 'p', '0', '9'):
> + av_strlcpy(fourcc, fourcc_data, sizeof(fourcc));
> + ff_amf_write_string(&p, fourcc);
> + break;
> + default:
When this fails, the user definitely needs to know what was wrong, so we
should print the string that didn't match the expectation. E.g.
("unsupported codec fourcc, %.*s", 4, fourcc_data) or something like that?
// Martin
_______________________________________________
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".
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 2/2] avformat/rtmpproto: support enhanced rtmp
2023-08-25 9:04 ` Martin Storsjö
@ 2023-08-25 9:11 ` Steven Liu
2023-08-25 9:38 ` Martin Storsjö
0 siblings, 1 reply; 24+ messages in thread
From: Steven Liu @ 2023-08-25 9:11 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Steven Liu
Martin Storsjö <martin@martin.st> 于2023年8月25日周五 17:04写道:
>
> On Fri, 25 Aug 2023, Steven Liu wrote:
>
> > 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 <lq@chinaffmpeg.org>
> > ---
> > doc/protocols.texi | 6 ++++++
> > libavformat/rtmpproto.c | 35 +++++++++++++++++++++++++++++++++++
> > 2 files changed, 41 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..ea25454362 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,39 @@ 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)
> > + return AVERROR(EINVAL);
>
> If we trigger this error, we definitely should tell the user what was
> wrong. 'Malformed rtmp_enhanched_codecs, should be of the form
> "fourcc[,fourcc..]"' or something like that? (Would it be better to use
> "frcc" or just "hvc1" or something else there, to show that it needs to be
> exactly a four char string for each element?)
Agreed
>
> > +
> > + 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];
> > + switch (AV_RN32(fourcc_data)) {
> > + case MKTAG('h', 'v', 'c', '1'):
>
> This feels a bit convoluted to use AV_RN32 + MKTAG on data that is already
> just a string - just using strncmp(fourcc_data, "hvc1", 4) would work just
I want use strncmp at first, but i think strncmp will slower than
switch uint32_t value, so i chose use uint32_t. or should i use
strncmp?
> as well. That doesn't fit quite as neatly into a switch, but would be a
> more unwieldy if statement though.
>
> > + case MKTAG('a', 'v', '0', '1'):
> > + case MKTAG('v', 'p', '0', '9'):
> > + av_strlcpy(fourcc, fourcc_data, sizeof(fourcc));
> > + ff_amf_write_string(&p, fourcc);
> > + break;
> > + default:
>
> When this fails, the user definitely needs to know what was wrong, so we
> should print the string that didn't match the expectation. E.g.
> ("unsupported codec fourcc, %.*s", 4, fourcc_data) or something like that?
good suggestion.
>
> // Martin
>
> _______________________________________________
> 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".
_______________________________________________
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".
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 2/2] avformat/rtmpproto: support enhanced rtmp
2023-08-25 9:11 ` Steven Liu
@ 2023-08-25 9:38 ` Martin Storsjö
2023-08-25 10:00 ` Steven Liu
2023-08-25 10:05 ` [FFmpeg-devel] [PATCH v3 1/2] avformat/rtmppkt: add ff_amf_write_array for write Steven Liu
0 siblings, 2 replies; 24+ messages in thread
From: Martin Storsjö @ 2023-08-25 9:38 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Steven Liu
On Fri, 25 Aug 2023, Steven Liu wrote:
>> > + 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];
>> > + switch (AV_RN32(fourcc_data)) {
>> > + case MKTAG('h', 'v', 'c', '1'):
>>
>> This feels a bit convoluted to use AV_RN32 + MKTAG on data that is already
>> just a string - just using strncmp(fourcc_data, "hvc1", 4) would work just
> I want use strncmp at first, but i think strncmp will slower than
> switch uint32_t value, so i chose use uint32_t. or should i use
> strncmp?
Yes, strncmp will be slower than switching on an uint32_t - but this isn't
really performance sensitive code. We do this once only, on startup, on a
handful of fourccs. So I believe code clarity is more important than
absolute performance here.
// Martin
_______________________________________________
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".
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 2/2] avformat/rtmpproto: support enhanced rtmp
2023-08-25 9:38 ` Martin Storsjö
@ 2023-08-25 10:00 ` Steven Liu
2023-08-25 10:06 ` Martin Storsjö
2023-08-25 10:05 ` [FFmpeg-devel] [PATCH v3 1/2] avformat/rtmppkt: add ff_amf_write_array for write Steven Liu
1 sibling, 1 reply; 24+ messages in thread
From: Steven Liu @ 2023-08-25 10:00 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Steven Liu
Martin Storsjö <martin@martin.st> 于2023年8月25日周五 17:38写道:
>
> On Fri, 25 Aug 2023, Steven Liu wrote:
>
> >> > + 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];
> >> > + switch (AV_RN32(fourcc_data)) {
> >> > + case MKTAG('h', 'v', 'c', '1'):
> >>
> >> This feels a bit convoluted to use AV_RN32 + MKTAG on data that is already
> >> just a string - just using strncmp(fourcc_data, "hvc1", 4) would work just
> > I want use strncmp at first, but i think strncmp will slower than
> > switch uint32_t value, so i chose use uint32_t. or should i use
> > strncmp?
>
> Yes, strncmp will be slower than switching on an uint32_t - but this isn't
> really performance sensitive code. We do this once only, on startup, on a
> handful of fourccs. So I believe code clarity is more important than
> absolute performance here.
Okay, i use strncasecmp next version patch. But i must told you, I
think MKTAG is clarity than use if+strncmp to me,
Because there looks like a fourcc codec list align code block.
>
> // Martin
>
> _______________________________________________
> 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".
_______________________________________________
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".
^ permalink raw reply [flat|nested] 24+ messages in thread
* [FFmpeg-devel] [PATCH v3 1/2] avformat/rtmppkt: add ff_amf_write_array for write
2023-08-25 9:38 ` Martin Storsjö
2023-08-25 10:00 ` Steven Liu
@ 2023-08-25 10:05 ` Steven Liu
2023-08-25 10:05 ` [FFmpeg-devel] [PATCH v3 2/2] avformat/rtmpproto: support enhanced rtmp Steven Liu
1 sibling, 1 reply; 24+ messages in thread
From: Steven Liu @ 2023-08-25 10:05 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Steven Liu
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
libavformat/rtmppkt.c | 6 ++++++
libavformat/rtmppkt.h | 8 ++++++++
2 files changed, 14 insertions(+)
diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
index 4b97c0833f..a602bf6a96 100644
--- a/libavformat/rtmppkt.c
+++ b/libavformat/rtmppkt.c
@@ -40,6 +40,12 @@ void ff_amf_write_number(uint8_t **dst, double val)
bytestream_put_be64(dst, av_double2int(val));
}
+void ff_amf_write_array_start(uint8_t **dst, uint32_t length)
+{
+ bytestream_put_byte(dst, AMF_DATA_TYPE_ARRAY);
+ bytestream_put_be32(dst, length);
+}
+
void ff_amf_write_string(uint8_t **dst, const char *str)
{
bytestream_put_byte(dst, AMF_DATA_TYPE_STRING);
diff --git a/libavformat/rtmppkt.h b/libavformat/rtmppkt.h
index a15d2a5773..7c580f2224 100644
--- a/libavformat/rtmppkt.h
+++ b/libavformat/rtmppkt.h
@@ -244,6 +244,14 @@ void ff_amf_write_null(uint8_t **dst);
*/
void ff_amf_write_object_start(uint8_t **dst);
+/**
+ * Write marker and length for AMF array to buffer.
+ *
+ * @param dst pointer to the input buffer (will be modified)
+ * @param length value to write
+ */
+void ff_amf_write_array_start(uint8_t **dst, uint32_t length);
+
/**
* Write string used as field name in AMF object to buffer.
*
--
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".
^ permalink raw reply [flat|nested] 24+ messages in thread
* [FFmpeg-devel] [PATCH v3 2/2] avformat/rtmpproto: support enhanced rtmp
2023-08-25 10:05 ` [FFmpeg-devel] [PATCH v3 1/2] avformat/rtmppkt: add ff_amf_write_array for write Steven Liu
@ 2023-08-25 10:05 ` Steven Liu
2023-08-25 10:09 ` Steven Liu
0 siblings, 1 reply; 24+ messages in thread
From: Steven Liu @ 2023-08-25 10:05 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Steven Liu
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 <lq@chinaffmpeg.org>
---
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".
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 2/2] avformat/rtmpproto: support enhanced rtmp
2023-08-25 10:00 ` Steven Liu
@ 2023-08-25 10:06 ` Martin Storsjö
0 siblings, 0 replies; 24+ messages in thread
From: Martin Storsjö @ 2023-08-25 10:06 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Steven Liu
On Fri, 25 Aug 2023, Steven Liu wrote:
> Martin Storsjö <martin@martin.st> 于2023年8月25日周五 17:38写道:
>>
>> On Fri, 25 Aug 2023, Steven Liu wrote:
>>
>> >> > + 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];
>> >> > + switch (AV_RN32(fourcc_data)) {
>> >> > + case MKTAG('h', 'v', 'c', '1'):
>> >>
>> >> This feels a bit convoluted to use AV_RN32 + MKTAG on data that is already
>> >> just a string - just using strncmp(fourcc_data, "hvc1", 4) would work just
>> > I want use strncmp at first, but i think strncmp will slower than
>> > switch uint32_t value, so i chose use uint32_t. or should i use
>> > strncmp?
>>
>> Yes, strncmp will be slower than switching on an uint32_t - but this isn't
>> really performance sensitive code. We do this once only, on startup, on a
>> handful of fourccs. So I believe code clarity is more important than
>> absolute performance here.
> Okay, i use strncasecmp next version patch.
I don't see a need for this to be case insensitive?
> But i must told you, I think MKTAG is clarity than use if+strncmp to me,
> Because there looks like a fourcc codec list align code block.
If you prefer MKTAG for clarity, then I guess the current solution is fine
here for me as well - it's not a hard opinion from me. Let's see if
someone else wants to comment on it first maybe.
// Martin
_______________________________________________
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".
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [FFmpeg-devel] [PATCH v3 2/2] avformat/rtmpproto: support enhanced rtmp
2023-08-25 10:05 ` [FFmpeg-devel] [PATCH v3 2/2] avformat/rtmpproto: support enhanced rtmp Steven Liu
@ 2023-08-25 10:09 ` Steven Liu
2023-08-26 7:49 ` Marton Balint
0 siblings, 1 reply; 24+ messages in thread
From: Steven Liu @ 2023-08-25 10:09 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Steven Liu <lq@chinaffmpeg.org> 于2023年8月25日周五 18:05写道:
>
> 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 <lq@chinaffmpeg.org>
> ---
> 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)) {
s/strncasecmp/av_strncasecmp/g fix local.
> + 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".
_______________________________________________
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".
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [FFmpeg-devel] [PATCH v3 2/2] avformat/rtmpproto: support enhanced rtmp
2023-08-25 10:09 ` Steven Liu
@ 2023-08-26 7:49 ` Marton Balint
2023-08-26 8:28 ` Steven Liu
0 siblings, 1 reply; 24+ messages in thread
From: Marton Balint @ 2023-08-26 7:49 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Fri, 25 Aug 2023, Steven Liu wrote:
> Steven Liu <lq@chinaffmpeg.org> 于2023年8月25日周五 18:05写道:
>>
>> 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 <lq@chinaffmpeg.org>
>> ---
>> 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,
This option should be set to a comma separated list of fourcc values, like
@code{hvc1,av01,vp09} for multiple codecs or @code{hvc1} for only one
codec. The specified list will be presented in the "fourCcLive" property
of the 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
Useless comment
>> + ff_amf_write_field_name(&p, "fourCcList");
>> +
>> + // write the fourcc array length
Useless comment
>> + 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)) {
>
> s/strncasecmp/av_strncasecmp/g fix local.
Why you want this to be case insensitive? The specs only contains the
lowercase variants as examples. So I'd rather use simply strncmp.
>
>> + 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;
As far as I saw the specs does not provide an explicit list of fourcc
that can be used, so we should not limit it either, it makes the code more
future-proof. Therefore I suggest we accept unknown fourccs, but warn the
user about them.
>> + }
>> +
>> + 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},
Maybe make the default "av01,vp09,hevc"? This is a list of codecs the
client advetises to support, and for the legacy counterpart of this,
"audioCodecs" and "videoCodecs", we also advertise to support almost
everything. So for consistency we should follow the same route, report to
support every codec that is in the specs, unless this causes some
compatibility issue I don't see.
Thanks,
Marton
>> {"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".
> _______________________________________________
> 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".
_______________________________________________
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".
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [FFmpeg-devel] [PATCH v3 2/2] avformat/rtmpproto: support enhanced rtmp
2023-08-26 7:49 ` Marton Balint
@ 2023-08-26 8:28 ` Steven Liu
2023-08-26 9:25 ` Marton Balint
0 siblings, 1 reply; 24+ messages in thread
From: Steven Liu @ 2023-08-26 8:28 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Marton Balint <cus@passwd.hu> 于2023年8月26日周六 15:52写道:
Hi Marton,
>
>
>
> On Fri, 25 Aug 2023, Steven Liu wrote:
>
> > Steven Liu <lq@chinaffmpeg.org> 于2023年8月25日周五 18:05写道:
> >>
> >> 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 <lq@chinaffmpeg.org>
> >> ---
> >> 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,
>
> This option should be set to a comma separated list of fourcc values, like
> @code{hvc1,av01,vp09} for multiple codecs or @code{hvc1} for only one
> codec. The specified list will be presented in the "fourCcLive" property
> of the Connect Command Message.
ok
>
>
> >> +
> >> @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
>
> Useless comment
ok
>
> >> + ff_amf_write_field_name(&p, "fourCcList");
> >> +
> >> + // write the fourcc array length
>
> Useless comment
ok
>
> >> + 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)) {
> >
> > s/strncasecmp/av_strncasecmp/g fix local.
>
> Why you want this to be case insensitive? The specs only contains the
> lowercase variants as examples. So I'd rather use simply strncmp.
ok
>
> >
> >> + 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;
>
> As far as I saw the specs does not provide an explicit list of fourcc
> that can be used, so we should not limit it either, it makes the code more
> future-proof. Therefore I suggest we accept unknown fourccs, but warn the
> user about them.
I set unsupported codec fourcc, and return a patchwelcome is because
there just add hevc,av1,vp9 codec supported in flvenc and flvdec,
dose not add the others in the flv right, so if user want use another
codecs, it should give a error and patch welcome.
>
> >> + }
> >> +
> >> + 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},
>
> Maybe make the default "av01,vp09,hevc"? This is a list of codecs the
I think make it null should better, because not should every body's
ffmpeg has been support hevc/av1/vp9 codec,
so I set it null default, and the other reason is not sure all rtmp
server has beed support enhanced rtmp, so make it null default
when user not use codec hevc/av1/vp9.
> client advetises to support, and for the legacy counterpart of this,
> "audioCodecs" and "videoCodecs", we also advertise to support almost
> everything. So for consistency we should follow the same route, report to
> support every codec that is in the specs, unless this causes some
> compatibility issue I don't see.
>
> Thanks,
> Marton
>
> >> {"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".
> > _______________________________________________
> > 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".
> _______________________________________________
> 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".
Thanks Marton,
Steven
_______________________________________________
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".
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [FFmpeg-devel] [PATCH v3 2/2] avformat/rtmpproto: support enhanced rtmp
2023-08-26 8:28 ` Steven Liu
@ 2023-08-26 9:25 ` Marton Balint
2023-08-28 2:00 ` [FFmpeg-devel] [PATCH v4 1/2] avformat/rtmppkt: add ff_amf_write_array for write Steven Liu
0 siblings, 1 reply; 24+ messages in thread
From: Marton Balint @ 2023-08-26 9:25 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Sat, 26 Aug 2023, Steven Liu wrote:
> Marton Balint <cus@passwd.hu> 于2023年8月26日周六 15:52写道:
> Hi Marton,
[...]
>> >
>> >> + 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;
>>
>> As far as I saw the specs does not provide an explicit list of fourcc
>> that can be used, so we should not limit it either, it makes the code more
>> future-proof. Therefore I suggest we accept unknown fourccs, but warn the
>> user about them.
> I set unsupported codec fourcc, and return a patchwelcome is because
> there just add hevc,av1,vp9 codec supported in flvenc and flvdec,
> dose not add the others in the flv right, so if user want use another
> codecs, it should give a error and patch welcome.
Ok, but if you only want to support a strict list, then maybe
AV_OPT_TYPE_FLAGS type would be a better option type? Fine with me either
way.
>>
>> >> + }
>> >> +
>> >> + 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},
>>
>> Maybe make the default "av01,vp09,hevc"? This is a list of codecs the
> I think make it null should better, because not should every body's
> ffmpeg has been support hevc/av1/vp9 codec,
And not everybody is using libavcodec for decoding hevc/av1/vp9, so which
decoders are compiled in does not really matter. Do we really want the
default to *not support* any recent codec?
> so I set it null default, and the other reason is not sure all rtmp
> server has beed support enhanced rtmp, so make it null default
> when user not use codec hevc/av1/vp9.
I'd expect that legacy rtmp servers will just ignore "fourCcList"
property as an unknown/unsupported property, but I am not sure what would
actually happen... Maybe some tests should be made with the most common
implementations. If it actually causes issues, then I am fine with
the NULL default.
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".
^ permalink raw reply [flat|nested] 24+ messages in thread
* [FFmpeg-devel] [PATCH v4 1/2] avformat/rtmppkt: add ff_amf_write_array for write
2023-08-26 9:25 ` Marton Balint
@ 2023-08-28 2:00 ` Steven Liu
2023-08-28 2:00 ` [FFmpeg-devel] [PATCH v4 2/2] avformat/rtmpproto: support enhanced rtmp Steven Liu
0 siblings, 1 reply; 24+ messages in thread
From: Steven Liu @ 2023-08-28 2:00 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Steven Liu
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
libavformat/rtmppkt.c | 6 ++++++
libavformat/rtmppkt.h | 8 ++++++++
2 files changed, 14 insertions(+)
diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
index 4b97c0833f..a602bf6a96 100644
--- a/libavformat/rtmppkt.c
+++ b/libavformat/rtmppkt.c
@@ -40,6 +40,12 @@ void ff_amf_write_number(uint8_t **dst, double val)
bytestream_put_be64(dst, av_double2int(val));
}
+void ff_amf_write_array_start(uint8_t **dst, uint32_t length)
+{
+ bytestream_put_byte(dst, AMF_DATA_TYPE_ARRAY);
+ bytestream_put_be32(dst, length);
+}
+
void ff_amf_write_string(uint8_t **dst, const char *str)
{
bytestream_put_byte(dst, AMF_DATA_TYPE_STRING);
diff --git a/libavformat/rtmppkt.h b/libavformat/rtmppkt.h
index a15d2a5773..7c580f2224 100644
--- a/libavformat/rtmppkt.h
+++ b/libavformat/rtmppkt.h
@@ -244,6 +244,14 @@ void ff_amf_write_null(uint8_t **dst);
*/
void ff_amf_write_object_start(uint8_t **dst);
+/**
+ * Write marker and length for AMF array to buffer.
+ *
+ * @param dst pointer to the input buffer (will be modified)
+ * @param length value to write
+ */
+void ff_amf_write_array_start(uint8_t **dst, uint32_t length);
+
/**
* Write string used as field name in AMF object to buffer.
*
--
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".
^ permalink raw reply [flat|nested] 24+ messages in thread
* [FFmpeg-devel] [PATCH v4 2/2] avformat/rtmpproto: support enhanced rtmp
2023-08-28 2:00 ` [FFmpeg-devel] [PATCH v4 1/2] avformat/rtmppkt: add ff_amf_write_array for write Steven Liu
@ 2023-08-28 2:00 ` Steven Liu
2023-08-28 19:33 ` Marton Balint
0 siblings, 1 reply; 24+ messages in thread
From: Steven Liu @ 2023-08-28 2:00 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Steven Liu
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 <lq@chinaffmpeg.org>
---
doc/protocols.texi | 11 +++++++++++
libavformat/rtmpproto.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+)
diff --git a/doc/protocols.texi b/doc/protocols.texi
index b3fad55591..c7637c11c9 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -896,6 +896,17 @@ 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 be set to a comma separated
+list of fourcc values, like @code{hvc1,av01,vp09} for multiple codecs
+or @code{hvc1} for only one codec. The specified list will be presented
+in the "fourCcLive" property of the Connect Command Message.
+
+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..98718bc6da 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,38 @@ 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;
+ ff_amf_write_field_name(&p, "fourCcList");
+ ff_amf_write_array_start(&p, list_len);
+
+ while(fourcc_data - rt->enhanced_codecs < fourcc_str_len) {
+ unsigned char fourcc[5];
+ if (!strncmp(fourcc_data, "hvc1", 4) ||
+ !strncmp(fourcc_data, "av01", 4) ||
+ !strncmp(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 +3137,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".
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [FFmpeg-devel] [PATCH v4 2/2] avformat/rtmpproto: support enhanced rtmp
2023-08-28 2:00 ` [FFmpeg-devel] [PATCH v4 2/2] avformat/rtmpproto: support enhanced rtmp Steven Liu
@ 2023-08-28 19:33 ` Marton Balint
2023-08-29 1:06 ` Steven Liu
0 siblings, 1 reply; 24+ messages in thread
From: Marton Balint @ 2023-08-28 19:33 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Mon, 28 Aug 2023, Steven Liu wrote:
> 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 <lq@chinaffmpeg.org>
> ---
> doc/protocols.texi | 11 +++++++++++
> libavformat/rtmpproto.c | 34 ++++++++++++++++++++++++++++++++++
> 2 files changed, 45 insertions(+)
>
> diff --git a/doc/protocols.texi b/doc/protocols.texi
> index b3fad55591..c7637c11c9 100644
> --- a/doc/protocols.texi
> +++ b/doc/protocols.texi
> @@ -896,6 +896,17 @@ 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 be set to a comma separated
> +list of fourcc values, like @code{hvc1,av01,vp09} for multiple codecs
> +or @code{hvc1} for only one codec. The specified list will be presented
> +in the "fourCcLive" property of the Connect Command Message.
> +
> +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,
This paragraph looks like some unintetional leftover, as the same
information is there in the earlier paragraph.
Regards,
Marton
> +
> @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..98718bc6da 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,38 @@ 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;
> + ff_amf_write_field_name(&p, "fourCcList");
> + ff_amf_write_array_start(&p, list_len);
> +
> + while(fourcc_data - rt->enhanced_codecs < fourcc_str_len) {
> + unsigned char fourcc[5];
> + if (!strncmp(fourcc_data, "hvc1", 4) ||
> + !strncmp(fourcc_data, "av01", 4) ||
> + !strncmp(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 +3137,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".
>
_______________________________________________
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".
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [FFmpeg-devel] [PATCH v4 2/2] avformat/rtmpproto: support enhanced rtmp
2023-08-28 19:33 ` Marton Balint
@ 2023-08-29 1:06 ` Steven Liu
0 siblings, 0 replies; 24+ messages in thread
From: Steven Liu @ 2023-08-29 1:06 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Marton Balint <cus@passwd.hu> 于2023年8月29日周二 03:35写道:
Hi Marton,
>
>
>
> On Mon, 28 Aug 2023, Steven Liu wrote:
>
> > 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 <lq@chinaffmpeg.org>
> > ---
> > doc/protocols.texi | 11 +++++++++++
> > libavformat/rtmpproto.c | 34 ++++++++++++++++++++++++++++++++++
> > 2 files changed, 45 insertions(+)
> >
> > diff --git a/doc/protocols.texi b/doc/protocols.texi
> > index b3fad55591..c7637c11c9 100644
> > --- a/doc/protocols.texi
> > +++ b/doc/protocols.texi
> > @@ -896,6 +896,17 @@ 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 be set to a comma separated
> > +list of fourcc values, like @code{hvc1,av01,vp09} for multiple codecs
> > +or @code{hvc1} for only one codec. The specified list will be presented
> > +in the "fourCcLive" property of the Connect Command Message.
> > +
> > +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,
>
> This paragraph looks like some unintetional leftover, as the same
> information is there in the earlier paragraph.
good catch, fixed locally
Any other comments?
>
> Regards,
> Marton
>
> > +
> > @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..98718bc6da 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,38 @@ 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;
> > + ff_amf_write_field_name(&p, "fourCcList");
> > + ff_amf_write_array_start(&p, list_len);
> > +
> > + while(fourcc_data - rt->enhanced_codecs < fourcc_str_len) {
> > + unsigned char fourcc[5];
> > + if (!strncmp(fourcc_data, "hvc1", 4) ||
> > + !strncmp(fourcc_data, "av01", 4) ||
> > + !strncmp(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 +3137,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".
> >
> _______________________________________________
> 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".
Thanks
Steven
_______________________________________________
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".
^ permalink raw reply [flat|nested] 24+ messages in thread
end of thread, other threads:[~2023-08-29 1:07 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-24 5:32 [FFmpeg-devel] [PATCH v1 1/2] avformat/rtmppkt: add ff_amf_write_array for write array strings Steven Liu
2023-08-24 5:32 ` [FFmpeg-devel] [PATCH v1 2/2] avformat/rtmpproto: support enhanced rtmp Steven Liu
2023-08-24 20:10 ` Tristan Matthews
2023-08-24 21:45 ` Marton Balint
2023-08-25 5:30 ` [FFmpeg-devel] [PATCH v2 1/2] avformat/rtmppkt: add ff_amf_write_array for write array strings Steven Liu
2023-08-25 5:30 ` [FFmpeg-devel] [PATCH v2 2/2] avformat/rtmpproto: support enhanced rtmp Steven Liu
2023-08-25 9:04 ` Martin Storsjö
2023-08-25 9:11 ` Steven Liu
2023-08-25 9:38 ` Martin Storsjö
2023-08-25 10:00 ` Steven Liu
2023-08-25 10:06 ` Martin Storsjö
2023-08-25 10:05 ` [FFmpeg-devel] [PATCH v3 1/2] avformat/rtmppkt: add ff_amf_write_array for write Steven Liu
2023-08-25 10:05 ` [FFmpeg-devel] [PATCH v3 2/2] avformat/rtmpproto: support enhanced rtmp Steven Liu
2023-08-25 10:09 ` Steven Liu
2023-08-26 7:49 ` Marton Balint
2023-08-26 8:28 ` Steven Liu
2023-08-26 9:25 ` Marton Balint
2023-08-28 2:00 ` [FFmpeg-devel] [PATCH v4 1/2] avformat/rtmppkt: add ff_amf_write_array for write Steven Liu
2023-08-28 2:00 ` [FFmpeg-devel] [PATCH v4 2/2] avformat/rtmpproto: support enhanced rtmp Steven Liu
2023-08-28 19:33 ` Marton Balint
2023-08-29 1:06 ` Steven Liu
2023-08-25 5:33 ` [FFmpeg-devel] [PATCH v1 " Steven Liu
2023-08-25 5:32 ` Steven Liu
2023-08-24 20:47 ` [FFmpeg-devel] [PATCH v1 1/2] avformat/rtmppkt: add ff_amf_write_array for write array strings Marton Balint
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git