compatible rtsp sdp parse no samplerate for audio (#3740)

兼容rtsp sdp协商中未声明采样率但是可以通过a 字段中fmtp中有config中解析出来的情况
This commit is contained in:
xiongguangjie 2024-07-21 20:43:52 +08:00 committed by GitHub
parent 9463d1291d
commit 8398ae17e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -15,6 +15,7 @@
#include "Common/Parser.h"
#include "Common/config.h"
#include "Network/Socket.h"
#include "Extension/Factory.h"
using namespace std;
using namespace toolkit;
@ -236,10 +237,6 @@ void SdpParser::load(const string &sdp) {
track._codec = codec;
track._samplerate = samplerate;
}
if (!track._samplerate && track._type == TrackVideo) {
// 未设置视频采样率时赋值为90000
track._samplerate = 90000;
}
++it;
}
@ -260,6 +257,17 @@ void SdpParser::load(const string &sdp) {
if (it != track._attr.end()) {
track._control = it->second;
}
if (!track._samplerate && track._type == TrackVideo) {
// 未设置视频采样率时赋值为90000
track._samplerate = 90000;
} else if (!track._samplerate && track._type == TrackAudio) {
// some rtsp sdp no sample rate but has fmt config to parser get sample rate
auto t = Factory::getTrackBySdp(track_ptr);
if (t) {
track._samplerate = std::static_pointer_cast<AudioTrack>(t)->getAudioSampleRate();
}
}
}
}