From 79267ae5512ba6f1ab5a58428caa06f2d72b4e6a Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Tue, 6 Apr 2021 23:47:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AF=94=E5=AF=B9codec=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=85=88=E5=85=B3=E9=97=ADprofile=E6=AF=94?= =?UTF-8?q?=E5=AF=B9=EF=BC=8C=E5=86=8D=E5=85=B3=E9=97=ADcodec=E6=AF=94?= =?UTF-8?q?=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webrtc/Sdp.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/webrtc/Sdp.cpp b/webrtc/Sdp.cpp index 38506b5e..490890b0 100644 --- a/webrtc/Sdp.cpp +++ b/webrtc/Sdp.cpp @@ -1342,7 +1342,8 @@ void RtcConfigure::matchMedia(shared_ptr &ret, TrackType type, const if (!configure.enable) { return; } - bool failed = false; + bool check_profile = true; + bool check_codec = true; RETRY: @@ -1357,15 +1358,13 @@ RETRY: } const RtcCodecPlan *offer_plan_ptr = nullptr; for (auto &plan : offer_media.plan) { - if (getCodecId(plan.codec) != codec) { + //先检查编码格式是否为偏好 + if (check_codec && getCodecId(plan.codec) != codec) { continue; } - //如果匹配失败了,那么随便选择一个plan - if (!failed) { - //命中偏好的编码格式 - if (!onMatchCodecPlan(plan, codec)) { - continue; - } + //命中偏好的编码格式,然后检查规格 + if (check_profile && !onCheckCodecProfile(plan, codec)) { + continue; } //找到中意的codec offer_plan_ptr = &plan; @@ -1495,9 +1494,15 @@ RETRY: } } - if (!failed) { - //只重试一次 - failed = true; + if (check_profile) { + //如果是由于检查profile导致匹配失败,那么重试一次,且不检查profile + check_profile = false; + goto RETRY; + } + + if (check_codec) { + //如果是由于检查codec导致匹配失败,那么重试一次,且不检查codec + check_codec = false; goto RETRY; } }