Skip to content

Commit a801a38

Browse files
Merge branch 'v0.16'
2 parents 64e03d0 + 977c660 commit a801a38

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

src/impl/peerconnection.cpp

+19-18
Original file line numberDiff line numberDiff line change
@@ -863,24 +863,6 @@ void PeerConnection::processLocalDescription(Description description) {
863863

864864
if (description.type() == Description::Type::Offer) {
865865
// This is an offer, add locally created data channels and tracks
866-
// Add application for data channels
867-
if (!description.hasApplication()) {
868-
std::shared_lock lock(mDataChannelsMutex);
869-
if (!mDataChannels.empty()) {
870-
unsigned int m = 0;
871-
while (description.hasMid(std::to_string(m)))
872-
++m;
873-
Description::Application app(std::to_string(m));
874-
app.setSctpPort(localSctpPort);
875-
app.setMaxMessageSize(localMaxMessageSize);
876-
877-
PLOG_DEBUG << "Adding application to local description, mid=\"" << app.mid()
878-
<< "\"";
879-
880-
description.addMedia(std::move(app));
881-
}
882-
}
883-
884866
// Add media for local tracks
885867
std::shared_lock lock(mTracksMutex);
886868
for (auto it = mTrackLines.begin(); it != mTrackLines.end(); ++it) {
@@ -901,6 +883,25 @@ void PeerConnection::processLocalDescription(Description description) {
901883
}
902884
}
903885

886+
// Add application for data channels
887+
if (!description.hasApplication()) {
888+
std::shared_lock lock(mDataChannelsMutex);
889+
if (!mDataChannels.empty()) {
890+
// Prevents mid collision with remote or local tracks
891+
unsigned int m = 0;
892+
while (description.hasMid(std::to_string(m)))
893+
++m;
894+
Description::Application app(std::to_string(m));
895+
app.setSctpPort(localSctpPort);
896+
app.setMaxMessageSize(localMaxMessageSize);
897+
898+
PLOG_DEBUG << "Adding application to local description, mid=\"" << app.mid()
899+
<< "\"";
900+
901+
description.addMedia(std::move(app));
902+
}
903+
}
904+
904905
// There might be no media at this point if the user created a Track, deleted it,
905906
// then called setLocalDescription().
906907
if (description.mediaCount() == 0)

0 commit comments

Comments
 (0)