From 9b7c9b91093a8b98d0b3c71caed7d3157544f7fc Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Sun, 28 Feb 2021 21:02:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9sdp=E4=B8=8D=E8=A7=84?= =?UTF-8?q?=E8=8C=83=E7=9A=84rtsp=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtsp/Rtsp.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Rtsp/Rtsp.cpp b/src/Rtsp/Rtsp.cpp index 984dfe4e..492eb644 100644 --- a/src/Rtsp/Rtsp.cpp +++ b/src/Rtsp/Rtsp.cpp @@ -188,7 +188,7 @@ void SdpParser::load(const string &sdp) { char rtp[16] = {0}, type[16]; if (4 == sscanf(opt_val.data(), " %15[^ ] %d %15[^ ] %d", type, &port, rtp, &pt)) { track->_pt = pt; - track->_samplerate = RtpPayload::getClockRate(pt) ; + track->_samplerate = RtpPayload::getClockRate(pt); track->_channel = RtpPayload::getAudioChannel(pt); track->_type = toTrackType(type); track->_m = opt_val; @@ -223,14 +223,14 @@ void SdpParser::load(const string &sdp) { if (strcmp(start, "now") == 0) { strcpy(start, "0"); } - track._start = (float)atof(start); - track._end = (float)atof(end); + track._start = (float) atof(start); + track._end = (float) atof(end); track._duration = track._end - track._start; } } it = track._attr.find("rtpmap"); - if(it != track._attr.end()){ + if (it != track._attr.end()) { auto rtpmap = it->second; int pt, samplerate, channel; char codec[16] = {0}; @@ -239,20 +239,24 @@ void SdpParser::load(const string &sdp) { track._codec = codec; track._samplerate = samplerate; track._channel = channel; - }else if (3 == sscanf(rtpmap.data(), "%d %15[^/]/%d", &pt, codec, &samplerate)) { + } else if (3 == sscanf(rtpmap.data(), "%d %15[^/]/%d", &pt, codec, &samplerate)) { track._pt = pt; track._codec = codec; track._samplerate = samplerate; } + if (!track._samplerate && track._type == TrackVideo) { + //未设置视频采样率时,赋值为90000 + track._samplerate = 90000; + } } it = track._attr.find("fmtp"); - if(it != track._attr.end()) { + if (it != track._attr.end()) { track._fmtp = it->second; } it = track._attr.find("control"); - if(it != track._attr.end()) { + if (it != track._attr.end()) { track._control = it->second; } }