[FFmpeg-devel] [PATCH 08/18] avformat/tls: move openssl specific init out of generic code
Timo Rothenpieler
timo at rothenpieler.org
Thu Jul 3 19:41:35 EEST 2025
On 03.07.2025 17:22, Jack Lau wrote:
>
>
>> On Jul 3, 2025, at 22:24, Timo Rothenpieler <timo at rothenpieler.org> wrote:
>>
>> On 03.07.2025 03:07, Jack Lau wrote:
>>>> On Jul 3, 2025, at 00:56, Timo Rothenpieler <timo at rothenpieler.org> wrote:
>>>>
>>>> ---
>>>> libavformat/tls.c | 9 ---------
>>>> libavformat/tls_openssl.c | 3 +++
>>>> 2 files changed, 3 insertions(+), 9 deletions(-)
>>>>
>>>> diff --git a/libavformat/tls.c b/libavformat/tls.c
>>>> index 5ec4cca58a..f888970969 100644
>>>> --- a/libavformat/tls.c
>>>> +++ b/libavformat/tls.c
>>>> @@ -135,15 +135,6 @@ int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AV
>>>> ret = ffurl_open_whitelist(c->is_dtls ? &c->udp : &c->tcp, buf, AVIO_FLAG_READ_WRITE,
>>>> &parent->interrupt_callback, options,
>>>> parent->protocol_whitelist, parent->protocol_blacklist, parent);
>>>> - if (c->is_dtls) {
>>>> - if (ret < 0) {
>>>> - av_log(c, AV_LOG_ERROR, "Failed to open udp://%s:%d\n", c->underlying_host, port);
>>>> - return ret;
>>>> - }
>>>> - /* Make the socket non-blocking, set to READ and WRITE mode after connected */
>>>> - ff_socket_nonblock(ffurl_get_file_handle(c->udp), 1);
>>>> - c->udp->flags |= AVIO_FLAG_READ | AVIO_FLAG_NONBLOCK;
>>>> - }
>>>> return ret;
>>>> }
>>>>
>>>> diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c
>>>> index 2a3905891d..d83fe602d5 100644
>>>> --- a/libavformat/tls_openssl.c
>>>> +++ b/libavformat/tls_openssl.c
>>>> @@ -985,6 +985,9 @@ static int dtls_start(URLContext *h, const char *url, int flags, AVDictionary **
>>>> av_log(p, AV_LOG_ERROR, "Failed to connect %s\n", url);
>>>> return ret;
>>>> }
>>>> + /* Make the socket non-blocking, set to READ and WRITE mode after connected */
>>>> + ff_socket_nonblock(ffurl_get_file_handle(p->tls_shared.udp), 1);
>>>> + p->tls_shared.udp->flags |= AVIO_FLAG_READ | AVIO_FLAG_NONBLOCK;
>>> Since AVIO_FLAG_READ_WRITE was flagged, it can be just "p->tls_shared.udp->flags |= AVIO_FLAG_NONBLOCK;”
>>
>> Isn't that redundant with ff_socket_nonblock right above it as well?
> No, I think we need keep them all.
>
> The first line ff_socket_nonblock tells the system nonblock
> The second line NONBLOCK flag tells ffmpeg to skip ff_network_wait_fd (can see that in udp_read or udp_write)
>
> I’m not very sure if I explained it right, but when I remove one line of them, the streaming is so choppy and it is almost unusable.
But shouldn't then instead _whip_ be setting the socket to nonblock, and
not tls_openssl set it to nonblock for literally everyone?
tls_openssl, and all the other tls implementations, forward the
nonblocking state.
More information about the ffmpeg-devel
mailing list