From patchwork Sat Sep 7 10:23:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyun Yoo X-Patchwork-Id: 14966 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 279C044997D for ; Sat, 7 Sep 2019 13:31:40 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EE56F6806B6; Sat, 7 Sep 2019 13:31:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F33EF680572 for ; Sat, 7 Sep 2019 13:31:32 +0300 (EEST) Received: by mail-lj1-f196.google.com with SMTP id a4so8272910ljk.8 for ; Sat, 07 Sep 2019 03:31:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=r+7f5qcKis6rQCHhl5qVHI7HAprox5xpbnarbTDZ6pA=; b=jLffisFsoHclXieGokgEvMiVm43zCx6qZQFIs3XxmV7Lp9dfGfej0W8vgEsnasmJqg e9cc2njHnIQdREPMHq0T9yNpMF7Og1cKgNRM+FPKb0zzNHAbLWFCcA9lbiTzh/eSA7vm 8cS9q/OJV0HadQ5ICZghhjkeny5d+l/nAGA9dr6uv6Js+76COdSuc2Uw0Le50hCDWJ3F 1eQYblVG6kjpmnAfOKJZNhlva0hUsaLX3dr0OEPmhu6xg1Drn0Hd1VoRc2zkYJEHQJq/ kpNEBARIBdka4K5A10FsAqBX1+YUWowvMWyZ4ykgz7i0yQVDz/tq4cdiTyLcRYouEmjj t6TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=r+7f5qcKis6rQCHhl5qVHI7HAprox5xpbnarbTDZ6pA=; b=Rxg94RD2Gb9fv1LC3arWXucPOLj3Gy/5P5tsLmGaJK6Sp3Eew8qk53rEDxVjQzk3+W zpoy8YEALn0qyrQ3lG42k9fhR4G6FxtbLFvABJg5hXBkxHGT7jXgj0MMd3Ga+kJ1/4RO 3GT/Mp5e25CVJKfFe7SiVyNTeYbzXAscYKZOkB+YojCB3dqDQNfxvp++q/QUm9/bcEoR yRgCZ7RzCt90D/K1gHsgvJuvL3clhYF8PlpILa76sNjcH/Lbou0dzVEFn0MjenRgvwYr kQNSzqpGuG064FhHnaoXKHmDQVMZgop7geiUbBmaTC8wEl2Oa0n/Cs4y+E2mmxQ8xcOd dEfA== X-Gm-Message-State: APjAAAU5IUEuUfEUPfEcj0foNbJ5U6re2C4j6i3xDYfCBmA1Ubo3NTnh wOTAj7aaJSfo/Ha/Z37uYJptguFx09/aLNs5wG9gmg== X-Google-Smtp-Source: APXvYqwq6a00qUvc8Wmda53CHRYLJfTDSmhTL/LIAw9xA35Ue/Ii2pAXCDD2Gem5XLPSqodq/uzShX0UH9lrHRZOEt4= X-Received: by 2002:a2e:5358:: with SMTP id t24mr8911613ljd.209.1567851805726; Sat, 07 Sep 2019 03:23:25 -0700 (PDT) MIME-Version: 1.0 References: <20190905000231.818-1-easetheworld@gmail.com> In-Reply-To: <20190905000231.818-1-easetheworld@gmail.com> From: Hyun Yoo Date: Sat, 7 Sep 2019 19:23:13 +0900 Message-ID: To: ffmpeg-devel@ffmpeg.org X-Content-Filtered-By: Mailman/MimeDel 2.1.20 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Hyun Yoo 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(+) 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 { 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];