Browse Source

Generated SDP description now uses CRLF instead of LF

Paul-Louis Ageneau 5 years ago
parent
commit
a92438e94d
4 changed files with 27 additions and 22 deletions
  1. 1 1
      deps/libjuice
  2. 2 0
      include/rtc/description.hpp
  3. 22 20
      src/description.cpp
  4. 2 1
      src/icetransport.cpp

+ 1 - 1
deps/libjuice

@@ -1 +1 @@
-Subproject commit d230147d1563e7420de57443ee25c5c70d2caea6
+Subproject commit 10e14dd4b341569095bb6bbd0dd93fc0b26114bf

+ 2 - 0
include/rtc/description.hpp

@@ -57,6 +57,8 @@ public:
 
 	operator string() const;
 
+	string generateSdp(const string &eol) const;
+
 private:
 	Type mType;
 	Role mRole;

+ 22 - 20
src/description.cpp

@@ -130,37 +130,39 @@ std::vector<Candidate> Description::extractCandidates() {
 	return result;
 }
 
-Description::operator string() const {
+Description::operator string() const { return generateSdp("\r\n"); }
+
+string Description::generateSdp(const string &eol) const {
 	if (!mFingerprint)
-		throw std::logic_error("Fingerprint must be set to generate a SDP");
+		throw std::logic_error("Fingerprint must be set to generate an SDP string");
 
 	std::ostringstream sdp;
-	sdp << "v=0\n";
-	sdp << "o=- " << mSessionId << " 0 IN IP4 127.0.0.1\n";
-	sdp << "s=-\n";
-	sdp << "t=0 0\n";
-	sdp << "a=group:BUNDLE 0\n";
-	sdp << "m=application 9 UDP/DTLS/SCTP webrtc-datachannel\n";
-	sdp << "c=IN IP4 0.0.0.0\n";
-	sdp << "a=ice-ufrag:" << mIceUfrag << "\n";
-	sdp << "a=ice-pwd:" << mIcePwd << "\n";
+	sdp << "v=0" << eol;
+	sdp << "o=- " << mSessionId << " 0 IN IP4 127.0.0.1" << eol;
+	sdp << "s=-" << eol;
+	sdp << "t=0 0" << eol;
+	sdp << "a=group:BUNDLE 0" << eol;
+	sdp << "m=application 9 UDP/DTLS/SCTP webrtc-datachannel" << eol;
+	sdp << "c=IN IP4 0.0.0.0" << eol;
+	sdp << "a=ice-ufrag:" << mIceUfrag << eol;
+	sdp << "a=ice-pwd:" << mIcePwd << eol;
 	if (mTrickle)
-		sdp << "a=ice-options:trickle\n";
-	sdp << "a=mid:" << mMid << "\n";
-	sdp << "a=setup:" << roleToString(mRole) << "\n";
-	sdp << "a=dtls-id:1\n";
+		sdp << "a=ice-options:trickle" << eol;
+	sdp << "a=mid:" << mMid << eol;
+	sdp << "a=setup:" << roleToString(mRole) << eol;
+	sdp << "a=dtls-id:1" << eol;
 	if (mFingerprint)
-		sdp << "a=fingerprint:sha-256 " << *mFingerprint << "\n";
+		sdp << "a=fingerprint:sha-256 " << *mFingerprint << eol;
 	if (mSctpPort)
-		sdp << "a=sctp-port:" << *mSctpPort << "\n";
+		sdp << "a=sctp-port:" << *mSctpPort << eol;
 	if (mMaxMessageSize)
-		sdp << "a=max-message-size:" << *mMaxMessageSize << "\n";
+		sdp << "a=max-message-size:" << *mMaxMessageSize << eol;
 	for (const auto &candidate : mCandidates) {
-		sdp << string(candidate) << "\n";
+		sdp << string(candidate) << eol;
 	}
 
 	if (!mTrickle)
-		sdp << "a=end-of-candidates\n";
+		sdp << "a=end-of-candidates" << eol;
 
 	return sdp.str();
 }

+ 2 - 1
src/icetransport.cpp

@@ -446,7 +446,8 @@ void IceTransport::setRemoteDescription(const Description &description) {
 	mMid = description.mid();
 	mTrickleTimeout = description.trickleEnabled() ? 30s : 0s;
 
-	if (nice_agent_parse_remote_sdp(mNiceAgent.get(), string(description).c_str()) < 0)
+	// Warning: libnice expects "\n" as end of line
+	if (nice_agent_parse_remote_sdp(mNiceAgent.get(), description.generateSdp("\n").c_str()) < 0)
 		throw std::runtime_error("Failed to parse remote SDP");
 }