修复音频相关的bug

This commit is contained in:
xiongziliang 2021-04-05 11:07:41 +08:00
parent ce04a7279c
commit 606f251311

View File

@ -558,6 +558,10 @@ void SdpAttrRtpMap::parse(const string &str) {
if (sscanf(str.data(), "%" SCNu8 " %31[^/]/%" SCNd32, &pt, buf, &sample_rate) != 3) { if (sscanf(str.data(), "%" SCNu8 " %31[^/]/%" SCNd32, &pt, buf, &sample_rate) != 3) {
SDP_THROW(); SDP_THROW();
} }
if (getTrackType(getCodecId(buf)) == TrackAudio) {
//未指定通道数时且为音频时那么通道数默认为1
channel = 1;
}
} }
codec = buf; codec = buf;
} }
@ -890,7 +894,7 @@ void RtcSession::loadFrom(const string &str, bool check) {
auto rtpmap_it = rtpmap_map.find(pt); auto rtpmap_it = rtpmap_map.find(pt);
if (rtpmap_it == rtpmap_map.end()) { if (rtpmap_it == rtpmap_map.end()) {
plan.pt = pt; plan.pt = pt;
plan.codec = RtpPayload::getCodecId(pt); plan.codec = RtpPayload::getName(pt);
plan.sample_rate = RtpPayload::getClockRate(pt); plan.sample_rate = RtpPayload::getClockRate(pt);
plan.channel = RtpPayload::getAudioChannel(pt); plan.channel = RtpPayload::getAudioChannel(pt);
} else { } else {