@@ -424,15 +424,15 @@ void PeerConnection::forwardMessage(message_ptr message) {
424
424
return ;
425
425
}
426
426
427
+ auto iceTransport = std::atomic_load (&mIceTransport );
428
+ auto sctpTransport = std::atomic_load (&mSctpTransport );
429
+ if (!iceTransport || !sctpTransport)
430
+ return ;
431
+
427
432
const uint16_t stream = uint16_t (message->stream );
428
433
auto channel = findDataChannel (stream);
429
434
430
435
if (DataChannel::IsOpenMessage (message)) {
431
- auto iceTransport = getIceTransport ();
432
- auto sctpTransport = getSctpTransport ();
433
- if (!iceTransport || !sctpTransport)
434
- return ;
435
-
436
436
const uint16_t remoteParity = (iceTransport->role () == Description::Role::Active) ? 1 : 0 ;
437
437
if (stream % 2 != remoteParity) {
438
438
// The odd/even rule is violated, close the DataChannel
@@ -462,9 +462,7 @@ void PeerConnection::forwardMessage(message_ptr message) {
462
462
463
463
// Invalid, close the DataChannel
464
464
PLOG_WARNING << " Got unexpected message on stream " << stream;
465
- if (auto sctpTransport = getSctpTransport ())
466
- sctpTransport->closeStream (message->stream );
467
-
465
+ sctpTransport->closeStream (message->stream );
468
466
return ;
469
467
}
470
468
@@ -591,7 +589,7 @@ shared_ptr<DataChannel> PeerConnection::emplaceDataChannel(string label, DataCha
591
589
lock.unlock (); // we are going to call assignDataChannels()
592
590
593
591
// If SCTP is connected, assign and open now
594
- auto sctpTransport = getSctpTransport ( );
592
+ auto sctpTransport = std::atomic_load (& mSctpTransport );
595
593
if (sctpTransport && sctpTransport->state () == SctpTransport::State::Connected) {
596
594
assignDataChannels ();
597
595
channel->open (sctpTransport);
@@ -617,7 +615,7 @@ uint16_t PeerConnection::maxDataChannelStream() const {
617
615
void PeerConnection::assignDataChannels () {
618
616
std::unique_lock lock (mDataChannelsMutex ); // we are going to emplace
619
617
620
- auto iceTransport = getIceTransport ( );
618
+ auto iceTransport = std::atomic_load (& mIceTransport );
621
619
if (!iceTransport)
622
620
throw std::logic_error (" Attempted to assign DataChannels without ICE transport" );
623
621
@@ -1019,12 +1017,6 @@ void PeerConnection::processRemoteDescription(Description description) {
1019
1017
mRemoteDescription ->addCandidates (std::move (existingCandidates));
1020
1018
}
1021
1019
1022
- auto iceTransport = initIceTransport ();
1023
- if (!iceTransport)
1024
- return ; // closed
1025
-
1026
- iceTransport->setRemoteDescription (std::move (description));
1027
-
1028
1020
if (description.hasApplication ()) {
1029
1021
auto dtlsTransport = std::atomic_load (&mDtlsTransport );
1030
1022
auto sctpTransport = std::atomic_load (&mSctpTransport );
0 commit comments