Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Timo Rothenpieler <timo@rothenpieler.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Timo Rothenpieler <timo@rothenpieler.org>
Subject: [FFmpeg-devel] [PATCH v2 1/8] avformat/tls: move whip specific init out of generic tls code
Date: Sun,  6 Jul 2025 20:36:22 +0200
Message-ID: <20250706183634.38579-2-timo@rothenpieler.org> (raw)
In-Reply-To: <20250706183634.38579-1-timo@rothenpieler.org>

---
 libavformat/tls.c         |  9 ---------
 libavformat/tls_openssl.c | 12 ++++++++----
 libavformat/whip.c        |  5 +++++
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/libavformat/tls.c b/libavformat/tls.c
index c0adaf61ce..bd9c05e6dc 100644
--- a/libavformat/tls.c
+++ b/libavformat/tls.c
@@ -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;
 }
 
diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c
index 08527418b0..0c76f110e3 100644
--- a/libavformat/tls_openssl.c
+++ b/libavformat/tls_openssl.c
@@ -1128,14 +1128,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[] = {
@@ -1177,6 +1179,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,
diff --git a/libavformat/whip.c b/libavformat/whip.c
index 84d4c5a1f3..4ac76e79f2 100644
--- a/libavformat/whip.c
+++ b/libavformat/whip.c
@@ -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;
 }
 
-- 
2.49.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  reply	other threads:[~2025-07-06 18:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-06 18:36 [FFmpeg-devel] [PATCH v2 0/8] WHIP + TLS + UDP fixes and SChannel DTLS support Timo Rothenpieler
2025-07-06 18:36 ` Timo Rothenpieler [this message]
2025-07-07  6:30   ` [FFmpeg-devel] [PATCH v2 1/8] avformat/tls: move whip specific init out of generic tls code Jack Lau
2025-07-06 18:36 ` [FFmpeg-devel] [PATCH v2 2/8] avformat/udp: make recv addr of each packet available Timo Rothenpieler
2025-07-07  8:03   ` Jack Lau
2025-07-06 18:36 ` [FFmpeg-devel] [PATCH v2 3/8] avformat/udp: separate rx and tx fifo Timo Rothenpieler
2025-07-06 18:36 ` [FFmpeg-devel] [PATCH v2 4/8] avformat/udp: add function to set remote address directly Timo Rothenpieler
2025-07-06 18:36 ` [FFmpeg-devel] [PATCH v2 5/8] avformat/tls: make passing an external socket universal Timo Rothenpieler
2025-07-06 18:36 ` [FFmpeg-devel] [PATCH v2 6/8] avformat/tls_schannel: add DTLS support Timo Rothenpieler
2025-07-06 18:36 ` [FFmpeg-devel] [PATCH v2 7/8] avformat/tls_schannel: add option to load server certificate from store Timo Rothenpieler
2025-07-06 18:36 ` [FFmpeg-devel] [PATCH v2 8/8] avformat/tls_schannel: fix non-blocking write breaking TLS sessions Timo Rothenpieler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250706183634.38579-2-timo@rothenpieler.org \
    --to=timo@rothenpieler.org \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git