Remove unnecessary calls to BaseChannel::SetRtpTransport

Also updating SocketOptionsMergedOnSetTransport test code to make the
call to SetRtpTransport from the right context.

Bug: webrtc:12636
Change-Id: I343851bcf8ac663d7559128d12447a9a742786f0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/213660
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33633}
diff --git a/pc/channel.cc b/pc/channel.cc
index 1408c4c..f37be67 100644
--- a/pc/channel.cc
+++ b/pc/channel.cc
@@ -228,11 +228,6 @@
 }
 
 bool BaseChannel::SetRtpTransport(webrtc::RtpTransportInternal* rtp_transport) {
-  if (!network_thread_->IsCurrent()) {
-    return network_thread_->Invoke<bool>(RTC_FROM_HERE, [this, rtp_transport] {
-      return SetRtpTransport(rtp_transport);
-    });
-  }
   RTC_DCHECK_RUN_ON(network_thread());
   if (rtp_transport == rtp_transport_) {
     return true;
@@ -881,10 +876,6 @@
   Deinit();
 }
 
-void VoiceChannel::Init_w(webrtc::RtpTransportInternal* rtp_transport) {
-  BaseChannel::Init_w(rtp_transport);
-}
-
 void VoiceChannel::UpdateMediaSendRecvState_w() {
   // Render incoming data if we're the active call, and we have the local
   // content. We receive data on the default channel and multiplexed streams.
diff --git a/pc/channel.h b/pc/channel.h
index b418188..dbcdf9d 100644
--- a/pc/channel.h
+++ b/pc/channel.h
@@ -434,7 +434,6 @@
   cricket::MediaType media_type() const override {
     return cricket::MEDIA_TYPE_AUDIO;
   }
-  void Init_w(webrtc::RtpTransportInternal* rtp_transport) override;
 
  private:
   // overrides from BaseChannel
diff --git a/pc/channel_unittest.cc b/pc/channel_unittest.cc
index ea4e828..7ff25a9 100644
--- a/pc/channel_unittest.cc
+++ b/pc/channel_unittest.cc
@@ -1276,11 +1276,11 @@
 
     new_rtp_transport_ = CreateDtlsSrtpTransport(
         fake_rtp_dtls_transport2_.get(), fake_rtcp_dtls_transport2_.get());
-    channel1_->SetRtpTransport(new_rtp_transport_.get());
 
     bool rcv_success, send_success;
     int rcv_buf, send_buf;
     network_thread_->Invoke<void>(RTC_FROM_HERE, [&] {
+      channel1_->SetRtpTransport(new_rtp_transport_.get());
       send_success = fake_rtp_dtls_transport2_->GetOption(
           rtc::Socket::Option::OPT_SNDBUF, &send_buf);
       rcv_success = fake_rtp_dtls_transport2_->GetOption(
diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc
index 2d9f9c8..3499e4c 100644
--- a/pc/sdp_offer_answer.cc
+++ b/pc/sdp_offer_answer.cc
@@ -4629,8 +4629,6 @@
   }
   voice_channel->SignalSentPacket().connect(pc_,
                                             &PeerConnection::OnSentPacket_w);
-  voice_channel->SetRtpTransport(rtp_transport);
-
   return voice_channel;
 }
 
@@ -4654,8 +4652,6 @@
   }
   video_channel->SignalSentPacket().connect(pc_,
                                             &PeerConnection::OnSentPacket_w);
-  video_channel->SetRtpTransport(rtp_transport);
-
   return video_channel;
 }
 
@@ -4688,8 +4684,6 @@
       }
       data_channel_controller()->rtp_data_channel()->SignalSentPacket().connect(
           pc_, &PeerConnection::OnSentPacket_w);
-      data_channel_controller()->rtp_data_channel()->SetRtpTransport(
-          rtp_transport);
       have_pending_rtp_data_channel_ = true;
       return true;
   }