|
@@ -150,6 +150,14 @@ string Description::roleString() const { return roleToString(mRole); }
|
|
|
|
|
|
string Description::dataMid() const { return mData.mid; }
|
|
|
|
|
|
+string Description::bundleMid() const {
|
|
|
+ // Get the mid of the first media
|
|
|
+ if (auto it = mMedia.find(0); it != mMedia.end())
|
|
|
+ return it->second.mid;
|
|
|
+ else
|
|
|
+ return mData.mid;
|
|
|
+}
|
|
|
+
|
|
|
std::optional<string> Description::fingerprint() const { return mFingerprint; }
|
|
|
|
|
|
std::optional<uint16_t> Description::sctpPort() const { return mData.sctpPort; }
|
|
@@ -199,9 +207,6 @@ void Description::addMedia(const Description &source) {
|
|
|
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 an SDP string");
|
|
|
-
|
|
|
std::ostringstream sdp;
|
|
|
|
|
|
// Header
|
|
@@ -221,8 +226,6 @@ string Description::generateSdp(const string &eol) const {
|
|
|
sdp << ' ' << mData.mid;
|
|
|
sdp << eol;
|
|
|
|
|
|
- sdp << "a=msid-semantic: WMS" << eol;
|
|
|
-
|
|
|
// Non-data media
|
|
|
if (!mMedia.empty()) {
|
|
|
// Lip-sync
|
|
@@ -232,7 +235,19 @@ string Description::generateSdp(const string &eol) const {
|
|
|
sdp << eol;
|
|
|
}
|
|
|
|
|
|
- // Descriptions and attributes
|
|
|
+ // Session-level attributes
|
|
|
+ sdp << "a=msid-semantic:WMS *" << eol;
|
|
|
+ sdp << "a=setup:" << roleToString(mRole) << eol;
|
|
|
+ sdp << "a=ice-ufrag:" << mIceUfrag << eol;
|
|
|
+ sdp << "a=ice-pwd:" << mIcePwd << eol;
|
|
|
+
|
|
|
+ if (!mEnded)
|
|
|
+ sdp << "a=ice-options:trickle" << eol;
|
|
|
+
|
|
|
+ if (mFingerprint)
|
|
|
+ sdp << "a=fingerprint:sha-256 " << *mFingerprint << eol;
|
|
|
+
|
|
|
+ // Media descriptions and attributes
|
|
|
for (int i = 0; i < int(mMedia.size() + 1); ++i) {
|
|
|
if (auto it = mMedia.find(i); it != mMedia.end()) {
|
|
|
// Non-data media
|
|
@@ -252,6 +267,7 @@ string Description::generateSdp(const string &eol) const {
|
|
|
if (!mMedia.empty())
|
|
|
sdp << "a=bundle-only" << eol;
|
|
|
sdp << "a=mid:" << mData.mid << eol;
|
|
|
+ sdp << "a=sendrecv" << eol;
|
|
|
if (mData.sctpPort)
|
|
|
sdp << "a=sctp-port:" << *mData.sctpPort << eol;
|
|
|
if (mData.maxMessageSize)
|
|
@@ -259,14 +275,41 @@ string Description::generateSdp(const string &eol) const {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // Common
|
|
|
- if (!mEnded)
|
|
|
- sdp << "a=ice-options:trickle" << eol;
|
|
|
+ // Candidates
|
|
|
+ for (const auto &candidate : mCandidates)
|
|
|
+ sdp << string(candidate) << eol;
|
|
|
|
|
|
+ if (mEnded)
|
|
|
+ sdp << "a=end-of-candidates" << eol;
|
|
|
+
|
|
|
+ return sdp.str();
|
|
|
+}
|
|
|
+
|
|
|
+string Description::generateDataSdp(const string &eol) const {
|
|
|
+ std::ostringstream sdp;
|
|
|
+
|
|
|
+ // Header
|
|
|
+ sdp << "v=0" << eol;
|
|
|
+ sdp << "o=- " << mSessionId << " 0 IN IP4 127.0.0.1" << eol;
|
|
|
+ sdp << "s=-" << eol;
|
|
|
+ sdp << "t=0 0" << eol;
|
|
|
+
|
|
|
+ // Data
|
|
|
+ sdp << "m=application 9 UDP/DTLS/SCTP webrtc-datachannel";
|
|
|
+ sdp << "c=IN IP4 0.0.0.0" << eol;
|
|
|
+ sdp << "a=mid:" << mData.mid << eol;
|
|
|
+ sdp << "a=sendrecv" << eol;
|
|
|
+ if (mData.sctpPort)
|
|
|
+ sdp << "a=sctp-port:" << *mData.sctpPort << eol;
|
|
|
+ if (mData.maxMessageSize)
|
|
|
+ sdp << "a=max-message-size:" << *mData.maxMessageSize << eol;
|
|
|
+
|
|
|
+ sdp << "a=setup:" << roleToString(mRole) << eol;
|
|
|
sdp << "a=ice-ufrag:" << mIceUfrag << eol;
|
|
|
sdp << "a=ice-pwd:" << mIcePwd << eol;
|
|
|
- sdp << "a=setup:" << roleToString(mRole) << eol;
|
|
|
- sdp << "a=tls-id:1" << eol;
|
|
|
+
|
|
|
+ if (!mEnded)
|
|
|
+ sdp << "a=ice-options:trickle" << eol;
|
|
|
|
|
|
if (mFingerprint)
|
|
|
sdp << "a=fingerprint:sha-256 " << *mFingerprint << eol;
|
|
@@ -274,6 +317,7 @@ string Description::generateSdp(const string &eol) const {
|
|
|
// Candidates
|
|
|
for (const auto &candidate : mCandidates)
|
|
|
sdp << string(candidate) << eol;
|
|
|
+
|
|
|
if (mEnded)
|
|
|
sdp << "a=end-of-candidates" << eol;
|
|
|
|