[FFmpeg-devel] [PATCH 10/18] avformat/tls: fix udp init

Steven Liu lingjiujianke at gmail.com
Thu Jul 3 17:06:42 EEST 2025


Timo Rothenpieler <timo at rothenpieler.org> 于2025年7月3日周四 01:09写道:
>
> ---
>  libavformat/tls.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/libavformat/tls.c b/libavformat/tls.c
> index f888970969..bd9c05e6dc 100644
> --- a/libavformat/tls.c
> +++ b/libavformat/tls.c
> @@ -81,7 +81,7 @@ int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AV
>      if (ret < 0)
>          return ret;
>
> -    if (c->listen)
> +    if (c->listen && !c->is_dtls)
>          snprintf(opts, sizeof(opts), "?listen=1");
>
>      av_url_split(NULL, 0, NULL, 0, c->underlying_host, sizeof(c->underlying_host), &port, NULL, 0, uri);
> @@ -95,7 +95,7 @@ int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AV
>              c->listen = 1;
>      }
>
> -    ff_url_join(buf, sizeof(buf), c->is_dtls ? "udp" : "tcp", NULL, c->underlying_host, port, "%s", p);
> +    ff_url_join(buf, sizeof(buf), c->is_dtls ? "udp" : "tcp", NULL, (c->is_dtls && c->listen) ? "" : c->underlying_host, port, "%s", p);
>
>      hints.ai_flags = AI_NUMERICHOST;
>      if (!getaddrinfo(c->underlying_host, NULL, &hints, &ai)) {
> @@ -127,7 +127,13 @@ int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AV
>
>      freeenv_utf8(env_http_proxy);
>      if (c->is_dtls) {
> -        av_dict_set_int(options, "connect", 1, 0);
> +        if (c->listen) {
> +            av_dict_set_int(options, "localport", port, 0);
> +            av_dict_set(options, "localaddr", c->underlying_host, 0);
> +        } else {
> +            av_dict_set_int(options, "localport", 0, 0);
> +            av_dict_set_int(options, "connect", 1, 0);
> +        }
>          av_dict_set_int(options, "fifo_size", 0, 0);
>          /* Set the max packet size to the buffer size. */
>          av_dict_set_int(options, "pkt_size", c->mtu, 0);
> --
> 2.49.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".

LGTM

Thanks
Steven


More information about the ffmpeg-devel mailing list