diff --git a/doc/protocols.texi b/doc/protocols.texi index 9f88f005b9..b74383122a 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -2052,12 +2052,19 @@ Datagram Transport Layer Security (DTLS) The required syntax for a DTLS URL is: @example -dtls://@var{hostname}:@var{port} +dtls://@var{hostname}:@var{port}[?@var{options}] @end example +@var{options} contains a list of &-separated options of the form +@var{key}=@var{val}. Standard percent-encoding (and using the plus sign for +space) can be used to escape keys and values. + +Options can also can be specified via command line options (or in code via +@code{AVOption}s). + DTLS shares most options with TLS, but operates over UDP instead of TCP. -The following parameters can be set via command line options -(or in code via @code{AVOption}s): + +The list of supported options follows. @table @option diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c index 5fc0b639d7..c2adaa38d1 100644 --- a/libavformat/tls_openssl.c +++ b/libavformat/tls_openssl.c @@ -747,6 +747,13 @@ static int dtls_start(URLContext *h, const char *url, int flags, AVDictionary ** int ret = 0; s->is_dtls = 1; + if (!c->tls_shared.external_sock) { + if ((ret = ff_tls_open_underlying(&c->tls_shared, h, url, options)) < 0) { + av_log(c, AV_LOG_ERROR, "Failed to connect %s\n", url); + return ret; + } + } + c->ctx = SSL_CTX_new(s->listen ? DTLS_server_method() : DTLS_client_method()); if (!c->ctx) { ret = AVERROR(ENOMEM); @@ -799,13 +806,6 @@ static int dtls_start(URLContext *h, const char *url, int flags, AVDictionary ** DTLS_set_link_mtu(c->ssl, s->mtu); init_bio_method(h); - if (!c->tls_shared.external_sock) { - if ((ret = ff_tls_open_underlying(&c->tls_shared, h, url, options)) < 0) { - av_log(c, AV_LOG_ERROR, "Failed to connect %s\n", url); - return ret; - } - } - /* This seems to be necessary despite explicitly setting client/server method above. */ if (s->listen) SSL_set_accept_state(c->ssl); @@ -836,6 +836,7 @@ static int dtls_start(URLContext *h, const char *url, int flags, AVDictionary ** ret = 0; fail: + tls_close(h); return ret; }