Bug 1344556 - Part 4: Fix bug where direction on negotiated extmaps was recorded backwards. r?drno
MozReview-Commit-ID: BFQ2WcNs4OH
--- a/media/webrtc/signaling/src/sdp/SdpHelper.cpp
+++ b/media/webrtc/signaling/src/sdp/SdpHelper.cpp
@@ -742,45 +742,38 @@ SdpHelper::AddCommonExtmaps(
{
if (!remoteMsection.GetAttributeList().HasAttribute(
SdpAttribute::kExtmapAttribute)) {
return;
}
UniquePtr<SdpExtmapAttributeList> localExtmap(new SdpExtmapAttributeList);
auto& theirExtmap = remoteMsection.GetAttributeList().GetExtmap().mExtmaps;
- for (auto i = theirExtmap.begin(); i != theirExtmap.end(); ++i) {
- for (auto j = localExtensions.begin(); j != localExtensions.end(); ++j) {
- // verify we have a valid combination of directions. For kInactive
- // we'll just not add the response
- if (i->extensionname == j->extensionname &&
- (((i->direction == SdpDirectionAttribute::Direction::kSendrecv ||
- i->direction == SdpDirectionAttribute::Direction::kSendonly) &&
- (j->direction == SdpDirectionAttribute::Direction::kSendrecv ||
- j->direction == SdpDirectionAttribute::Direction::kRecvonly)) ||
+ for (const auto& theirExt : theirExtmap) {
+ for (const auto& ourExt : localExtensions) {
+ if (theirExt.extensionname != ourExt.extensionname) {
+ continue;
+ }
+
+ auto negotiatedExt = theirExt;
- ((i->direction == SdpDirectionAttribute::Direction::kSendrecv ||
- i->direction == SdpDirectionAttribute::Direction::kRecvonly) &&
- (j->direction == SdpDirectionAttribute::Direction::kSendrecv ||
- j->direction == SdpDirectionAttribute::Direction::kSendonly)))) {
- auto k = *i; // we need to modify it
- if (j->direction == SdpDirectionAttribute::Direction::kSendonly) {
- k.direction = SdpDirectionAttribute::Direction::kRecvonly;
- } else if (j->direction == SdpDirectionAttribute::Direction::kRecvonly) {
- k.direction = SdpDirectionAttribute::Direction::kSendonly;
- }
- localExtmap->mExtmaps.push_back(k);
+ negotiatedExt.direction = ~negotiatedExt.direction & ourExt.direction;
+ if (negotiatedExt.direction ==
+ SdpDirectionAttribute::Direction::kInactive) {
+ continue;
+ }
- // RFC 5285 says that ids >= 4096 can be used by the offerer to
- // force the answerer to pick, otherwise the value in the offer is
- // used.
- if (localExtmap->mExtmaps.back().entry >= 4096) {
- localExtmap->mExtmaps.back().entry = j->entry;
- }
+ // RFC 5285 says that ids >= 4096 can be used by the offerer to
+ // force the answerer to pick, otherwise the value in the offer is
+ // used.
+ if (negotiatedExt.entry >= 4096) {
+ negotiatedExt.entry = ourExt.entry;
}
+
+ localExtmap->mExtmaps.push_back(negotiatedExt);
}
}
if (!localExtmap->mExtmaps.empty()) {
localMsection->GetAttributeList().SetAttribute(localExtmap.release());
}
}