@@ -851,8 +851,7 @@ nsresult PeerConnectionImpl::GetDatachannelParameters(
851
851
transportId->clear ();
852
852
853
853
RefPtr<JsepTransceiver> datachannelTransceiver;
854
- for (const auto & [id, transceiver] : mJsepSession ->GetTransceivers ()) {
855
- (void )id; // Lame, but no better way to do this right now.
854
+ for (const auto & transceiver : mJsepSession ->GetTransceivers ()) {
856
855
if ((transceiver->GetMediaType () == SdpMediaSection::kApplication ) &&
857
856
transceiver->mSendTrack .GetNegotiatedDetails ()) {
858
857
datachannelTransceiver = transceiver;
@@ -958,18 +957,8 @@ already_AddRefed<RTCRtpTransceiver> PeerConnectionImpl::AddTransceiver(
958
957
return nullptr ;
959
958
}
960
959
961
- RefPtr<JsepTransceiver> jsepTransceiver = new JsepTransceiver (*type);
962
-
963
- RefPtr<RTCRtpTransceiver> transceiver =
964
- CreateTransceiver (jsepTransceiver, aInit, aSendTrack, aRv);
965
-
966
- if (aRv.Failed ()) {
967
- // Would be nice if we could peek at the rv without stealing it, so we
968
- // could log...
969
- CSFLogError (LOGTAG, " %s: failed" , __FUNCTION__);
970
- return nullptr ;
971
- }
972
-
960
+ RefPtr<JsepTransceiver> jsepTransceiver =
961
+ new JsepTransceiver (*type, *mUuidGen );
973
962
jsepTransceiver->SetRtxIsAllowed (mRtxIsAllowed );
974
963
975
964
// Do this last, since it is not possible to roll back.
@@ -981,6 +970,18 @@ already_AddRefed<RTCRtpTransceiver> PeerConnectionImpl::AddTransceiver(
981
970
return nullptr ;
982
971
}
983
972
973
+ RefPtr<RTCRtpTransceiver> transceiver = CreateTransceiver (
974
+ jsepTransceiver->GetUuid (),
975
+ jsepTransceiver->GetMediaType () == SdpMediaSection::kVideo , aInit,
976
+ aSendTrack, aRv);
977
+
978
+ if (aRv.Failed ()) {
979
+ // Would be nice if we could peek at the rv without stealing it, so we
980
+ // could log...
981
+ CSFLogError (LOGTAG, " %s: failed" , __FUNCTION__);
982
+ return nullptr ;
983
+ }
984
+
984
985
mTransceivers .AppendElement (transceiver);
985
986
return transceiver.forget ();
986
987
}
@@ -1073,17 +1074,16 @@ PeerConnectionImpl::CreateDataChannel(
1073
1074
CSFLogDebug (LOGTAG, " %s: making DOMDataChannel" , __FUNCTION__);
1074
1075
1075
1076
RefPtr<JsepTransceiver> dcTransceiver;
1076
- for (auto & [id, transceiver] : mJsepSession ->GetTransceivers ()) {
1077
- (void )id; // Lame, but no better way to do this right now.
1077
+ for (auto & transceiver : mJsepSession ->GetTransceivers ()) {
1078
1078
if (transceiver->GetMediaType () == SdpMediaSection::kApplication ) {
1079
1079
dcTransceiver = transceiver;
1080
1080
break ;
1081
1081
}
1082
1082
}
1083
1083
1084
1084
if (!dcTransceiver) {
1085
- dcTransceiver =
1086
- new JsepTransceiver ( SdpMediaSection::MediaType::kApplication );
1085
+ dcTransceiver = new JsepTransceiver (
1086
+ SdpMediaSection::MediaType::kApplication , * mUuidGen );
1087
1087
mJsepSession ->AddTransceiver (dcTransceiver);
1088
1088
}
1089
1089
@@ -1609,25 +1609,37 @@ PeerConnectionImpl::SetRemoteDescription(int32_t action, const char* aSDP) {
1609
1609
mPCObserver ->OnSetDescriptionError (*buildJSErrorData (result, errorString),
1610
1610
jrv);
1611
1611
} else {
1612
- for (const auto & [id, jsepTransceiver] : mJsepSession ->GetTransceivers ()) {
1612
+ for (const auto & jsepTransceiver : mJsepSession ->GetTransceivers ()) {
1613
1613
if (jsepTransceiver->GetMediaType () ==
1614
1614
SdpMediaSection::MediaType::kApplication ) {
1615
1615
continue ;
1616
1616
}
1617
1617
1618
- if (originalTransceivers.count (id)) {
1619
- continue ;
1618
+ CSFLogDebug (LOGTAG, " %s: Looking for match" , __FUNCTION__);
1619
+ RefPtr<RTCRtpTransceiver> transceiver;
1620
+ for (auto & temp : mTransceivers ) {
1621
+ if (temp->GetJsepTransceiverId () == jsepTransceiver->GetUuid ()) {
1622
+ CSFLogDebug (LOGTAG, " %s: Found match" , __FUNCTION__);
1623
+ transceiver = temp;
1624
+ break ;
1625
+ }
1620
1626
}
1621
1627
1622
- dom::RTCRtpTransceiverInit init;
1623
- init.mDirection = RTCRtpTransceiverDirection::Recvonly;
1624
- RefPtr<RTCRtpTransceiver> transceiver =
1625
- CreateTransceiver (jsepTransceiver, init, nullptr , jrv);
1626
- if (jrv.Failed ()) {
1627
- appendHistory ();
1628
- return NS_ERROR_FAILURE;
1628
+ if (!transceiver) {
1629
+ CSFLogDebug (LOGTAG, " %s: No match, making new" , __FUNCTION__);
1630
+ dom::RTCRtpTransceiverInit init;
1631
+ init.mDirection = RTCRtpTransceiverDirection::Recvonly;
1632
+ IgnoredErrorResult rv;
1633
+ transceiver = CreateTransceiver (
1634
+ jsepTransceiver->GetUuid (),
1635
+ jsepTransceiver->GetMediaType () == SdpMediaSection::kVideo , init,
1636
+ nullptr , rv);
1637
+ if (NS_WARN_IF(rv.Failed ())) {
1638
+ MOZ_ASSERT (false );
1639
+ break ;
1640
+ }
1641
+ mTransceivers .AppendElement (transceiver);
1629
1642
}
1630
- mTransceivers .AppendElement (transceiver);
1631
1643
}
1632
1644
1633
1645
if (wasRestartingIce) {
@@ -3213,8 +3225,7 @@ bool PeerConnectionImpl::ShouldForceProxy() const {
3213
3225
}
3214
3226
3215
3227
void PeerConnectionImpl::EnsureTransports (const JsepSession& aSession) {
3216
- for (const auto & [id, transceiver] : aSession.GetTransceivers ()) {
3217
- (void )id; // Lame, but no better way to do this right now.
3228
+ for (const auto & transceiver : aSession.GetTransceivers ()) {
3218
3229
if (transceiver->HasOwnTransport ()) {
3219
3230
mTransportHandler ->EnsureProvisionalTransport (
3220
3231
transceiver->mTransport .mTransportId ,
@@ -3264,8 +3275,7 @@ void PeerConnectionImpl::RemoveRTCDtlsTransportsExcept(
3264
3275
nsresult PeerConnectionImpl::UpdateTransports (const JsepSession& aSession,
3265
3276
const bool forceIceTcp) {
3266
3277
std::set<std::string> finalTransports;
3267
- for (const auto & [id, transceiver] : aSession.GetTransceivers ()) {
3268
- (void )id; // Lame, but no better way to do this right now.
3278
+ for (const auto & transceiver : aSession.GetTransceivers ()) {
3269
3279
if (transceiver->HasOwnTransport ()) {
3270
3280
finalTransports.insert (transceiver->mTransport .mTransportId );
3271
3281
UpdateTransport (*transceiver, forceIceTcp);
@@ -3636,7 +3646,7 @@ void PeerConnectionImpl::EnsureIceGathering(bool aDefaultRouteOnly,
3636
3646
}
3637
3647
3638
3648
already_AddRefed<dom::RTCRtpTransceiver> PeerConnectionImpl::CreateTransceiver (
3639
- JsepTransceiver* aJsepTransceiver , const RTCRtpTransceiverInit& aInit,
3649
+ const std::string& aId, bool aIsVideo , const RTCRtpTransceiverInit& aInit,
3640
3650
dom::MediaStreamTrack* aSendTrack, ErrorResult& aRv) {
3641
3651
PeerConnectionCtx* ctx = PeerConnectionCtx::GetInstance ();
3642
3652
if (!mCall ) {
@@ -3649,8 +3659,8 @@ already_AddRefed<dom::RTCRtpTransceiver> PeerConnectionImpl::CreateTransceiver(
3649
3659
}
3650
3660
3651
3661
RefPtr<RTCRtpTransceiver> transceiver = new RTCRtpTransceiver (
3652
- mWindow , PrivacyNeeded (), this , mTransportHandler , aJsepTransceiver ,
3653
- mSTSThread .get (), aSendTrack, mCall .get (), mIdGenerator );
3662
+ mWindow , PrivacyNeeded (), this , mTransportHandler , mJsepSession . get () ,
3663
+ aId, aIsVideo, mSTSThread .get (), aSendTrack, mCall .get (), mIdGenerator );
3654
3664
3655
3665
transceiver->Init (aInit, aRv);
3656
3666
if (aRv.Failed ()) {
0 commit comments