From patchwork Sun Sep 8 23:51:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyun Yoo X-Patchwork-Id: 14980 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 6703644991E for ; Mon, 9 Sep 2019 02:58:00 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 424166807D8; Mon, 9 Sep 2019 02:58:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DD71D680508 for ; Mon, 9 Sep 2019 02:57:52 +0300 (EEST) Received: by mail-pf1-f193.google.com with SMTP id y22so8031975pfr.3 for ; Sun, 08 Sep 2019 16:57:52 -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:mime-version :content-transfer-encoding; bh=DIdFqCgYq2Q0yZfnRltMIfEIv2xn5WZp+EUMu+9opdg=; b=l83s/V8cHDsbIgd6sl5C8IZ1A59tsfO9JBzLD4ix6y1hbn1BzeoT8xpqR4jeaoFiGk biDZJXGxcj0zIt+LOrfyjeUq8G3Ne8OigtIAccqn55TVYW/Sj849rKEhD6ihctVfCSF1 zqTGlqOoOxAOJRt+ou9U5CZFpguhRje2AzaJPnkHesN6gHBENOI3CnrGpm0QVbBQt65P GxxqLucVN/VN+mOHdJlFcyZ5Z1Q06+FWhGYFgD8yMUJukPpBwwQR8Orhm4o02nEf5bjR oQl1HGc0yPlHs2Yyh7cNcrhtSfU8WYitgfqcsV/YsKLvz1N0KAO6CFbj711SvdQXJ4Nk TExg== 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:mime-version :content-transfer-encoding; bh=DIdFqCgYq2Q0yZfnRltMIfEIv2xn5WZp+EUMu+9opdg=; b=hVZhrgXh6uHaxHBcQT8yzLyOtiVoVM+FgndABRQiwjfwCIH3CqJgYKQ+xUidcyDRSe +rr3IMh9TG0OLQsiSlTx273oRj4EMa+ZHuRM3I4EQozMAkDBkImz1xaCnnsw2kHK5FSg vM0ygi0KqEXOG8Qdb+lAZTggZrOekTO2H/mdH2pnMQOiv6P3q8m5fUBS9hOBQZZPrWZJ cUifcO/ao1p77PtJLJMg37MQTKiyDPxwUvlCZhqdwrcmy0/ldIxFTj4d3ULs/3Yq82ZF mwZ/2bQDGb2EMf4FGZ6kPhoARERsqcuyyK9OI76AaBaID8xz0DskBuF97yr6SIOPxK41 WwlQ== X-Gm-Message-State: APjAAAWEZNvihCEVf3CDLYngxoLrXZhINsJWbqErtFcE5GWXq7dImDsT YZsThNmWfHgdSTEUdj27YEQVqpHV X-Google-Smtp-Source: APXvYqwx4aWTiZSOS6OQvnDBrTc/ex5JrGTAoERne4wIXoX9/T5P631PxOWXddmsoYp4R8z1gccXxQ== X-Received: by 2002:a17:90a:8c94:: with SMTP id b20mr21442103pjo.127.1567986701710; Sun, 08 Sep 2019 16:51:41 -0700 (PDT) Received: from localhost.localdomain ([61.74.228.231]) by smtp.gmail.com with ESMTPSA id g18sm14650301pgm.9.2019.09.08.16.51.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Sep 2019 16:51:40 -0700 (PDT) From: Hyun Yoo To: ffmpeg-devel@ffmpeg.org Date: Mon, 9 Sep 2019 08:51:38 +0900 Message-Id: <20190908235138.257-1-easetheworld@gmail.com> X-Mailer: git-send-email 2.23.0.windows.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] rtsp: fix wrong codec setup for some 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: EaseTheWorld Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: EaseTheWorld rtsp_st->sdp_payload_type is the first codec in 'm=' tag st->codecpar->id is the first supported codec in 'a=' tag the two is not guaranteed to be same for example when 1) the order between attributes is random(rfc4566 doesn't force it) 2) the first codec is same for 'm=' and 'a=' but it is unsupported codec then st->codecpar->id will be the next one in 'a='(if it's supported) Signed-off-by: EaseTheWorld --- libavformat/rtsp.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index c153cac88b..be3002690e 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -569,6 +569,9 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, get_word(buf1, sizeof(buf1), &p); payload_type = atoi(buf1); rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; + // parse only sdp_payload_type specified in 'm=' tag + if (rtsp_st->sdp_payload_type != payload_type) + return; if (rtsp_st->stream_index >= 0) { st = s->streams[rtsp_st->stream_index]; sdp_parse_rtpmap(s, st, rtsp_st, payload_type, p); @@ -582,6 +585,10 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, // let dynamic protocol handlers have a stab at the line. get_word(buf1, sizeof(buf1), &p); payload_type = atoi(buf1); + rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; + // parse only sdp_payload_type specified in 'm=' tag + if (rtsp_st->sdp_payload_type != payload_type) + return; if (s1->seen_rtpmap) { parse_fmtp(s, rt, payload_type, buf); } else {