From patchwork Thu Nov 25 10:45:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 31660 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp475022iob; Thu, 25 Nov 2021 02:45:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJzRgn60wLEE+kq4ZWIyl8b3vnZT2wDLx2QUXVVFXyzc5ZwD2hKGXVRHO/wqsNVGCUlLbdeq X-Received: by 2002:a17:906:48cd:: with SMTP id d13mr29360029ejt.35.1637837145971; Thu, 25 Nov 2021 02:45:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637837145; cv=none; d=google.com; s=arc-20160816; b=j6k4y9O5CRYXK/xcGTXEOuWZb4yM5DRItLLjFQOCfvARPP4ZLns9RUtaIC0lnsvv9a m9iDz7j+Q6TdjWl1pslSkB5Uju0T22DKDonFxZR3ftlgydPvmnxU+OWJq3oIQuofxtul dXmHTw88EqPPL/XcCfkbkbN8y8sgAXXfFfnHPn7z5wozX7vNFjyn7LdlVlEDqt/C0hAR u46vfFuHh3qRqiPFdEn+eLauz/C0Uq35nf+9VsC8PAFUpAjmCdHXjjxN+JGBkMebIQul kQuSXCCEnCJe7oXcuDET4iTt+AFuRokPvh56pdEe2PHAtSoQVnwwDr7/jHyeeRmS0rKy 1ieA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to; bh=E98ZoNdGy/IiAzf5dIqkhMgLuPeBpQ1ccQzDhjWkUyA=; b=oc+m1u6fAEa15H4EXKPYRguMeLbqPF4oNSgIbrkc3KjR1d6yXGdL4YjJNkjlZkpBzP kdlI5JaC/UaTwJ4i81BM97GijilhGXscnrqR3V9gT8x5Y40ugtZc1huMChv+Hw2CdS7O L9wAcp+PtP/FQb9jRLkf7Hma17qYVHI3mk5LxL6dQC7lEJV5/ZkRnvCnERrqlpvqZ1DM 406YKMbxaZzctzWWUSa33tXMjag4ff1/4/KkW12sZB8/7t/Nge1PcFy2RvZKUXH9IysN WTwfsoVAkG0dYHPJBYeOE6RHLWgRoh/w/ILD8XNlFsO/UUlBhO1uujr9/OwDMJfT/AFV 9Pag== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=bVfWR4VY; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id mq7si3965185ejc.19.2021.11.25.02.45.44; Thu, 25 Nov 2021 02:45:45 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=bVfWR4VY; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E6BAA689A13; Thu, 25 Nov 2021 12:45:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8DC08689A13 for ; Thu, 25 Nov 2021 12:45:34 +0200 (EET) Received: by mail-pg1-f176.google.com with SMTP id 71so4881406pgb.4 for ; Thu, 25 Nov 2021 02:45:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id; bh=5Rt9bkIk2BnGWbt6zuJMzPcg1YgV4r6oOjsg3mgm+ds=; b=bVfWR4VYKrgJS2LsXF3YoGtfHqqvEXfgWbFr54VldTy+Ixe35lmqVg9RothTAug0iK YkaPdba7fFvxwaf7XYFOt3qHD1eAOcWO3+4E1hLcqeMUInUQwm74FlCdZS9xRFFTsX6O kMMbPgB6CNV/Y1nJODlGuGbT7z/MaVGqZ5Sb8McdorDyoMBNUAY1UKqksuA0JFwpjsVc 2t/bwByNOUy44l6YdAx1VSvOjkbXgKgpYAt44PL4UOF1pIzQnV/v71eyqV0+N1mvc0Ap Aug0wmLO+R2Tq+zMr3pHTpmIA4OJ9qNdxmCmNgpFJKdEPZP2CAhXPJAIDf4k2j8ZllmK PJtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=5Rt9bkIk2BnGWbt6zuJMzPcg1YgV4r6oOjsg3mgm+ds=; b=iUlAMKgzUOAm18pfMBymzw8TFkLhs5uYy+yNjTYQZwmcKZ/pDqf+fkpcP/Gf34BNFY CK8eazpc1Io2p4USAFoDXwcR4xCx076Rx+qU6SrGMgnsuWzuFNJQalZfa+PCaQZRxjQM FFPCECz+S6ojv8x36elGSLKkyHh5cKk+j64VSZIBMlzrD4+jiLo2coQVTJ4BOeYSiKux 4rewELKGJFNr3+LH9Jy2NyRhcUcSf85oV7y4HWRBcvRhZrk1fn1UCsAmWtMn6juFPRCq odCSl5H6rkO4SMFZCLvqWvbhNlKYt7puklSBLcHvl78Ppa90E+MaDMBDXLxxXHtYoSN4 DimQ== X-Gm-Message-State: AOAM532RMGueadyKTsV0ZDTTRn3EjbbCP1TdoopTh8auHCsqIJfcbAuN K2zUKsF8KcjRE6zfDHoMvNiNMm7mjA0= X-Received: by 2002:a05:6a00:188e:b0:4a4:f2fd:d7b9 with SMTP id x14-20020a056a00188e00b004a4f2fdd7b9mr12851193pfh.20.1637837132433; Thu, 25 Nov 2021 02:45:32 -0800 (PST) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id g9sm3110429pfc.182.2021.11.25.02.45.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Nov 2021 02:45:32 -0800 (PST) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Nov 2021 18:45:27 +0800 Message-Id: <1637837128-31393-1-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 Subject: [FFmpeg-devel] [PATCH 1/2] avformat/rtp: add localaddr for network interface selection X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: 6SMAqCzoS6+5 From: Limin Wang Signed-off-by: Limin Wang --- doc/protocols.texi | 4 ++++ libavformat/rtpproto.c | 17 ++++++++++++++--- libavformat/rtsp.c | 3 +++ libavformat/rtsp.h | 1 + 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/doc/protocols.texi b/doc/protocols.texi index c100f23..d207df0 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -1087,6 +1087,10 @@ 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 localaddr=@var{addr} +Local IP address of a network interface used for sending packets or joining +multicast groups. + @item timeout=@var{n} Set timeout (in microseconds) of socket I/O operations to @var{n}. diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c index 7dd6042..c92cda6 100644 --- a/libavformat/rtpproto.c +++ b/libavformat/rtpproto.c @@ -61,6 +61,7 @@ typedef struct RTPContext { char *block; char *fec_options_str; int64_t rw_timeout; + char *localaddr; } RTPContext; #define OFFSET(x) offsetof(RTPContext, x) @@ -80,6 +81,7 @@ static const AVOption options[] = { { "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 }, + { "localaddr", "Local address", OFFSET(localaddr), AV_OPT_TYPE_STRING, { .str = NULL }, .flags = D|E }, { NULL } }; @@ -173,6 +175,7 @@ static av_printf_format(3, 4) void url_add_option(char *buf, int buf_size, const static void build_udp_url(RTPContext *s, char *buf, int buf_size, const char *hostname, + const char *localaddr, int port, int local_port, const char *include_sources, const char *exclude_sources) @@ -195,6 +198,8 @@ static void build_udp_url(RTPContext *s, url_add_option(buf, buf_size, "sources=%s", include_sources); if (exclude_sources && exclude_sources[0]) url_add_option(buf, buf_size, "block=%s", exclude_sources); + if (localaddr && localaddr[0]) + url_add_option(buf, buf_size, "localaddr=%s", localaddr); } /** @@ -284,6 +289,12 @@ static int rtp_open(URLContext *h, const char *uri, int flags) ff_ip_parse_blocks(h, s->block, &s->filters); block = s->block; } + if (av_find_info_tag(buf, sizeof(buf), "localaddr", p)) { + av_freep(&s->localaddr); + s->localaddr = av_strdup(buf); + if (!s->localaddr) + goto fail; + } } if (s->rw_timeout >= 0) h->rw_timeout = s->rw_timeout; @@ -314,7 +325,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags) for (i = 0; i < max_retry_count; i++) { build_udp_url(s, buf, sizeof(buf), - hostname, rtp_port, s->local_rtpport, + hostname, s->localaddr, rtp_port, s->local_rtpport, sources, block); if (ffurl_open_whitelist(&s->rtp_hd, buf, flags, &h->interrupt_callback, NULL, h->protocol_whitelist, h->protocol_blacklist, h) < 0) @@ -328,7 +339,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags) if (s->local_rtcpport < 0) { s->local_rtcpport = s->local_rtpport + 1; build_udp_url(s, buf, sizeof(buf), - hostname, s->rtcp_port, s->local_rtcpport, + hostname, s->localaddr, s->rtcp_port, s->local_rtcpport, sources, block); if (ffurl_open_whitelist(&s->rtcp_hd, buf, rtcpflags, &h->interrupt_callback, NULL, @@ -339,7 +350,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags) break; } build_udp_url(s, buf, sizeof(buf), - hostname, s->rtcp_port, s->local_rtcpport, + hostname, s->localaddr, s->rtcp_port, s->local_rtcpport, sources, block); if (ffurl_open_whitelist(&s->rtcp_hd, buf, rtcpflags, &h->interrupt_callback, NULL, h->protocol_whitelist, h->protocol_blacklist, h) < 0) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index a1aa969..3897826 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -74,6 +74,7 @@ #define COMMON_OPTS() \ { "reorder_queue_size", "set number of packets to buffer for handling of reordered packets", OFFSET(reordering_queue_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, DEC }, \ { "buffer_size", "Underlying protocol send/receive buffer size", OFFSET(buffer_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, DEC|ENC }, \ + { "localaddr", "local address", OFFSET(localaddr), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC|ENC }, \ { "pkt_size", "Underlying protocol send packet size", OFFSET(pkt_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, ENC } \ @@ -2424,6 +2425,8 @@ static int sdp_read_header(AVFormatContext *s) rt->rtsp_flags & RTSP_FLAG_FILTER_SRC ? 1 : 0, rt->rtsp_flags & RTSP_FLAG_RTCP_TO_SOURCE ? 1 : 0); + if (rt->localaddr && rt->localaddr[0]) + av_strlcatf(url, sizeof(url), "&localaddr=%s", rt->localaddr); append_source_addrs(url, sizeof(url), "sources", rtsp_st->nb_include_source_addrs, rtsp_st->include_source_addrs); diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h index 4ec974e..d6fdfe0 100644 --- a/libavformat/rtsp.h +++ b/libavformat/rtsp.h @@ -419,6 +419,7 @@ typedef struct RTSPState { char default_lang[4]; int buffer_size; int pkt_size; + char *localaddr; } RTSPState; #define RTSP_FLAG_FILTER_SRC 0x1 /**< Filter incoming UDP packets - From patchwork Thu Nov 25 10:45:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 31659 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp475211iob; Thu, 25 Nov 2021 02:45:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJxi1glnvR3WL7u+/KQVrLQKMicCjPpm+WzV9dUFrprL3F2FkoPh+fD2dbZVvNxuDNODtBl/ X-Received: by 2002:a17:906:a1da:: with SMTP id bx26mr30479184ejb.558.1637837154044; Thu, 25 Nov 2021 02:45:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637837154; cv=none; d=google.com; s=arc-20160816; b=UkXkevDyuiABIMNft/LSm0L2bqcLPknXP/kfHyvYgraFSGOM8bIzC2n0X9LgNIEB8G fwWDIuD0YxbWvr9+H+z1rqRtGxvMZU1KheXyZEIwxrtZeJYqSNWLLEEqx+6qvTBuf4G5 ACz6FHVP1D/645FxrQuy7GTjdjw6nww+DckGHEPJ6lRingvdMvIPysHQ8BuYTbowo0+3 7r1/fl1dcZHq6+Aj4cT2mC/Y1hTLvzgfHCuioN7pzIrSEGJHoFaD4/+s/S0mopGUhemG JNCJO4s6PS1L3AiUVQwu+Vq5Zv31cAIVW9C7YbDk8n8Q7EVCcbftGNhOC4guPdcCgaqN tCIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=ligwG/E21khfgyLKw3g38LbiP5zSwSLBF6idWHB1emg=; b=oWLzS4HoCE58+uHPCdvySsA9097gwlYb11Z+qzmvDeslp3305E0LoXXOhcAKstwTak Udz2Wn/gmemG6XdRsf4mGxygXrt3J6y0fp4MaQFACuk5RJomNCLiy7zxs6LU/bbw+KXV lYl0RXgQXU4jAuwtR3kKuVM/jJuBYuMIpDQA+bLBK1W80bAf9zBY+3G2+6m9X9P9uJj3 9a6kLzxplDP5Pkl7gbNmbFjNnhE6IaXxEricVP/uea2/SJ8lvHXTecvb52WBXERgMjPw spgHPzAD6swDNYuedO9byJtxnqYSerg3hXT/dIHs9Nn+hZvojIGEXFt/UMoXsFQxRMJj bERg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=llF9jkEX; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hq3si10157422ejc.142.2021.11.25.02.45.53; Thu, 25 Nov 2021 02:45:54 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=llF9jkEX; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DC69068AEC1; Thu, 25 Nov 2021 12:45:42 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4DD49689A13 for ; Thu, 25 Nov 2021 12:45:35 +0200 (EET) Received: by mail-pg1-f176.google.com with SMTP id r138so4850304pgr.13 for ; Thu, 25 Nov 2021 02:45:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cVn75nqYfOCLA9J9NiLkkPJWegutNAlxHs6RXMGS0LE=; b=llF9jkEXvn7RcyS5FDOtLRI09AzTp2UsiZnlmIayZQTJTVQ5QjbQLSjjpEkNzyLMn/ CG5JI+wCGEZpkklSYi/NcLVaW41cIowRs1NrMy3tLy9/eGi33ApD0YWAoI4vNlhYlBbI 4aNHBHWX9PhxgGbQz8wwe1PDpR1I2552+gt2IhHCbHRqMbg5u8hYh6a1JAZyy8ngsiya wc8xDgYV2n90Qo3uvuLvaDr0XLdH2O6uIV4pE4FAxoJAjbwMY4IEap7kxdbgGWIc6T7L 0IhaLiVDzltrD1dmKoIEzeGw0PimH+cTots9X6UrlZZjbVHsgzxdS8iePBO1Ml1jkCYj QdsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cVn75nqYfOCLA9J9NiLkkPJWegutNAlxHs6RXMGS0LE=; b=xIbYXuFhYXL5H35J/qdmPBN8J992DyaA+3icw9aW3gCzmo5lxQKyOULwO3vlF0BJ1l 22W7LSuNl+7gwsw5LpkaCuBuwjlrp83OjKIUo+5vzmPWae4TYOqIq9hduaetNaGnDHPx pLvnJ8zLONlQ2TfrziWWThhtGIk/wjdI/NJyjB7nYPp9gbLrGLz+YonowP8Kpic9TRuU 2KMMHLd1xRyv7jciYggawycxMUlyhuWeaCYF8/wJwcrVKhhFGCH6ck9e2OYKKHGUovRa +LuUPD4qFlDl8lJHCYZWRqOUHOqZkSqGWSu5svLaahIEOpTYn1Dpo0g3iRD6TVUl7lsD kLyQ== X-Gm-Message-State: AOAM530+Cn1LmiSf+Qx8UIU3aJEpnW2mJXQPjJWDBvt6DSHZFe9I9UIp gDhLwSmCuZ2JaqRIKwD9v416VASpVB0= X-Received: by 2002:aa7:9d9e:0:b0:4a0:25d0:a06f with SMTP id f30-20020aa79d9e000000b004a025d0a06fmr13648447pfq.82.1637837133646; Thu, 25 Nov 2021 02:45:33 -0800 (PST) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id g9sm3110429pfc.182.2021.11.25.02.45.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Nov 2021 02:45:33 -0800 (PST) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Nov 2021 18:45:28 +0800 Message-Id: <1637837128-31393-2-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1637837128-31393-1-git-send-email-lance.lmwang@gmail.com> References: <1637837128-31393-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH 2/2] avformat/udp: remove local localaddr array X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: aeeoLiz4WQH1 From: Limin Wang Signed-off-by: Limin Wang --- libavformat/udp.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libavformat/udp.c b/libavformat/udp.c index bbe5aec..b8b0e19 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -623,7 +623,7 @@ end: /* return non zero if error */ static int udp_open(URLContext *h, const char *uri, int flags) { - char hostname[1024], localaddr[1024] = ""; + char hostname[1024]; int port, udp_fd = -1, tmp, bind_ret = -1, dscp = -1; UDPContext *s = h->priv_data; int is_output; @@ -708,7 +708,8 @@ static int udp_open(URLContext *h, const char *uri, int flags) s->burst_bits = strtoll(buf, NULL, 10); } if (av_find_info_tag(buf, sizeof(buf), "localaddr", p)) { - av_strlcpy(localaddr, buf, sizeof(localaddr)); + av_freep(&s->localaddr); + s->localaddr = av_strdup(buf); } if (av_find_info_tag(buf, sizeof(buf), "sources", p)) { if ((ret = ff_ip_parse_sources(h, buf, &s->filters)) < 0) @@ -748,10 +749,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) if ((s->is_multicast || s->local_port <= 0) && (h->flags & AVIO_FLAG_READ)) s->local_port = port; - if (localaddr[0]) - udp_fd = udp_socket_create(h, &my_addr, &len, localaddr); - else - udp_fd = udp_socket_create(h, &my_addr, &len, s->localaddr); + udp_fd = udp_socket_create(h, &my_addr, &len, s->localaddr); if (udp_fd < 0) goto fail;