Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: webrtc/api/webrtcsession.cc

Issue 2637503003: More minor improvements to BaseChannel/transport code. (Closed)
Patch Set: Merge with master Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/api/webrtcsession.h ('k') | webrtc/p2p/base/transportcontroller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 cricket::TransportChannel* rtp_transport = 1085 cricket::TransportChannel* rtp_transport =
1086 transport_controller_->CreateTransportChannel( 1086 transport_controller_->CreateTransportChannel(
1087 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); 1087 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
1088 bool need_rtcp = (ch->rtcp_transport() != nullptr); 1088 bool need_rtcp = (ch->rtcp_transport() != nullptr);
1089 cricket::TransportChannel* rtcp_transport = nullptr; 1089 cricket::TransportChannel* rtcp_transport = nullptr;
1090 if (need_rtcp) { 1090 if (need_rtcp) {
1091 rtcp_transport = transport_controller_->CreateTransportChannel_n( 1091 rtcp_transport = transport_controller_->CreateTransportChannel_n(
1092 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); 1092 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
1093 } 1093 }
1094 1094
1095 if (!ch->SetTransport(rtp_transport, rtcp_transport)) { 1095 ch->SetTransports(rtp_transport, rtcp_transport);
1096 LOG(LS_WARNING) << "Failed to enable BUNDLE for " << ch->content_name();
1097 return false;
1098 }
1099 LOG(LS_INFO) << "Enabled BUNDLE for " << ch->content_name() << " on " 1096 LOG(LS_INFO) << "Enabled BUNDLE for " << ch->content_name() << " on "
1100 << transport_name << "."; 1097 << transport_name << ".";
1101 DestroyTransport(old_transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); 1098 transport_controller_->DestroyTransportChannel(
1099 old_transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
1102 // If the channel needs rtcp, it means that the channel used to have a 1100 // If the channel needs rtcp, it means that the channel used to have a
1103 // rtcp transport which needs to be deleted now. 1101 // rtcp transport which needs to be deleted now.
1104 if (need_rtcp) { 1102 if (need_rtcp) {
1105 DestroyTransport(old_transport_name, 1103 transport_controller_->DestroyTransportChannel(
1106 cricket::ICE_CANDIDATE_COMPONENT_RTCP); 1104 old_transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
1107 } 1105 }
1108 return true; 1106 return true;
1109 }; 1107 };
1110 1108
1111 if (!maybe_set_transport(voice_channel()) || 1109 if (!maybe_set_transport(voice_channel()) ||
1112 !maybe_set_transport(video_channel()) || 1110 !maybe_set_transport(video_channel()) ||
1113 !maybe_set_transport(rtp_data_channel())) { 1111 !maybe_set_transport(rtp_data_channel())) {
1114 return false; 1112 return false;
1115 } 1113 }
1116 // For SCTP, transport creation/deletion happens here instead of in the 1114 // For SCTP, transport creation/deletion happens here instead of in the
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
1798 if (!require_rtcp_mux) { 1796 if (!require_rtcp_mux) {
1799 rtcp_transport = transport_controller_->CreateTransportChannel( 1797 rtcp_transport = transport_controller_->CreateTransportChannel(
1800 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); 1798 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
1801 } 1799 }
1802 1800
1803 voice_channel_.reset(channel_manager_->CreateVoiceChannel( 1801 voice_channel_.reset(channel_manager_->CreateVoiceChannel(
1804 media_controller_, rtp_transport, rtcp_transport, 1802 media_controller_, rtp_transport, rtcp_transport,
1805 transport_controller_->signaling_thread(), content->name, 1803 transport_controller_->signaling_thread(), content->name,
1806 bundle_transport, require_rtcp_mux, SrtpRequired(), audio_options_)); 1804 bundle_transport, require_rtcp_mux, SrtpRequired(), audio_options_));
1807 if (!voice_channel_) { 1805 if (!voice_channel_) {
1806 transport_controller_->DestroyTransportChannel(
1807 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
1808 if (rtcp_transport) {
1809 transport_controller_->DestroyTransportChannel(
1810 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
1811 }
1808 return false; 1812 return false;
1809 } 1813 }
1810 1814
1811 voice_channel_->SignalRtcpMuxFullyActive.connect( 1815 voice_channel_->SignalRtcpMuxFullyActive.connect(
1812 this, &WebRtcSession::DestroyRtcpTransport_n); 1816 this, &WebRtcSession::DestroyRtcpTransport_n);
1813 voice_channel_->SignalDtlsSrtpSetupFailure.connect( 1817 voice_channel_->SignalDtlsSrtpSetupFailure.connect(
1814 this, &WebRtcSession::OnDtlsSrtpSetupFailure); 1818 this, &WebRtcSession::OnDtlsSrtpSetupFailure);
1815 1819
1816 SignalVoiceChannelCreated(); 1820 SignalVoiceChannelCreated();
1817 voice_channel_->SignalSentPacket.connect(this, 1821 voice_channel_->SignalSentPacket.connect(this,
(...skipping 17 matching lines...) Expand all
1835 rtcp_transport = transport_controller_->CreateTransportChannel( 1839 rtcp_transport = transport_controller_->CreateTransportChannel(
1836 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); 1840 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
1837 } 1841 }
1838 1842
1839 video_channel_.reset(channel_manager_->CreateVideoChannel( 1843 video_channel_.reset(channel_manager_->CreateVideoChannel(
1840 media_controller_, rtp_transport, rtcp_transport, 1844 media_controller_, rtp_transport, rtcp_transport,
1841 transport_controller_->signaling_thread(), content->name, 1845 transport_controller_->signaling_thread(), content->name,
1842 bundle_transport, require_rtcp_mux, SrtpRequired(), video_options_)); 1846 bundle_transport, require_rtcp_mux, SrtpRequired(), video_options_));
1843 1847
1844 if (!video_channel_) { 1848 if (!video_channel_) {
1849 transport_controller_->DestroyTransportChannel(
1850 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
1851 if (rtcp_transport) {
1852 transport_controller_->DestroyTransportChannel(
1853 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
1854 }
1845 return false; 1855 return false;
1846 } 1856 }
1847 1857
1848 video_channel_->SignalRtcpMuxFullyActive.connect( 1858 video_channel_->SignalRtcpMuxFullyActive.connect(
1849 this, &WebRtcSession::DestroyRtcpTransport_n); 1859 this, &WebRtcSession::DestroyRtcpTransport_n);
1850 video_channel_->SignalDtlsSrtpSetupFailure.connect( 1860 video_channel_->SignalDtlsSrtpSetupFailure.connect(
1851 this, &WebRtcSession::OnDtlsSrtpSetupFailure); 1861 this, &WebRtcSession::OnDtlsSrtpSetupFailure);
1852 1862
1853 SignalVideoChannelCreated(); 1863 SignalVideoChannelCreated();
1854 video_channel_->SignalSentPacket.connect(this, 1864 video_channel_->SignalSentPacket.connect(this,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1894 rtcp_transport = transport_controller_->CreateTransportChannel( 1904 rtcp_transport = transport_controller_->CreateTransportChannel(
1895 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); 1905 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
1896 } 1906 }
1897 1907
1898 rtp_data_channel_.reset(channel_manager_->CreateRtpDataChannel( 1908 rtp_data_channel_.reset(channel_manager_->CreateRtpDataChannel(
1899 media_controller_, rtp_transport, rtcp_transport, 1909 media_controller_, rtp_transport, rtcp_transport,
1900 transport_controller_->signaling_thread(), content->name, 1910 transport_controller_->signaling_thread(), content->name,
1901 bundle_transport, require_rtcp_mux, SrtpRequired())); 1911 bundle_transport, require_rtcp_mux, SrtpRequired()));
1902 1912
1903 if (!rtp_data_channel_) { 1913 if (!rtp_data_channel_) {
1914 transport_controller_->DestroyTransportChannel(
1915 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
1916 if (rtcp_transport) {
1917 transport_controller_->DestroyTransportChannel(
1918 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
1919 }
1904 return false; 1920 return false;
1905 } 1921 }
1906 1922
1907 rtp_data_channel_->SignalRtcpMuxFullyActive.connect( 1923 rtp_data_channel_->SignalRtcpMuxFullyActive.connect(
1908 this, &WebRtcSession::DestroyRtcpTransport_n); 1924 this, &WebRtcSession::DestroyRtcpTransport_n);
1909 rtp_data_channel_->SignalDtlsSrtpSetupFailure.connect( 1925 rtp_data_channel_->SignalDtlsSrtpSetupFailure.connect(
1910 this, &WebRtcSession::OnDtlsSrtpSetupFailure); 1926 this, &WebRtcSession::OnDtlsSrtpSetupFailure);
1911 rtp_data_channel_->SignalSentPacket.connect(this, 1927 rtp_data_channel_->SignalSentPacket.connect(this,
1912 &WebRtcSession::OnSentPacket_w); 1928 &WebRtcSession::OnSentPacket_w);
1913 } 1929 }
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
2358 if (content_name == *sctp_content_name_) { 2374 if (content_name == *sctp_content_name_) {
2359 return *sctp_transport_name_; 2375 return *sctp_transport_name_;
2360 } 2376 }
2361 } 2377 }
2362 // Return an empty string if failed to retrieve the transport name. 2378 // Return an empty string if failed to retrieve the transport name.
2363 return ""; 2379 return "";
2364 } 2380 }
2365 return channel->transport_name(); 2381 return channel->transport_name();
2366 } 2382 }
2367 2383
2368 void WebRtcSession::DestroyTransport(const std::string& transport_name,
2369 int component) {
2370 network_thread_->Invoke<void>(
2371 RTC_FROM_HERE,
2372 rtc::Bind(&cricket::TransportController::DestroyTransportChannel_n,
2373 transport_controller_.get(), transport_name, component));
2374 }
2375
2376 void WebRtcSession::DestroyRtcpTransport_n(const std::string& transport_name) { 2384 void WebRtcSession::DestroyRtcpTransport_n(const std::string& transport_name) {
2377 RTC_DCHECK(network_thread()->IsCurrent()); 2385 RTC_DCHECK(network_thread()->IsCurrent());
2378 transport_controller_->DestroyTransportChannel_n( 2386 transport_controller_->DestroyTransportChannel_n(
2379 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); 2387 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
2380 } 2388 }
2381 2389
2382 void WebRtcSession::DestroyVideoChannel() { 2390 void WebRtcSession::DestroyVideoChannel() {
2383 SignalVideoChannelDestroyed(); 2391 SignalVideoChannelDestroyed();
2384 RTC_DCHECK(video_channel_->rtp_transport()); 2392 RTC_DCHECK(video_channel_->rtp_transport());
2385 std::string transport_name; 2393 std::string transport_name;
2386 transport_name = video_channel_->rtp_transport()->transport_name(); 2394 transport_name = video_channel_->rtp_transport()->transport_name();
2387 bool need_to_delete_rtcp = (video_channel_->rtcp_transport() != nullptr); 2395 bool need_to_delete_rtcp = (video_channel_->rtcp_transport() != nullptr);
2388 channel_manager_->DestroyVideoChannel(video_channel_.release()); 2396 channel_manager_->DestroyVideoChannel(video_channel_.release());
2389 DestroyTransport(transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); 2397 transport_controller_->DestroyTransportChannel(
2398 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
2390 if (need_to_delete_rtcp) { 2399 if (need_to_delete_rtcp) {
2391 DestroyTransport(transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); 2400 transport_controller_->DestroyTransportChannel(
2401 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
2392 } 2402 }
2393 } 2403 }
2394 2404
2395 void WebRtcSession::DestroyVoiceChannel() { 2405 void WebRtcSession::DestroyVoiceChannel() {
2396 SignalVoiceChannelDestroyed(); 2406 SignalVoiceChannelDestroyed();
2397 RTC_DCHECK(voice_channel_->rtp_transport()); 2407 RTC_DCHECK(voice_channel_->rtp_transport());
2398 std::string transport_name; 2408 std::string transport_name;
2399 transport_name = voice_channel_->rtp_transport()->transport_name(); 2409 transport_name = voice_channel_->rtp_transport()->transport_name();
2400 bool need_to_delete_rtcp = (voice_channel_->rtcp_transport() != nullptr); 2410 bool need_to_delete_rtcp = (voice_channel_->rtcp_transport() != nullptr);
2401 channel_manager_->DestroyVoiceChannel(voice_channel_.release()); 2411 channel_manager_->DestroyVoiceChannel(voice_channel_.release());
2402 DestroyTransport(transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); 2412 transport_controller_->DestroyTransportChannel(
2413 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
2403 if (need_to_delete_rtcp) { 2414 if (need_to_delete_rtcp) {
2404 DestroyTransport(transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); 2415 transport_controller_->DestroyTransportChannel(
2416 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
2405 } 2417 }
2406 } 2418 }
2407 2419
2408 void WebRtcSession::DestroyDataChannel() { 2420 void WebRtcSession::DestroyDataChannel() {
2409 SignalDataChannelDestroyed(); 2421 SignalDataChannelDestroyed();
2410 RTC_DCHECK(rtp_data_channel_->rtp_transport()); 2422 RTC_DCHECK(rtp_data_channel_->rtp_transport());
2411 std::string transport_name; 2423 std::string transport_name;
2412 transport_name = rtp_data_channel_->rtp_transport()->transport_name(); 2424 transport_name = rtp_data_channel_->rtp_transport()->transport_name();
2413 bool need_to_delete_rtcp = (rtp_data_channel_->rtcp_transport() != nullptr); 2425 bool need_to_delete_rtcp = (rtp_data_channel_->rtcp_transport() != nullptr);
2414 channel_manager_->DestroyRtpDataChannel(rtp_data_channel_.release()); 2426 channel_manager_->DestroyRtpDataChannel(rtp_data_channel_.release());
2415 DestroyTransport(transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); 2427 transport_controller_->DestroyTransportChannel(
2428 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
2416 if (need_to_delete_rtcp) { 2429 if (need_to_delete_rtcp) {
2417 DestroyTransport(transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); 2430 transport_controller_->DestroyTransportChannel(
2431 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
2418 } 2432 }
2419 } 2433 }
2420 } // namespace webrtc 2434 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/api/webrtcsession.h ('k') | webrtc/p2p/base/transportcontroller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698