1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

avformat/tls: move whip specific init out of generic tls code

This commit is contained in:
Timo Rothenpieler
2025-06-26 01:42:36 +02:00
parent 7c91ae9419
commit 2c7e117fe0
3 changed files with 13 additions and 13 deletions

View File

@ -141,15 +141,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;
}

View File

@ -975,14 +975,16 @@ static int tls_write(URLContext *h, const uint8_t *buf, int size)
static int tls_get_file_handle(URLContext *h)
{
TLSContext *c = h->priv_data;
return ffurl_get_file_handle(c->tls_shared.tcp);
TLSContext *p = h->priv_data;
TLSShared *c = &p->tls_shared;
return ffurl_get_file_handle(c->is_dtls ? c->udp : c->tcp);
}
static int tls_get_short_seek(URLContext *h)
{
TLSContext *s = h->priv_data;
return ffurl_get_short_seek(s->tls_shared.tcp);
TLSContext *p = h->priv_data;
TLSShared *c = &p->tls_shared;
return ffurl_get_short_seek(c->is_dtls ? c->udp : c->tcp);
}
static const AVOption options[] = {
@ -1024,6 +1026,8 @@ const URLProtocol ff_dtls_protocol = {
.url_close = dtls_close,
.url_read = tls_read,
.url_write = tls_write,
.url_get_file_handle = tls_get_file_handle,
.url_get_short_seek = tls_get_short_seek,
.priv_data_size = sizeof(TLSContext),
.flags = URL_PROTOCOL_FLAG_NETWORK,
.priv_data_class = &dtls_class,

View File

@ -388,6 +388,11 @@ static av_cold int dtls_initialize(AVFormatContext *s)
WHIPContext *whip = s->priv_data;
/* reuse the udp created by whip */
ff_dtls_set_udp(whip->dtls_uc, whip->udp);
/* Make the socket non-blocking */
ff_socket_nonblock(ffurl_get_file_handle(whip->dtls_uc), 1);
whip->dtls_uc->flags |= AVIO_FLAG_NONBLOCK;
return 0;
}