Browse Source

Invert directions of extmap when reciprocating media

Paul-Louis Ageneau 3 years ago
parent
commit
c00436133a
2 changed files with 18 additions and 2 deletions
  1. 1 1
      include/rtc/description.hpp
  2. 17 1
      src/description.cpp

+ 1 - 1
include/rtc/description.hpp

@@ -119,13 +119,13 @@ public:
 		virtual string generateSdpLines(string_view eol) const;
 
 		std::vector<string> mAttributes;
+		std::map<int, ExtMap> mExtMap;
 
 	private:
 		string mType;
 		string mDescription;
 		string mMid;
 		Direction mDirection;
-		std::map<int, ExtMap> mExtMap;
 	};
 
 	struct RTC_CPP_EXPORT Application : public Entry {

+ 17 - 1
src/description.cpp

@@ -774,7 +774,7 @@ Description::Media Description::Media::reciprocate() const {
 	Media reciprocated(*this);
 
 	// Invert direction
-	switch (direction()) {
+	switch (reciprocated.direction()) {
 	case Direction::RecvOnly:
 		reciprocated.setDirection(Direction::SendOnly);
 		break;
@@ -786,6 +786,22 @@ Description::Media Description::Media::reciprocate() const {
 		break;
 	}
 
+	// Invert directions of extmap
+	for (auto it = reciprocated.mExtMap.begin(); it != reciprocated.mExtMap.end(); ++it) {
+		auto &map = it->second;
+		switch (map.direction) {
+		case Direction::RecvOnly:
+			map.direction = Direction::SendOnly;
+			break;
+		case Direction::SendOnly:
+			map.direction = Direction::RecvOnly;
+			break;
+		default:
+			// We are good
+			break;
+		}
+	}
+
 	// Clear all ssrc attributes as they are individual
 	auto it = reciprocated.mAttributes.begin();
 	while (it != reciprocated.mAttributes.end()) {