[FFmpeg-devel] [PATCH v2] examples/transcoding: Fix time_base handling
The `dec_ctx->time_base` was incorrectly default set by avcodec_open2(), while `enc_ctx->time_base` was derived from `dec_ctx->framerate`. This mismatch could cause incorrect video duration in the output. This patch corrects the issue by adjusting the `enc_ctx->time_base` calculation to account for `ticks_per_frame`, ensuring that the time base is consistent between the decoder and encoder contexts. --- Begin Message --- From 6a02fbaf6c6068040640ff105ad70115fb81b5d2 Mon Sep 17 00:00:00 2001 From: Jack Lau Date: Tue, 4 Feb 2025 21:39:20 +0800 Subject: [PATCH] examples/transcoding: Fix time_base handling X-Unsent: 1 To: ffmpeg-devel@ffmpeg.org The `dec_ctx->time_base` was incorrectly default set by avcodec_open2(), while `enc_ctx->time_base` was derived from `dec_ctx->framerate`. This mismatch could cause incorrect video duration in the output. This patch corrects the issue by adjusting the `enc_ctx->time_base` calculation to account for `ticks_per_frame`, ensuring that the time base is consistent between the decoder and encoder contexts. Signed-off-by: Jack Lau --- doc/examples/transcoding.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/examples/transcoding.c b/doc/examples/transcoding.c index 013f89fc7d..8cc1991267 100644 --- a/doc/examples/transcoding.c +++ b/doc/examples/transcoding.c @@ -172,7 +172,7 @@ static int open_output_file(const char *filename) else enc_ctx->pix_fmt = dec_ctx->pix_fmt; /* video time_base can be set to whatever is handy and supported by encoder */ -enc_ctx->time_base = av_inv_q(dec_ctx->framerate); +enc_ctx->time_base = av_inv_q(av_mul_q(dec_ctx->framerate, (AVRational){dec_ctx->ticks_per_frame, 1})); } else { enc_ctx->sample_rate = dec_ctx->sample_rate; ret = av_channel_layout_copy(&enc_ctx->ch_layout, &dec_ctx->ch_layout); @@ -180,7 +180,7 @@ static int open_output_file(const char *filename) return ret; /* take first format from list of supported formats */ enc_ctx->sample_fmt = encoder->sample_fmts[0]; -enc_ctx->time_base = (AVRational){1, enc_ctx->sample_rate}; +enc_ctx->time_base = (AVRational){1,dec_ctx->sample_rate}; } if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) -- 2.48.1 --- End Message --- ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] examples/transcoding: Fix time_base handling
From: Jack Lau The `dec_ctx->time_base` was incorrectly default set by avcodec_open2(), while `enc_ctx->time_base` was derived from `dec_ctx->framerate`. This mismatch could cause incorrect video duration in the output. This patch corrects the issue by adjusting the `enc_ctx->time_base` calculation to account for `ticks_per_frame`, ensuring that the time base is consistent between the decoder and encoder contexts. --- doc/examples/transcoding.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/examples/transcoding.c b/doc/examples/transcoding.c index 013f89fc7d..09c2ad4b62 100644 --- a/doc/examples/transcoding.c +++ b/doc/examples/transcoding.c @@ -172,7 +172,7 @@ static int open_output_file(const char *filename) else enc_ctx->pix_fmt = dec_ctx->pix_fmt; /* video time_base can be set to whatever is handy and supported by encoder */ -enc_ctx->time_base = av_inv_q(dec_ctx->framerate); +enc_ctx->time_base = av_inv_q(av_mul_q(dec_ctx->framerate, (AVRational){dec_ctx->ticks_per_frame, 1})); } else { enc_ctx->sample_rate = dec_ctx->sample_rate; ret = av_channel_layout_copy(&enc_ctx->ch_layout, &dec_ctx->ch_layout); @@ -180,7 +180,7 @@ static int open_output_file(const char *filename) return ret; /* take first format from list of supported formats */ enc_ctx->sample_fmt = encoder->sample_fmts[0]; -enc_ctx->time_base = (AVRational){1, enc_ctx->sample_rate}; +enc_ctx->time_base = (AVRational){1, dec_ctx->sample_rate}; } if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) -- 2.48.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/hls: fix typo There is an extra space in the original comment
--- libavformat/hls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index 3bdc1bc848..c2130bb883 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -1993,7 +1993,7 @@ static int hls_read_header(AVFormatContext *s) return ret; /* XXX: Some HLS servers don't like being sent the range header, - in this case, need to setting http_seekable = 0 to disable + in this case, need to setting http_seekable = 0 to disable the range header */ av_dict_set_int(&c->avio_opts, "seekable", c->http_seekable, 0); -- 2.48.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/mpegenc: increase the default size of the VBV buffer
Increase the default buffer size to match more modern encoding scenarios. --- libavformat/mpegenc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c index 6b6763c30f..2b3b98b894 100644 --- a/libavformat/mpegenc.c +++ b/libavformat/mpegenc.c @@ -446,11 +446,10 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) stream->max_buffer_size = 6 * 1024 + props->buffer_size / 8; else { av_log(ctx, AV_LOG_WARNING, - "VBV buffer size not set, using default size of 230KB\n" + "VBV buffer size not set, using default size of 2048KB\n" "If you want the mpeg file to be compliant to some specification\n" "Like DVD, VCD or others, make sure you set the correct buffer size\n"); -// FIXME: this is probably too small as default -stream->max_buffer_size = 230 * 1024; +stream->max_buffer_size = 2048 * 1024; } if (stream->max_buffer_size > 1024 * 8191) { av_log(ctx, AV_LOG_WARNING, "buffer size %d, too large\n", stream->max_buffer_size); -- 2.48.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/hlsenc: calculate bitrate for segments with duration < 0.5
The previous code sets the bitrate to be calculated only when duration>0.5, which is obviously not general enough. In some scenarios, we may need to set hls_time<0.5, then the generated segments are all <0.5. At this time, because the bitrate is not calculated, max_bitrate is empty, and ff_hls_write_stream_info cannot write stream info normally, causing master_pl to be unavailable. Signed-off-by: Jack Lau --- libavformat/hlsenc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index c6ffdb99e5..223c516103 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -1150,9 +1150,7 @@ static int hls_append_segment(struct AVFormatContext *s, HLSContext *hls, vs->total_size += size; vs->total_duration += duration; -if (duration > 0.5) { -// Don't include the final, possibly very short segment in the -// calculation of the max bitrate. +if (duration > 0) { int cur_bitrate = (int)(8 * size / duration); if (cur_bitrate > vs->max_bitrate) vs->max_bitrate = cur_bitrate; -- 2.47.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/dashdec: just make seg->url in absolute path once
Should fix ticket 11543 if input url is relative path, the seg-url would make absolute url twice in get_content_url and open_input function but it doesn't need make absolute url in open_input since we set it already Signed-off-by: Jack Lau --- libavformat/dashdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index c3f3d7f3f8..2915f6eb82 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -1700,7 +1700,7 @@ static int open_input(DASHContext *c, struct representation *pls, struct fragmen av_dict_set_int(&opts, "end_offset", seg->url_offset + seg->size, 0); } -ff_make_absolute_url(url, c->max_url_size, c->base_url, seg->url); +ff_make_absolute_url(url, c->max_url_size, "", seg->url); av_log(pls->parent, AV_LOG_VERBOSE, "DASH request for url '%s', offset %"PRId64"\n", url, seg->url_offset); ret = open_url(pls->parent, &pls->input, url, &c->avio_opts, opts, NULL); -- 2.49.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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/rtpdec_mpeg4: add need_parsing for rtsp AAC
fix ticket #11531 the rtsp aac did not marked keyframe which cannot easy copy to output. because f265f9c9d04863180503707bfad285f48e6bf080 commit change the AAC props to match xHE-AAC. in some formats like MOV, need_parsing is set, so AAC can be still parsed be keyframe but rtsp did not, so this patch add it Signed-off-by: Jack Lau --- libavformat/rtpdec_mpeg4.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/rtpdec_mpeg4.c b/libavformat/rtpdec_mpeg4.c index 6531632b2d..c506bcbed1 100644 --- a/libavformat/rtpdec_mpeg4.c +++ b/libavformat/rtpdec_mpeg4.c @@ -363,6 +363,7 @@ const RTPDynamicProtocolHandler ff_mpeg4_generic_dynamic_handler = { .enc_name = "mpeg4-generic", .codec_type = AVMEDIA_TYPE_AUDIO, .codec_id = AV_CODEC_ID_AAC, +.need_parsing = AVSTREAM_PARSE_HEADERS, .priv_data_size = sizeof(PayloadContext), .parse_sdp_a_line = parse_sdp_line, .close = close_context, -- 2.49.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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/hlsenc: fix CODECS Attribute hard code in hevc EXT-X-STREAM-INF
fix ticket: 10786 parse the SPS from extradata and get profile_compatibility, tier, constraints which was been hard code before. HEVC CODECS Attribute reference to: ISO/IEC14496-15 Signed-off-by: Jack Lau --- libavformat/hlsenc.c | 41 ++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 6148685f40..849130196f 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -379,7 +379,10 @@ static void write_codec_attr(AVStream *st, VariantStream *vs) } else if (st->codecpar->codec_id == AV_CODEC_ID_HEVC) { uint8_t *data = st->codecpar->extradata; int profile = AV_PROFILE_UNKNOWN; +uint32_t profile_compatibility = AV_PROFILE_UNKNOWN; +char tier = 0; int level = AV_LEVEL_UNKNOWN; +char constraints[8] = ""; if (st->codecpar->profile != AV_PROFILE_UNKNOWN) profile = st->codecpar->profile; @@ -393,6 +396,8 @@ static void write_codec_attr(AVStream *st, VariantStream *vs) uint8_t *rbsp_buf; int remain_size = 0; int rbsp_size = 0; +uint32_t profile_compatibility_flags = 0; +uint8_t high_nibble = 0; /* skip start code + nalu header */ data += 6; /* process by reference General NAL unit syntax */ @@ -406,8 +411,35 @@ static void write_codec_attr(AVStream *st, VariantStream *vs) } /* skip sps_video_parameter_set_id u(4), * sps_max_sub_layers_minus1u(3), - * and sps_temporal_id_nesting_flag u(1) */ + * and sps_temporal_id_nesting_flag u(1) + * + * TIER represents the general_tier_flag, with 'L' indicating the flag is 0, + * and 'H' indicating the flag is 1 + */ +tier = (int)(rbsp_buf[1] & 0x20) == 0 ? 'L' : 'H'; profile = rbsp_buf[1] & 0x1f; +/* PROFILE_COMPATIBILITY is general_profile_compatibility_flags, but in reverse bit order, + * in a hexadecimal representation (leading zeroes may be omitted). + */ +profile_compatibility_flags = AV_RB32(rbsp_buf + 2); +/* revise these bits to get the profile compatibility value */ +{ + uint32_t x = profile_compatibility_flags; +x = ((x & 0xU) << 1) | ((x >> 1) & 0xU); +x = ((x & 0xU) << 2) | ((x >> 2) & 0xU); +x = ((x & 0x0F0F0F0FU) << 4) | ((x >> 4) & 0x0F0F0F0FU); +x = ((x & 0x00FF00FFU) << 8) | ((x >> 8) & 0x00FF00FFU); +profile_compatibility = (x << 16) | (x >> 16); +} +/* skip 8 + 8 + 32 + * CONSTRAINTS is a hexadecimal representation of the general_constraint_indicator_flags. + * each byte is separated by a '.', and trailing zero bytes may be omitted. + * drop the trailing zero bytes refer to ISO/IEC14496-15. + */ +high_nibble = rbsp_buf[7] >> 4; +snprintf(constraints, sizeof(constraints), + high_nibble ? "%02x.%x" : "%02x", + rbsp_buf[6], high_nibble); /* skip 8 + 8 + 32 + 4 + 43 + 1 bit */ level = rbsp_buf[12]; av_freep(&rbsp_buf); @@ -417,8 +449,11 @@ static void write_codec_attr(AVStream *st, VariantStream *vs) } if (st->codecpar->codec_tag == MKTAG('h','v','c','1') && profile != AV_PROFILE_UNKNOWN && -level != AV_LEVEL_UNKNOWN) { -snprintf(attr, sizeof(attr), "%s.%d.4.L%d.B01", av_fourcc2str(st->codecpar->codec_tag), profile, level); +profile_compatibility != AV_PROFILE_UNKNOWN && +tier != 0 && +level != AV_LEVEL_UNKNOWN && +constraints[0] != '\0') { +snprintf(attr, sizeof(attr), "%s.%d.%x.%c%d.%s", av_fourcc2str(st->codecpar->codec_tag), profile, profile_compatibility, tier, level, constraints); } else goto fail; } else if (st->codecpar->codec_id == AV_CODEC_ID_MP2) { -- 2.47.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/hlsenc: fix CODECS Attribute hard code in hevc EXT-X-STREAM-INF
fix ticket: 10786 parse the SPS from extradata and get profile_compatibility, tier, constraints which was been hard code before. HEVC CODECS Attribute reference to: ISO/IEC14496-15 Signed-off-by: Jack Lau --- libavformat/hlsenc.c | 38 +++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 6148685f40..c6ffdb99e5 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -379,7 +379,10 @@ static void write_codec_attr(AVStream *st, VariantStream *vs) } else if (st->codecpar->codec_id == AV_CODEC_ID_HEVC) { uint8_t *data = st->codecpar->extradata; int profile = AV_PROFILE_UNKNOWN; +uint32_t profile_compatibility = AV_PROFILE_UNKNOWN; +char tier = 0; int level = AV_LEVEL_UNKNOWN; +char constraints[8] = ""; if (st->codecpar->profile != AV_PROFILE_UNKNOWN) profile = st->codecpar->profile; @@ -393,6 +396,8 @@ static void write_codec_attr(AVStream *st, VariantStream *vs) uint8_t *rbsp_buf; int remain_size = 0; int rbsp_size = 0; +uint32_t profile_compatibility_flags = 0; +uint8_t high_nibble = 0; /* skip start code + nalu header */ data += 6; /* process by reference General NAL unit syntax */ @@ -406,8 +411,32 @@ static void write_codec_attr(AVStream *st, VariantStream *vs) } /* skip sps_video_parameter_set_id u(4), * sps_max_sub_layers_minus1u(3), - * and sps_temporal_id_nesting_flag u(1) */ + * and sps_temporal_id_nesting_flag u(1) + * + * TIER represents the general_tier_flag, with 'L' indicating the flag is 0, + * and 'H' indicating the flag is 1 + */ +tier = (rbsp_buf[1] & 0x20) == 0 ? 'L' : 'H'; profile = rbsp_buf[1] & 0x1f; +/* PROFILE_COMPATIBILITY is general_profile_compatibility_flags, but in reverse bit order, + * in a hexadecimal representation (leading zeroes may be omitted). + */ +profile_compatibility_flags = AV_RB32(rbsp_buf + 2); +/* revise these bits to get the profile compatibility value */ +profile_compatibility_flags = ((profile_compatibility_flags & 0xU) << 1) | ((profile_compatibility_flags >> 1) & 0xU); +profile_compatibility_flags = ((profile_compatibility_flags & 0xU) << 2) | ((profile_compatibility_flags >> 2) & 0xU); +profile_compatibility_flags = ((profile_compatibility_flags & 0x0F0F0F0FU) << 4) | ((profile_compatibility_flags >> 4) & 0x0F0F0F0FU); +profile_compatibility_flags = ((profile_compatibility_flags & 0x00FF00FFU) << 8) | ((profile_compatibility_flags >> 8) & 0x00FF00FFU); +profile_compatibility = (profile_compatibility_flags << 16) | (profile_compatibility_flags >> 16); +/* skip 8 + 8 + 32 + * CONSTRAINTS is a hexadecimal representation of the general_constraint_indicator_flags. + * each byte is separated by a '.', and trailing zero bytes may be omitted. + * drop the trailing zero bytes refer to ISO/IEC14496-15. + */ +high_nibble = rbsp_buf[7] >> 4; +snprintf(constraints, sizeof(constraints), + high_nibble ? "%02x.%x" : "%02x", + rbsp_buf[6], high_nibble); /* skip 8 + 8 + 32 + 4 + 43 + 1 bit */ level = rbsp_buf[12]; av_freep(&rbsp_buf); @@ -417,8 +446,11 @@ static void write_codec_attr(AVStream *st, VariantStream *vs) } if (st->codecpar->codec_tag == MKTAG('h','v','c','1') && profile != AV_PROFILE_UNKNOWN && -level != AV_LEVEL_UNKNOWN) { -snprintf(attr, sizeof(attr), "%s.%d.4.L%d.B01", av_fourcc2str(st->codecpar->codec_tag), profile, level); +profile_compatibility != AV_PROFILE_UNKNOWN && +tier != 0 && +level != AV_LEVEL_UNKNOWN && +constraints[0] != '\0') { +snprintf(attr, sizeof(attr), "%s.%d.%x.%c%d.%s", av_fourcc2str(st->codecpar->codec_tag), profile, profile_compatibility, tier, level, constraints); } else goto fail; } else if (st->codecpar->codec_id == AV_CODEC_ID_MP2) { -- 2.47.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/hlsenc: fix CODECS Attribute hard code in hevc EXT-X-STREAM-INF
fix ticket: 10786 parse the SPS from extradata and get profile_compatibility, tier, constraints which was been hard code before. HEVC CODECS Attribute reference to: ISO/IEC14496-15 Signed-off-by: Jack Lau --- libavformat/hlsenc.c | 37 ++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 6148685f40..be7a78021a 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -379,7 +379,10 @@ static void write_codec_attr(AVStream *st, VariantStream *vs) } else if (st->codecpar->codec_id == AV_CODEC_ID_HEVC) { uint8_t *data = st->codecpar->extradata; int profile = AV_PROFILE_UNKNOWN; +uint32_t profile_compatibility = AV_PROFILE_UNKNOWN; +char tier = '0'; int level = AV_LEVEL_UNKNOWN; +char constraints[5] = "0"; if (st->codecpar->profile != AV_PROFILE_UNKNOWN) profile = st->codecpar->profile; @@ -393,6 +396,8 @@ static void write_codec_attr(AVStream *st, VariantStream *vs) uint8_t *rbsp_buf; int remain_size = 0; int rbsp_size = 0; +uint32_t profile_compatibility_flags = 0; +uint8_t high_nibble = 0; /* skip start code + nalu header */ data += 6; /* process by reference General NAL unit syntax */ @@ -406,8 +411,31 @@ static void write_codec_attr(AVStream *st, VariantStream *vs) } /* skip sps_video_parameter_set_id u(4), * sps_max_sub_layers_minus1u(3), - * and sps_temporal_id_nesting_flag u(1) */ + * and sps_temporal_id_nesting_flag u(1) + * + * TIER represents the general_tier_flag, with 'L' indicating the flag is 0, + * and 'H' indicating the flag is 1 + */ +tier = (int)(rbsp_buf[1] & 0x20) == 0 ? 'L' : 'H'; profile = rbsp_buf[1] & 0x1f; +/* PROFILE_COMPATIBILITY is general_profile_compatibility_flags, but in reverse bit order, + * in a hexadecimal representation (leading zeroes may be omitted). + */ +profile_compatibility_flags = (rbsp_buf[2] << 24) | (rbsp_buf[3] << 16) | (rbsp_buf[4] << 8) | rbsp_buf[5]; +/* revise these bits to get the profile compatibility value */ +for (int i = 0; i < 32; i++) { +profile_compatibility = (profile_compatibility << 1) | (profile_compatibility_flags & 1); +profile_compatibility_flags >>= 1; +} +/* skip 8 + 8 + 32 + * CONSTRAINTS is a hexadecimal representation of the general_constraint_indicator_flags. + * each byte is separated by a '.', and trailing zero bytes may be omitted. + * drop the trailing zero bytes refer to ISO/IEC14496-15. + */ +high_nibble = rbsp_buf[7] >> 4; +snprintf(constraints, sizeof(constraints), + high_nibble ? "%02x.%x" : "%02x", + rbsp_buf[6], high_nibble); /* skip 8 + 8 + 32 + 4 + 43 + 1 bit */ level = rbsp_buf[12]; av_freep(&rbsp_buf); @@ -417,8 +445,11 @@ static void write_codec_attr(AVStream *st, VariantStream *vs) } if (st->codecpar->codec_tag == MKTAG('h','v','c','1') && profile != AV_PROFILE_UNKNOWN && -level != AV_LEVEL_UNKNOWN) { -snprintf(attr, sizeof(attr), "%s.%d.4.L%d.B01", av_fourcc2str(st->codecpar->codec_tag), profile, level); +profile_compatibility != AV_PROFILE_UNKNOWN && +tier != '0' && +level != AV_LEVEL_UNKNOWN && +strcmp(constraints, "0") != 0) { +snprintf(attr, sizeof(attr), "%s.%d.%x.%c%d.%s", av_fourcc2str(st->codecpar->codec_tag), profile, profile_compatibility, tier, level, constraints); } else goto fail; } else if (st->codecpar->codec_id == AV_CODEC_ID_MP2) { -- 2.47.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/hlsenc: fix CODECS Attribute hard code in hevc EXT-X-STREAM-INF
fix ticket: 10786 parse the SPS from extradata and get profile_compatibility, tier, constraints which was been hard code before. HEVC CODECS Attribute reference to: ISO/IEC14496-15 Signed-off-by: Jack Lau --- libavformat/hlsenc.c | 38 +++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 6148685f40..c6ffdb99e5 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -379,7 +379,10 @@ static void write_codec_attr(AVStream *st, VariantStream *vs) } else if (st->codecpar->codec_id == AV_CODEC_ID_HEVC) { uint8_t *data = st->codecpar->extradata; int profile = AV_PROFILE_UNKNOWN; +uint32_t profile_compatibility = AV_PROFILE_UNKNOWN; +char tier = 0; int level = AV_LEVEL_UNKNOWN; +char constraints[8] = ""; if (st->codecpar->profile != AV_PROFILE_UNKNOWN) profile = st->codecpar->profile; @@ -393,6 +396,8 @@ static void write_codec_attr(AVStream *st, VariantStream *vs) uint8_t *rbsp_buf; int remain_size = 0; int rbsp_size = 0; +uint32_t profile_compatibility_flags = 0; +uint8_t high_nibble = 0; /* skip start code + nalu header */ data += 6; /* process by reference General NAL unit syntax */ @@ -406,8 +411,32 @@ static void write_codec_attr(AVStream *st, VariantStream *vs) } /* skip sps_video_parameter_set_id u(4), * sps_max_sub_layers_minus1u(3), - * and sps_temporal_id_nesting_flag u(1) */ + * and sps_temporal_id_nesting_flag u(1) + * + * TIER represents the general_tier_flag, with 'L' indicating the flag is 0, + * and 'H' indicating the flag is 1 + */ +tier = (rbsp_buf[1] & 0x20) == 0 ? 'L' : 'H'; profile = rbsp_buf[1] & 0x1f; +/* PROFILE_COMPATIBILITY is general_profile_compatibility_flags, but in reverse bit order, + * in a hexadecimal representation (leading zeroes may be omitted). + */ +profile_compatibility_flags = AV_RB32(rbsp_buf + 2); +/* revise these bits to get the profile compatibility value */ +profile_compatibility_flags = ((profile_compatibility_flags & 0xU) << 1) | ((profile_compatibility_flags >> 1) & 0xU); +profile_compatibility_flags = ((profile_compatibility_flags & 0xU) << 2) | ((profile_compatibility_flags >> 2) & 0xU); +profile_compatibility_flags = ((profile_compatibility_flags & 0x0F0F0F0FU) << 4) | ((profile_compatibility_flags >> 4) & 0x0F0F0F0FU); +profile_compatibility_flags = ((profile_compatibility_flags & 0x00FF00FFU) << 8) | ((profile_compatibility_flags >> 8) & 0x00FF00FFU); +profile_compatibility = (profile_compatibility_flags << 16) | (profile_compatibility_flags >> 16); +/* skip 8 + 8 + 32 + * CONSTRAINTS is a hexadecimal representation of the general_constraint_indicator_flags. + * each byte is separated by a '.', and trailing zero bytes may be omitted. + * drop the trailing zero bytes refer to ISO/IEC14496-15. + */ +high_nibble = rbsp_buf[7] >> 4; +snprintf(constraints, sizeof(constraints), + high_nibble ? "%02x.%x" : "%02x", + rbsp_buf[6], high_nibble); /* skip 8 + 8 + 32 + 4 + 43 + 1 bit */ level = rbsp_buf[12]; av_freep(&rbsp_buf); @@ -417,8 +446,11 @@ static void write_codec_attr(AVStream *st, VariantStream *vs) } if (st->codecpar->codec_tag == MKTAG('h','v','c','1') && profile != AV_PROFILE_UNKNOWN && -level != AV_LEVEL_UNKNOWN) { -snprintf(attr, sizeof(attr), "%s.%d.4.L%d.B01", av_fourcc2str(st->codecpar->codec_tag), profile, level); +profile_compatibility != AV_PROFILE_UNKNOWN && +tier != 0 && +level != AV_LEVEL_UNKNOWN && +constraints[0] != '\0') { +snprintf(attr, sizeof(attr), "%s.%d.%x.%c%d.%s", av_fourcc2str(st->codecpar->codec_tag), profile, profile_compatibility, tier, level, constraints); } else goto fail; } else if (st->codecpar->codec_id == AV_CODEC_ID_MP2) { -- 2.47.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/dashenc: add hevc codec attributes parse
fix ticket: 11316 add set_hevc_codec_str function refer to hlsenc.c but do some necessary changes Signed-off-by: Jack Lau --- libavformat/dashenc.c | 81 +++ 1 file changed, 81 insertions(+) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index d4a6fe0304..04c5b562d5 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -57,6 +57,7 @@ #include "url.h" #include "vpcc.h" #include "dash.h" +#include "nal.h" typedef enum { SEGMENT_TYPE_AUTO = 0, @@ -344,6 +345,84 @@ static void set_vp9_codec_str(AVFormatContext *s, AVCodecParameters *par, return; } +static void set_hevc_codec_str(AVCodecParameters *par, char *str, int size) { +uint8_t *data = par->extradata; +int profile = AV_PROFILE_UNKNOWN; +uint32_t profile_compatibility = AV_PROFILE_UNKNOWN; +char tier = 0; +int level = AV_LEVEL_UNKNOWN; +char constraints[8] = ""; + +if (par->profile != AV_PROFILE_UNKNOWN) +profile = par->profile; +if (par->level != AV_LEVEL_UNKNOWN) +level = par->level; + +/* check the boundary of data which from current position is small than extradata_size */ +while (data && (data - par->extradata + 19) < par->extradata_size) { +/* get HEVC SPS NAL and seek to profile_tier_level */ +if (!(data[0] | data[1] | data[2]) && data[3] == 1 && ((data[4] & 0x7E) == 0x42)) { +uint8_t *rbsp_buf; +int remain_size = 0; +int rbsp_size = 0; +uint32_t profile_compatibility_flags = 0; +uint8_t high_nibble = 0; +/* skip start code + nalu header */ +data += 6; +/* process by reference General NAL unit syntax */ +remain_size = par->extradata_size - (data - par->extradata); +rbsp_buf = ff_nal_unit_extract_rbsp(data, remain_size, &rbsp_size, 0); +if (!rbsp_buf) +return; +if (rbsp_size < 13) { +av_freep(&rbsp_buf); +break; +} +/* skip sps_video_parameter_set_id u(4), +* sps_max_sub_layers_minus1u(3), +* and sps_temporal_id_nesting_flag u(1) +* +* TIER represents the general_tier_flag, with 'L' indicating the flag is 0, +* and 'H' indicating the flag is 1 +*/ +tier = (rbsp_buf[1] & 0x20) == 0 ? 'L' : 'H'; +profile = rbsp_buf[1] & 0x1f; +/* PROFILE_COMPATIBILITY is general_profile_compatibility_flags, but in reverse bit order, +* in a hexadecimal representation (leading zeroes may be omitted). +*/ +profile_compatibility_flags = AV_RB32(rbsp_buf + 2); +/* revise these bits to get the profile compatibility value */ +profile_compatibility_flags = ((profile_compatibility_flags & 0xU) << 1) | ((profile_compatibility_flags >> 1) & 0xU); +profile_compatibility_flags = ((profile_compatibility_flags & 0xU) << 2) | ((profile_compatibility_flags >> 2) & 0xU); +profile_compatibility_flags = ((profile_compatibility_flags & 0x0F0F0F0FU) << 4) | ((profile_compatibility_flags >> 4) & 0x0F0F0F0FU); +profile_compatibility_flags = ((profile_compatibility_flags & 0x00FF00FFU) << 8) | ((profile_compatibility_flags >> 8) & 0x00FF00FFU); +profile_compatibility = (profile_compatibility_flags << 16) | (profile_compatibility_flags >> 16); +/* skip 8 + 8 + 32 +* CONSTRAINTS is a hexadecimal representation of the general_constraint_indicator_flags. +* each byte is separated by a '.', and trailing zero bytes may be omitted. +* drop the trailing zero bytes refer to ISO/IEC14496-15. +*/ +high_nibble = rbsp_buf[7] >> 4; +snprintf(constraints, sizeof(constraints), +high_nibble ? "%02x.%x" : "%02x", +rbsp_buf[6], high_nibble); +/* skip 8 + 8 + 32 + 4 + 43 + 1 bit */ +level = rbsp_buf[12]; +av_freep(&rbsp_buf); +break; +} +data++; +} +if (profile != AV_PROFILE_UNKNOWN && +profile_compatibility != AV_PROFILE_UNKNOWN && +tier != 0 && +level != AV_LEVEL_UNKNOWN && +constraints[0] != '\0') { +av_strlcatf(str, size, ".%d.%x.%c%d.%s", profile, profile_compatibility, tier, level, constraints); +} +return; +} + static void set_codec_str(AVFormatContext *s, AVCodecParameters *par, AVRational *frame_rate, char *str, int size) { @@ -422,6 +501,8 @@ static void set_codec_str(AVFormatContext *s, AVCodecParameters *par, av_strlcatf(str, size, ".%02x%02x%02x", extradata[1], extradata[2], extradata[3]); av_free(tmpbuf); +} else if (!strcmp(str, "
[FFmpeg-devel] [PATCH] avformat/whip: set this muxer as experimental
Signed-off-by: Jack Lau --- libavformat/whip.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/libavformat/whip.c b/libavformat/whip.c index 0671e23635..e7cd57400d 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -1733,6 +1733,12 @@ static av_cold int whip_init(AVFormatContext *s) int ret; WHIPContext *whip = s->priv_data; +if (s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { +av_log(s, AV_LOG_ERROR, +"WHIP: This muxer is experimental, please set -strict experimental in order to enable it\n"); +return AVERROR_EXPERIMENTAL; +} + if ((ret = initialize(s)) < 0) goto end; -- 2.49.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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2] avformat/tls_openssl: fix build error when openssl version < 3
add the missing data structure pkey in the tls_context properly set this pkey and free it Signed-off-by: Jack Lau --- libavformat/tls_openssl.c | 33 - 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c index b589d5d90a..86e8935fee 100644 --- a/libavformat/tls_openssl.c +++ b/libavformat/tls_openssl.c @@ -467,6 +467,7 @@ typedef struct TLSContext { TLSShared tls_shared; SSL_CTX *ctx; SSL *ssl; +EVP_PKEY *pkey; #if OPENSSL_VERSION_NUMBER >= 0x101fL BIO_METHOD* url_bio_method; #endif @@ -849,7 +850,7 @@ static av_cold int openssl_init_ca_key_cert(URLContext *h) goto fail; } } else if (p->tls_shared.key_buf) { -pkey = pkey_from_pem_string(p->tls_shared.key_buf, 1); +p->pkey = pkey = pkey_from_pem_string(p->tls_shared.key_buf, 1); if (SSL_CTX_use_PrivateKey(p->ctx, pkey) != 1) { av_log(p, AV_LOG_ERROR, "TLS: Init SSL_CTX_use_PrivateKey failed, %s\n", openssl_get_error(p)); ret = AVERROR(EINVAL); @@ -876,6 +877,9 @@ static int dtls_start(URLContext *h, const char *url, int flags, AVDictionary ** int ret = 0; c->is_dtls = 1; const char* ciphers = "ALL"; +#if OPENSSL_VERSION_NUMBER < 0x10002000L // v1.0.2 +EC_KEY *ec_key = NULL; +#endif /** * The profile for OpenSSL's SRTP is SRTP_AES128_CM_SHA1_80, see ssl/d1_srtp.c. * The profile for FFmpeg's SRTP is SRTP_AES128_CM_HMAC_SHA1_80, see libavformat/srtp.c. @@ -908,15 +912,6 @@ static int dtls_start(URLContext *h, const char *url, int flags, AVDictionary ** } #endif -#if OPENSSL_VERSION_NUMBER < 0x1010L // v1.1.x -#if OPENSSL_VERSION_NUMBER < 0x10002000L // v1.0.2 -if (ctx->dtls_eckey) -SSL_CTX_set_tmp_ecdh(p->ctx, p->dtls_eckey); -#else -SSL_CTX_set_ecdh_auto(p->ctx, 1); -#endif -#endif - /** * We activate "ALL" cipher suites to align with the peer's capabilities, * ensuring maximum compatibility. @@ -930,6 +925,17 @@ static int dtls_start(URLContext *h, const char *url, int flags, AVDictionary ** ret = openssl_init_ca_key_cert(h); if (ret < 0) goto fail; +#if OPENSSL_VERSION_NUMBER < 0x1010L // v1.1.x +#if OPENSSL_VERSION_NUMBER < 0x10002000L // v1.0.2 +if (p->pkey) +ec_key = EVP_PKEY_get1_EC_KEY(p->pkey); +if (ec_key) +SSL_CTX_set_tmp_ecdh(p->ctx, ec_key); +#else +SSL_CTX_set_ecdh_auto(p->ctx, 1); +#endif +#endif + /* Server will send Certificate Request. */ SSL_CTX_set_verify(p->ctx, SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE, openssl_dtls_verify_callback); /* The depth count is "level 0:peer certificate", "level 1: CA certificate", @@ -1001,6 +1007,9 @@ static int dtls_start(URLContext *h, const char *url, int flags, AVDictionary ** ret = 0; fail: +#if OPENSSL_VERSION_NUMBER < 0x10002000L // v1.0.2 +EC_KEY_free(ec_key); +#endif return ret; } @@ -1015,9 +1024,7 @@ static av_cold int dtls_close(URLContext *h) av_freep(&ctx->tls_shared.fingerprint); av_freep(&ctx->tls_shared.cert_buf); av_freep(&ctx->tls_shared.key_buf); -#if OPENSSL_VERSION_NUMBER < 0x3000L /* OpenSSL 3.0 */ -EC_KEY_free(ctx->dtls_eckey); -#endif +EVP_PKEY_free(ctx->pkey); return 0; } -- 2.49.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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/whip: mark as experimental
--- Begin Message --- This muxer has been marked AVFMT_EXPERIMENTAL. Add a note in muxers.texi that WHIP is an experimental feature This patch doesn't effect WHIP usage command, as WHIP always needs to be explicitly specified The details as follows: https://ffmpeg.org/pipermail/ffmpeg-devel/2025-June/344705.html Signed-off-by: Jack Lau --- doc/muxers.texi| 2 ++ libavformat/whip.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index 30c95c3d34..d2ee90bf33 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -3885,6 +3885,8 @@ ffmpeg -f webm_dash_manifest -i video1.webm \ WebRTC (Real-Time Communication) muxer that supports sub-second latency streaming according to the WHIP (WebRTC-HTTP ingestion protocol) specification. +This is an experimental feature. + It uses HTTP as a signaling protocol to exchange SDP capabilities and ICE lite candidates. Then, it uses STUN binding requests and responses to establish a session over UDP. Subsequently, it initiates a DTLS handshake to exchange the SRTP encryption keys. Lastly, it splits video and diff --git a/libavformat/whip.c b/libavformat/whip.c index 710f24fc5a..bb7b8657dc 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -1907,7 +1907,7 @@ const FFOutputFormat ff_whip_muxer = { .p.long_name= NULL_IF_CONFIG_SMALL("WHIP(WebRTC-HTTP ingestion protocol) muxer"), .p.audio_codec = AV_CODEC_ID_OPUS, .p.video_codec = AV_CODEC_ID_H264, -.p.flags= AVFMT_GLOBALHEADER | AVFMT_NOFILE, +.p.flags= AVFMT_GLOBALHEADER | AVFMT_NOFILE | AVFMT_EXPERIMENTAL, .p.priv_class = &whip_muxer_class, .priv_data_size = sizeof(WHIPContext), .init = whip_init, -- 2.49.0 --- End Message --- ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 1/2] avformat/whip: add whip_flags ignore_ipv6 to skip IPv6 candidates
--- Begin Message --- replace AV_OPT_FLAG_DECODING_PARAM to ENCODING mark this ignore_ipv6 flag could ignore any ipv6 ICE candidate, preventing “No route to host” errors on devices without IPv6 connectivity. Signed-off-by: Jack Lau --- libavformat/whip.c | 25 +++-- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/libavformat/whip.c b/libavformat/whip.c index 710f24fc5a..84c2092e5e 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -193,9 +193,14 @@ enum WHIPState { WHIP_STATE_FAILED, }; +typedef enum WHIPFlags { +WHIP_FLAG_IGNORE_IPV6 = (1 << 0) // Ignore ipv6 candidate +} WHIPFlags; + typedef struct WHIPContext { AVClass *av_class; +uint32_t flags;// enum WHIPFlags /* The state of the RTC connection. */ enum WHIPState state; /* The callback return value for DTLS. */ @@ -871,6 +876,7 @@ static int parse_answer(AVFormatContext *s) if (ptr && av_stristr(ptr, "host")) { char protocol[17], host[129]; int priority, port; +struct in6_addr addr6; ret = sscanf(ptr, "%16s %d %128s %d typ host", protocol, &priority, host, &port); if (ret != 4) { av_log(whip, AV_LOG_ERROR, "WHIP: Failed %d to parse line %d %s from %s\n", @@ -879,6 +885,11 @@ static int parse_answer(AVFormatContext *s) goto end; } +if (whip->flags & WHIP_FLAG_IGNORE_IPV6 && inet_pton(AF_INET6, host, &addr6) == 1) { +av_log(whip, AV_LOG_DEBUG, "WHIP: Ignore ipv6 %s, line %d %s \n", host, i, line); +continue; +} + if (av_strcasecmp(protocol, "udp")) { av_log(whip, AV_LOG_ERROR, "WHIP: Protocol %s is not supported by RTC, choose udp, line %d %s of %s\n", protocol, i, line, whip->sdp_answer); @@ -1885,13 +1896,15 @@ static int whip_check_bitstream(AVFormatContext *s, AVStream *st, const AVPacket } #define OFFSET(x) offsetof(WHIPContext, x) -#define DEC AV_OPT_FLAG_DECODING_PARAM +#define ENC AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { -{ "handshake_timeout", "Timeout in milliseconds for ICE and DTLS handshake.", OFFSET(handshake_timeout), AV_OPT_TYPE_INT,{ .i64 = 5000 },-1, INT_MAX, DEC }, -{ "pkt_size", "The maximum size, in bytes, of RTP packets that send out", OFFSET(pkt_size), AV_OPT_TYPE_INT,{ .i64 = 1200 }, -1, INT_MAX, DEC }, -{ "authorization", "The optional Bearer token for WHIP Authorization", OFFSET(authorization), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, DEC }, -{ "cert_file", "The optional certificate file path for DTLS", OFFSET(cert_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, DEC }, -{ "key_file", "The optional private key file path for DTLS", OFFSET(key_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, DEC }, +{ "handshake_timeout", "Timeout in milliseconds for ICE and DTLS handshake.", OFFSET(handshake_timeout), AV_OPT_TYPE_INT,{ .i64 = 5000 },-1, INT_MAX, ENC }, +{ "pkt_size", "The maximum size, in bytes, of RTP packets that send out", OFFSET(pkt_size), AV_OPT_TYPE_INT,{ .i64 = 1200 }, -1, INT_MAX, ENC }, +{ "authorization", "The optional Bearer token for WHIP Authorization", OFFSET(authorization), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, +{ "cert_file", "The optional certificate file path for DTLS", OFFSET(cert_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, +{ "key_file", "The optional private key file path for DTLS", OFFSET(key_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, +{ "whip_flags", "Set flags affecting WHIP connection behavior", OFFSET(flags), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, 0, UINT_MAX, ENC, .unit = "flags" }, +{ "ignore_ipv6","The optional ignore any IPv6 ICE candidate", 0, AV_OPT_TYPE_CONST, { .i64 = WHIP_FLAG_IGNORE_IPV6 }, 0, UINT_MAX, ENC, .unit = "flags" }, { NULL }, }; -- 2.49.0 --- End Message --- ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 2/2] avformat/whip: reindent whip options
--- Begin Message --- Signed-off-by: Jack Lau --- libavformat/whip.c | 21 ++--- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/libavformat/whip.c b/libavformat/whip.c index 84c2092e5e..ef219defb7 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -1898,13 +1898,20 @@ static int whip_check_bitstream(AVFormatContext *s, AVStream *st, const AVPacket #define OFFSET(x) offsetof(WHIPContext, x) #define ENC AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { -{ "handshake_timeout", "Timeout in milliseconds for ICE and DTLS handshake.", OFFSET(handshake_timeout), AV_OPT_TYPE_INT,{ .i64 = 5000 },-1, INT_MAX, ENC }, -{ "pkt_size", "The maximum size, in bytes, of RTP packets that send out", OFFSET(pkt_size), AV_OPT_TYPE_INT,{ .i64 = 1200 }, -1, INT_MAX, ENC }, -{ "authorization", "The optional Bearer token for WHIP Authorization", OFFSET(authorization), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, -{ "cert_file", "The optional certificate file path for DTLS", OFFSET(cert_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, -{ "key_file", "The optional private key file path for DTLS", OFFSET(key_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, -{ "whip_flags", "Set flags affecting WHIP connection behavior", OFFSET(flags), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, 0, UINT_MAX, ENC, .unit = "flags" }, -{ "ignore_ipv6","The optional ignore any IPv6 ICE candidate", 0, AV_OPT_TYPE_CONST, { .i64 = WHIP_FLAG_IGNORE_IPV6 }, 0, UINT_MAX, ENC, .unit = "flags" }, +{ "handshake_timeout", "Timeout in milliseconds for ICE and DTLS handshake.", OFFSET(handshake_timeout), +AV_OPT_TYPE_INT,{ .i64 = 5000 },-1, INT_MAX, ENC }, +{ "pkt_size", "The maximum size, in bytes, of RTP packets that send out", OFFSET(pkt_size), +AV_OPT_TYPE_INT,{ .i64 = 1200 },-1, INT_MAX, ENC }, +{ "authorization", "The optional Bearer token for WHIP Authorization", OFFSET(authorization), +AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, +{ "cert_file", "The optional certificate file path for DTLS", OFFSET(cert_file), +AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, +{ "key_file", "The optional private key file path for DTLS", OFFSET(key_file), +AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, +{ "whip_flags", "Set flags affecting WHIP connection behavior", OFFSET(flags), +AV_OPT_TYPE_FLAGS, { .i64 = 0 },0, UINT_MAX, ENC, .unit = "flags" }, +{ "ignore_ipv6","The optional ignore any IPv6 ICE candidate", 0, +AV_OPT_TYPE_CONST, { .i64 = WHIP_FLAG_IGNORE_IPV6 },0, UINT_MAX, ENC, .unit = "flags" }, { NULL }, }; -- 2.49.0 --- End Message --- ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3 1/3] avformat/whip: replace AV_OPT_FLAG_DECODING_PARAM to ENCODING
--- Begin Message --- Signed-off-by: Jack Lau --- libavformat/whip.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavformat/whip.c b/libavformat/whip.c index 710f24fc5a..a6827d3478 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -1885,13 +1885,13 @@ static int whip_check_bitstream(AVFormatContext *s, AVStream *st, const AVPacket } #define OFFSET(x) offsetof(WHIPContext, x) -#define DEC AV_OPT_FLAG_DECODING_PARAM +#define ENC AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { -{ "handshake_timeout", "Timeout in milliseconds for ICE and DTLS handshake.", OFFSET(handshake_timeout), AV_OPT_TYPE_INT,{ .i64 = 5000 },-1, INT_MAX, DEC }, -{ "pkt_size", "The maximum size, in bytes, of RTP packets that send out", OFFSET(pkt_size), AV_OPT_TYPE_INT,{ .i64 = 1200 }, -1, INT_MAX, DEC }, -{ "authorization", "The optional Bearer token for WHIP Authorization", OFFSET(authorization), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, DEC }, -{ "cert_file", "The optional certificate file path for DTLS", OFFSET(cert_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, DEC }, -{ "key_file", "The optional private key file path for DTLS", OFFSET(key_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, DEC }, +{ "handshake_timeout", "Timeout in milliseconds for ICE and DTLS handshake.", OFFSET(handshake_timeout), AV_OPT_TYPE_INT,{ .i64 = 5000 },-1, INT_MAX, ENC }, +{ "pkt_size", "The maximum size, in bytes, of RTP packets that send out", OFFSET(pkt_size), AV_OPT_TYPE_INT,{ .i64 = 1200 }, -1, INT_MAX, ENC }, +{ "authorization", "The optional Bearer token for WHIP Authorization", OFFSET(authorization), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, +{ "cert_file", "The optional certificate file path for DTLS", OFFSET(cert_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, +{ "key_file", "The optional private key file path for DTLS", OFFSET(key_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, { NULL }, }; -- 2.49.0 --- End Message --- ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3 2/3] avformat/whip: add whip_flags ignore_ipv6 to skip IPv6 candidates
--- Begin Message --- mark this ignore_ipv6 flag could ignore any ipv6 ICE candidate, preventing “No route to host” errors on devices without IPv6 connectivity. Signed-off-by: Jack Lau --- libavformat/whip.c | 13 + 1 file changed, 13 insertions(+) diff --git a/libavformat/whip.c b/libavformat/whip.c index a6827d3478..84c2092e5e 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -193,9 +193,14 @@ enum WHIPState { WHIP_STATE_FAILED, }; +typedef enum WHIPFlags { +WHIP_FLAG_IGNORE_IPV6 = (1 << 0) // Ignore ipv6 candidate +} WHIPFlags; + typedef struct WHIPContext { AVClass *av_class; +uint32_t flags;// enum WHIPFlags /* The state of the RTC connection. */ enum WHIPState state; /* The callback return value for DTLS. */ @@ -871,6 +876,7 @@ static int parse_answer(AVFormatContext *s) if (ptr && av_stristr(ptr, "host")) { char protocol[17], host[129]; int priority, port; +struct in6_addr addr6; ret = sscanf(ptr, "%16s %d %128s %d typ host", protocol, &priority, host, &port); if (ret != 4) { av_log(whip, AV_LOG_ERROR, "WHIP: Failed %d to parse line %d %s from %s\n", @@ -879,6 +885,11 @@ static int parse_answer(AVFormatContext *s) goto end; } +if (whip->flags & WHIP_FLAG_IGNORE_IPV6 && inet_pton(AF_INET6, host, &addr6) == 1) { +av_log(whip, AV_LOG_DEBUG, "WHIP: Ignore ipv6 %s, line %d %s \n", host, i, line); +continue; +} + if (av_strcasecmp(protocol, "udp")) { av_log(whip, AV_LOG_ERROR, "WHIP: Protocol %s is not supported by RTC, choose udp, line %d %s of %s\n", protocol, i, line, whip->sdp_answer); @@ -1892,6 +1903,8 @@ static const AVOption options[] = { { "authorization", "The optional Bearer token for WHIP Authorization", OFFSET(authorization), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, { "cert_file", "The optional certificate file path for DTLS", OFFSET(cert_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, { "key_file", "The optional private key file path for DTLS", OFFSET(key_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, +{ "whip_flags", "Set flags affecting WHIP connection behavior", OFFSET(flags), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, 0, UINT_MAX, ENC, .unit = "flags" }, +{ "ignore_ipv6","The optional ignore any IPv6 ICE candidate", 0, AV_OPT_TYPE_CONST, { .i64 = WHIP_FLAG_IGNORE_IPV6 }, 0, UINT_MAX, ENC, .unit = "flags" }, { NULL }, }; -- 2.49.0 --- End Message --- ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3 3/3] avformat/whip: reindent whip options
--- Begin Message --- Signed-off-by: Jack Lau --- libavformat/whip.c | 21 ++--- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/libavformat/whip.c b/libavformat/whip.c index 84c2092e5e..6a33966472 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -1898,13 +1898,20 @@ static int whip_check_bitstream(AVFormatContext *s, AVStream *st, const AVPacket #define OFFSET(x) offsetof(WHIPContext, x) #define ENC AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { -{ "handshake_timeout", "Timeout in milliseconds for ICE and DTLS handshake.", OFFSET(handshake_timeout), AV_OPT_TYPE_INT,{ .i64 = 5000 },-1, INT_MAX, ENC }, -{ "pkt_size", "The maximum size, in bytes, of RTP packets that send out", OFFSET(pkt_size), AV_OPT_TYPE_INT,{ .i64 = 1200 }, -1, INT_MAX, ENC }, -{ "authorization", "The optional Bearer token for WHIP Authorization", OFFSET(authorization), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, -{ "cert_file", "The optional certificate file path for DTLS", OFFSET(cert_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, -{ "key_file", "The optional private key file path for DTLS", OFFSET(key_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, -{ "whip_flags", "Set flags affecting WHIP connection behavior", OFFSET(flags), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, 0, UINT_MAX, ENC, .unit = "flags" }, -{ "ignore_ipv6","The optional ignore any IPv6 ICE candidate", 0, AV_OPT_TYPE_CONST, { .i64 = WHIP_FLAG_IGNORE_IPV6 }, 0, UINT_MAX, ENC, .unit = "flags" }, +{ "handshake_timeout", "Timeout in milliseconds for ICE and DTLS handshake.", OFFSET(handshake_timeout), +AV_OPT_TYPE_INT,{ .i64 = 5000 },-1, INT_MAX, ENC }, +{ "pkt_size", "The maximum size, in bytes, of RTP packets that send out", OFFSET(pkt_size), +AV_OPT_TYPE_INT,{ .i64 = 1200 },-1, INT_MAX, ENC }, +{ "authorization", "The optional Bearer token for WHIP Authorization", OFFSET(authorization), +AV_OPT_TYPE_STRING, { .str = NULL },0, 0, ENC }, +{ "cert_file", "The optional certificate file path for DTLS", OFFSET(cert_file), +AV_OPT_TYPE_STRING, { .str = NULL },0, 0, ENC }, +{ "key_file", "The optional private key file path for DTLS", OFFSET(key_file), +AV_OPT_TYPE_STRING, { .str = NULL },0, 0, ENC }, +{ "whip_flags", "Set flags affecting WHIP connection behavior", OFFSET(flags), +AV_OPT_TYPE_FLAGS, { .i64 = 0 }, 0, UINT_MAX, ENC, .unit = "flags" }, +{ "ignore_ipv6","The optional Ignore any IPv6 ICE candidate", 0, +AV_OPT_TYPE_CONST, { .i64 = WHIP_FLAG_IGNORE_IPV6 }, 0, UINT_MAX, ENC, .unit = "flags" }, { NULL }, }; -- 2.49.0 --- End Message --- ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3] avformat/tls_openssl: fix warnings when openssl is lower version
--- Begin Message --- api doc: https://docs.openssl.org/1.0.2/man3/BIO_s_mem In higher versions (openssl 1.0.2 and higher), the function signature is BIO *BIO_new_mem_buf(const void *buf, int len), so passing a const string doesn't cause an warnings. However, in lower versions of OpenSSL, the function signature becomes BIO *BIO_new_mem_buf(void *buf, int len), which leads to warnings. OpenSSL guarantees that it will not modify the string, so it's safe to cast the pem_str to (void *) to avoid this warning. Signed-off-by: Jack Lau --- libavformat/tls_openssl.c | 8 1 file changed, 8 insertions(+) diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c index 86e8935fee..2a3905891d 100644 --- a/libavformat/tls_openssl.c +++ b/libavformat/tls_openssl.c @@ -415,7 +415,11 @@ error: */ static EVP_PKEY *pkey_from_pem_string(const char *pem_str, int is_priv) { +#if OPENSSL_VERSION_NUMBER < 0x10002000L /* OpenSSL 1.0.2 */ +BIO *mem = BIO_new_mem_buf((void *)pem_str, -1); +#else BIO *mem = BIO_new_mem_buf(pem_str, -1); +#endif if (!mem) { av_log(NULL, AV_LOG_ERROR, "BIO_new_mem_buf failed\n"); return NULL; @@ -445,7 +449,11 @@ static EVP_PKEY *pkey_from_pem_string(const char *pem_str, int is_priv) */ static X509 *cert_from_pem_string(const char *pem_str) { +#if OPENSSL_VERSION_NUMBER < 0x10002000L /* OpenSSL 1.0.2 */ +BIO *mem = BIO_new_mem_buf((void *)pem_str, -1); +#else BIO *mem = BIO_new_mem_buf(pem_str, -1); +#endif if (!mem) { av_log(NULL, AV_LOG_ERROR, "BIO_new_mem_buf failed\n"); return NULL; -- 2.49.0 --- End Message --- ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/tls_openssl: fix build error when openssl version < 3
fix the missing data structure pkey in the tls_context Signed-off-by: Jack Lau --- libavformat/tls_openssl.c | 30 +- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c index b589d5d90a..bddeee9af8 100644 --- a/libavformat/tls_openssl.c +++ b/libavformat/tls_openssl.c @@ -467,6 +467,7 @@ typedef struct TLSContext { TLSShared tls_shared; SSL_CTX *ctx; SSL *ssl; +EVP_PKEY *pkey; #if OPENSSL_VERSION_NUMBER >= 0x101fL BIO_METHOD* url_bio_method; #endif @@ -811,7 +812,7 @@ static av_cold int openssl_init_ca_key_cert(URLContext *h) int ret; TLSContext *p = h->priv_data; TLSShared *c = &p->tls_shared; -EVP_PKEY *pkey = NULL; +EVP_PKEY *pkey = p->pkey; X509 *cert = NULL; /* setup ca, private key, certificate */ if (c->ca_file) { @@ -876,6 +877,9 @@ static int dtls_start(URLContext *h, const char *url, int flags, AVDictionary ** int ret = 0; c->is_dtls = 1; const char* ciphers = "ALL"; +#if OPENSSL_VERSION_NUMBER < 0x10002000L // v1.0.2 +EC_KEY *ec_key; +#endif /** * The profile for OpenSSL's SRTP is SRTP_AES128_CM_SHA1_80, see ssl/d1_srtp.c. * The profile for FFmpeg's SRTP is SRTP_AES128_CM_HMAC_SHA1_80, see libavformat/srtp.c. @@ -908,15 +912,6 @@ static int dtls_start(URLContext *h, const char *url, int flags, AVDictionary ** } #endif -#if OPENSSL_VERSION_NUMBER < 0x1010L // v1.1.x -#if OPENSSL_VERSION_NUMBER < 0x10002000L // v1.0.2 -if (ctx->dtls_eckey) -SSL_CTX_set_tmp_ecdh(p->ctx, p->dtls_eckey); -#else -SSL_CTX_set_ecdh_auto(p->ctx, 1); -#endif -#endif - /** * We activate "ALL" cipher suites to align with the peer's capabilities, * ensuring maximum compatibility. @@ -930,6 +925,17 @@ static int dtls_start(URLContext *h, const char *url, int flags, AVDictionary ** ret = openssl_init_ca_key_cert(h); if (ret < 0) goto fail; +#if OPENSSL_VERSION_NUMBER < 0x1010L // v1.1.x +#if OPENSSL_VERSION_NUMBER < 0x10002000L // v1.0.2 +if (p->pkey) +ec_key = EVP_PKEY_get1_EC_KEY(p->pkey); +if (ec_key) +SSL_CTX_set_tmp_ecdh(p->ctx, ec_key); +#else +SSL_CTX_set_ecdh_auto(p->ctx, 1); +#endif +#endif + /* Server will send Certificate Request. */ SSL_CTX_set_verify(p->ctx, SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE, openssl_dtls_verify_callback); /* The depth count is "level 0:peer certificate", "level 1: CA certificate", @@ -1015,9 +1021,7 @@ static av_cold int dtls_close(URLContext *h) av_freep(&ctx->tls_shared.fingerprint); av_freep(&ctx->tls_shared.cert_buf); av_freep(&ctx->tls_shared.key_buf); -#if OPENSSL_VERSION_NUMBER < 0x3000L /* OpenSSL 3.0 */ -EC_KEY_free(ctx->dtls_eckey); -#endif +EVP_PKEY_free(ctx->pkey); return 0; } -- 2.49.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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/tls_openssl: fix warnings when openssl is lower version
In higher versions (like openssl 1.1.1 and higher), the function signature is BIO *BIO_new_mem_buf(const void *buf, int len), so passing a const string doesn't cause an warnings. However, in lower versions of OpenSSL, the function signature becomes BIO *BIO_new_mem_buf(void *buf, int len), which leads to warnings. OpenSSL guarantees that it will not modify the string, so it's safe to cast the pem_str to (void *) to avoid this warning. Signed-off-by: Jack Lau --- libavformat/tls_openssl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c index 86e8935fee..5387e21df1 100644 --- a/libavformat/tls_openssl.c +++ b/libavformat/tls_openssl.c @@ -415,7 +415,7 @@ error: */ static EVP_PKEY *pkey_from_pem_string(const char *pem_str, int is_priv) { -BIO *mem = BIO_new_mem_buf(pem_str, -1); +BIO *mem = BIO_new_mem_buf((void *)pem_str, -1); if (!mem) { av_log(NULL, AV_LOG_ERROR, "BIO_new_mem_buf failed\n"); return NULL; @@ -445,7 +445,7 @@ static EVP_PKEY *pkey_from_pem_string(const char *pem_str, int is_priv) */ static X509 *cert_from_pem_string(const char *pem_str) { -BIO *mem = BIO_new_mem_buf(pem_str, -1); +BIO *mem = BIO_new_mem_buf((void *)pem_str, -1); if (!mem) { av_log(NULL, AV_LOG_ERROR, "BIO_new_mem_buf failed\n"); return NULL; -- 2.49.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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2] avformat/tls_openssl: fix warnings when openssl is lower version
api doc: https://docs.openssl.org/1.0.2/man3/BIO_s_mem In higher versions (openssl 1.0.2 and higher), the function signature is BIO *BIO_new_mem_buf(const void *buf, int len), so passing a const string doesn't cause an warnings. However, in lower versions of OpenSSL, the function signature becomes BIO *BIO_new_mem_buf(void *buf, int len), which leads to warnings. OpenSSL guarantees that it will not modify the string, so it's safe to cast the pem_str to (void *) to avoid this warning. Signed-off-by: Jack Lau --- libavformat/tls_openssl.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c index 86e8935fee..0a6e5680f4 100644 --- a/libavformat/tls_openssl.c +++ b/libavformat/tls_openssl.c @@ -415,7 +415,12 @@ error: */ static EVP_PKEY *pkey_from_pem_string(const char *pem_str, int is_priv) { -BIO *mem = BIO_new_mem_buf(pem_str, -1); +BIO *mem = NULL; +#if OPENSSL_VERSION_NUMBER < 0x10002000L /* OpenSSL 1.0.2 */ +mem = BIO_new_mem_buf((void *)pem_str, -1); +#else +mem = BIO_new_mem_buf(pem_str, -1); +#endif if (!mem) { av_log(NULL, AV_LOG_ERROR, "BIO_new_mem_buf failed\n"); return NULL; @@ -445,7 +450,12 @@ static EVP_PKEY *pkey_from_pem_string(const char *pem_str, int is_priv) */ static X509 *cert_from_pem_string(const char *pem_str) { -BIO *mem = BIO_new_mem_buf(pem_str, -1); +BIO *mem = NULL; +#if OPENSSL_VERSION_NUMBER < 0x10002000L /* OpenSSL 1.0.2 */ +mem = BIO_new_mem_buf((void *)pem_str, -1); +#else +mem = BIO_new_mem_buf(pem_str, -1); +#endif if (!mem) { av_log(NULL, AV_LOG_ERROR, "BIO_new_mem_buf failed\n"); return NULL; -- 2.49.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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/format: fix muxer experimental check is always false
if muxer has a name, !short_name is always false Signed-off-by: Jack Lau --- libavformat/format.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/format.c b/libavformat/format.c index 516925e7e4..ad8c17b6d7 100644 --- a/libavformat/format.c +++ b/libavformat/format.c @@ -95,7 +95,7 @@ const AVOutputFormat *av_guess_format(const char *short_name, const char *filena /* Find the proper file type. */ score_max = 0; while ((fmt = av_muxer_iterate(&i))) { -if (fmt->flags & AVFMT_EXPERIMENTAL && !short_name) +if (fmt->flags & AVFMT_EXPERIMENTAL && short_name) continue; score = 0; if (fmt->name && short_name && av_match_name(short_name, fmt->name)) -- 2.49.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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3] avformat/whip: mark as experimental
--- Begin Message --- Signed-off-by: Jack Lau --- libavformat/whip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/whip.c b/libavformat/whip.c index 710f24fc5a..bb7b8657dc 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -1907,7 +1907,7 @@ const FFOutputFormat ff_whip_muxer = { .p.long_name= NULL_IF_CONFIG_SMALL("WHIP(WebRTC-HTTP ingestion protocol) muxer"), .p.audio_codec = AV_CODEC_ID_OPUS, .p.video_codec = AV_CODEC_ID_H264, -.p.flags= AVFMT_GLOBALHEADER | AVFMT_NOFILE, +.p.flags= AVFMT_GLOBALHEADER | AVFMT_NOFILE | AVFMT_EXPERIMENTAL, .p.priv_class = &whip_muxer_class, .priv_data_size = sizeof(WHIPContext), .init = whip_init, -- 2.49.0 --- End Message --- ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2] avformat/whip: set this muxer as experimental
--- Begin Message --- Signed-off-by: Jack Lau --- libavformat/whip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/whip.c b/libavformat/whip.c index 710f24fc5a..bb7b8657dc 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -1907,7 +1907,7 @@ const FFOutputFormat ff_whip_muxer = { .p.long_name= NULL_IF_CONFIG_SMALL("WHIP(WebRTC-HTTP ingestion protocol) muxer"), .p.audio_codec = AV_CODEC_ID_OPUS, .p.video_codec = AV_CODEC_ID_H264, -.p.flags= AVFMT_GLOBALHEADER | AVFMT_NOFILE, +.p.flags= AVFMT_GLOBALHEADER | AVFMT_NOFILE | AVFMT_EXPERIMENTAL, .p.priv_class = &whip_muxer_class, .priv_data_size = sizeof(WHIPContext), .init = whip_init, -- 2.49.0 --- End Message --- ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/3] avformat/whip: replace AV_OPT_FLAG_DECODING_PARAM to ENCODING
--- Begin Message --- Signed-off-by: Jack Lau --- libavformat/whip.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavformat/whip.c b/libavformat/whip.c index 710f24fc5a..a6827d3478 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -1885,13 +1885,13 @@ static int whip_check_bitstream(AVFormatContext *s, AVStream *st, const AVPacket } #define OFFSET(x) offsetof(WHIPContext, x) -#define DEC AV_OPT_FLAG_DECODING_PARAM +#define ENC AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { -{ "handshake_timeout", "Timeout in milliseconds for ICE and DTLS handshake.", OFFSET(handshake_timeout), AV_OPT_TYPE_INT,{ .i64 = 5000 },-1, INT_MAX, DEC }, -{ "pkt_size", "The maximum size, in bytes, of RTP packets that send out", OFFSET(pkt_size), AV_OPT_TYPE_INT,{ .i64 = 1200 }, -1, INT_MAX, DEC }, -{ "authorization", "The optional Bearer token for WHIP Authorization", OFFSET(authorization), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, DEC }, -{ "cert_file", "The optional certificate file path for DTLS", OFFSET(cert_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, DEC }, -{ "key_file", "The optional private key file path for DTLS", OFFSET(key_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, DEC }, +{ "handshake_timeout", "Timeout in milliseconds for ICE and DTLS handshake.", OFFSET(handshake_timeout), AV_OPT_TYPE_INT,{ .i64 = 5000 },-1, INT_MAX, ENC }, +{ "pkt_size", "The maximum size, in bytes, of RTP packets that send out", OFFSET(pkt_size), AV_OPT_TYPE_INT,{ .i64 = 1200 }, -1, INT_MAX, ENC }, +{ "authorization", "The optional Bearer token for WHIP Authorization", OFFSET(authorization), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, +{ "cert_file", "The optional certificate file path for DTLS", OFFSET(cert_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, +{ "key_file", "The optional private key file path for DTLS", OFFSET(key_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, { NULL }, }; -- 2.49.0 --- End Message --- ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/3] avformat/whip: add whip_flags ignore_ipv6 to skip IPv6 candidates
--- Begin Message --- mark this ignore_ipv6 flag could ignore any ipv6 ICE candidate, preventing “No route to host” errors on devices without IPv6 connectivity. Signed-off-by: Jack Lau --- libavformat/whip.c | 13 + 1 file changed, 13 insertions(+) diff --git a/libavformat/whip.c b/libavformat/whip.c index a6827d3478..ed007255ce 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -193,9 +193,14 @@ enum WHIPState { WHIP_STATE_FAILED, }; +typedef enum WHIPFlags { +WHIP_FLAG_IGNORE_IPV6 = (1 << 0) // Ignore ipv6 candidate +} WHIPFlags; + typedef struct WHIPContext { AVClass *av_class; +uint32_t flags;// enum WHIPFlags /* The state of the RTC connection. */ enum WHIPState state; /* The callback return value for DTLS. */ @@ -871,6 +876,7 @@ static int parse_answer(AVFormatContext *s) if (ptr && av_stristr(ptr, "host")) { char protocol[17], host[129]; int priority, port; +struct in6_addr addr6; ret = sscanf(ptr, "%16s %d %128s %d typ host", protocol, &priority, host, &port); if (ret != 4) { av_log(whip, AV_LOG_ERROR, "WHIP: Failed %d to parse line %d %s from %s\n", @@ -879,6 +885,11 @@ static int parse_answer(AVFormatContext *s) goto end; } +if (whip->flags & WHIP_FLAG_IGNORE_IPV6 && inet_pton(AF_INET6, host, &addr6) == 1) { +av_log(whip, AV_LOG_DEBUG, "WHIP: Ignore ipv6 %s, line %d %s \n", host, i, line); +continue; +} + if (av_strcasecmp(protocol, "udp")) { av_log(whip, AV_LOG_ERROR, "WHIP: Protocol %s is not supported by RTC, choose udp, line %d %s of %s\n", protocol, i, line, whip->sdp_answer); @@ -1892,6 +1903,8 @@ static const AVOption options[] = { { "authorization", "The optional Bearer token for WHIP Authorization", OFFSET(authorization), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, { "cert_file", "The optional certificate file path for DTLS", OFFSET(cert_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, { "key_file", "The optional private key file path for DTLS", OFFSET(key_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, +{ "whip_flags", "set flags affecting WHIP connection behavior", OFFSET(flags), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, 0, UINT_MAX, ENC, .unit = "flags" }, +{ "ignore_ipv6","ignore any IPv6 ICE candidate", 0, AV_OPT_TYPE_CONST, { .i64 = WHIP_FLAG_IGNORE_IPV6 }, 0, UINT_MAX, ENC, .unit = "flags" }, { NULL }, }; -- 2.49.0 --- End Message --- ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/3] avformat/whip: align whip options
--- Begin Message --- Signed-off-by: Jack Lau --- libavformat/whip.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavformat/whip.c b/libavformat/whip.c index ed007255ce..e713f7c741 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -1898,13 +1898,13 @@ static int whip_check_bitstream(AVFormatContext *s, AVStream *st, const AVPacket #define OFFSET(x) offsetof(WHIPContext, x) #define ENC AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { -{ "handshake_timeout", "Timeout in milliseconds for ICE and DTLS handshake.", OFFSET(handshake_timeout), AV_OPT_TYPE_INT,{ .i64 = 5000 },-1, INT_MAX, ENC }, -{ "pkt_size", "The maximum size, in bytes, of RTP packets that send out", OFFSET(pkt_size), AV_OPT_TYPE_INT,{ .i64 = 1200 }, -1, INT_MAX, ENC }, -{ "authorization", "The optional Bearer token for WHIP Authorization", OFFSET(authorization), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, -{ "cert_file", "The optional certificate file path for DTLS", OFFSET(cert_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, -{ "key_file", "The optional private key file path for DTLS", OFFSET(key_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, -{ "whip_flags", "set flags affecting WHIP connection behavior", OFFSET(flags), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, 0, UINT_MAX, ENC, .unit = "flags" }, -{ "ignore_ipv6","ignore any IPv6 ICE candidate", 0, AV_OPT_TYPE_CONST, { .i64 = WHIP_FLAG_IGNORE_IPV6 }, 0, UINT_MAX, ENC, .unit = "flags" }, +{ "handshake_timeout", "Timeout in milliseconds for ICE and DTLS handshake.", OFFSET(handshake_timeout), AV_OPT_TYPE_INT,{ .i64 = 5000 },-1, INT_MAX, ENC }, +{ "pkt_size", "The maximum size, in bytes, of RTP packets that send out", OFFSET(pkt_size), AV_OPT_TYPE_INT,{ .i64 = 1200 }, -1, INT_MAX, ENC }, +{ "authorization", "The optional Bearer token for WHIP Authorization", OFFSET(authorization), AV_OPT_TYPE_STRING, { .str = NULL },0,0, ENC }, +{ "cert_file", "The optional certificate file path for DTLS", OFFSET(cert_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0,0, ENC }, +{ "key_file", "The optional private key file path for DTLS", OFFSET(key_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0,0, ENC }, +{ "whip_flags", "set flags affecting WHIP connection behavior", OFFSET(flags), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, 0, UINT_MAX, ENC, .unit = "flags" }, +{ "ignore_ipv6","ignore any IPv6 ICE candidate", 0, AV_OPT_TYPE_CONST, { .i64 = WHIP_FLAG_IGNORE_IPV6 }, 0, UINT_MAX, ENC, .unit = "flags" }, { NULL }, }; -- 2.49.0 --- End Message --- ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] doc/muxers: add a note that WHIP is an experimental feaeture
--- Begin Message --- this muxer has been marked AVFMT_EXPERIMENTAL. Signed-off-by: Jack Lau --- doc/muxers.texi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/muxers.texi b/doc/muxers.texi index 30c95c3d34..d2ee90bf33 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -3885,6 +3885,8 @@ ffmpeg -f webm_dash_manifest -i video1.webm \ WebRTC (Real-Time Communication) muxer that supports sub-second latency streaming according to the WHIP (WebRTC-HTTP ingestion protocol) specification. +This is an experimental feature. + It uses HTTP as a signaling protocol to exchange SDP capabilities and ICE lite candidates. Then, it uses STUN binding requests and responses to establish a session over UDP. Subsequently, it initiates a DTLS handshake to exchange the SRTP encryption keys. Lastly, it splits video and -- 2.49.0 --- End Message --- ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v5 3/3] avformat/whip: fix typos
--- Begin Message --- Remove redundant "WHIP: " prefix in log context since it already add whip context. Fix grammers in whip options descriptions Signed-off-by: Jack Lau --- libavformat/tls.c | 2 +- libavformat/whip.c | 152 ++--- 2 files changed, 77 insertions(+), 77 deletions(-) diff --git a/libavformat/tls.c b/libavformat/tls.c index da53835200..7f9b940387 100644 --- a/libavformat/tls.c +++ b/libavformat/tls.c @@ -137,7 +137,7 @@ int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AV parent->protocol_whitelist, parent->protocol_blacklist, parent); if (c->is_dtls) { if (ret < 0) { -av_log(c, AV_LOG_ERROR, "WHIP: Failed to connect udp://%s:%d\n", c->underlying_host, port); +av_log(c, AV_LOG_ERROR, "Failed to connect udp://%s:%d\n", c->underlying_host, port); return ret; } /* Make the socket non-blocking, set to READ and WRITE mode after connected */ diff --git a/libavformat/whip.c b/libavformat/whip.c index 8d1be90f32..8b011b8b1c 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -364,14 +364,14 @@ static int dtls_context_on_state(AVFormatContext *s, const char* type, const cha if (state == DTLS_STATE_CLOSED) { whip->dtls_closed = 1; -av_log(whip, AV_LOG_VERBOSE, "WHIP: DTLS session closed, type=%s, desc=%s, elapsed=%dms\n", +av_log(whip, AV_LOG_VERBOSE, "DTLS session closed, type=%s, desc=%s, elapsed=%dms\n", type ? type : "", desc ? desc : "", ELAPSED(whip->whip_starttime, av_gettime())); goto error; } if (state == DTLS_STATE_FAILED) { whip->state = WHIP_STATE_FAILED; -av_log(whip, AV_LOG_ERROR, "WHIP: DTLS session failed, type=%s, desc=%s\n", +av_log(whip, AV_LOG_ERROR, "DTLS session failed, type=%s, desc=%s\n", type ? type : "", desc ? desc : ""); whip->dtls_ret = AVERROR(EIO); goto error; @@ -380,7 +380,7 @@ static int dtls_context_on_state(AVFormatContext *s, const char* type, const cha if (state == DTLS_STATE_FINISHED && whip->state < WHIP_STATE_DTLS_FINISHED) { whip->state = WHIP_STATE_DTLS_FINISHED; whip->whip_dtls_time = av_gettime(); -av_log(whip, AV_LOG_VERBOSE, "WHIP: DTLS handshake is done, elapsed=%dms\n", +av_log(whip, AV_LOG_VERBOSE, "DTLS handshake is done, elapsed=%dms\n", ELAPSED(whip->whip_starttime, av_gettime())); return ret; } @@ -409,7 +409,7 @@ static av_cold int initialize(AVFormatContext *s) ret = certificate_key_init(s); if (ret < 0) { -av_log(whip, AV_LOG_ERROR, "WHIP: Failed to init certificate and key\n"); +av_log(whip, AV_LOG_ERROR, "Failed to init certificate and key\n"); return ret; } @@ -418,13 +418,13 @@ static av_cold int initialize(AVFormatContext *s) av_lfg_init(&whip->rnd, seed); if (whip->pkt_size < ideal_pkt_size) -av_log(whip, AV_LOG_WARNING, "WHIP: pkt_size=%d(<%d) is too small, may cause packet loss\n", +av_log(whip, AV_LOG_WARNING, "pkt_size=%d(<%d) is too small, may cause packet loss\n", whip->pkt_size, ideal_pkt_size); if (whip->state < WHIP_STATE_INIT) whip->state = WHIP_STATE_INIT; whip->whip_init_time = av_gettime(); -av_log(whip, AV_LOG_VERBOSE, "WHIP: Init state=%d, handshake_timeout=%dms, pkt_size=%d, seed=%d, elapsed=%dms\n", +av_log(whip, AV_LOG_VERBOSE, "Init state=%d, handshake_timeout=%dms, pkt_size=%d, seed=%d, elapsed=%dms\n", whip->state, whip->handshake_timeout, whip->pkt_size, seed, ELAPSED(whip->whip_starttime, av_gettime())); return 0; @@ -457,7 +457,7 @@ static int parse_profile_level(AVFormatContext *s, AVCodecParameters *par) return ret; if (!par->extradata || par->extradata_size <= 0) { -av_log(whip, AV_LOG_ERROR, "WHIP: Unable to parse profile from empty extradata=%p, size=%d\n", +av_log(whip, AV_LOG_ERROR, "Unable to parse profile from empty extradata=%p, size=%d\n", par->extradata, par->extradata_size); return AVERROR(EINVAL); } @@ -471,12 +471,12 @@ static int parse_profile_level(AVFormatContext *s, AVCodecParameters *par) if ((state & 0x1f) == H264_NAL_SPS) { ret = ff_avc_decode_sps(sps, r, r1 - r); if (ret < 0) { -av_log(whip, AV_LOG_ERROR, "WHIP: Failed to decode SPS, state=%x, size=%d\n", +av_log(whip, AV_LOG_ERROR, "Failed to decode SPS, state=%x, size=%d\n", state, (int)(r1 - r)); return ret; } -av_log(whip, AV_LOG_VERBOSE, "WHIP: Parse profile=%d, level=%d from SPS\n", +av_log(whip, AV_LOG_VERBOSE, "Parse profile=%d, level=%d from SPS\n", sps->profile_idc, sps->level_idc);
[FFmpeg-devel] [PATCH 1/3] avformat/whip: add whip_flags ignore_ipv6 to skip IPv6 ICE candidates
--- Begin Message --- mark this ignore_ipv6 flag could ignore any IPv6 ICE candidate, preventing “No route to host” errors on devices without IPv6 connectivity. Signed-off-by: Jack Lau --- libavformat/whip.c | 13 + 1 file changed, 13 insertions(+) diff --git a/libavformat/whip.c b/libavformat/whip.c index 5fdbd6949d..be6ee9c951 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -193,9 +193,14 @@ enum WHIPState { WHIP_STATE_FAILED, }; +typedef enum WHIPFlags { +WHIP_FLAG_IGNORE_IPV6 = (1 << 0) // Ignore ipv6 candidate +} WHIPFlags; + typedef struct WHIPContext { AVClass *av_class; +uint32_t flags;// enum WHIPFlags /* The state of the RTC connection. */ enum WHIPState state; /* The callback return value for DTLS. */ @@ -879,6 +884,7 @@ static int parse_answer(AVFormatContext *s) if (ptr && av_stristr(ptr, "host")) { char protocol[17], host[129]; int priority, port; +struct in6_addr addr6; ret = sscanf(ptr, "%16s %d %128s %d typ host", protocol, &priority, host, &port); if (ret != 4) { av_log(whip, AV_LOG_ERROR, "WHIP: Failed %d to parse line %d %s from %s\n", @@ -887,6 +893,11 @@ static int parse_answer(AVFormatContext *s) goto end; } +if (whip->flags & WHIP_FLAG_IGNORE_IPV6 && inet_pton(AF_INET6, host, &addr6) == 1) { +av_log(whip, AV_LOG_DEBUG, "Ignoring IPv6 ICE candidates %s, line %d %s \n", host, i, line); +continue; +} + if (av_strcasecmp(protocol, "udp")) { av_log(whip, AV_LOG_ERROR, "WHIP: Protocol %s is not supported by RTC, choose udp, line %d %s of %s\n", protocol, i, line, whip->sdp_answer); @@ -1898,6 +1909,8 @@ static const AVOption options[] = { { "authorization", "The optional Bearer token for WHIP Authorization", OFFSET(authorization), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, { "cert_file", "The optional certificate file path for DTLS", OFFSET(cert_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, { "key_file", "The optional private key file path for DTLS", OFFSET(key_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, +{ "whip_flags", "Set flags affecting WHIP connection behavior", OFFSET(flags), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, 0, UINT_MAX, ENC, .unit = "flags" }, +{ "ignore_ipv6","(Optional) Ignore any IPv6 ICE candidate", 0, AV_OPT_TYPE_CONST, { .i64 = WHIP_FLAG_IGNORE_IPV6 }, 0, UINT_MAX, ENC, .unit = "flags" }, { NULL }, }; -- 2.49.0 --- End Message --- ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v4 2/3] avformat/whip: reindent whip options
--- Begin Message --- Signed-off-by: Jack Lau --- libavformat/whip.c | 21 ++--- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/libavformat/whip.c b/libavformat/whip.c index be6ee9c951..8d1be90f32 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -1904,13 +1904,20 @@ static int whip_check_bitstream(AVFormatContext *s, AVStream *st, const AVPacket #define OFFSET(x) offsetof(WHIPContext, x) #define ENC AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { -{ "handshake_timeout", "Timeout in milliseconds for ICE and DTLS handshake.", OFFSET(handshake_timeout), AV_OPT_TYPE_INT,{ .i64 = 5000 },-1, INT_MAX, ENC }, -{ "pkt_size", "The maximum size, in bytes, of RTP packets that send out", OFFSET(pkt_size), AV_OPT_TYPE_INT,{ .i64 = 1200 }, -1, INT_MAX, ENC }, -{ "authorization", "The optional Bearer token for WHIP Authorization", OFFSET(authorization), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, -{ "cert_file", "The optional certificate file path for DTLS", OFFSET(cert_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, -{ "key_file", "The optional private key file path for DTLS", OFFSET(key_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, -{ "whip_flags", "Set flags affecting WHIP connection behavior", OFFSET(flags), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, 0, UINT_MAX, ENC, .unit = "flags" }, -{ "ignore_ipv6","(Optional) Ignore any IPv6 ICE candidate", 0, AV_OPT_TYPE_CONST, { .i64 = WHIP_FLAG_IGNORE_IPV6 }, 0, UINT_MAX, ENC, .unit = "flags" }, +{ "handshake_timeout", "Timeout in milliseconds for ICE and DTLS handshake.", OFFSET(handshake_timeout), +AV_OPT_TYPE_INT,{ .i64 = 5000 },-1, INT_MAX, ENC }, +{ "pkt_size", "The maximum size, in bytes, of RTP packets that send out", OFFSET(pkt_size), +AV_OPT_TYPE_INT,{ .i64 = 1200 },-1, INT_MAX, ENC }, +{ "authorization", "The optional Bearer token for WHIP Authorization", OFFSET(authorization), +AV_OPT_TYPE_STRING, { .str = NULL },0, 0, ENC }, +{ "cert_file", "The optional certificate file path for DTLS", OFFSET(cert_file), +AV_OPT_TYPE_STRING, { .str = NULL },0, 0, ENC }, +{ "key_file", "The optional private key file path for DTLS", OFFSET(key_file), +AV_OPT_TYPE_STRING, { .str = NULL },0, 0, ENC }, +{ "whip_flags", "Set flags affecting WHIP connection behavior", OFFSET(flags), +AV_OPT_TYPE_FLAGS, { .i64 = 0 }, 0, UINT_MAX, ENC, .unit = "flags" }, +{ "ignore_ipv6","(Optional) Ignore any IPv6 ICE candidate", 0, +AV_OPT_TYPE_CONST, { .i64 = WHIP_FLAG_IGNORE_IPV6 }, 0, UINT_MAX, ENC, .unit = "flags" }, { NULL }, }; -- 2.49.0 --- End Message --- ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v4 3/3] avformat/whip: fix typos
--- Begin Message --- Remove redundant "WHIP: " prefix in log context since it already add whip context. Fix grammers in whip options "The Optional" > "(Optional)" Signed-off-by: Jack Lau --- libavformat/tls.c | 2 +- libavformat/whip.c | 152 ++--- 2 files changed, 77 insertions(+), 77 deletions(-) diff --git a/libavformat/tls.c b/libavformat/tls.c index da53835200..7f9b940387 100644 --- a/libavformat/tls.c +++ b/libavformat/tls.c @@ -137,7 +137,7 @@ int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AV parent->protocol_whitelist, parent->protocol_blacklist, parent); if (c->is_dtls) { if (ret < 0) { -av_log(c, AV_LOG_ERROR, "WHIP: Failed to connect udp://%s:%d\n", c->underlying_host, port); +av_log(c, AV_LOG_ERROR, "Failed to connect udp://%s:%d\n", c->underlying_host, port); return ret; } /* Make the socket non-blocking, set to READ and WRITE mode after connected */ diff --git a/libavformat/whip.c b/libavformat/whip.c index 8d1be90f32..530f140b63 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -364,14 +364,14 @@ static int dtls_context_on_state(AVFormatContext *s, const char* type, const cha if (state == DTLS_STATE_CLOSED) { whip->dtls_closed = 1; -av_log(whip, AV_LOG_VERBOSE, "WHIP: DTLS session closed, type=%s, desc=%s, elapsed=%dms\n", +av_log(whip, AV_LOG_VERBOSE, "DTLS session closed, type=%s, desc=%s, elapsed=%dms\n", type ? type : "", desc ? desc : "", ELAPSED(whip->whip_starttime, av_gettime())); goto error; } if (state == DTLS_STATE_FAILED) { whip->state = WHIP_STATE_FAILED; -av_log(whip, AV_LOG_ERROR, "WHIP: DTLS session failed, type=%s, desc=%s\n", +av_log(whip, AV_LOG_ERROR, "DTLS session failed, type=%s, desc=%s\n", type ? type : "", desc ? desc : ""); whip->dtls_ret = AVERROR(EIO); goto error; @@ -380,7 +380,7 @@ static int dtls_context_on_state(AVFormatContext *s, const char* type, const cha if (state == DTLS_STATE_FINISHED && whip->state < WHIP_STATE_DTLS_FINISHED) { whip->state = WHIP_STATE_DTLS_FINISHED; whip->whip_dtls_time = av_gettime(); -av_log(whip, AV_LOG_VERBOSE, "WHIP: DTLS handshake is done, elapsed=%dms\n", +av_log(whip, AV_LOG_VERBOSE, "DTLS handshake is done, elapsed=%dms\n", ELAPSED(whip->whip_starttime, av_gettime())); return ret; } @@ -409,7 +409,7 @@ static av_cold int initialize(AVFormatContext *s) ret = certificate_key_init(s); if (ret < 0) { -av_log(whip, AV_LOG_ERROR, "WHIP: Failed to init certificate and key\n"); +av_log(whip, AV_LOG_ERROR, "Failed to init certificate and key\n"); return ret; } @@ -418,13 +418,13 @@ static av_cold int initialize(AVFormatContext *s) av_lfg_init(&whip->rnd, seed); if (whip->pkt_size < ideal_pkt_size) -av_log(whip, AV_LOG_WARNING, "WHIP: pkt_size=%d(<%d) is too small, may cause packet loss\n", +av_log(whip, AV_LOG_WARNING, "pkt_size=%d(<%d) is too small, may cause packet loss\n", whip->pkt_size, ideal_pkt_size); if (whip->state < WHIP_STATE_INIT) whip->state = WHIP_STATE_INIT; whip->whip_init_time = av_gettime(); -av_log(whip, AV_LOG_VERBOSE, "WHIP: Init state=%d, handshake_timeout=%dms, pkt_size=%d, seed=%d, elapsed=%dms\n", +av_log(whip, AV_LOG_VERBOSE, "Init state=%d, handshake_timeout=%dms, pkt_size=%d, seed=%d, elapsed=%dms\n", whip->state, whip->handshake_timeout, whip->pkt_size, seed, ELAPSED(whip->whip_starttime, av_gettime())); return 0; @@ -457,7 +457,7 @@ static int parse_profile_level(AVFormatContext *s, AVCodecParameters *par) return ret; if (!par->extradata || par->extradata_size <= 0) { -av_log(whip, AV_LOG_ERROR, "WHIP: Unable to parse profile from empty extradata=%p, size=%d\n", +av_log(whip, AV_LOG_ERROR, "Unable to parse profile from empty extradata=%p, size=%d\n", par->extradata, par->extradata_size); return AVERROR(EINVAL); } @@ -471,12 +471,12 @@ static int parse_profile_level(AVFormatContext *s, AVCodecParameters *par) if ((state & 0x1f) == H264_NAL_SPS) { ret = ff_avc_decode_sps(sps, r, r1 - r); if (ret < 0) { -av_log(whip, AV_LOG_ERROR, "WHIP: Failed to decode SPS, state=%x, size=%d\n", +av_log(whip, AV_LOG_ERROR, "Failed to decode SPS, state=%x, size=%d\n", state, (int)(r1 - r)); return ret; } -av_log(whip, AV_LOG_VERBOSE, "WHIP: Parse profile=%d, level=%d from SPS\n", +av_log(whip, AV_LOG_VERBOSE, "Parse profile=%d, level=%d from SPS\n", sps->profile_idc, sps->level_i
[FFmpeg-devel] [PATCH v4 1/3] avformat/whip: add whip_flags ignore_ipv6 to skip IPv6 ICE candidates
--- Begin Message --- mark this ignore_ipv6 flag could ignore any IPv6 ICE candidate, preventing “No route to host” errors on devices without IPv6 connectivity. Signed-off-by: Jack Lau --- libavformat/whip.c | 13 + 1 file changed, 13 insertions(+) diff --git a/libavformat/whip.c b/libavformat/whip.c index 5fdbd6949d..be6ee9c951 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -193,9 +193,14 @@ enum WHIPState { WHIP_STATE_FAILED, }; +typedef enum WHIPFlags { +WHIP_FLAG_IGNORE_IPV6 = (1 << 0) // Ignore ipv6 candidate +} WHIPFlags; + typedef struct WHIPContext { AVClass *av_class; +uint32_t flags;// enum WHIPFlags /* The state of the RTC connection. */ enum WHIPState state; /* The callback return value for DTLS. */ @@ -879,6 +884,7 @@ static int parse_answer(AVFormatContext *s) if (ptr && av_stristr(ptr, "host")) { char protocol[17], host[129]; int priority, port; +struct in6_addr addr6; ret = sscanf(ptr, "%16s %d %128s %d typ host", protocol, &priority, host, &port); if (ret != 4) { av_log(whip, AV_LOG_ERROR, "WHIP: Failed %d to parse line %d %s from %s\n", @@ -887,6 +893,11 @@ static int parse_answer(AVFormatContext *s) goto end; } +if (whip->flags & WHIP_FLAG_IGNORE_IPV6 && inet_pton(AF_INET6, host, &addr6) == 1) { +av_log(whip, AV_LOG_DEBUG, "Ignoring IPv6 ICE candidates %s, line %d %s \n", host, i, line); +continue; +} + if (av_strcasecmp(protocol, "udp")) { av_log(whip, AV_LOG_ERROR, "WHIP: Protocol %s is not supported by RTC, choose udp, line %d %s of %s\n", protocol, i, line, whip->sdp_answer); @@ -1898,6 +1909,8 @@ static const AVOption options[] = { { "authorization", "The optional Bearer token for WHIP Authorization", OFFSET(authorization), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, { "cert_file", "The optional certificate file path for DTLS", OFFSET(cert_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, { "key_file", "The optional private key file path for DTLS", OFFSET(key_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, +{ "whip_flags", "Set flags affecting WHIP connection behavior", OFFSET(flags), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, 0, UINT_MAX, ENC, .unit = "flags" }, +{ "ignore_ipv6","(Optional) Ignore any IPv6 ICE candidate", 0, AV_OPT_TYPE_CONST, { .i64 = WHIP_FLAG_IGNORE_IPV6 }, 0, UINT_MAX, ENC, .unit = "flags" }, { NULL }, }; -- 2.49.0 --- End Message --- ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".