From c9950dda99e7b59db34b4a942a36e3341312b6b9 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Fri, 2 Nov 2018 14:55:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dsdp=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Extension/Factory.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Extension/Factory.cpp b/src/Extension/Factory.cpp index 5c3f2f17..63cab300 100644 --- a/src/Extension/Factory.cpp +++ b/src/Extension/Factory.cpp @@ -82,7 +82,7 @@ Sdp::Ptr Factory::getSdpByTrack(const Track::Ptr &track) { Track::Ptr Factory::getTrackBySdp(const SdpTrack::Ptr &track) { if (strcasestr(track->_codec.data(), "mpeg4-generic") != nullptr) { - string aac_cfg_str = FindField(track->_fmtp.c_str(), "config=", "\r\n"); + string aac_cfg_str = FindField(track->_fmtp.c_str(), "config=", nullptr); if (aac_cfg_str.size() != 4) { aac_cfg_str = FindField(track->_fmtp.c_str(), "config=", ";"); } @@ -106,7 +106,7 @@ Track::Ptr Factory::getTrackBySdp(const SdpTrack::Ptr &track) { } if (strcasestr(track->_codec.data(), "h264") != nullptr) { - string sps_pps = FindField(track->_fmtp.c_str(), "sprop-parameter-sets=", "\r\n"); + string sps_pps = FindField(track->_fmtp.c_str(), "sprop-parameter-sets=", nullptr); if(sps_pps.empty()){ return std::make_shared(); } @@ -124,13 +124,19 @@ Track::Ptr Factory::getTrackBySdp(const SdpTrack::Ptr &track) { if (strcasestr(track->_codec.data(), "h265") != nullptr) { //a=fmtp:96 sprop-sps=QgEBAWAAAAMAsAAAAwAAAwBdoAKAgC0WNrkky/AIAAADAAgAAAMBlQg=; sprop-pps=RAHA8vA8kAA= int pt; - char sprop_sps[128] = {0},sprop_pps[128] = {0}; - if (3 != sscanf(track->_fmtp.c_str(), "%d sprop-sps=%127[^;]; sprop-pps=%127[^;]", &pt, sprop_sps, sprop_pps)) { - return std::make_shared(); + char sprop_vps[128] = {0},sprop_sps[128] = {0},sprop_pps[128] = {0}; + if (4 == sscanf(track->_fmtp.c_str(), "%d sprop-vps=%127[^;]; sprop-sps=%127[^;]; sprop-pps=%127[^;]", &pt, sprop_vps,sprop_sps, sprop_pps)) { + auto vps = decodeBase64(sprop_vps); + auto sps = decodeBase64(sprop_sps); + auto pps = decodeBase64(sprop_pps); + return std::make_shared(vps,sps,pps,0,0,0); } - auto sps = decodeBase64(sprop_sps); - auto pps = decodeBase64(sprop_pps); - return std::make_shared("",sps,pps,0,0,0); + if (3 == sscanf(track->_fmtp.c_str(), "%d sprop-sps=%127[^;]; sprop-pps=%127[^;]", &pt,sprop_sps, sprop_pps)) { + auto sps = decodeBase64(sprop_sps); + auto pps = decodeBase64(sprop_pps); + return std::make_shared("",sps,pps,0,0,0); + } + return std::make_shared(); }