From patchwork Wed Oct 14 14:34:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 22951 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 05A9644B680 for ; Wed, 14 Oct 2020 18:03:08 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E110F68BAE3; Wed, 14 Oct 2020 18:03:07 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi1-f193.google.com (mail-oi1-f193.google.com [209.85.167.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 309D768B704 for ; Wed, 14 Oct 2020 18:03:01 +0300 (EEST) Received: by mail-oi1-f193.google.com with SMTP id m128so3529050oig.7 for ; Wed, 14 Oct 2020 08:03:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=hd6qr6wQLajixR3SXXetnCG9ij4zXjXN8DSEDs3ND8c=; b=joCHREErTMeiGdYmKVFDfeVVLs8rICG6YjgFwDh8yAtXlmQY3mgPUWgnr5I4EphwrY KStPAHPxD53oTPnmnPBleA/sCtnYzLGxmK7yjTU5WHDRyFV2VMlukiiuafGpYf20n/rk qryeAd1EzZwx3gU9rKZf1tUiTDzhxEpyPT2RGSE8i+qZT6dxwXRMeEAXVMd6lfYpd99b pfdOxQaHZNeqBYFIyjJmE/a9/lnSVxntCPDe5FbhiosXpv8aImfybBehQWiqnErGcvrS /KiJMy6k9On2TpCiWIWyDcAvqMhJEXC7lHxJW8SLzWfpQ+bWfV/+F8OlfDucK6O3fHsJ eDxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=hd6qr6wQLajixR3SXXetnCG9ij4zXjXN8DSEDs3ND8c=; b=itB6G5qL4+UvBE5iFv5yBVM1LPi/UWoZbfZuarN5whBD+ea4kJzsUJaQzNRYsFDkF1 A5oBlzaddJ2wIWl1+6PVGJUfVssAJb+Fq5XiOwIFeCQ60vvUatvRnpr+3vyrKG4xa9vK xt3uG+Z38hDPs5t2noazPBXpoZbDx0CwA5GQpShY21dp/RzKe+MoyOmVNc5iRWRr2cRv Ywra6I/QGt2GCUOfDvIDDK8IfQXYW5TAUuoAIgEArPnCzsd3tn6XvIoXx+L2OC9sXcBB FchklEtvdPx3ozCUAeP/ExNpqD5gJWmGqkE/bMYfbMnNwRXq9lASJ7clilku819Bmgy7 inQw== X-Gm-Message-State: AOAM531j3TB1f1rdF1AVZz7CPvWi7zWUQ24HE5o8fISZt+S9rsz4wwYf a1TokmmZVbT3ln5kmVBzzxptVo2M2Ac= X-Google-Smtp-Source: ABdhPJyKx8WSHYIB8RZwGn8XnRAc7YXMht39fKLsnQba0qLQlTXI3UsIpzLkdHSD/ICvEMRRDLGXwA== X-Received: by 2002:a17:90a:db91:: with SMTP id h17mr3802128pjv.94.1602686119847; Wed, 14 Oct 2020 07:35:19 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id o4sm3612035pjj.38.2020.10.14.07.35.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Oct 2020 07:35:18 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 14 Oct 2020 22:34:58 +0800 Message-Id: <1602686103-3427-1-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 Subject: [FFmpeg-devel] [PATCH 1/6] avformat/rtpdec: update the previous with new seq 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang If the rtp input is discontinued, we'll drop all the new received packets now, It's better to update the previous seq with the new seq so that the following packets will not be dropped always. Signed-off-by: Limin Wang --- libavformat/rtpdec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c index 3d5b200..de79536 100644 --- a/libavformat/rtpdec.c +++ b/libavformat/rtpdec.c @@ -833,6 +833,7 @@ static int rtp_parse_one_packet(RTPDemuxContext *s, AVPacket *pkt, /* Packet older than the previously emitted one, drop */ av_log(s->ic, AV_LOG_WARNING, "RTP: dropping old packet received too late\n"); + s->seq = seq; return -1; } else if (diff <= 1) { /* Correct packet */ From patchwork Wed Oct 14 14:34:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 22947 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 9C9BB44AB0D for ; Wed, 14 Oct 2020 17:35:30 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4949E68B9F5; Wed, 14 Oct 2020 17:35:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B45B468ADC1 for ; Wed, 14 Oct 2020 17:35:23 +0300 (EEST) Received: by mail-pg1-f175.google.com with SMTP id o3so2080405pgr.11 for ; Wed, 14 Oct 2020 07:35:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=x1WA5lLsg7QMX4gdR68MyWGsOCCYOB96w57WpXTBpoU=; b=JTbRdgugS3pX44m+MQkEomQMD/H2PsqSdlaHgbGOuKnH+YVgY3PtM7Vy704befsb/8 Xadtw3ZuVz4GYxw3sNJRZ9MC7pImPqNvTx6j6rerOxttLoYg4cqgaBv7e6xZ5RKo6A9U h3Z4JnZO/wEAPEDG2KE27HidK9IqV0CfjJUVijlCYB+bP4pD3Oil8MzDFxjbZC/F28/o C9l0Oe/zagYUuLA7CwWKQdqJArmWKxrfxPPQUV01QAs/GA64f1voAjN6XLCeF5gQSUcd ZqO7uRWtY8G8+IdkWCxW0mFvtpXQfTuapSD59hOUPdfMuLXC3m8zvwvDPAdE96UaaiAJ AQwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=x1WA5lLsg7QMX4gdR68MyWGsOCCYOB96w57WpXTBpoU=; b=Jxknnid51Z8mut0ssw0QqhzuNR+8ZKPFue+mfcnynk1kmcsWpN5Gp+oHLsXlYBaFxp D+crb7mFo8L9bI8luVxiN4lTJBZ7vgKy2xuUIn6z+wn9U3M+6NpnHsexONNRU5Tc0geO Xpgdl1+siyidw/My1yklmo5TTvq4D9tQYKW/0YIa2OXH7R0lrsS87xuQ8G3AktZ65X3+ FQM/TPA8zMZ0mS4yZgAe1ZJsThHCdAO0m9ABhRhkzDPUQkZWBXIGxA/JhjdMuMpoiMYW oO/E22XlKWl/y7/Aqg3GTVVasAv8b1rqPs8hTAVKb2Qcls0Tgw/B99LoyosLuYULg3B3 Jc/A== X-Gm-Message-State: AOAM532oPiIDsldqzojG8T7VytWxb6sajoP1zhqj7+EuUPJA4rGn92Kc hpUVAsU9cC3DcI+5rfzk3FdgtX105h8= X-Google-Smtp-Source: ABdhPJxfe+4MvX9FdwmoLhUGjwo9sCRcWIJSF0w9FL0k3aXRZQaD1uK+4igY+FbXMY5EzIQHwQDOGg== X-Received: by 2002:a63:ff4e:: with SMTP id s14mr4020310pgk.137.1602686121384; Wed, 14 Oct 2020 07:35:21 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id o4sm3612035pjj.38.2020.10.14.07.35.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Oct 2020 07:35:20 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 14 Oct 2020 22:34:59 +0800 Message-Id: <1602686103-3427-2-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1602686103-3427-1-git-send-email-lance.lmwang@gmail.com> References: <1602686103-3427-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH 2/6] avformat/rtpproto: support for rtp read timeout 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang then we can set the rtp read timeout instead of infinite timeout. How to test(5s timeout): ./ffprobe -i rtp://192.168.1.67:1234?timeout=5000000 Signed-off-by: Limin Wang --- doc/protocols.texi | 3 +++ libavformat/rtpproto.c | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/protocols.texi b/doc/protocols.texi index 7b3df96..b4efa14 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -990,6 +990,9 @@ set to 1) or to a default remote address (if set to 0). @item localport=@var{n} Set the local RTP port to @var{n}. +@item timeout=@var{n} +Set timeout (in microseconds) of socket I/O operations to @var{n}. + This is a deprecated option. Instead, @option{localrtpport} should be used. diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c index 19e940d..7dd6042 100644 --- a/libavformat/rtpproto.c +++ b/libavformat/rtpproto.c @@ -60,6 +60,7 @@ typedef struct RTPContext { char *sources; char *block; char *fec_options_str; + int64_t rw_timeout; } RTPContext; #define OFFSET(x) offsetof(RTPContext, x) @@ -75,6 +76,7 @@ static const AVOption options[] = { { "write_to_source", "Send packets to the source address of the latest received packet", OFFSET(write_to_source), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, .flags = D|E }, { "pkt_size", "Maximum packet size", OFFSET(pkt_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, { "dscp", "DSCP class", OFFSET(dscp), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, + { "timeout", "set timeout (in microseconds) of socket I/O operations", OFFSET(rw_timeout), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, .flags = D|E }, { "sources", "Source list", OFFSET(sources), AV_OPT_TYPE_STRING, { .str = NULL }, .flags = D|E }, { "block", "Block list", OFFSET(block), AV_OPT_TYPE_STRING, { .str = NULL }, .flags = D|E }, { "fec", "FEC", OFFSET(fec_options_str), AV_OPT_TYPE_STRING, { .str = NULL }, .flags = E }, @@ -265,6 +267,9 @@ static int rtp_open(URLContext *h, const char *uri, int flags) if (av_find_info_tag(buf, sizeof(buf), "dscp", p)) { s->dscp = strtol(buf, NULL, 10); } + if (av_find_info_tag(buf, sizeof(buf), "timeout", p)) { + s->rw_timeout = strtol(buf, NULL, 10); + } if (av_find_info_tag(buf, sizeof(buf), "sources", p)) { av_strlcpy(include_sources, buf, sizeof(include_sources)); ff_ip_parse_sources(h, buf, &s->filters); @@ -280,6 +285,8 @@ static int rtp_open(URLContext *h, const char *uri, int flags) block = s->block; } } + if (s->rw_timeout >= 0) + h->rw_timeout = s->rw_timeout; if (s->fec_options_str) { p = s->fec_options_str; @@ -375,9 +382,10 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size) RTPContext *s = h->priv_data; int len, n, i; struct pollfd p[2] = {{s->rtp_fd, POLLIN, 0}, {s->rtcp_fd, POLLIN, 0}}; - int poll_delay = h->flags & AVIO_FLAG_NONBLOCK ? 0 : 100; + int poll_delay = h->flags & AVIO_FLAG_NONBLOCK ? 0 : POLLING_TIME; struct sockaddr_storage *addrs[2] = { &s->last_rtp_source, &s->last_rtcp_source }; socklen_t *addr_lens[2] = { &s->last_rtp_source_len, &s->last_rtcp_source_len }; + int runs = h->rw_timeout / 1000 / POLLING_TIME; for(;;) { if (ff_check_interrupt(&h->interrupt_callback)) @@ -401,6 +409,8 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size) continue; return len; } + } else if (n == 0 && h->rw_timeout > 0 && --runs <= 0) { + return AVERROR(ETIMEDOUT); } else if (n < 0) { if (ff_neterrno() == AVERROR(EINTR)) continue; From patchwork Wed Oct 14 14:35:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 22949 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 C9CAA44AF87 for ; Wed, 14 Oct 2020 18:00:27 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A310B68BA08; Wed, 14 Oct 2020 18:00:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi1-f194.google.com (mail-oi1-f194.google.com [209.85.167.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7444768B9F1 for ; Wed, 14 Oct 2020 18:00:21 +0300 (EEST) Received: by mail-oi1-f194.google.com with SMTP id x62so3493462oix.11 for ; Wed, 14 Oct 2020 08:00:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=z3naL8/boS6fSfP0NnatnKkZJyiD2qfWczxjpQLTEx8=; b=KFcc6ltzyXTIFLIP7sy1f4NkPEd1Q1Fr1qO1l0bSC7LwVjpTnQ/WgXzz+ZFsvLwcpV u5Yga4o2esyJAYQafGAs6gAz3tTp6lJTXQotSQj1oY3LnDs/XEf4nS20FPyRqXky3UTy Ar92Z7dnAGK5sZAqWUdRrTxddA1+OX6FgFwoMSmpn6N3Mdf5CSicnniSxAInZvsLaAo2 3mzBbcn9xebZUXjXMOd2DdT+z2kErcaH+xus5iNzGkjD7gGYEqiTCHR3UrtSANreEcau N/oPUm5kIb07VWmNUD5Ltg7y3hO/Qw7qk18nNHpQ/stYl8Q2x3yzC3dmJ/S5+13S0bXX RCJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=z3naL8/boS6fSfP0NnatnKkZJyiD2qfWczxjpQLTEx8=; b=e3pkg9bAEfZiZwovYgvxp9jDHQfq+9OlzJlIkDSqH5NvUNYmsoMfuKXhWlw6B9NBfk cdq5RVkvfWIBO791t58KJSffKNpLlPIh9aMVZHEX4Q58NCL81/7Ka3SNpD0G0EJdnslA NXdcS405WoHoX05HGGn2MlEeaPJDsAu+X03mhX+Csl0fvAb+vM+K9qhgoiLx1bIWbyL9 WryVrzgj26OrlGgSSEqAsIYVVNKFjFLuquCdIHXT6KwvNVr0JeOJcCAibTKwgM/edTy0 OQPOmSTuxhXOWBVviHh1GDpR6HS2xefZpI4xDJ+HUnN3ud5rX77wx8WjgSJhuFoarGbA +Hug== X-Gm-Message-State: AOAM5337EsuPRGBujMGt3rLUHl0NLZLlg5AsYIX6g5nTGT++AVxP7PDr JZhTEPFLtv/D9bllxAraulYiQ1xoofk= X-Google-Smtp-Source: ABdhPJyop+39glOa+OUwL30wmTurcYJX6/zbBRuR2GVz9Cn1Le0vQJtDG81rrNe0f7CVFmHqBMvl4g== X-Received: by 2002:a17:90a:9509:: with SMTP id t9mr3700387pjo.188.1602686122880; Wed, 14 Oct 2020 07:35:22 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id o4sm3612035pjj.38.2020.10.14.07.35.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Oct 2020 07:35:22 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 14 Oct 2020 22:35:00 +0800 Message-Id: <1602686103-3427-3-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1602686103-3427-1-git-send-email-lance.lmwang@gmail.com> References: <1602686103-3427-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH 3/6] avformat/rtsp: support for listen_timeout option for sdp 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Now the listen timeout is hardcoded(10s). How to test(30s timeout): ./ffprobe -listen_timeout 30 -protocol_whitelist rtp,udp,file -i test.sdp Signed-off-by: Limin Wang --- libavformat/rtsp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index e9fca03..4ecd702 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -55,7 +55,6 @@ * and read_packet(), in seconds */ #define POLL_TIMEOUT_MS 100 #define READ_PACKET_TIMEOUT_S 10 -#define MAX_TIMEOUTS READ_PACKET_TIMEOUT_S * 1000 / POLL_TIMEOUT_MS #define SDP_MAX_SIZE 16384 #define RECVBUF_SIZE 10 * RTP_MAX_PACKET_LENGTH #define DEFAULT_REORDERING_DELAY 100000 @@ -115,6 +114,7 @@ static const AVOption sdp_options[] = { RTSP_FLAG_OPTS("sdp_flags", "SDP flags"), { "custom_io", "use custom I/O", 0, AV_OPT_TYPE_CONST, {.i64 = RTSP_FLAG_CUSTOM_IO}, 0, 0, DEC, "rtsp_flags" }, { "rtcp_to_source", "send RTCP packets to the source address of received packets", 0, AV_OPT_TYPE_CONST, {.i64 = RTSP_FLAG_RTCP_TO_SOURCE}, 0, 0, DEC, "rtsp_flags" }, + { "listen_timeout", "set maximum timeout (in seconds) to wait for incoming connections", OFFSET(initial_timeout), AV_OPT_TYPE_INT, {.i64 = READ_PACKET_TIMEOUT_S}, INT_MIN, INT_MAX, DEC }, RTSP_MEDIATYPE_OPTS("allowed_media_types", "set media types to accept from the server"), COMMON_OPTS(), { NULL }, @@ -122,6 +122,8 @@ static const AVOption sdp_options[] = { static const AVOption rtp_options[] = { RTSP_FLAG_OPTS("rtp_flags", "set RTP flags"), + { "listen_timeout", "set maximum timeout (in seconds) to wait for incoming connections", OFFSET(initial_timeout), AV_OPT_TYPE_INT, {.i64 = READ_PACKET_TIMEOUT_S}, INT_MIN, INT_MAX, DEC }, + RTSP_MEDIATYPE_OPTS("allowed_media_types", "set media types to accept from the server"), COMMON_OPTS(), { NULL }, }; @@ -1985,9 +1987,10 @@ static int udp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st, { RTSPState *rt = s->priv_data; RTSPStream *rtsp_st; - int n, i, ret, timeout_cnt = 0; + int n, i, ret; struct pollfd *p = rt->p; int *fds = NULL, fdsnum, fdsidx; + int runs = rt->initial_timeout * 1000LL / POLL_TIMEOUT_MS; if (!p) { p = rt->p = av_malloc_array(2 * rt->nb_rtsp_streams + 1, sizeof(struct pollfd)); @@ -2028,7 +2031,6 @@ static int udp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st, n = poll(p, rt->max_p, POLL_TIMEOUT_MS); if (n > 0) { int j = rt->rtsp_hd ? 1 : 0; - timeout_cnt = 0; for (i = 0; i < rt->nb_rtsp_streams; i++) { rtsp_st = rt->rtsp_streams[i]; if (rtsp_st->rtp_handle) { @@ -2049,7 +2051,7 @@ static int udp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st, } } #endif - } else if (n == 0 && ++timeout_cnt >= MAX_TIMEOUTS) { + } else if (n == 0 && --runs <= 0) { return AVERROR(ETIMEDOUT); } else if (n < 0 && errno != EINTR) return AVERROR(errno); From patchwork Wed Oct 14 14:35:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 22948 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 20DF0448D83 for ; Wed, 14 Oct 2020 17:42:46 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F361368BA6D; Wed, 14 Oct 2020 17:42:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qv1-f67.google.com (mail-qv1-f67.google.com [209.85.219.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ABF0C68B8DB for ; Wed, 14 Oct 2020 17:42:39 +0300 (EEST) Received: by mail-qv1-f67.google.com with SMTP id ev17so1607709qvb.3 for ; Wed, 14 Oct 2020 07:42:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=j577ZzFO4D+bb6rIdnOXOBzpUsXZP/peukXRqso8xHI=; b=jmB7Y6lp8xcI1RX85VKKjryhyDXHBg/PopN1Pyfsjvgip546+/S6cc67Fptsdhjr2J oirQntS2AtOPGVTRq/hiDe8/2iJ8D5YG+3iUBg27mBy/xsc2jGpD3oRJgIDvyHcsVmvX 8mk5wOioZW+9MvCRhPdNCrnBozhDwW9aFbNDTRyDmOClEj1062ieH2k9EqijxLigfVE2 J2VzMdgqgjEE8vqr5dbHvKJNWI0bkPaWkbCSndD+/YYbG6zFWITsxGwpc390Nb/PkfYL ZKpI7rxZMeRm/e8nEW8JSIBO9tGFw7DBp5iUl7cmE+GH/iddce2UvM5mjEA06czMlLjM /85A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=j577ZzFO4D+bb6rIdnOXOBzpUsXZP/peukXRqso8xHI=; b=eGy9pBCWpjd5ocYH6DPRjPXZ1Yz15gBApGCXL7qzyNAytPq0Fgemf8TwDgJjxSyc1R JlS7fxeJuJ/EcGuhVg8bd/ss0wrieY/9HB832zBEloHh52lkT0S5X9ZxyBQyff2UmeVU cX9aFlGkPm/JJimIPTL7LWFYVp0otqcCtO6WJ5lw4pSESHZJcUw3mBiLgdY620xGeiaQ dCC4b33+T5HkqtVcyXoeHTAFQz0qLMf8LXqmoV2hH/557R8yHxDPqBaHEy/23PyrGwwR XIRHC/Ed9NpS1UAtcHRKJHpr3QRWv+rZle/FLDl4B1nsVTAp6bCZqBCRLRvuXlOrOvAl eypQ== X-Gm-Message-State: AOAM533iWtu/io9ASWgVbReKfLqz7JGRYyeGhLvgFbArhGAtTXHZI+/E Qj4pfc2iKOrB63oVNAbHyOiQG85PkEY= X-Google-Smtp-Source: ABdhPJwk/DwltskhNWCDIm+LmlOtOB6zmiOZXFBo2PVHPzIe0pQ+yaCCtWeZkG9Na5OnjGUT+vvEhg== X-Received: by 2002:a17:902:5999:b029:d3:f00b:8ae3 with SMTP id p25-20020a1709025999b02900d3f00b8ae3mr4637126pli.36.1602686124371; Wed, 14 Oct 2020 07:35:24 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id o4sm3612035pjj.38.2020.10.14.07.35.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Oct 2020 07:35:23 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 14 Oct 2020 22:35:01 +0800 Message-Id: <1602686103-3427-4-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1602686103-3427-1-git-send-email-lance.lmwang@gmail.com> References: <1602686103-3427-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH 4/6] avformat/rtsp: reuse POLLING_TIME and remove POLL_TIMEOUT_MS 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Signed-off-by: Limin Wang --- libavformat/rtsp.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 4ecd702..49c2d52 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -51,9 +51,7 @@ #include "rtpenc.h" #include "mpegts.h" -/* Timeout values for socket poll, in ms, - * and read_packet(), in seconds */ -#define POLL_TIMEOUT_MS 100 +/* Default timeout values for read packet in seconds */ #define READ_PACKET_TIMEOUT_S 10 #define SDP_MAX_SIZE 16384 #define RECVBUF_SIZE 10 * RTP_MAX_PACKET_LENGTH @@ -1990,7 +1988,7 @@ static int udp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st, int n, i, ret; struct pollfd *p = rt->p; int *fds = NULL, fdsnum, fdsidx; - int runs = rt->initial_timeout * 1000LL / POLL_TIMEOUT_MS; + int runs = rt->initial_timeout * 1000LL / POLLING_TIME; if (!p) { p = rt->p = av_malloc_array(2 * rt->nb_rtsp_streams + 1, sizeof(struct pollfd)); @@ -2028,7 +2026,7 @@ static int udp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st, return AVERROR_EXIT; if (wait_end && wait_end - av_gettime_relative() < 0) return AVERROR(EAGAIN); - n = poll(p, rt->max_p, POLL_TIMEOUT_MS); + n = poll(p, rt->max_p, POLLING_TIME); if (n > 0) { int j = rt->rtsp_hd ? 1 : 0; for (i = 0; i < rt->nb_rtsp_streams; i++) { From patchwork Wed Oct 14 14:35:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 22950 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 0769B44B524 for ; Wed, 14 Oct 2020 18:02:12 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D983368BA2D; Wed, 14 Oct 2020 18:02:11 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qv1-f68.google.com (mail-qv1-f68.google.com [209.85.219.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7271868B817 for ; Wed, 14 Oct 2020 18:02:05 +0300 (EEST) Received: by mail-qv1-f68.google.com with SMTP id b10so1654191qvf.0 for ; Wed, 14 Oct 2020 08:02:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YV/CMhaE1psU76WcpxwRHPbi68+A/8RnAMJStMqfV5E=; b=D/QXP/fN9dZG8tVWDVIdx3+X0vbgBYPQX/maiNfJrsGW/o5sRiTgt7XB7eDO8/E0+R bOzZFhH8O2Dtv+x1okMmEo+Ao9yeZvhkONYEEJCJatoHFcCFshbokRv8Aub/IUI7Wg8v waY5aRa3Wj1CryhlN/vGkEYgrI5IvKrNr/5A4CU+1c3vYDGATVeYaIeJslLsiAPKBxS1 tTNn3KVX/yL/uMuKgwgwUuOQ0IfySl6GSdVHAgd8vwdTttCE81HyBcm2jZsbd6W4WPPf BvEkIaJA629gOXeAFf19MlT/5jEg0j+zgOBOeNJ2gqIaCzEnYyBcunohTYAtN9NrXtql vLcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YV/CMhaE1psU76WcpxwRHPbi68+A/8RnAMJStMqfV5E=; b=GfKr1EXNDeFuqR/ROh2srl9DfUTE5cGPQ0c2NBSolJz0+pDXukST8jqbTSjqMjM+fm sRXNmFXqH0g/3LG6o0XEthK+Naq/5P1SqF7Rp7QZqr5JshsHuRYBt41LnFDHq/raFR17 3yu2mNj2BCjbtH9qIGBcaZew7XK7O3qosm1qKNbDUU9ZEXmKrN8vzRetERD3mzaT8INH sgpcMz7Sa0aXF8fRzqqJJUjw6ebnxOqWkjWUYcVXIeKI6+cFvfEMyQggKCD1gPZXfpuo RcQ/kqI1dN2tHG6UGkrILe3lhLc9ZncuU0ZEQWMDZL7pT1zv/X+al+6RO82xIbDfoi3B fTfg== X-Gm-Message-State: AOAM532l15e9O5EuFxiy0moP3AcLOEKpqKFlY2qzFfOpE4KEGM971llc 7ecFmrw48PYS5eOvr118+uMB/4omnPY= X-Google-Smtp-Source: ABdhPJzhUdo/WIXYaqSk3tLsqx09eh2Imw/6TEZLhILn/B9O5dcysO2d3mkM8ChOIS5tAeHP1fYU/w== X-Received: by 2002:a17:902:bc4b:b029:d3:d350:eb69 with SMTP id t11-20020a170902bc4bb02900d3d350eb69mr4874798plz.45.1602686125916; Wed, 14 Oct 2020 07:35:25 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id o4sm3612035pjj.38.2020.10.14.07.35.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Oct 2020 07:35:25 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 14 Oct 2020 22:35:02 +0800 Message-Id: <1602686103-3427-5-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1602686103-3427-1-git-send-email-lance.lmwang@gmail.com> References: <1602686103-3427-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH 5/6] avformat/udp: clarify option description for timeout unit 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Signed-off-by: Limin Wang --- libavformat/udp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/udp.c b/libavformat/udp.c index 30d8041..ee5fa84 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -138,7 +138,7 @@ static const AVOption options[] = { { "connect", "set if connect() should be called on socket", OFFSET(is_connected), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, .flags = D|E }, { "fifo_size", "set the UDP receiving circular buffer size, expressed as a number of packets with size of 188 bytes", OFFSET(circular_buffer_size), AV_OPT_TYPE_INT, {.i64 = 7*4096}, 0, INT_MAX, D }, { "overrun_nonfatal", "survive in case of UDP receiving circular buffer overrun", OFFSET(overrun_nonfatal), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, D }, - { "timeout", "set raise error timeout (only in read mode)", OFFSET(timeout), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, D }, + { "timeout", "set raise error timeout, in microseconds(only in read mode)",OFFSET(timeout), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, D }, { "sources", "Source list", OFFSET(sources), AV_OPT_TYPE_STRING, { .str = NULL }, .flags = D|E }, { "block", "Block list", OFFSET(block), AV_OPT_TYPE_STRING, { .str = NULL }, .flags = D|E }, { NULL } From patchwork Wed Oct 14 14:35:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 22952 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 0C96B44B6A8 for ; Wed, 14 Oct 2020 18:37:46 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D578F68B986; Wed, 14 Oct 2020 18:37:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 11AD868B868 for ; Wed, 14 Oct 2020 18:37:39 +0300 (EEST) Received: by mail-pg1-f193.google.com with SMTP id x13so2224463pgp.7 for ; Wed, 14 Oct 2020 08:37:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=b6hedX4ewTblyaLL4nFBKMPuvn7RQC9S62yDTJqPIZs=; b=p53MB1b3lXNBtQ9hwzvNhecc+FbPqmUpohHjvQ6AmM289w3cZR4GHgE5Ynie9u5qvt c7kU1ZVgIor/X6UT3DWwaKfFMiWVWl5C+JubA3Fsky4E0RrnUF200ZZeYD0l5+CPDpHn jvBdSksGhzrh5yTVjpfr6sAPda5r7b9V11pkS3O/S1JLXflAR7WYYcdvw086QfXADnaX NhHgV480viRMzglf56XGz81ppc8N8D13/ZVGTLE4AMItkAvHSOZ46fliJLupd/h+LVAy skqo7pgj+Irf/dkRiyQcwR0syAJA3/pKB6iXvgB5kYuPrC8rYQN5bPm30A38K6jAf1+c ikKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=b6hedX4ewTblyaLL4nFBKMPuvn7RQC9S62yDTJqPIZs=; b=SpXc531yT9i5J0eknR2ffz+FthiX3vC+Cwu2ExcBQTjJMgLUxZOXRzV6ROivegyzgS VPnBOSjw+femfGq3I9r+Him1w47Ay2xKeV0R8wTvaVf+FaK9piKfVvqmlgtTG7sVBTUf 6t3ty5vT/U6cxzeg7sojzCVLXMNjM1R7/RFc4zH24lOCgM0aT4E/3Rn+FZP9ILsh6Mag /Nt8Y9YNlpSzq9i1Md5wRcCx9Aorz6X96vVVPA2By+rnWvdjgrEgRQk86wbLSJTGeICU t+pNTYqxQWYNSLO/v+DVG1kYDsUNf5EQITzrHjrUTsjP33HOSc86VybOKYNfZIuQRnWC HpEg== X-Gm-Message-State: AOAM533lFaLIeyNxNa3rR2ATflthFWWMQ0NcUta+skQZW+RqnOk5Ounc Yiu+yVCelduW3/9YDK/ZJ9cXt00jZU0= X-Google-Smtp-Source: ABdhPJwFSy4QosUl7n+rthVaLTUufMFMBIEGIYpIT2rwnsUP9fwJoqoqVDjVWOkzXVsE8zf5/1fABA== X-Received: by 2002:a17:902:934b:b029:d4:e4c7:26f5 with SMTP id g11-20020a170902934bb02900d4e4c726f5mr4578096plp.60.1602686127487; Wed, 14 Oct 2020 07:35:27 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id o4sm3612035pjj.38.2020.10.14.07.35.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Oct 2020 07:35:26 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 14 Oct 2020 22:35:03 +0800 Message-Id: <1602686103-3427-6-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1602686103-3427-1-git-send-email-lance.lmwang@gmail.com> References: <1602686103-3427-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH 6/6] avformat/udp: cosmetics 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Signed-off-by: Limin Wang --- libavformat/udp.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/libavformat/udp.c b/libavformat/udp.c index ee5fa84..0ff7deb 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -190,7 +190,7 @@ static int udp_join_multicast_group(int sockfd, struct sockaddr *addr,struct soc if (local_addr) mreq.imr_interface= ((struct sockaddr_in *)local_addr)->sin_addr; else - mreq.imr_interface.s_addr= INADDR_ANY; + mreq.imr_interface.s_addr = INADDR_ANY; if (setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const void *)&mreq, sizeof(mreq)) < 0) { ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IP_ADD_MEMBERSHIP)"); return -1; @@ -203,7 +203,7 @@ static int udp_join_multicast_group(int sockfd, struct sockaddr *addr,struct soc memcpy(&mreq6.ipv6mr_multiaddr, &(((struct sockaddr_in6 *)addr)->sin6_addr), sizeof(struct in6_addr)); //TODO: Interface index should be looked up from local_addr - mreq6.ipv6mr_interface= 0; + mreq6.ipv6mr_interface = 0; if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq6, sizeof(mreq6)) < 0) { ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IPV6_ADD_MEMBERSHIP)"); return -1; @@ -221,9 +221,9 @@ static int udp_leave_multicast_group(int sockfd, struct sockaddr *addr,struct so mreq.imr_multiaddr.s_addr = ((struct sockaddr_in *)addr)->sin_addr.s_addr; if (local_addr) - mreq.imr_interface= ((struct sockaddr_in *)local_addr)->sin_addr; + mreq.imr_interface = ((struct sockaddr_in *)local_addr)->sin_addr; else - mreq.imr_interface.s_addr= INADDR_ANY; + mreq.imr_interface.s_addr = INADDR_ANY; if (setsockopt(sockfd, IPPROTO_IP, IP_DROP_MEMBERSHIP, (const void *)&mreq, sizeof(mreq)) < 0) { ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IP_DROP_MEMBERSHIP)"); return -1; @@ -236,7 +236,7 @@ static int udp_leave_multicast_group(int sockfd, struct sockaddr *addr,struct so memcpy(&mreq6.ipv6mr_multiaddr, &(((struct sockaddr_in6 *)addr)->sin6_addr), sizeof(struct in6_addr)); //TODO: Interface index should be looked up from local_addr - mreq6.ipv6mr_interface= 0; + mreq6.ipv6mr_interface = 0; if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, &mreq6, sizeof(mreq6)) < 0) { ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IPV6_DROP_MEMBERSHIP)"); return -1; @@ -295,9 +295,9 @@ static int udp_set_multicast_sources(URLContext *h, mreqs.imr_multiaddr.s_addr = ((struct sockaddr_in *)addr)->sin_addr.s_addr; if (local_addr) - mreqs.imr_interface= ((struct sockaddr_in *)local_addr)->sin_addr; + mreqs.imr_interface = ((struct sockaddr_in *)local_addr)->sin_addr; else - mreqs.imr_interface.s_addr= INADDR_ANY; + mreqs.imr_interface.s_addr = INADDR_ANY; mreqs.imr_sourceaddr.s_addr = ((struct sockaddr_in *)&sources[i])->sin_addr.s_addr; if (setsockopt(sockfd, IPPROTO_IP, @@ -545,7 +545,7 @@ static void *circular_buffer_task_tx( void *_URLContext) uint8_t tmp[4]; int64_t timestamp; - len=av_fifo_size(s->fifo); + len = av_fifo_size(s->fifo); while (len<4) { if (s->close_req) @@ -553,11 +553,11 @@ static void *circular_buffer_task_tx( void *_URLContext) if (pthread_cond_wait(&s->cond, &s->mutex) < 0) { goto end; } - len=av_fifo_size(s->fifo); + len = av_fifo_size(s->fifo); } av_fifo_generic_read(s->fifo, tmp, 4, NULL); - len=AV_RL32(tmp); + len = AV_RL32(tmp); av_assert0(len >= 0); av_assert0(len <= sizeof(s->tmp)); @@ -956,10 +956,10 @@ static int udp_read(URLContext *h, uint8_t *buf, int size) uint8_t tmp[4]; av_fifo_generic_read(s->fifo, tmp, 4, NULL); - avail= AV_RL32(tmp); + avail = AV_RL32(tmp); if(avail > size){ av_log(h, AV_LOG_WARNING, "Part of datagram lost due to insufficient buffer size\n"); - avail= size; + avail = size; } av_fifo_generic_read(s->fifo, buf, avail, NULL); @@ -973,8 +973,7 @@ static int udp_read(URLContext *h, uint8_t *buf, int size) } else if(nonblock) { pthread_mutex_unlock(&s->mutex); return AVERROR(EAGAIN); - } - else { + } else { /* FIXME: using the monotonic clock would be better, but it does not exist on all supported platforms. */ int64_t t = av_gettime() + 100000; @@ -987,7 +986,7 @@ static int udp_read(URLContext *h, uint8_t *buf, int size) } nonblock = 1; } - } while( 1); + } while(1); } #endif @@ -1020,7 +1019,7 @@ static int udp_write(URLContext *h, const uint8_t *buf, int size) Here we can't know on which packet error was, but it needs to know that error exists. */ if (s->circular_buffer_error<0) { - int err=s->circular_buffer_error; + int err = s->circular_buffer_error; pthread_mutex_unlock(&s->mutex); return err; }