From patchwork Mon Feb 17 00:36:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 17807 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id C8B4F44AC15 for ; Mon, 17 Feb 2020 02:37:22 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A56B66880E7; Mon, 17 Feb 2020 02:37:22 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2FD3B687F3D for ; Mon, 17 Feb 2020 02:37:17 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id AF683E38A5; Mon, 17 Feb 2020 01:37:16 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id s805MA9mBzze; Mon, 17 Feb 2020 01:37:15 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 351F9E36B4; Mon, 17 Feb 2020 01:37:15 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Feb 2020 01:36:45 +0100 Message-Id: <20200217003653.20027-1-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200213231624.28373-1-cus@passwd.hu> References: <20200213231624.28373-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH v2 1/9] avformat/libsrt: fix timeout unit confusion between milisec and microsec X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- libavformat/libsrt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c index d7faa603f5..1d748f0e81 100644 --- a/libavformat/libsrt.c +++ b/libavformat/libsrt.c @@ -210,7 +210,7 @@ static int libsrt_network_wait_fd_timeout(URLContext *h, int eid, int fd, int wr } } -static int libsrt_listen(int eid, int fd, const struct sockaddr *addr, socklen_t addrlen, URLContext *h, int timeout) +static int libsrt_listen(int eid, int fd, const struct sockaddr *addr, socklen_t addrlen, URLContext *h, int64_t timeout) { int ret; int reuse = 1; @@ -243,7 +243,7 @@ static int libsrt_listen(int eid, int fd, const struct sockaddr *addr, socklen_t return ret; } -static int libsrt_listen_connect(int eid, int fd, const struct sockaddr *addr, socklen_t addrlen, int timeout, URLContext *h, int will_try_next) +static int libsrt_listen_connect(int eid, int fd, const struct sockaddr *addr, socklen_t addrlen, int64_t timeout, URLContext *h, int will_try_next) { int ret; @@ -447,7 +447,7 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags) } if (s->mode == SRT_MODE_LISTENER) { // multi-client - if ((ret = libsrt_listen(s->eid, fd, cur_ai->ai_addr, cur_ai->ai_addrlen, h, open_timeout / 1000)) < 0) + if ((ret = libsrt_listen(s->eid, fd, cur_ai->ai_addr, cur_ai->ai_addrlen, h, open_timeout)) < 0) goto fail1; fd = ret; } else { @@ -458,7 +458,7 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags) } if ((ret = libsrt_listen_connect(s->eid, fd, cur_ai->ai_addr, cur_ai->ai_addrlen, - open_timeout / 1000, h, !!cur_ai->ai_next)) < 0) { + open_timeout, h, !!cur_ai->ai_next)) < 0) { if (ret == AVERROR_EXIT) goto fail1; else From patchwork Mon Feb 17 00:36:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 17808 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id A240344AC15 for ; Mon, 17 Feb 2020 02:37:27 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 84BD1688187; Mon, 17 Feb 2020 02:37:27 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7CB97687F18 for ; Mon, 17 Feb 2020 02:37:20 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 52E21E36B4; Mon, 17 Feb 2020 01:37:20 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZX19BYH7lMDv; Mon, 17 Feb 2020 01:37:18 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 9E182E39F2; Mon, 17 Feb 2020 01:37:18 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Feb 2020 01:36:46 +0100 Message-Id: <20200217003653.20027-2-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200217003653.20027-1-cus@passwd.hu> References: <20200213231624.28373-1-cus@passwd.hu> <20200217003653.20027-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH v2 2/9] avformat/libsrt: fix name of timeout option X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" rw_timeout is the generic URLcontext option, not the protocol specific timeout option, also ?rw_timeout never worked because ?timeout was parsed instead. Signed-off-by: Marton Balint --- doc/protocols.texi | 2 +- libavformat/libsrt.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/protocols.texi b/doc/protocols.texi index 5e8c97d164..57814c7831 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -1347,7 +1347,7 @@ Set UDP receive buffer size, expressed in bytes. @item send_buffer_size=@var{bytes} Set UDP send buffer size, expressed in bytes. -@item rw_timeout +@item timeout Set raise error timeout for read/write optations. This option is only relevant in read mode: diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c index 1d748f0e81..378acb045a 100644 --- a/libavformat/libsrt.c +++ b/libavformat/libsrt.c @@ -96,7 +96,7 @@ typedef struct SRTContext { #define E AV_OPT_FLAG_ENCODING_PARAM #define OFFSET(x) offsetof(SRTContext, x) static const AVOption libsrt_options[] = { - { "rw_timeout", "Timeout of socket I/O operations", OFFSET(rw_timeout), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, .flags = D|E }, + { "timeout", "Timeout of socket I/O operations", OFFSET(rw_timeout), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, .flags = D|E }, { "listen_timeout", "Connection awaiting timeout", OFFSET(listen_timeout), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, .flags = D|E }, { "send_buffer_size", "Socket send buffer size (in bytes)", OFFSET(send_buffer_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, { "recv_buffer_size", "Socket receive buffer size (in bytes)", OFFSET(recv_buffer_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, From patchwork Mon Feb 17 00:36:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 17809 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id BF82B44AC15 for ; Mon, 17 Feb 2020 02:37:29 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A42FD689BBA; Mon, 17 Feb 2020 02:37:29 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 20252689B4D for ; Mon, 17 Feb 2020 02:37:23 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 06443E38A5; Mon, 17 Feb 2020 01:37:23 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XGjZ6keXymiU; Mon, 17 Feb 2020 01:37:21 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 4069AE3A14; Mon, 17 Feb 2020 01:37:21 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Feb 2020 01:36:47 +0100 Message-Id: <20200217003653.20027-3-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200217003653.20027-1-cus@passwd.hu> References: <20200213231624.28373-1-cus@passwd.hu> <20200217003653.20027-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH v2 3/9] avformat/libsrt: fix checking connection result in non-blocking mode X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" After f8990c5f414d4575415e2a3981c3b142222ca3d4 we properly set non-blocking mode which makes the connect() call return always 0 even if no connection can be established. Fix this by always doing a poll after calling connect(). Also there was some leftover copy paste code which checks for various errors which are simply not possible with SRT. Signed-off-by: Marton Balint --- libavformat/libsrt.c | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c index 378acb045a..1ab6c1ddb3 100644 --- a/libavformat/libsrt.c +++ b/libavformat/libsrt.c @@ -250,34 +250,19 @@ static int libsrt_listen_connect(int eid, int fd, const struct sockaddr *addr, s if (libsrt_socket_nonblock(fd, 1) < 0) av_log(h, AV_LOG_DEBUG, "ff_socket_nonblock failed\n"); - while ((ret = srt_connect(fd, addr, addrlen))) { - ret = libsrt_neterrno(h); - switch (ret) { - case AVERROR(EINTR): - if (ff_check_interrupt(&h->interrupt_callback)) - return AVERROR_EXIT; - continue; - case AVERROR(EINPROGRESS): - case AVERROR(EAGAIN): - ret = libsrt_network_wait_fd_timeout(h, eid, fd, 1, timeout, &h->interrupt_callback); - if (ret < 0) - return ret; - ret = srt_getlasterror(NULL); - srt_clearlasterror(); - if (ret != 0) { - char buf[128]; - ret = AVERROR(ret); - av_strerror(ret, buf, sizeof(buf)); - if (will_try_next) - av_log(h, AV_LOG_WARNING, - "Connection to %s failed (%s), trying next address\n", - h->filename, buf); - else - av_log(h, AV_LOG_ERROR, "Connection to %s failed: %s\n", - h->filename, buf); - } - default: - return ret; + ret = srt_connect(fd, addr, addrlen); + if (ret < 0) + return libsrt_neterrno(h); + + ret = libsrt_network_wait_fd_timeout(h, eid, fd, 1, timeout, &h->interrupt_callback); + if (ret < 0) { + if (will_try_next) { + av_log(h, AV_LOG_WARNING, + "Connection to %s failed (%s), trying next address\n", + h->filename, av_err2str(ret)); + } else { + av_log(h, AV_LOG_ERROR, "Connection to %s failed: %s\n", + h->filename, av_err2str(ret)); } } return ret; From patchwork Mon Feb 17 00:36:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 17810 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id E487A44AC15 for ; Mon, 17 Feb 2020 02:37:30 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D0D93689C96; Mon, 17 Feb 2020 02:37:30 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CDB6D689C6C for ; Mon, 17 Feb 2020 02:37:24 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id B6039E3A16; Mon, 17 Feb 2020 01:37:24 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 00MKFqQ6UxvP; Mon, 17 Feb 2020 01:37:23 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 512F3E3A04; Mon, 17 Feb 2020 01:37:23 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Feb 2020 01:36:48 +0100 Message-Id: <20200217003653.20027-4-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200217003653.20027-1-cus@passwd.hu> References: <20200213231624.28373-1-cus@passwd.hu> <20200217003653.20027-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH v2 4/9] avformat/libsrt: poll for error conditions as well X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- libavformat/libsrt.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c index 1ab6c1ddb3..38d047ca88 100644 --- a/libavformat/libsrt.c +++ b/libavformat/libsrt.c @@ -164,16 +164,17 @@ static int libsrt_socket_nonblock(int socket, int enable) static int libsrt_network_wait_fd(URLContext *h, int eid, int fd, int write) { - int ret, len = 1; - int modes = write ? SRT_EPOLL_OUT : SRT_EPOLL_IN; + int ret, len = 1, errlen = 1; + int modes = SRT_EPOLL_ERR | (write ? SRT_EPOLL_OUT : SRT_EPOLL_IN); SRTSOCKET ready[1]; + SRTSOCKET error[1]; if (srt_epoll_add_usock(eid, fd, &modes) < 0) return libsrt_neterrno(h); if (write) { - ret = srt_epoll_wait(eid, 0, 0, ready, &len, POLLING_TIME, 0, 0, 0, 0); + ret = srt_epoll_wait(eid, error, &errlen, ready, &len, POLLING_TIME, 0, 0, 0, 0); } else { - ret = srt_epoll_wait(eid, ready, &len, 0, 0, POLLING_TIME, 0, 0, 0, 0); + ret = srt_epoll_wait(eid, ready, &len, error, &errlen, POLLING_TIME, 0, 0, 0, 0); } if (ret < 0) { if (srt_getlasterror(NULL) == SRT_ETIMEOUT) @@ -181,7 +182,7 @@ static int libsrt_network_wait_fd(URLContext *h, int eid, int fd, int write) else ret = libsrt_neterrno(h); } else { - ret = 0; + ret = errlen ? AVERROR(EIO) : 0; } if (srt_epoll_remove_usock(eid, fd) < 0) return libsrt_neterrno(h); From patchwork Mon Feb 17 00:36:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 17811 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 1E83644AC15 for ; Mon, 17 Feb 2020 02:37:33 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 03649689E33; Mon, 17 Feb 2020 02:37:33 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B4F0F689DC8 for ; Mon, 17 Feb 2020 02:37:26 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 85D7EE36B4; Mon, 17 Feb 2020 01:37:26 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 60u8oY-Y2RWw; Mon, 17 Feb 2020 01:37:25 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 24127E39F2; Mon, 17 Feb 2020 01:37:25 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Feb 2020 01:36:49 +0100 Message-Id: <20200217003653.20027-5-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200217003653.20027-1-cus@passwd.hu> References: <20200213231624.28373-1-cus@passwd.hu> <20200217003653.20027-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH v2 5/9] avformat/libsrt: small fixes in libsrt_neterrno() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Return os error code if available, check for both SRT_EASYNCRCV and SRT_EASYNCSND when transforming them to EAGAIN and only display error if it is not EAGAIN. Signed-off-by: Marton Balint --- libavformat/libsrt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c index 38d047ca88..c3c96b35e0 100644 --- a/libavformat/libsrt.c +++ b/libavformat/libsrt.c @@ -145,11 +145,12 @@ static const AVOption libsrt_options[] = { static int libsrt_neterrno(URLContext *h) { - int err = srt_getlasterror(NULL); - av_log(h, AV_LOG_ERROR, "%s\n", srt_getlasterror_str()); - if (err == SRT_EASYNCRCV) + int os_errno; + int err = srt_getlasterror(&os_errno); + if (err == SRT_EASYNCRCV || err == SRT_EASYNCSND) return AVERROR(EAGAIN); - return AVERROR_UNKNOWN; + av_log(h, AV_LOG_ERROR, "%s\n", srt_getlasterror_str()); + return os_errno ? AVERROR(os_errno) : AVERROR_UNKNOWN; } static int libsrt_socket_nonblock(int socket, int enable) From patchwork Mon Feb 17 00:36:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 17812 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id DE2BB44AC15 for ; Mon, 17 Feb 2020 02:37:34 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C8939689DC8; Mon, 17 Feb 2020 02:37:34 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A42B1689CFF for ; Mon, 17 Feb 2020 02:37:32 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 756F8E36B4; Mon, 17 Feb 2020 01:37:32 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LqUYmEysTJCR; Mon, 17 Feb 2020 01:37:31 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id E8498E38A5; Mon, 17 Feb 2020 01:37:30 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Feb 2020 01:36:50 +0100 Message-Id: <20200217003653.20027-6-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200217003653.20027-1-cus@passwd.hu> References: <20200213231624.28373-1-cus@passwd.hu> <20200217003653.20027-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH v2 6/9] avformat/libsrt: send non-blocking mode on both the listen and the connect socket X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- libavformat/libsrt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c index c3c96b35e0..fe3e7d4207 100644 --- a/libavformat/libsrt.c +++ b/libavformat/libsrt.c @@ -249,9 +249,6 @@ static int libsrt_listen_connect(int eid, int fd, const struct sockaddr *addr, s { int ret; - if (libsrt_socket_nonblock(fd, 1) < 0) - av_log(h, AV_LOG_DEBUG, "ff_socket_nonblock failed\n"); - ret = srt_connect(fd, addr, addrlen); if (ret < 0) return libsrt_neterrno(h); @@ -432,6 +429,9 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags) if (s->send_buffer_size > 0) { srt_setsockopt(fd, SOL_SOCKET, SRTO_UDP_SNDBUF, &s->send_buffer_size, sizeof (s->send_buffer_size)); } + if (libsrt_socket_nonblock(fd, 1) < 0) + av_log(h, AV_LOG_DEBUG, "libsrt_socket_nonblock failed\n"); + if (s->mode == SRT_MODE_LISTENER) { // multi-client if ((ret = libsrt_listen(s->eid, fd, cur_ai->ai_addr, cur_ai->ai_addrlen, h, open_timeout)) < 0) From patchwork Mon Feb 17 00:36:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 17813 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id C792D44AC15 for ; Mon, 17 Feb 2020 02:37:36 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B2D9668A0AE; Mon, 17 Feb 2020 02:37:36 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 20D8668A0A3 for ; Mon, 17 Feb 2020 02:37:35 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id F110EE36B4; Mon, 17 Feb 2020 01:37:34 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oxVMM8JIM5WQ; Mon, 17 Feb 2020 01:37:33 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 769CDE38A5; Mon, 17 Feb 2020 01:37:33 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Feb 2020 01:36:51 +0100 Message-Id: <20200217003653.20027-7-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200217003653.20027-1-cus@passwd.hu> References: <20200213231624.28373-1-cus@passwd.hu> <20200217003653.20027-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH v2 7/9] avformat/libsrt: use listen_timeout for listening X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- libavformat/libsrt.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c index fe3e7d4207..f24ce46831 100644 --- a/libavformat/libsrt.c +++ b/libavformat/libsrt.c @@ -227,14 +227,9 @@ static int libsrt_listen(int eid, int fd, const struct sockaddr *addr, socklen_t if (ret) return libsrt_neterrno(h); - while ((ret = libsrt_network_wait_fd_timeout(h, eid, fd, 1, timeout, &h->interrupt_callback))) { - switch (ret) { - case AVERROR(ETIMEDOUT): - continue; - default: - return ret; - } - } + ret = libsrt_network_wait_fd_timeout(h, eid, fd, 1, timeout, &h->interrupt_callback); + if (ret < 0) + return ret; ret = srt_accept(fd, NULL, NULL); if (ret < 0) @@ -434,7 +429,7 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags) if (s->mode == SRT_MODE_LISTENER) { // multi-client - if ((ret = libsrt_listen(s->eid, fd, cur_ai->ai_addr, cur_ai->ai_addrlen, h, open_timeout)) < 0) + if ((ret = libsrt_listen(s->eid, fd, cur_ai->ai_addr, cur_ai->ai_addrlen, h, s->listen_timeout)) < 0) goto fail1; fd = ret; } else { From patchwork Mon Feb 17 00:36:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 17814 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id B487E44AC15 for ; Mon, 17 Feb 2020 02:37:38 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9830A68A0C7; Mon, 17 Feb 2020 02:37:38 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BFE92689C76 for ; Mon, 17 Feb 2020 02:37:37 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 8CC9EE36B4; Mon, 17 Feb 2020 01:37:37 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id X4972t8kKZEU; Mon, 17 Feb 2020 01:37:36 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 1F341E3A04; Mon, 17 Feb 2020 01:37:35 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Feb 2020 01:36:52 +0100 Message-Id: <20200217003653.20027-8-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200217003653.20027-1-cus@passwd.hu> References: <20200213231624.28373-1-cus@passwd.hu> <20200217003653.20027-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH v2 8/9] avformat/libsrt: make the non-API controlled connect timeout 0 by default X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Otherwise the user is not able to override the API connect timeout above 5 sec without setting also timeout. Signed-off-by: Marton Balint --- libavformat/libsrt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c index f24ce46831..2d6fc4b7e7 100644 --- a/libavformat/libsrt.c +++ b/libavformat/libsrt.c @@ -361,7 +361,7 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags) int ret; char hostname[1024],proto[1024],path[1024]; char portstr[10]; - int open_timeout = 5000000; + int open_timeout = 0; int eid; eid = srt_epoll_create(); From patchwork Mon Feb 17 00:36:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 17815 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 9DCEE44AC15 for ; Mon, 17 Feb 2020 02:37:40 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 811C668A24C; Mon, 17 Feb 2020 02:37:40 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2AFD8689F10 for ; Mon, 17 Feb 2020 02:37:38 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id E7551E36B4; Mon, 17 Feb 2020 01:37:37 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6iA1PnYPk06i; Mon, 17 Feb 2020 01:37:36 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 91D5AE38A5; Mon, 17 Feb 2020 01:37:36 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Feb 2020 01:36:53 +0100 Message-Id: <20200217003653.20027-9-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200217003653.20027-1-cus@passwd.hu> References: <20200213231624.28373-1-cus@passwd.hu> <20200217003653.20027-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH v2 9/9] doc/protocols: clarify SRT timeout options docs X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- doc/protocols.texi | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/doc/protocols.texi b/doc/protocols.texi index 57814c7831..54a287f488 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -1348,11 +1348,9 @@ Set UDP receive buffer size, expressed in bytes. Set UDP send buffer size, expressed in bytes. @item timeout -Set raise error timeout for read/write optations. - -This option is only relevant in read mode: -if no data arrived in more than this time -interval, raise error. +Set raise error timeouts for read, write and connect operations. Note that the +SRT library has internal timeouts which can be controlled separately, the +value set here is only a cap on those. @item tlpktdrop=@var{1|0} Too-late Packet Drop. When enabled on receiver, it skips