Bläddra i källkod

Exposed some more APIs in Description

Staz M 4 år sedan
förälder
incheckning
1a723c59aa
4 ändrade filer med 23 tillägg och 7 borttagningar
  1. 6 0
      include/rtc/description.hpp
  2. 13 0
      src/description.cpp
  3. 3 6
      src/icetransport.cpp
  4. 1 1
      src/track.cpp

+ 6 - 0
include/rtc/description.hpp

@@ -78,6 +78,11 @@ public:
 		virtual void parseSdpLine(string_view line);
 
 
+        std::vector<string>::iterator beginAttributes();
+        std::vector<string>::iterator endAttributes();
+        std::vector<string>::iterator removeAttribute(std::vector<string>::iterator iterator);
+
+
 	protected:
 		Entry(const string &mline, string mid, Direction dir = Direction::Unknown);
 		virtual string generateSdpLines(string_view eol) const;
@@ -165,6 +170,7 @@ public:
 
         std::map<int, RTPMap>::iterator beginMaps();
         std::map<int, RTPMap>::iterator endMaps();
+        std::map<int, RTPMap>::iterator removeMap(std::map<int, RTPMap>::iterator iterator);
 
 	private:
 		virtual string generateSdpLines(string_view eol) const override;

+ 13 - 0
src/description.cpp

@@ -500,6 +500,15 @@ void Description::Entry::parseSdpLine(string_view line) {
 			mAttributes.emplace_back(line.substr(2));
 	}
 }
+std::vector< string>::iterator Description::Entry::beginAttributes() {
+    return mAttributes.begin();
+}
+std::vector< string>::iterator Description::Entry::endAttributes() {
+    return mAttributes.end();
+}
+std::vector< string>::iterator Description::Entry::removeAttribute(std::vector<string>::iterator it) {
+    return mAttributes.erase(it);
+}
 
 void Description::Media::addSSRC(uint32_t ssrc, std::string name) {
     mAttributes.emplace_back("ssrc:" + std::to_string(ssrc) + " cname:" + name);
@@ -824,6 +833,10 @@ std::map<int, Description::Media::RTPMap>::iterator Description::Media::endMaps(
     return mRtpMap.end();
 }
 
+std::map<int, Description::Media::RTPMap>::iterator
+Description::Media::removeMap(std::map<int, Description::Media::RTPMap>::iterator iterator) {
+    return mRtpMap.erase(iterator);
+}
 
 Description::Media::RTPMap::RTPMap(string_view mline) {
     setMLine(mline);

+ 3 - 6
src/icetransport.cpp

@@ -141,15 +141,12 @@ Description IceTransport::getLocalDescription(Description::Type type) const {
 	if (juice_get_local_description(mAgent.get(), sdp, JUICE_MAX_SDP_STRING_LEN) < 0)
 		throw std::runtime_error("Failed to generate local SDP");
 
-	return Description(string(sdp), type, mRole);
+    return Description(string(sdp), type, type == Description::Type::Offer ? Description::Role::ActPass : mRole);
 }
 
 void IceTransport::setRemoteDescription(const Description &description) {
-    if (description.role() == Description::Role::ActPass)
-        mRole = Description::Role::Passive;
-    else
-	    mRole = description.role() == Description::Role::Active ? Description::Role::Passive
-	                                                        : Description::Role::Active;
+    mRole = description.role() == Description::Role::Active ? Description::Role::Passive  : Description::Role::Active;
+
 	mMid = description.bundleMid();
 	if (juice_set_remote_description(mAgent.get(),
 	                                 description.generateApplicationSdp("\r\n").c_str()) < 0)

+ 1 - 1
src/track.cpp

@@ -147,7 +147,7 @@ void Track::incoming(message_ptr message) {
 void Track::setRtcpHandler(std::shared_ptr<RtcpHandler> handler) {
 	mRtcpHandler = std::move(handler);
 	if (mRtcpHandler) {
-		mRtcpHandler->onOutgoing([&](const rtc::message_ptr& message) {
+		mRtcpHandler->onOutgoing([&]([[maybe_unused]] const rtc::message_ptr& message) {
 		#if RTC_ENABLE_MEDIA
 			auto transport = mDtlsSrtpTransport.lock();
 			if (!transport)