|
@@ -759,27 +759,28 @@ void Description::Media::parseSdpLine(string_view line) {
|
|
|
auto [key, value] = parse_pair(attr);
|
|
|
|
|
|
if (key == "rtpmap") {
|
|
|
- Description::Media::RTPMap map(value);
|
|
|
- int pt = map.pt;
|
|
|
- mRtpMap.emplace(pt, std::move(map));
|
|
|
+ auto pt = Description::Media::RTPMap::parsePT(value);
|
|
|
+ auto it = mRtpMap.find(pt);
|
|
|
+ if (it == mRtpMap.end()) {
|
|
|
+ it = mRtpMap.insert(std::make_pair(pt, Description::Media::RTPMap(value))).first;
|
|
|
+ }else {
|
|
|
+ it->second.setMLine(value);
|
|
|
+ }
|
|
|
} else if (key == "rtcp-fb") {
|
|
|
size_t p = value.find(' ');
|
|
|
int pt = to_integer<int>(value.substr(0, p));
|
|
|
auto it = mRtpMap.find(pt);
|
|
|
if (it == mRtpMap.end()) {
|
|
|
- PLOG_WARNING << "rtcp-fb applied before the corresponding rtpmap, ignoring";
|
|
|
- } else {
|
|
|
- it->second.rtcpFbs.emplace_back(value.substr(p + 1));
|
|
|
- }
|
|
|
+ it = mRtpMap.insert(std::make_pair(pt, Description::Media::RTPMap())).first;
|
|
|
+ }
|
|
|
+ it->second.rtcpFbs.emplace_back(value.substr(p + 1));
|
|
|
} else if (key == "fmtp") {
|
|
|
size_t p = value.find(' ');
|
|
|
int pt = to_integer<int>(value.substr(0, p));
|
|
|
auto it = mRtpMap.find(pt);
|
|
|
- if (it == mRtpMap.end()) {
|
|
|
- PLOG_WARNING << "fmtp applied before the corresponding rtpmap, ignoring";
|
|
|
- } else {
|
|
|
- it->second.fmtps.emplace_back(value.substr(p + 1));
|
|
|
- }
|
|
|
+ if (it == mRtpMap.end())
|
|
|
+ it = mRtpMap.insert(std::make_pair(pt, Description::Media::RTPMap())).first;
|
|
|
+ it->second.fmtps.emplace_back(value.substr(p + 1));
|
|
|
} else if (key == "rtcp-mux") {
|
|
|
// always added
|
|
|
}else if (key == "ssrc") {
|
|
@@ -812,25 +813,7 @@ std::vector<uint32_t> Description::Media::getSSRCs() {
|
|
|
|
|
|
|
|
|
Description::Media::RTPMap::RTPMap(string_view mline) {
|
|
|
- size_t p = mline.find(' ');
|
|
|
-
|
|
|
- this->pt = to_integer<int>(mline.substr(0, p));
|
|
|
-
|
|
|
- string_view line = mline.substr(p + 1);
|
|
|
- size_t spl = line.find('/');
|
|
|
- this->format = line.substr(0, spl);
|
|
|
-
|
|
|
- line = line.substr(spl + 1);
|
|
|
- spl = line.find('/');
|
|
|
- if (spl == string::npos) {
|
|
|
- spl = line.find(' ');
|
|
|
- }
|
|
|
- if (spl == string::npos)
|
|
|
- this->clockRate = to_integer<int>(line);
|
|
|
- else {
|
|
|
- this->clockRate = to_integer<int>(line.substr(0, spl));
|
|
|
- this->encParams = line.substr(spl+1);
|
|
|
- }
|
|
|
+ setMLine(mline);
|
|
|
}
|
|
|
|
|
|
void Description::Media::RTPMap::removeFB(const string &str) {
|
|
@@ -845,6 +828,34 @@ void Description::Media::RTPMap::removeFB(const string &str) {
|
|
|
|
|
|
void Description::Media::RTPMap::addFB(const string &str) { rtcpFbs.emplace_back(str); }
|
|
|
|
|
|
+int Description::Media::RTPMap::parsePT(string_view view) {
|
|
|
+ size_t p = view.find(' ');
|
|
|
+
|
|
|
+ return to_integer<int>(view.substr(0, p));
|
|
|
+}
|
|
|
+
|
|
|
+void Description::Media::RTPMap::setMLine(string_view mline) {
|
|
|
+ size_t p = mline.find(' ');
|
|
|
+
|
|
|
+ this->pt = to_integer<int>(mline.substr(0, p));
|
|
|
+
|
|
|
+ string_view line = mline.substr(p + 1);
|
|
|
+ size_t spl = line.find('/');
|
|
|
+ this->format = line.substr(0, spl);
|
|
|
+
|
|
|
+ line = line.substr(spl + 1);
|
|
|
+ spl = line.find('/');
|
|
|
+ if (spl == string::npos) {
|
|
|
+ spl = line.find(' ');
|
|
|
+ }
|
|
|
+ if (spl == string::npos)
|
|
|
+ this->clockRate = to_integer<int>(line);
|
|
|
+ else {
|
|
|
+ this->clockRate = to_integer<int>(line.substr(0, spl));
|
|
|
+ this->encParams = line.substr(spl+1);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
Description::Audio::Audio(string mid, Direction dir)
|
|
|
: Media("audio 9 UDP/TLS/RTP/SAVPF", std::move(mid), dir) {}
|
|
|
|