Backed out 4 changesets (bug 1622384) for causing build bustages on JsepSession.h

CLOSED TREE

Backed out changeset d339ce87c2ef (bug 1622384)
Backed out changeset 13101fc544bc (bug 1622384)
Backed out changeset aad4412b43e2 (bug 1622384)
Backed out changeset eba5d05e59b2 (bug 1622384)
This commit is contained in:
Arthur Iakab 2020-05-01 00:03:03 +03:00
Родитель b7c5fd62b7
Коммит 0dd3332a55
9 изменённых файлов: 219 добавлений и 274 удалений

Просмотреть файл

@ -101,12 +101,12 @@ class JsepSessionTest : public JsepSessionTestBase,
}
void CheckTransceiverInvariants(
const std::map<size_t, RefPtr<JsepTransceiver>>& oldTransceivers,
const std::map<size_t, RefPtr<JsepTransceiver>>& newTransceivers) {
const std::vector<RefPtr<JsepTransceiver>>& oldTransceivers,
const std::vector<RefPtr<JsepTransceiver>>& newTransceivers) {
ASSERT_LE(oldTransceivers.size(), newTransceivers.size());
std::set<size_t> levels;
for (const auto& [id, newTransceiver] : newTransceivers) {
for (const RefPtr<JsepTransceiver>& newTransceiver : newTransceivers) {
if (newTransceiver->HasLevel()) {
ASSERT_FALSE(levels.count(newTransceiver->GetLevel()))
<< "Two new transceivers are mapped to level "
@ -124,7 +124,7 @@ class JsepSessionTest : public JsepSessionTestBase,
"transceivers.";
}
for (const auto& [id, oldTransceiver] : oldTransceivers) {
for (const RefPtr<JsepTransceiver>& oldTransceiver : oldTransceivers) {
if (oldTransceiver->HasLevel()) {
ASSERT_TRUE(levels.count(oldTransceiver->GetLevel()))
<< "Level " << oldTransceiver->GetLevel()
@ -136,17 +136,18 @@ class JsepSessionTest : public JsepSessionTestBase,
}
}
std::map<size_t, RefPtr<JsepTransceiver>> DeepCopy(
const std::map<size_t, RefPtr<JsepTransceiver>>& transceivers) {
std::map<size_t, RefPtr<JsepTransceiver>> copy;
for (const auto& [id, transceiver] : transceivers) {
copy[id] = new JsepTransceiver(*transceiver);
std::vector<RefPtr<JsepTransceiver>> DeepCopy(
const std::vector<RefPtr<JsepTransceiver>>& transceivers) {
std::vector<RefPtr<JsepTransceiver>> copy;
copy.reserve(transceivers.size());
for (const RefPtr<JsepTransceiver>& transceiver : transceivers) {
copy.push_back(new JsepTransceiver(*transceiver));
}
return copy;
}
std::string CreateOffer(const Maybe<JsepOfferOptions>& options = Nothing()) {
std::map<size_t, RefPtr<JsepTransceiver>> transceiversBefore =
std::vector<RefPtr<JsepTransceiver>> transceiversBefore =
DeepCopy(mSessionOff->GetTransceivers());
JsepOfferOptions defaultOptions;
const JsepOfferOptions& optionsRef = options ? *options : defaultOptions;
@ -301,36 +302,35 @@ class JsepSessionTest : public JsepSessionTestBase,
for (auto type : mediatypes) {
ASSERT_TRUE(uuid_gen.Generate(&track_id));
RefPtr<JsepTransceiver> suitableTransceiver;
size_t i;
std::vector<RefPtr<JsepTransceiver>>& transceivers(
side.GetTransceivers());
size_t i = transceivers.size();
if (magic == ADDTRACK_MAGIC) {
for (auto& [id, transceiver] : side.GetTransceivers()) {
if (transceiver->mSendTrack.GetMediaType() != type) {
for (i = 0; i < transceivers.size(); ++i) {
if (transceivers[i]->mSendTrack.GetMediaType() != type) {
continue;
}
if (IsNull(transceiver->mSendTrack) ||
transceiver->GetMediaType() == SdpMediaSection::kApplication) {
suitableTransceiver = transceiver;
i = id;
if (IsNull(transceivers[i]->mSendTrack) ||
transceivers[i]->GetMediaType() ==
SdpMediaSection::kApplication) {
break;
}
}
}
if (!suitableTransceiver) {
suitableTransceiver = new JsepTransceiver(type);
side.AddTransceiver(suitableTransceiver);
i = side.GetTransceivers().rbegin()->first;
if (i == transceivers.size()) {
side.AddTransceiver(new JsepTransceiver(type));
MOZ_ASSERT(i < transceivers.size());
}
std::cerr << "Updating send track for transceiver " << i << std::endl;
if (magic == ADDTRACK_MAGIC) {
suitableTransceiver->SetAddTrackMagic();
transceivers[i]->SetAddTrackMagic();
}
suitableTransceiver->mJsDirection |=
transceivers[i]->mJsDirection |=
SdpDirectionAttribute::Direction::kSendonly;
suitableTransceiver->mSendTrack.UpdateStreamIds(
transceivers[i]->mSendTrack.UpdateStreamIds(
std::vector<std::string>(1, stream_id));
}
}
@ -351,7 +351,7 @@ class JsepSessionTest : public JsepSessionTestBase,
std::vector<JsepTrack> GetLocalTracks(const JsepSession& session) const {
std::vector<JsepTrack> result;
for (const auto& [id, transceiver] : session.GetTransceivers()) {
for (const auto& transceiver : session.GetTransceivers()) {
if (!IsNull(transceiver->mSendTrack)) {
result.push_back(transceiver->mSendTrack);
}
@ -361,7 +361,7 @@ class JsepSessionTest : public JsepSessionTestBase,
std::vector<JsepTrack> GetRemoteTracks(const JsepSession& session) const {
std::vector<JsepTrack> result;
for (const auto& [id, transceiver] : session.GetTransceivers()) {
for (const auto& transceiver : session.GetTransceivers()) {
if (!IsNull(transceiver->mRecvTrack)) {
result.push_back(transceiver->mRecvTrack);
}
@ -370,7 +370,7 @@ class JsepSessionTest : public JsepSessionTestBase,
}
JsepTransceiver* GetDatachannelTransceiver(JsepSession& side) {
for (const auto& [id, transceiver] : side.GetTransceivers()) {
for (const auto& transceiver : side.GetTransceivers()) {
if (transceiver->mSendTrack.GetMediaType() ==
SdpMediaSection::MediaType::kApplication) {
return transceiver.get();
@ -381,7 +381,7 @@ class JsepSessionTest : public JsepSessionTestBase,
}
JsepTransceiver* GetNegotiatedTransceiver(JsepSession& side, size_t index) {
for (const auto& [id, transceiver] : side.GetTransceivers()) {
for (RefPtr<JsepTransceiver>& transceiver : side.GetTransceivers()) {
if (transceiver->mSendTrack.GetNegotiatedDetails() ||
transceiver->mRecvTrack.GetNegotiatedDetails()) {
if (index) {
@ -397,9 +397,8 @@ class JsepSessionTest : public JsepSessionTestBase,
}
JsepTransceiver* GetTransceiverByLevel(
const std::map<size_t, RefPtr<JsepTransceiver>>& transceivers,
size_t level) {
for (const auto& [id, transceiver] : transceivers) {
const std::vector<RefPtr<JsepTransceiver>>& transceivers, size_t level) {
for (auto& transceiver : transceivers) {
if (transceiver->HasLevel() && transceiver->GetLevel() == level) {
return transceiver.get();
}
@ -455,7 +454,7 @@ class JsepSessionTest : public JsepSessionTestBase,
JsepTrack GetTrack(JsepSessionImpl& side, SdpMediaSection::MediaType type,
size_t index) const {
for (const auto& [id, transceiver] : side.GetTransceivers()) {
for (const auto& transceiver : side.GetTransceivers()) {
if (IsNull(transceiver->mSendTrack) ||
transceiver->mSendTrack.GetMediaType() != type) {
continue;
@ -648,19 +647,16 @@ class JsepSessionTest : public JsepSessionTestBase,
return true;
}
bool Equals(const std::map<size_t, RefPtr<JsepTransceiver>>& t1,
const std::map<size_t, RefPtr<JsepTransceiver>>& t2) const {
bool Equals(const std::vector<RefPtr<JsepTransceiver>>& t1,
const std::vector<RefPtr<JsepTransceiver>>& t2) const {
if (t1.size() != t2.size()) {
std::cerr << "Size differs: t1.size = " << t1.size()
<< ", t2.size = " << t2.size() << std::endl;
return false;
}
for (const auto& [id, transceiver] : t1) {
if (!t2.count(id)) {
return false;
}
if (!Equals(*transceiver, *t2.at(id))) {
for (size_t i = 0; i < t1.size(); ++i) {
if (!Equals(*t1[i], *t2[i])) {
return false;
}
}
@ -736,7 +732,7 @@ class JsepSessionTest : public JsepSessionTestBase,
}
std::string CreateAnswer() {
std::map<size_t, RefPtr<JsepTransceiver>> transceiversBefore =
std::vector<RefPtr<JsepTransceiver>> transceiversBefore =
DeepCopy(mSessionAns->GetTransceivers());
JsepAnswerOptions options;
@ -772,7 +768,7 @@ class JsepSessionTest : public JsepSessionTestBase,
void SetLocalOffer(const std::string& offer,
uint32_t checkFlags = ALL_CHECKS) {
std::map<size_t, RefPtr<JsepTransceiver>> transceiversBefore =
std::vector<RefPtr<JsepTransceiver>> transceiversBefore =
DeepCopy(mSessionOff->GetTransceivers());
JsepSession::Result result =
@ -788,7 +784,7 @@ class JsepSessionTest : public JsepSessionTestBase,
if (checkFlags & CHECK_TRACKS) {
// This assumes no recvonly or inactive transceivers.
ASSERT_EQ(types.size(), mSessionOff->GetTransceivers().size());
for (const auto& [id, transceiver] : mSessionOff->GetTransceivers()) {
for (const auto& transceiver : mSessionOff->GetTransceivers()) {
if (!transceiver->HasLevel()) {
continue;
}
@ -812,7 +808,7 @@ class JsepSessionTest : public JsepSessionTestBase,
void SetRemoteOffer(const std::string& offer,
uint32_t checkFlags = ALL_CHECKS) {
std::map<size_t, RefPtr<JsepTransceiver>> transceiversBefore =
std::vector<RefPtr<JsepTransceiver>> transceiversBefore =
DeepCopy(mSessionAns->GetTransceivers());
JsepSession::Result result =
@ -828,7 +824,7 @@ class JsepSessionTest : public JsepSessionTestBase,
if (checkFlags & CHECK_TRACKS) {
// This assumes no recvonly or inactive transceivers.
ASSERT_EQ(types.size(), mSessionAns->GetTransceivers().size());
for (const auto& [id, transceiver] : mSessionAns->GetTransceivers()) {
for (const auto& transceiver : mSessionAns->GetTransceivers()) {
if (!transceiver->HasLevel()) {
continue;
}
@ -849,7 +845,7 @@ class JsepSessionTest : public JsepSessionTestBase,
void SetLocalAnswer(const std::string& answer,
uint32_t checkFlags = ALL_CHECKS) {
std::map<size_t, RefPtr<JsepTransceiver>> transceiversBefore =
std::vector<RefPtr<JsepTransceiver>> transceiversBefore =
DeepCopy(mSessionAns->GetTransceivers());
JsepSession::Result result =
@ -864,7 +860,7 @@ class JsepSessionTest : public JsepSessionTestBase,
if (checkFlags & CHECK_TRACKS) {
// Verify that the right stuff is in the tracks.
ASSERT_EQ(types.size(), mSessionAns->GetTransceivers().size());
for (const auto& [id, transceiver] : mSessionAns->GetTransceivers()) {
for (const auto& transceiver : mSessionAns->GetTransceivers()) {
if (!transceiver->HasLevel()) {
continue;
}
@ -896,7 +892,7 @@ class JsepSessionTest : public JsepSessionTestBase,
void SetRemoteAnswer(const std::string& answer,
uint32_t checkFlags = ALL_CHECKS) {
std::map<size_t, RefPtr<JsepTransceiver>> transceiversBefore =
std::vector<RefPtr<JsepTransceiver>> transceiversBefore =
DeepCopy(mSessionOff->GetTransceivers());
JsepSession::Result result =
@ -911,7 +907,7 @@ class JsepSessionTest : public JsepSessionTestBase,
if (checkFlags & CHECK_TRACKS) {
// Verify that the right stuff is in the tracks.
ASSERT_EQ(types.size(), mSessionOff->GetTransceivers().size());
for (const auto& [id, transceiver] : mSessionOff->GetTransceivers()) {
for (const auto& transceiver : mSessionOff->GetTransceivers()) {
if (!transceiver->HasLevel()) {
continue;
}
@ -939,7 +935,7 @@ class JsepSessionTest : public JsepSessionTestBase,
}
std::string GetTransportId(const JsepSession& session, size_t level) {
for (const auto& [id, transceiver] : session.GetTransceivers()) {
for (const auto& transceiver : session.GetTransceivers()) {
if (transceiver->HasLevel() && transceiver->GetLevel() == level) {
return transceiver->mTransport.mTransportId;
}
@ -954,7 +950,7 @@ class JsepSessionTest : public JsepSessionTestBase,
CandidateSet() {}
void Gather(JsepSession& session, ComponentType maxComponent = RTCP) {
for (const auto& [id, transceiver] : session.GetTransceivers()) {
for (const auto& transceiver : session.GetTransceivers()) {
if (transceiver->HasOwnTransport()) {
Gather(session, transceiver->mTransport.mTransportId, RTP);
if (transceiver->mTransport.mComponents > 1) {
@ -1186,7 +1182,7 @@ class JsepSessionTest : public JsepSessionTestBase,
void CheckTransceiversAreBundled(const JsepSession& session,
const std::string& context) {
for (const auto& [id, transceiver] : session.GetTransceivers()) {
for (const auto& transceiver : session.GetTransceivers()) {
ASSERT_TRUE(transceiver->HasBundleLevel())
<< context;
ASSERT_EQ(0U, transceiver->BundleLevel()) << context;
@ -1334,7 +1330,7 @@ class JsepSessionTest : public JsepSessionTestBase,
}
void DumpTransceivers(const JsepSessionImpl& session) {
for (const auto& [id, transceiver] : session.GetTransceivers()) {
for (const auto& transceiver : session.GetTransceivers()) {
std::cerr << "Transceiver ";
if (transceiver->HasLevel()) {
std::cerr << transceiver->GetLevel() << std::endl;
@ -1571,9 +1567,9 @@ TEST_P(JsepSessionTest, RenegotiationNoChange) {
ValidateSetupAttribute(*mSessionOff, SdpSetupAttribute::kActpass);
ValidateSetupAttribute(*mSessionAns, SdpSetupAttribute::kActive);
std::map<size_t, RefPtr<JsepTransceiver>> origOffererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origOffererTransceivers =
DeepCopy(mSessionOff->GetTransceivers());
std::map<size_t, RefPtr<JsepTransceiver>> origAnswererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origAnswererTransceivers =
DeepCopy(mSessionAns->GetTransceivers());
std::string reoffer = CreateOffer();
@ -1632,14 +1628,6 @@ TEST_P(JsepSessionTest, DISABLED_RenegotiationSwappedRolesNoChange) {
ASSERT_TRUE(Equals(answererTransceivers, newOffererTransceivers));
}
static void RemoveLastN(
std::map<size_t, RefPtr<JsepTransceiver>>& aTransceivers, size_t aNum) {
while (aNum--) {
// erase doesn't take reverse_iterator :(
aTransceivers.erase(--aTransceivers.end());
}
}
TEST_P(JsepSessionTest, RenegotiationOffererAddsTrack) {
AddTracks(*mSessionOff);
AddTracks(*mSessionAns);
@ -1649,9 +1637,9 @@ TEST_P(JsepSessionTest, RenegotiationOffererAddsTrack) {
ValidateSetupAttribute(*mSessionOff, SdpSetupAttribute::kActpass);
ValidateSetupAttribute(*mSessionAns, SdpSetupAttribute::kActive);
std::map<size_t, RefPtr<JsepTransceiver>> origOffererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origOffererTransceivers =
DeepCopy(mSessionOff->GetTransceivers());
std::map<size_t, RefPtr<JsepTransceiver>> origAnswererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origAnswererTransceivers =
DeepCopy(mSessionAns->GetTransceivers());
std::vector<SdpMediaSection::MediaType> extraTypes;
@ -1669,11 +1657,11 @@ TEST_P(JsepSessionTest, RenegotiationOffererAddsTrack) {
auto newAnswererTransceivers = mSessionAns->GetTransceivers();
ASSERT_LE(2U, newOffererTransceivers.size());
RemoveLastN(newOffererTransceivers, 2);
newOffererTransceivers.resize(newOffererTransceivers.size() - 2);
ASSERT_TRUE(Equals(origOffererTransceivers, newOffererTransceivers));
ASSERT_LE(2U, newAnswererTransceivers.size());
RemoveLastN(newAnswererTransceivers, 2);
newAnswererTransceivers.resize(newAnswererTransceivers.size() - 2);
ASSERT_TRUE(Equals(origAnswererTransceivers, newAnswererTransceivers));
}
@ -1686,9 +1674,9 @@ TEST_P(JsepSessionTest, RenegotiationAnswererAddsTrack) {
ValidateSetupAttribute(*mSessionOff, SdpSetupAttribute::kActpass);
ValidateSetupAttribute(*mSessionAns, SdpSetupAttribute::kActive);
std::map<size_t, RefPtr<JsepTransceiver>> origOffererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origOffererTransceivers =
DeepCopy(mSessionOff->GetTransceivers());
std::map<size_t, RefPtr<JsepTransceiver>> origAnswererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origAnswererTransceivers =
DeepCopy(mSessionAns->GetTransceivers());
std::vector<SdpMediaSection::MediaType> extraTypes;
@ -1718,11 +1706,11 @@ TEST_P(JsepSessionTest, RenegotiationAnswererAddsTrack) {
auto newAnswererTransceivers = mSessionAns->GetTransceivers();
ASSERT_LE(2U, newOffererTransceivers.size());
RemoveLastN(newOffererTransceivers, 2);
newOffererTransceivers.resize(newOffererTransceivers.size() - 2);
ASSERT_TRUE(Equals(origOffererTransceivers, newOffererTransceivers));
ASSERT_LE(2U, newAnswererTransceivers.size());
RemoveLastN(newAnswererTransceivers, 2);
newAnswererTransceivers.resize(newAnswererTransceivers.size() - 2);
ASSERT_TRUE(Equals(origAnswererTransceivers, newAnswererTransceivers));
}
@ -1735,9 +1723,9 @@ TEST_P(JsepSessionTest, RenegotiationBothAddTrack) {
ValidateSetupAttribute(*mSessionOff, SdpSetupAttribute::kActpass);
ValidateSetupAttribute(*mSessionAns, SdpSetupAttribute::kActive);
std::map<size_t, RefPtr<JsepTransceiver>> origOffererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origOffererTransceivers =
DeepCopy(mSessionOff->GetTransceivers());
std::map<size_t, RefPtr<JsepTransceiver>> origAnswererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origAnswererTransceivers =
DeepCopy(mSessionAns->GetTransceivers());
std::vector<SdpMediaSection::MediaType> extraTypes;
@ -1756,11 +1744,11 @@ TEST_P(JsepSessionTest, RenegotiationBothAddTrack) {
auto newAnswererTransceivers = mSessionAns->GetTransceivers();
ASSERT_LE(2U, newOffererTransceivers.size());
RemoveLastN(newOffererTransceivers, 2);
newOffererTransceivers.resize(newOffererTransceivers.size() - 2);
ASSERT_TRUE(Equals(origOffererTransceivers, newOffererTransceivers));
ASSERT_LE(2U, newAnswererTransceivers.size());
RemoveLastN(newAnswererTransceivers, 2);
newAnswererTransceivers.resize(newAnswererTransceivers.size() - 2);
ASSERT_TRUE(Equals(origAnswererTransceivers, newAnswererTransceivers));
}
@ -1898,15 +1886,14 @@ TEST_P(JsepSessionTest, RenegotiationOffererStopsTransceiver) {
OfferAnswer();
std::map<size_t, RefPtr<JsepTransceiver>> origOffererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origOffererTransceivers =
DeepCopy(mSessionOff->GetTransceivers());
std::map<size_t, RefPtr<JsepTransceiver>> origAnswererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origAnswererTransceivers =
DeepCopy(mSessionAns->GetTransceivers());
auto lastTransceiver = mSessionOff->GetTransceivers().rbegin()->second;
// Avoid bundle transport side effects; don't stop the BUNDLE-tag!
lastTransceiver->Stop();
JsepTrack removedTrack(lastTransceiver->mSendTrack);
mSessionOff->GetTransceivers().back()->Stop();
JsepTrack removedTrack(mSessionOff->GetTransceivers().back()->mSendTrack);
OfferAnswer(CHECK_SUCCESS);
@ -1928,15 +1915,17 @@ TEST_P(JsepSessionTest, RenegotiationOffererStopsTransceiver) {
ASSERT_EQ(origOffererTransceivers.size(), newOffererTransceivers.size());
ASSERT_FALSE(origOffererTransceivers.rbegin()->second->IsStopped());
ASSERT_TRUE(newOffererTransceivers.rbegin()->second->IsStopped());
ASSERT_FALSE(origOffererTransceivers.back()->IsStopped());
ASSERT_TRUE(newOffererTransceivers.back()->IsStopped());
ASSERT_FALSE(origAnswererTransceivers.rbegin()->second->IsStopped());
ASSERT_TRUE(newAnswererTransceivers.rbegin()->second->IsStopped());
RemoveLastN(origOffererTransceivers, 1); // Ignore this one
RemoveLastN(newOffererTransceivers, 1); // Ignore this one
RemoveLastN(origAnswererTransceivers, 1); // Ignore this one
RemoveLastN(newAnswererTransceivers, 1); // Ignore this one
ASSERT_FALSE(origOffererTransceivers.back()->IsStopped());
ASSERT_TRUE(newOffererTransceivers.back()->IsStopped());
ASSERT_FALSE(origAnswererTransceivers.back()->IsStopped());
ASSERT_TRUE(newAnswererTransceivers.back()->IsStopped());
origOffererTransceivers.pop_back(); // Ignore this one
newOffererTransceivers.pop_back(); // Ignore this one
origAnswererTransceivers.pop_back(); // Ignore this one
newAnswererTransceivers.pop_back(); // Ignore this one
ASSERT_TRUE(Equals(origOffererTransceivers, newOffererTransceivers));
ASSERT_TRUE(Equals(origAnswererTransceivers, newAnswererTransceivers));
@ -1951,15 +1940,14 @@ TEST_P(JsepSessionTest, RenegotiationAnswererStopsTransceiver) {
OfferAnswer();
std::map<size_t, RefPtr<JsepTransceiver>> origOffererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origOffererTransceivers =
DeepCopy(mSessionOff->GetTransceivers());
std::map<size_t, RefPtr<JsepTransceiver>> origAnswererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origAnswererTransceivers =
DeepCopy(mSessionAns->GetTransceivers());
// Avoid bundle transport side effects; don't stop the BUNDLE-tag!
mSessionAns->GetTransceivers().rbegin()->second->Stop();
JsepTrack removedTrack(
mSessionAns->GetTransceivers().rbegin()->second->mSendTrack);
mSessionAns->GetTransceivers().back()->Stop();
JsepTrack removedTrack(mSessionAns->GetTransceivers().back()->mSendTrack);
OfferAnswer(CHECK_SUCCESS);
@ -1982,14 +1970,14 @@ TEST_P(JsepSessionTest, RenegotiationAnswererStopsTransceiver) {
ASSERT_EQ(origOffererTransceivers.size(), newOffererTransceivers.size());
ASSERT_FALSE(origOffererTransceivers.rbegin()->second->IsStopped());
ASSERT_TRUE(newOffererTransceivers.rbegin()->second->IsStopped());
ASSERT_FALSE(origAnswererTransceivers.rbegin()->second->IsStopped());
ASSERT_TRUE(newAnswererTransceivers.rbegin()->second->IsStopped());
RemoveLastN(origOffererTransceivers, 1); // Ignore this one
RemoveLastN(newOffererTransceivers, 1); // Ignore this one
RemoveLastN(origAnswererTransceivers, 1); // Ignore this one
RemoveLastN(newAnswererTransceivers, 1); // Ignore this one
ASSERT_FALSE(origOffererTransceivers.back()->IsStopped());
ASSERT_TRUE(newOffererTransceivers.back()->IsStopped());
ASSERT_FALSE(origAnswererTransceivers.back()->IsStopped());
ASSERT_TRUE(newAnswererTransceivers.back()->IsStopped());
origOffererTransceivers.pop_back(); // Ignore this one
newOffererTransceivers.pop_back(); // Ignore this one
origAnswererTransceivers.pop_back(); // Ignore this one
newAnswererTransceivers.pop_back(); // Ignore this one
ASSERT_TRUE(Equals(origOffererTransceivers, newOffererTransceivers));
ASSERT_TRUE(Equals(origAnswererTransceivers, newAnswererTransceivers));
@ -2004,18 +1992,18 @@ TEST_P(JsepSessionTest, RenegotiationBothStopSameTransceiver) {
OfferAnswer();
std::map<size_t, RefPtr<JsepTransceiver>> origOffererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origOffererTransceivers =
DeepCopy(mSessionOff->GetTransceivers());
std::map<size_t, RefPtr<JsepTransceiver>> origAnswererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origAnswererTransceivers =
DeepCopy(mSessionAns->GetTransceivers());
// Avoid bundle transport side effects; don't stop the BUNDLE-tag!
mSessionOff->GetTransceivers().rbegin()->second->Stop();
mSessionOff->GetTransceivers().back()->Stop();
JsepTrack removedTrackOffer(
mSessionOff->GetTransceivers().rbegin()->second->mSendTrack);
mSessionAns->GetTransceivers().rbegin()->second->Stop();
mSessionOff->GetTransceivers().back()->mSendTrack);
mSessionAns->GetTransceivers().back()->Stop();
JsepTrack removedTrackAnswer(
mSessionAns->GetTransceivers().rbegin()->second->mSendTrack);
mSessionAns->GetTransceivers().back()->mSendTrack);
OfferAnswer(CHECK_SUCCESS);
@ -2037,14 +2025,14 @@ TEST_P(JsepSessionTest, RenegotiationBothStopSameTransceiver) {
ASSERT_EQ(origOffererTransceivers.size(), newOffererTransceivers.size());
ASSERT_FALSE(origOffererTransceivers.rbegin()->second->IsStopped());
ASSERT_TRUE(newOffererTransceivers.rbegin()->second->IsStopped());
ASSERT_FALSE(origAnswererTransceivers.rbegin()->second->IsStopped());
ASSERT_TRUE(newAnswererTransceivers.rbegin()->second->IsStopped());
RemoveLastN(origOffererTransceivers, 1); // Ignore this one
RemoveLastN(newOffererTransceivers, 1); // Ignore this one
RemoveLastN(origAnswererTransceivers, 1); // Ignore this one
RemoveLastN(newAnswererTransceivers, 1); // Ignore this one
ASSERT_FALSE(origOffererTransceivers.back()->IsStopped());
ASSERT_TRUE(newOffererTransceivers.back()->IsStopped());
ASSERT_FALSE(origAnswererTransceivers.back()->IsStopped());
ASSERT_TRUE(newAnswererTransceivers.back()->IsStopped());
origOffererTransceivers.pop_back(); // Ignore this one
newOffererTransceivers.pop_back(); // Ignore this one
origAnswererTransceivers.pop_back(); // Ignore this one
newAnswererTransceivers.pop_back(); // Ignore this one
ASSERT_TRUE(Equals(origOffererTransceivers, newOffererTransceivers));
ASSERT_TRUE(Equals(origAnswererTransceivers, newAnswererTransceivers));
@ -2062,18 +2050,18 @@ TEST_P(JsepSessionTest, RenegotiationBothStopTransceiverThenAddTrack) {
OfferAnswer();
// Avoid bundle transport side effects; don't stop the BUNDLE-tag!
mSessionOff->GetTransceivers().rbegin()->second->Stop();
mSessionOff->GetTransceivers().back()->Stop();
JsepTrack removedTrackOffer(
mSessionOff->GetTransceivers().rbegin()->second->mSendTrack);
mSessionOff->GetTransceivers().rbegin()->second->Stop();
mSessionOff->GetTransceivers().back()->mSendTrack);
mSessionOff->GetTransceivers().back()->Stop();
JsepTrack removedTrackAnswer(
mSessionOff->GetTransceivers().rbegin()->second->mSendTrack);
mSessionOff->GetTransceivers().back()->mSendTrack);
OfferAnswer(CHECK_SUCCESS);
std::map<size_t, RefPtr<JsepTransceiver>> origOffererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origOffererTransceivers =
DeepCopy(mSessionOff->GetTransceivers());
std::map<size_t, RefPtr<JsepTransceiver>> origAnswererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origAnswererTransceivers =
DeepCopy(mSessionAns->GetTransceivers());
std::vector<SdpMediaSection::MediaType> extraTypes;
@ -2092,11 +2080,11 @@ TEST_P(JsepSessionTest, RenegotiationBothStopTransceiverThenAddTrack) {
newAnswererTransceivers.size());
// Ensure that the m-section was re-used; no gaps
ASSERT_EQ(origOffererTransceivers.rbegin()->second->GetLevel(),
newOffererTransceivers.rbegin()->second->GetLevel());
ASSERT_EQ(origOffererTransceivers.back()->GetLevel(),
newOffererTransceivers.back()->GetLevel());
ASSERT_EQ(origAnswererTransceivers.rbegin()->second->GetLevel(),
newAnswererTransceivers.rbegin()->second->GetLevel());
ASSERT_EQ(origAnswererTransceivers.back()->GetLevel(),
newAnswererTransceivers.back()->GetLevel());
}
TEST_P(JsepSessionTest, RenegotiationBothStopTransceiverDifferentMsection) {
@ -2179,9 +2167,9 @@ TEST_P(JsepSessionTest, RenegotiationAutoAssignedMsidIsStable) {
SetRemoteAnswer(answer, CHECK_SUCCESS);
std::map<size_t, RefPtr<JsepTransceiver>> origOffererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origOffererTransceivers =
DeepCopy(mSessionOff->GetTransceivers());
std::map<size_t, RefPtr<JsepTransceiver>> origAnswererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origAnswererTransceivers =
DeepCopy(mSessionAns->GetTransceivers());
ASSERT_EQ(origOffererTransceivers.size(), origAnswererTransceivers.size());
@ -2216,7 +2204,7 @@ TEST_P(JsepSessionTest, RenegotiationOffererDisablesTelephoneEvent) {
// check all the audio tracks to make sure they have 2 codecs (109 and 101),
// and dtmf is enabled on all audio tracks
std::vector<JsepTrack> tracks;
for (const auto& [id, transceiver] : mSessionOff->GetTransceivers()) {
for (const auto& transceiver : mSessionOff->GetTransceivers()) {
tracks.push_back(transceiver->mSendTrack);
tracks.push_back(transceiver->mRecvTrack);
}
@ -2255,7 +2243,7 @@ TEST_P(JsepSessionTest, RenegotiationOffererDisablesTelephoneEvent) {
// check all the audio tracks to make sure they have 1 codec (109),
// and dtmf is disabled on all audio tracks
tracks.clear();
for (const auto& [id, transceiver] : mSessionOff->GetTransceivers()) {
for (const auto& transceiver : mSessionOff->GetTransceivers()) {
tracks.push_back(transceiver->mSendTrack);
tracks.push_back(transceiver->mRecvTrack);
}
@ -2293,9 +2281,9 @@ TEST_P(JsepSessionTest, RenegotiationAnswererEnablesMsid) {
SetRemoteAnswer(answer, CHECK_SUCCESS);
std::map<size_t, RefPtr<JsepTransceiver>> origOffererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origOffererTransceivers =
DeepCopy(mSessionOff->GetTransceivers());
std::map<size_t, RefPtr<JsepTransceiver>> origAnswererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origAnswererTransceivers =
DeepCopy(mSessionAns->GetTransceivers());
offer = CreateOffer();
@ -2339,9 +2327,9 @@ TEST_P(JsepSessionTest, RenegotiationAnswererDisablesMsid) {
SetLocalAnswer(answer);
SetRemoteAnswer(answer, CHECK_SUCCESS);
std::map<size_t, RefPtr<JsepTransceiver>> origOffererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origOffererTransceivers =
DeepCopy(mSessionOff->GetTransceivers());
std::map<size_t, RefPtr<JsepTransceiver>> origAnswererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origAnswererTransceivers =
DeepCopy(mSessionAns->GetTransceivers());
offer = CreateOffer();
@ -2399,9 +2387,9 @@ TEST_P(JsepSessionTest, RenegotiationOffererEnablesBundle) {
SetLocalAnswer(answer);
SetRemoteAnswer(answer);
std::map<size_t, RefPtr<JsepTransceiver>> origOffererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origOffererTransceivers =
DeepCopy(mSessionOff->GetTransceivers());
std::map<size_t, RefPtr<JsepTransceiver>> origAnswererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origAnswererTransceivers =
DeepCopy(mSessionAns->GetTransceivers());
OfferAnswer();
@ -2446,9 +2434,9 @@ TEST_P(JsepSessionTest, RenegotiationOffererDisablesBundleTransport) {
GetTransceiverByLevel(*mSessionOff, 0)->Stop();
std::map<size_t, RefPtr<JsepTransceiver>> origOffererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origOffererTransceivers =
DeepCopy(mSessionOff->GetTransceivers());
std::map<size_t, RefPtr<JsepTransceiver>> origAnswererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origAnswererTransceivers =
DeepCopy(mSessionAns->GetTransceivers());
OfferAnswer(CHECK_SUCCESS);
@ -2497,9 +2485,9 @@ TEST_P(JsepSessionTest, RenegotiationAnswererDisablesBundleTransport) {
OfferAnswer();
std::map<size_t, RefPtr<JsepTransceiver>> origOffererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origOffererTransceivers =
DeepCopy(mSessionOff->GetTransceivers());
std::map<size_t, RefPtr<JsepTransceiver>> origAnswererTransceivers =
std::vector<RefPtr<JsepTransceiver>> origAnswererTransceivers =
DeepCopy(mSessionAns->GetTransceivers());
GetTransceiverByLevel(*mSessionAns, 0)->Stop();
@ -3050,10 +3038,10 @@ TEST_F(JsepSessionTest, OfferAnswerRecvOnlyLines) {
SetLocalAnswer(answer, CHECK_SUCCESS);
SetRemoteAnswer(answer, CHECK_SUCCESS);
std::map<size_t, RefPtr<JsepTransceiver>> transceivers(
std::vector<RefPtr<JsepTransceiver>> transceivers(
mSessionOff->GetTransceivers());
ASSERT_EQ(3U, transceivers.size());
for (const auto& [id, transceiver] : transceivers) {
for (const auto& transceiver : transceivers) {
auto ssrcs = parsedOffer->GetMediaSection(transceiver->GetLevel())
.GetAttributeList()
.GetSsrc()
@ -4811,7 +4799,7 @@ TEST_P(JsepSessionTest, TestRejectOfferRollback) {
ASSERT_FALSE(
mSessionAns->SetRemoteDescription(kJsepSdpRollback, "").mError.isSome());
ASSERT_EQ(kJsepStateStable, mSessionAns->GetState());
for (const auto& [id, transceiver] : mSessionAns->GetTransceivers()) {
for (const auto& transceiver : mSessionAns->GetTransceivers()) {
ASSERT_EQ(0U, transceiver->mRecvTrack.GetStreamIds().size());
}
@ -4864,7 +4852,7 @@ TEST_P(JsepSessionTest, TestInvalidRollback) {
size_t GetActiveTransportCount(const JsepSession& session) {
size_t activeTransportCount = 0;
for (const auto& [id, transceiver] : session.GetTransceivers()) {
for (const auto& transceiver : session.GetTransceivers()) {
if (!transceiver->HasBundleLevel() ||
(transceiver->BundleLevel() == transceiver->GetLevel())) {
activeTransportCount += transceiver->mTransport.mComponents;
@ -6541,12 +6529,12 @@ TEST_F(JsepSessionTest, ComplicatedRemoteRollback) {
// Third audio transceiver should also be gone.
// Fourth audio transceiver, created after SetRemote
ASSERT_FALSE(mSessionAns->GetTransceivers()[5]->HasLevel());
ASSERT_FALSE(mSessionAns->GetTransceivers()[5]->IsStopped());
ASSERT_FALSE(mSessionAns->GetTransceivers()[5]->IsAssociated());
ASSERT_FALSE(mSessionAns->GetTransceivers()[5]->HasAddTrackMagic());
ASSERT_FALSE(mSessionAns->GetTransceivers()[3]->HasLevel());
ASSERT_FALSE(mSessionAns->GetTransceivers()[3]->IsStopped());
ASSERT_FALSE(mSessionAns->GetTransceivers()[3]->IsAssociated());
ASSERT_FALSE(mSessionAns->GetTransceivers()[3]->HasAddTrackMagic());
ASSERT_TRUE(
mSessionAns->GetTransceivers()[5]->mSendTrack.GetStreamIds().empty());
mSessionAns->GetTransceivers()[3]->mSendTrack.GetStreamIds().empty());
}
TEST_F(JsepSessionTest, LocalRollback) {

Просмотреть файл

@ -5,7 +5,6 @@
#ifndef _JSEPSESSION_H_
#define _JSEPSESSION_H_
#include <map>
#include <string>
#include <vector>
#include "mozilla/Attributes.h"
@ -107,7 +106,7 @@ class JsepSession {
template <class UnaryFunction>
void ForEachCodec(UnaryFunction& function) {
std::for_each(Codecs().begin(), Codecs().end(), function);
for (auto& [id, transceiver] : GetTransceivers()) {
for (auto& transceiver : GetTransceivers()) {
transceiver->mSendTrack.ForEachCodec(function);
transceiver->mRecvTrack.ForEachCodec(function);
}
@ -116,15 +115,15 @@ class JsepSession {
template <class BinaryPredicate>
void SortCodecs(BinaryPredicate& sorter) {
std::stable_sort(Codecs().begin(), Codecs().end(), sorter);
for (auto& [id, transceiver] : GetTransceivers()) {
for (auto& transceiver : GetTransceivers()) {
transceiver->mSendTrack.SortCodecs(sorter);
transceiver->mRecvTrack.SortCodecs(sorter);
}
}
virtual const std::map<size_t, RefPtr<JsepTransceiver>>& GetTransceivers()
virtual const std::vector<RefPtr<JsepTransceiver>>& GetTransceivers()
const = 0;
virtual std::map<size_t, RefPtr<JsepTransceiver>>& GetTransceivers() = 0;
virtual std::vector<RefPtr<JsepTransceiver>>& GetTransceivers() = 0;
virtual nsresult AddTransceiver(RefPtr<JsepTransceiver> transceiver) = 0;
class Result {
@ -191,7 +190,7 @@ class JsepSession {
memset(receiving, 0, sizeof(receiving));
memset(sending, 0, sizeof(sending));
for (const auto& [id, transceiver] : GetTransceivers()) {
for (const auto& transceiver : GetTransceivers()) {
if (transceiver->mRecvTrack.GetActive() ||
transceiver->GetMediaType() == SdpMediaSection::kApplication) {
receiving[transceiver->mRecvTrack.GetMediaType()]++;

Просмотреть файл

@ -113,7 +113,7 @@ nsresult JsepSessionImpl::AddTransceiver(RefPtr<JsepTransceiver> transceiver) {
// of asserting.
transceiver->mJsDirection = SdpDirectionAttribute::kSendrecv;
#ifdef DEBUG
for (const auto& [id, transceiver] : mTransceivers) {
for (auto& transceiver : mTransceivers) {
MOZ_ASSERT(transceiver->GetMediaType() != SdpMediaSection::kApplication);
}
#endif
@ -123,7 +123,7 @@ nsresult JsepSessionImpl::AddTransceiver(RefPtr<JsepTransceiver> transceiver) {
transceiver->mRecvTrack.PopulateCodecs(mSupportedCodecs);
// We do not set mLevel yet, we do that either on createOffer, or setRemote
mTransceivers[mTransceiverIdCounter++] = transceiver;
mTransceivers.push_back(transceiver);
return NS_OK;
}
@ -690,8 +690,8 @@ JsepSession::Result JsepSessionImpl::SetLocalDescription(
if (type == kJsepSdpOffer) {
// Save in case we need to rollback
mOldTransceivers.clear();
for (const auto& [id, transceiver] : mTransceivers) {
mOldTransceivers[id] = new JsepTransceiver(*transceiver);
for (const auto& transceiver : mTransceivers) {
mOldTransceivers.push_back(new JsepTransceiver(*transceiver));
}
}
@ -862,8 +862,8 @@ JsepSession::Result JsepSessionImpl::SetRemoteDescription(
// Save in case we need to rollback.
if (type == kJsepSdpOffer) {
mOldTransceivers.clear();
for (const auto& [id, transceiver] : mTransceivers) {
mOldTransceivers[id] = new JsepTransceiver(*transceiver);
for (const auto& transceiver : mTransceivers) {
mOldTransceivers.push_back(new JsepTransceiver(*transceiver));
if (!transceiver->IsNegotiated()) {
// We chose a level for this transceiver, but never negotiated it.
// Discard this state.
@ -958,7 +958,7 @@ nsresult JsepSessionImpl::HandleNegotiatedSession(
}
std::vector<JsepTrack*> remoteTracks;
for (const auto& [id, transceiver] : mTransceivers) {
for (const RefPtr<JsepTransceiver>& transceiver : mTransceivers) {
remoteTracks.push_back(&transceiver->mRecvTrack);
}
JsepTrack::SetUniquePayloadTypes(remoteTracks);
@ -1331,7 +1331,7 @@ nsresult JsepSessionImpl::SetRemoteDescriptionAnswer(JsepSdpType type,
}
JsepTransceiver* JsepSessionImpl::GetTransceiverForLevel(size_t level) {
for (auto& [id, transceiver] : mTransceivers) {
for (RefPtr<JsepTransceiver>& transceiver : mTransceivers) {
if (transceiver->HasLevel() && (transceiver->GetLevel() == level)) {
return transceiver.get();
}
@ -1341,7 +1341,7 @@ JsepTransceiver* JsepSessionImpl::GetTransceiverForLevel(size_t level) {
}
JsepTransceiver* JsepSessionImpl::GetTransceiverForMid(const std::string& mid) {
for (auto& [id, transceiver] : mTransceivers) {
for (RefPtr<JsepTransceiver>& transceiver : mTransceivers) {
if (transceiver->IsAssociated() && (transceiver->GetMid() == mid)) {
return transceiver.get();
}
@ -1371,7 +1371,7 @@ JsepTransceiver* JsepSessionImpl::GetTransceiverForLocal(size_t level) {
// There is no transceiver for |level| right now.
// Look for an RTP transceiver
for (auto& [id, transceiver] : mTransceivers) {
for (RefPtr<JsepTransceiver>& transceiver : mTransceivers) {
if (transceiver->GetMediaType() != SdpMediaSection::kApplication &&
!transceiver->IsStopped() && !transceiver->HasLevel()) {
transceiver->SetLevel(level);
@ -1380,7 +1380,7 @@ JsepTransceiver* JsepSessionImpl::GetTransceiverForLocal(size_t level) {
}
// Ok, look for a datachannel
for (auto& [id, transceiver] : mTransceivers) {
for (RefPtr<JsepTransceiver>& transceiver : mTransceivers) {
if (!transceiver->IsStopped() && !transceiver->HasLevel()) {
transceiver->SetLevel(level);
return transceiver.get();
@ -1417,12 +1417,12 @@ JsepTransceiver* JsepSessionImpl::GetTransceiverForRemote(
newTransceiver->SetCreatedBySetRemote();
nsresult rv = AddTransceiver(newTransceiver);
NS_ENSURE_SUCCESS(rv, nullptr);
return newTransceiver.get();
return mTransceivers.back().get();
}
JsepTransceiver* JsepSessionImpl::GetTransceiverWithTransport(
const std::string& transportId) {
for (const auto& [id, transceiver] : mTransceivers) {
for (const auto& transceiver : mTransceivers) {
if (transceiver->HasOwnTransport() &&
(transceiver->mTransport.mTransportId == transportId)) {
MOZ_ASSERT(transceiver->HasLevel(),
@ -1485,7 +1485,7 @@ nsresult JsepSessionImpl::UpdateTransceiversFromRemoteDescription(
JsepTransceiver* JsepSessionImpl::FindUnassociatedTransceiver(
SdpMediaSection::MediaType type, bool magic) {
// Look through transceivers that are not mapped to an m-section
for (auto& [id, transceiver] : mTransceivers) {
for (RefPtr<JsepTransceiver>& transceiver : mTransceivers) {
if (type == SdpMediaSection::kApplication &&
type == transceiver->GetMediaType()) {
transceiver->RestartDatachannelTransceiver();
@ -1502,10 +1502,10 @@ JsepTransceiver* JsepSessionImpl::FindUnassociatedTransceiver(
}
void JsepSessionImpl::RollbackLocalOffer() {
for (auto& [id, transceiver] : mTransceivers) {
if (mOldTransceivers.count(id)) {
transceiver->Rollback(*mOldTransceivers[id], false);
mOldTransceivers[id] = transceiver;
for (size_t i = 0; i < mTransceivers.size(); ++i) {
RefPtr<JsepTransceiver>& transceiver(mTransceivers[i]);
if (i < mOldTransceivers.size()) {
transceiver->Rollback(*mOldTransceivers[i], false);
continue;
}
@ -1514,18 +1514,16 @@ void JsepSessionImpl::RollbackLocalOffer() {
temp->mSendTrack.PopulateCodecs(mSupportedCodecs);
temp->mRecvTrack.PopulateCodecs(mSupportedCodecs);
transceiver->Rollback(*temp, false);
mOldTransceivers[id] = transceiver;
}
mTransceivers = std::move(mOldTransceivers);
mOldTransceivers.clear();
}
void JsepSessionImpl::RollbackRemoteOffer() {
for (auto& [id, transceiver] : mTransceivers) {
if (mOldTransceivers.count(id)) {
// Some stuff cannot be rolled back. Save this information.
transceiver->Rollback(*mOldTransceivers[id], true);
mOldTransceivers[id] = transceiver;
for (size_t i = 0; i < mTransceivers.size(); ++i) {
RefPtr<JsepTransceiver>& transceiver(mTransceivers[i]);
if (i < mOldTransceivers.size()) {
transceiver->Rollback(*mOldTransceivers[i], true);
continue;
}
@ -1544,12 +1542,12 @@ void JsepSessionImpl::RollbackRemoteOffer() {
if (shouldRemove) {
transceiver->Stop();
transceiver->SetRemoved();
} else {
mOldTransceivers[id] = transceiver;
mTransceivers.erase(mTransceivers.begin() + i);
--i;
}
}
mTransceivers = std::move(mOldTransceivers);
mOldTransceivers.clear();
}
nsresult JsepSessionImpl::ValidateLocalDescription(const Sdp& description,
@ -2135,7 +2133,7 @@ nsresult JsepSessionImpl::UpdateDefaultCandidate(
return NS_ERROR_UNEXPECTED;
}
for (const auto& [id, transceiver] : mTransceivers) {
for (const auto& transceiver : mTransceivers) {
// We set the default address for bundled m-sections, but not candidate
// attributes. Ugh.
if (transceiver->mTransport.mTransportId == transportId) {
@ -2238,7 +2236,7 @@ const std::string JsepSessionImpl::GetLastError() const { return mLastError; }
bool JsepSessionImpl::CheckNegotiationNeeded() const {
MOZ_ASSERT(mState == kJsepStateStable);
for (const auto& [id, transceiver] : mTransceivers) {
for (const auto& transceiver : mTransceivers) {
if (transceiver->IsStopped()) {
if (transceiver->IsAssociated()) {
MOZ_MTLOG(ML_DEBUG, "[" << mName

Просмотреть файл

@ -5,7 +5,6 @@
#ifndef _JSEPSESSIONIMPL_H_
#define _JSEPSESSIONIMPL_H_
#include <map>
#include <set>
#include <string>
#include <vector>
@ -132,13 +131,12 @@ class JsepSessionImpl : public JsepSession {
return !mOldIceUfrag.empty();
}
virtual const std::map<size_t, RefPtr<JsepTransceiver>>& GetTransceivers()
virtual const std::vector<RefPtr<JsepTransceiver>>& GetTransceivers()
const override {
return mTransceivers;
}
virtual std::map<size_t, RefPtr<JsepTransceiver>>& GetTransceivers()
override {
virtual std::vector<RefPtr<JsepTransceiver>>& GetTransceivers() override {
return mTransceivers;
}
@ -227,12 +225,11 @@ class JsepSessionImpl : public JsepSession {
const Sdp* GetAnswer() const;
void SetIceRestarting(bool restarting);
// !!!NOT INDEXED BY LEVEL!!! The level mapping is done with
// JsepTransceiver::mLevel. The keys are opaque, stable identifiers that are
// unique within the JsepSession.
std::map<size_t, RefPtr<JsepTransceiver>> mTransceivers;
// !!!NOT INDEXED BY LEVEL!!! These are in the order they were created in. The
// level mapping is done with JsepTransceiver::mLevel.
std::vector<RefPtr<JsepTransceiver>> mTransceivers;
// So we can rollback. Not as simple as just going back to the old, though...
std::map<size_t, RefPtr<JsepTransceiver>> mOldTransceivers;
std::vector<RefPtr<JsepTransceiver>> mOldTransceivers;
Maybe<bool> mIsPendingOfferer;
Maybe<bool> mIsCurrentOfferer;
@ -250,7 +247,6 @@ class JsepSessionImpl : public JsepSession {
size_t mMidCounter;
std::set<std::string> mUsedMids;
size_t mTransportIdCounter;
size_t mTransceiverIdCounter = 0;
std::vector<JsepExtmapMediaType> mRtpExtensions;
UniquePtr<JsepUuidGenerator> mUuidGen;
std::string mDefaultRemoteStreamId;

Просмотреть файл

@ -878,7 +878,7 @@ nsresult PeerConnectionImpl::GetDatachannelParameters(
transportId->clear();
RefPtr<JsepTransceiver> datachannelTransceiver;
for (const auto& [id, transceiver] : mJsepSession->GetTransceivers()) {
for (const auto& transceiver : mJsepSession->GetTransceivers()) {
if ((transceiver->GetMediaType() == SdpMediaSection::kApplication) &&
transceiver->mSendTrack.GetNegotiatedDetails()) {
datachannelTransceiver = transceiver;
@ -895,7 +895,7 @@ nsresult PeerConnectionImpl::GetDatachannelParameters(
transportTransceiver = datachannelTransceiver;
} else if (datachannelTransceiver->HasBundleLevel()) {
// Find the actual transport.
for (const auto& [id, transceiver] : mJsepSession->GetTransceivers()) {
for (const auto& transceiver : mJsepSession->GetTransceivers()) {
if (transceiver->HasLevel() &&
transceiver->GetLevel() == datachannelTransceiver->BundleLevel() &&
transceiver->HasOwnTransport()) {
@ -1118,7 +1118,7 @@ PeerConnectionImpl::CreateDataChannel(
CSFLogDebug(LOGTAG, "%s: making DOMDataChannel", __FUNCTION__);
RefPtr<JsepTransceiver> dcTransceiver;
for (auto& [id, transceiver] : mJsepSession->GetTransceivers()) {
for (auto& transceiver : mJsepSession->GetTransceivers()) {
if (transceiver->GetMediaType() == SdpMediaSection::kApplication) {
dcTransceiver = transceiver;
break;
@ -1403,7 +1403,7 @@ PeerConnectionImpl::SetRemoteDescription(int32_t action, const char* aSDP) {
return NS_ERROR_FAILURE;
}
auto originalTransceivers = mJsepSession->GetTransceivers();
size_t originalTransceiverCount = mJsepSession->GetTransceivers().size();
JsepSession::Result result =
mJsepSession->SetRemoteDescription(sdpType, mRemoteRequestedSDP);
if (result.mError.isSome()) {
@ -1413,17 +1413,18 @@ PeerConnectionImpl::SetRemoteDescription(int32_t action, const char* aSDP) {
mPCObserver->OnSetDescriptionError(*buildJSErrorData(result, errorString),
jrv);
} else {
for (const auto& [id, jsepTransceiver] : mJsepSession->GetTransceivers()) {
// Iterate over the JSEP transceivers that were just created
for (size_t i = originalTransceiverCount;
i < mJsepSession->GetTransceivers().size(); ++i) {
RefPtr<JsepTransceiver> jsepTransceiver =
mJsepSession->GetTransceivers()[i];
if (jsepTransceiver->GetMediaType() ==
SdpMediaSection::MediaType::kApplication) {
continue;
}
if (originalTransceivers.count(id)) {
continue;
}
// New audio or video transceiver, need to tell JS about it.
// Audio or video transceiver, need to tell JS about it.
RefPtr<TransceiverImpl> transceiverImpl =
CreateTransceiverImpl(jsepTransceiver, nullptr, jrv);
if (jrv.Failed()) {

Просмотреть файл

@ -165,7 +165,7 @@ nsresult PeerConnectionMedia::Init() {
}
void PeerConnectionMedia::EnsureTransports(const JsepSession& aSession) {
for (const auto& [id, transceiver] : aSession.GetTransceivers()) {
for (const auto& transceiver : aSession.GetTransceivers()) {
if (transceiver->HasOwnTransport()) {
mTransportHandler->EnsureProvisionalTransport(
transceiver->mTransport.mTransportId,
@ -181,7 +181,7 @@ void PeerConnectionMedia::EnsureTransports(const JsepSession& aSession) {
nsresult PeerConnectionMedia::UpdateTransports(const JsepSession& aSession,
const bool forceIceTcp) {
std::set<std::string> finalTransports;
for (const auto& [id, transceiver] : aSession.GetTransceivers()) {
for (const auto& transceiver : aSession.GetTransceivers()) {
if (transceiver->HasOwnTransport()) {
finalTransports.insert(transceiver->mTransport.mTransportId);
UpdateTransport(*transceiver, forceIceTcp);

Просмотреть файл

@ -1,21 +1,24 @@
[RTCPeerConnection-setRemoteDescription-rollback.html]
[rollback of a remote offer should keep a transceiver]
expected: FAIL
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1307996
expected:
if (os == "android") and not debug: [OK, TIMEOUT]
[rollback of a remote offer should keep a transceiver created by addtrack]
expected: FAIL
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1307996
[explicit rollback of local offer should remove transceivers and transport]
expected: FAIL
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1307996
[rollback of a local offer to negotiated stable state should enable applying of a remote offer]
expected: FAIL
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1307996
[rollback of a remote offer with stream changes]
expected: FAIL
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1510802
[implicit rollback of a local offer should visit stable state and fire negotiationneeded]
expected: FAIL
[explicit rollback of local offer should remove transceivers and transport]
expected: FAIL
[rollback of a local offer to negotiated stable state should enable applying of a remote offer]
expected: FAIL
[rollback of a remote offer should keep a transceiver]
expected: FAIL
[rollback a local offer with audio direction change to negotiated stable state and then add video receiver]
expected: FAIL

Просмотреть файл

@ -307,22 +307,4 @@
assert_equals(pc1.pendingRemoteDescription, null);
await promise_rejects_dom(t, 'RTCError', p);
}, 'setRemoteDescription(invalidOffer) from have-local-offer does not undo rollback');
promise_test(async t => {
const pc1 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());
pc1.addTransceiver('video');
const offer = await pc1.createOffer();
await pc2.setRemoteDescription(offer);
assert_equals(pc2.getTransceivers().length, 1);
await pc2.setRemoteDescription(offer);
assert_equals(pc2.getTransceivers().length, 1);
await pc1.setLocalDescription(offer);
const answer = await pc2.createAnswer();
await pc2.setLocalDescription(answer);
await pc1.setRemoteDescription(answer);
}, 'repeated sRD(offer) works');
</script>

Просмотреть файл

@ -282,7 +282,7 @@
const offer = await pc.createOffer();
await pc.setLocalDescription(offer);
assert_not_equals(pc.getTransceivers()[0].sender.transport, null);
await pc.setLocalDescription({type: "rollback"});
await pc.setRemoteDescription({type: "rollback"});
assert_equals(pc.getTransceivers().length, 1);
assert_equals(pc.getTransceivers()[0].mid, null)
assert_equals(pc.getTransceivers()[0].sender.transport, null);
@ -292,35 +292,6 @@
assert_array_equals(states, ['have-local-offer', 'stable', 'have-local-offer']);
}, "explicit rollback of local offer should remove transceivers and transport");
promise_test(async t => {
const pc1 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());
const states = [];
const signalingstatechangeResolver = new Resolver();
pc1.onsignalingstatechange = () => {
states.push(pc1.signalingState);
signalingstatechangeResolver.resolve();
};
const stream1 = await getNoiseStream({audio: true});
t.add_cleanup(() => stream1.getTracks().forEach(track => track.stop()));
pc1.addTransceiver(stream1.getTracks()[0], stream1);
const stream2 = await getNoiseStream({audio: true});
t.add_cleanup(() => stream2.getTracks().forEach(track => track.stop()));
pc2.addTransceiver(stream2.getTracks()[0], stream2);
await pc1.setLocalDescription(await pc1.createOffer());
pc1.onnegotiationneeded = t.step_func(() => assert_true(false, "There should be no negotiationneeded event right now"));
await pc1.setRemoteDescription(await pc2.createOffer());
await pc1.setLocalDescription(await pc1.createAnswer());
await signalingstatechangeResolver.promise;
assert_array_equals(states, ['have-local-offer', 'stable', 'have-remote-offer', 'stable']);
await new Promise(r => pc1.onnegotiationneeded = r);
}, "when using addTransceiver, implicit rollback of a local offer should visit stable state, but not fire negotiationneeded until we settle in stable");
promise_test(async t => {
const pc1 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
@ -337,17 +308,24 @@
t.add_cleanup(() => stream1.getTracks().forEach(track => track.stop()));
pc1.addTrack(stream1.getTracks()[0], stream1);
const stream2 = await getNoiseStream({audio: true});
const stream2 = await getNoiseStream({video: true});
t.add_cleanup(() => stream2.getTracks().forEach(track => track.stop()));
pc2.addTrack(stream2.getTracks()[0], stream2);
await pc1.setLocalDescription(await pc1.createOffer());
pc1.onnegotiationneeded = t.step_func(() => assert_true(false, "There should be no negotiationneeded event in this test"));
var onnegotiationneededCount = 0;
const negotiationneededResolver = new Resolver();
pc1.onnegotiationneeded = () => {
onnegotiationneededCount += 1;
negotiationneededResolver.resolve();
};
await pc1.setRemoteDescription(await pc2.createOffer());
await pc1.setLocalDescription(await pc1.createAnswer());
await negotiationneededResolver.promise;
assert_equals(onnegotiationneededCount, 1);
await signalingstatechangeResolver.promise;
assert_array_equals(states, ['have-local-offer', 'stable', 'have-remote-offer', 'stable']);
await new Promise(r => t.step_timeout(r, 0));
}, "when using addTrack, implicit rollback of a local offer should visit stable state, but not fire negotiationneeded");
}, "implicit rollback of a local offer should visit stable state and fire negotiationneeded");
promise_test(async t => {
const pc1 = new RTCPeerConnection();
@ -407,7 +385,7 @@
await pc2.setLocalDescription(await pc2.createOffer());
assert_equals(pc2.getTransceivers().length, 2);
assert_not_equals(pc2.getTransceivers()[1].sender.transport, null);
await pc2.setLocalDescription({type: "rollback"});
await pc2.setRemoteDescription({type: "rollback"});
assert_equals(pc2.getTransceivers().length, 2);
// Rollback didn't touch audio transceiver and transport is intact.
assert_not_equals(pc2.getTransceivers()[0].sender.transport, null);
@ -445,7 +423,7 @@
assert_equals(pc2.getTransceivers()[0].direction, "sendrecv");
await pc2.setLocalDescription(await pc2.createOffer());
assert_equals(pc2.getTransceivers()[0].direction, "sendrecv");
await pc2.setLocalDescription({type: "rollback"});
await pc2.setRemoteDescription({type: "rollback"});
assert_equals(pc2.getTransceivers().length, 1);
// setLocalDescription didn't change direction. So direction remains "sendrecv"
assert_equals(pc2.getTransceivers()[0].direction, "sendrecv");