History

avformat/tls: fix udp init

Timo Rothenpieler committed 1 year ago

Commit 2e729241 parent 23c70e31 file · +9 −3Browse files

Unified · Split

libavformat/tls.c+9−3
@@ -81,7 +81,7 @@ int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AV · 80 unmodified lines
8181 if (ret < 0)
8282 return ret;
8383
84− if (c->listen)
84+ if (c->listen && !c->is_dtls)
8585 snprintf(opts, sizeof(opts), "?listen=1");
8686
8787 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 · 7 unmodified lines
9595 c->listen = 1;
9696 }
9797
98− ff_url_join(buf, sizeof(buf), c->is_dtls ? "udp" : "tcp", NULL, c->underlying_host, port, "%s", p);
98+ ff_url_join(buf, sizeof(buf), c->is_dtls ? "udp" : "tcp", NULL, (c->is_dtls && c->listen) ? "" : c->underlying_host, port, "%s", p);
9999
100100 hints.ai_flags = AI_NUMERICHOST;
101101 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 · 25 unmodified lines
127127
128128 freeenv_utf8(env_http_proxy);
129129 if (c->is_dtls) {
130− av_dict_set_int(options, "connect", 1, 0);
130+ if (c->listen) {
131+ av_dict_set_int(options, "localport", port, 0);
132+ av_dict_set(options, "localaddr", c->underlying_host, 0);
133+ } else {
134+ av_dict_set_int(options, "localport", 0, 0);
135+ av_dict_set_int(options, "connect", 1, 0);
136+ }
131137 av_dict_set_int(options, "fifo_size", 0, 0);
132138 /* Set the max packet size to the buffer size. */
133139 av_dict_set_int(options, "pkt_size", c->mtu, 0);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t