From patchwork Tue Feb 4 00:34:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 17684 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 B7509449EB0 for ; Tue, 4 Feb 2020 02:40:58 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9B805687F30; Tue, 4 Feb 2020 02:40:58 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi1-f196.google.com (mail-oi1-f196.google.com [209.85.167.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 10F75680B6D for ; Tue, 4 Feb 2020 02:40:52 +0200 (EET) Received: by mail-oi1-f196.google.com with SMTP id d62so16669414oia.11 for ; Mon, 03 Feb 2020 16:40:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=ZEPzMYRt4jIe92ifEebCQbZ0ysgQMFT8KWRMtrrmlT4=; b=XmMSM9l3SmJoW33qSwcL5whtIZu3mAXwUfOMbjEbmxOhgL+Vm8EtHtgRR59sIMquih 7LdKsz59N5jd4D2Ddeexsw2ApvIve1rTRIeRMZLTren85hTvdRAawMqxlxNgzKP4hrfs 8racmE/a3Vwd4SsqyRYep0nmLL3XAphQKzESyb3fGxUZowMGjAsQx/PEqtRyVR6bqm7H eaWMfXRyDYsmJR8DSMgDC+u5AuNaLiUognVEhxncrv+awcxOsKydUWMYzksnuXwR3+MD UZpvtv2K+fzIKGz8OEOV0OKt3cUQaxnojW/K9dsv7ghmL3G5eEOZLP20DyyuZJZweNr/ YKUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=ZEPzMYRt4jIe92ifEebCQbZ0ysgQMFT8KWRMtrrmlT4=; b=IFXQY4J4DINdllGAcijr+SziyQ1uA2yfkR2LzQtaA/9+VsHEAfa1qzEK1Wd/nSy/r7 gejDbsbVMAX7HaqrPZpuBcfSF88Ca/b/fCnT1PmmnlK4P0NampVmLNhDW1bkrB34wh7w LN90dE3IaxN5UUqNSYQXGAVn4bCD3RuFAKm7HQkFK+FIE68uaRDIOYkR40n9MykhUXQ7 LFLaACt7WEqRuP6i4KujJELWyNBmJ/AHVSG9HzNRlRNH4Io6OlBbRuNaUkykKAA+xMGg s9rqH3tnxAoSwe+fCgRjounVTH1cBWSk5twBm3Aa0uUaxELmpx7/64qmBXbp80RwKOxr Y5VQ== X-Gm-Message-State: APjAAAVrxJ4VgkFrFK+U7ocGyzT8LCyRIOuasU4NRjedVCMkd14KntBe 0SqLs2CaCiWiO5fm5EpeL8/u6VF8SGw= X-Google-Smtp-Source: APXvYqyPuca426zXBhDsmuMJxPUYyc4av7QQ1giDtcDv1SJjO5X2XQVeDh180kE2Y68LcL2TxOu6wQ== X-Received: by 2002:a17:90a:fa81:: with SMTP id cu1mr2372720pjb.31.1580776454335; Mon, 03 Feb 2020 16:34:14 -0800 (PST) Received: from jun-ubuntu.corp.microsoft.com ([2001:4898:80e8:9:1545:8b7b:2e03:1631]) by smtp.googlemail.com with ESMTPSA id 196sm22096067pfy.86.2020.02.03.16.34.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 16:34:13 -0800 (PST) From: Jun Li To: ffmpeg-devel@ffmpeg.org Date: Mon, 3 Feb 2020 16:34:06 -0800 Message-Id: <20200204003407.3545-1-junli1026@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH v1 1/2] avformat/rtsp: apply rtcp attribute from sdp file 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fix #8479 Apply rtcpport from sdp file if it contains rtcp attribute. Signed-off-by: Jun Li --- libavformat/rtsp.c | 12 ++++++++++-- libavformat/rtsp.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index cd6fc32a29..c892f21142 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -577,6 +577,10 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, if (s1->seen_fmtp) { parse_fmtp(s, rt, payload_type, s1->delayed_fmtp); } + } else if (av_strstart(p, "rtcp:", &p) && s->nb_streams > 0) { + rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; + get_word(buf1, sizeof(buf1), &p); + rtsp_st->rtcp_port = strtol(buf1, NULL, 10); } else if (av_strstart(p, "fmtp:", &p) || av_strstart(p, "framesize:", &p)) { // let dynamic protocol handlers have a stab at the line. @@ -2367,6 +2371,7 @@ static int sdp_read_header(AVFormatContext *s) if (!(rt->rtsp_flags & RTSP_FLAG_CUSTOM_IO)) { AVDictionary *opts = map_to_opts(rt); + int rtcp_port = rtsp_st->rtcp_port; err = getnameinfo((struct sockaddr*) &rtsp_st->sdp_ip, sizeof(rtsp_st->sdp_ip), @@ -2377,10 +2382,13 @@ static int sdp_read_header(AVFormatContext *s) av_dict_free(&opts); goto fail; } + + if (rtcp_port <= 0) + rtcp_port = rtsp_st->sdp_port + 1; ff_url_join(url, sizeof(url), "rtp", NULL, namebuf, rtsp_st->sdp_port, - "?localport=%d&ttl=%d&connect=%d&write_to_source=%d", - rtsp_st->sdp_port, rtsp_st->sdp_ttl, + "?localport=%d&localrtcpport=%d&ttl=%d&connect=%d&write_to_source=%d", + rtsp_st->sdp_port, rtcp_port, rtsp_st->sdp_ttl, rt->rtsp_flags & RTSP_FLAG_FILTER_SRC ? 1 : 0, rt->rtsp_flags & RTSP_FLAG_RTCP_TO_SOURCE ? 1 : 0); diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h index 54a9a30c16..15747fe6d1 100644 --- a/libavformat/rtsp.h +++ b/libavformat/rtsp.h @@ -448,6 +448,7 @@ typedef struct RTSPStream { /** The following are used only in SDP, not RTSP */ //@{ int sdp_port; /**< port (from SDP content) */ + int rtcp_port; /**< rtcp port (from SDP content) */ struct sockaddr_storage sdp_ip; /**< IP address (from SDP content) */ int nb_include_source_addrs; /**< Number of source-specific multicast include source IP addresses (from SDP content) */ struct RTSPSource **include_source_addrs; /**< Source-specific multicast include source IP addresses (from SDP content) */