Unified · Split
| @@ -141,15 +141,6 @@ int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AV · 140 unmodified lines | ||
| 141 | 141 | ret = ffurl_open_whitelist(c->is_dtls ? &c->udp : &c->tcp, buf, AVIO_FLAG_READ_WRITE, |
| 142 | 142 | &parent->interrupt_callback, options, |
| 143 | 143 | parent->protocol_whitelist, parent->protocol_blacklist, parent); |
| 144 | − if (c->is_dtls) { | |
| 145 | − if (ret < 0) { | |
| 146 | − av_log(c, AV_LOG_ERROR, "Failed to open udp://%s:%d\n", c->underlying_host, port); | |
| 147 | − return ret; | |
| 148 | − } | |
| 149 | − /* Make the socket non-blocking, set to READ and WRITE mode after connected */ | |
| 150 | − ff_socket_nonblock(ffurl_get_file_handle(c->udp), 1); | |
| 151 | − c->udp->flags |= AVIO_FLAG_READ | AVIO_FLAG_NONBLOCK; | |
| 152 | − } | |
| 153 | 144 | return ret; |
| 154 | 145 | } |
| 155 | 146 | |
| @@ -975,14 +975,16 @@ static int tls_write(URLContext *h, const uint8_t *buf, int size) · 974 unmodified lines | ||
| 975 | 975 | |
| 976 | 976 | static int tls_get_file_handle(URLContext *h) |
| 977 | 977 | { |
| 978 | − TLSContext *c = h->priv_data; | |
| 979 | − return ffurl_get_file_handle(c->tls_shared.tcp); | |
| 978 | + TLSContext *p = h->priv_data; | |
| 979 | + TLSShared *c = &p->tls_shared; | |
| 980 | + return ffurl_get_file_handle(c->is_dtls ? c->udp : c->tcp); | |
| 980 | 981 | } |
| 981 | 982 | |
| 982 | 983 | static int tls_get_short_seek(URLContext *h) |
| 983 | 984 | { |
| 984 | − TLSContext *s = h->priv_data; | |
| 985 | − return ffurl_get_short_seek(s->tls_shared.tcp); | |
| 985 | + TLSContext *p = h->priv_data; | |
| 986 | + TLSShared *c = &p->tls_shared; | |
| 987 | + return ffurl_get_short_seek(c->is_dtls ? c->udp : c->tcp); | |
| 986 | 988 | } |
| 987 | 989 | |
| 988 | 990 | static const AVOption options[] = { |
| @@ -1024,6 +1026,8 @@ const URLProtocol ff_dtls_protocol = { · 35 unmodified lines | ||
| 1024 | 1026 | .url_close = dtls_close, |
| 1025 | 1027 | .url_read = tls_read, |
| 1026 | 1028 | .url_write = tls_write, |
| 1029 | + .url_get_file_handle = tls_get_file_handle, | |
| 1030 | + .url_get_short_seek = tls_get_short_seek, | |
| 1027 | 1031 | .priv_data_size = sizeof(TLSContext), |
| 1028 | 1032 | .flags = URL_PROTOCOL_FLAG_NETWORK, |
| 1029 | 1033 | .priv_data_class = &dtls_class, |
| @@ -388,6 +388,11 @@ static av_cold int dtls_initialize(AVFormatContext *s) · 387 unmodified lines | ||
| 388 | 388 | WHIPContext *whip = s->priv_data; |
| 389 | 389 | /* reuse the udp created by whip */ |
| 390 | 390 | ff_dtls_set_udp(whip->dtls_uc, whip->udp); |
| 391 | + | |
| 392 | + /* Make the socket non-blocking */ | |
| 393 | + ff_socket_nonblock(ffurl_get_file_handle(whip->dtls_uc), 1); | |
| 394 | + whip->dtls_uc->flags |= AVIO_FLAG_NONBLOCK; | |
| 395 | + | |
| 391 | 396 | return 0; |
| 392 | 397 | } |
| 393 | 398 | |