OLD | NEW |
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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 old_transport_desc->ice_ufrag, old_transport_desc->ice_pwd, | 454 old_transport_desc->ice_ufrag, old_transport_desc->ice_pwd, |
455 new_transport_desc->ice_ufrag, new_transport_desc->ice_pwd)) { | 455 new_transport_desc->ice_ufrag, new_transport_desc->ice_pwd)) { |
456 LOG(LS_INFO) << "Remote peer requests ICE restart for " << content_name | 456 LOG(LS_INFO) << "Remote peer requests ICE restart for " << content_name |
457 << "."; | 457 << "."; |
458 return true; | 458 return true; |
459 } | 459 } |
460 return false; | 460 return false; |
461 } | 461 } |
462 | 462 |
463 WebRtcSession::WebRtcSession( | 463 WebRtcSession::WebRtcSession( |
464 webrtc::MediaControllerInterface* media_controller, | 464 Call* call, |
| 465 cricket::ChannelManager* channel_manager, |
| 466 const cricket::MediaConfig& media_config, |
| 467 RtcEventLog* event_log, |
465 rtc::Thread* network_thread, | 468 rtc::Thread* network_thread, |
466 rtc::Thread* worker_thread, | 469 rtc::Thread* worker_thread, |
467 rtc::Thread* signaling_thread, | 470 rtc::Thread* signaling_thread, |
468 cricket::PortAllocator* port_allocator, | 471 cricket::PortAllocator* port_allocator, |
469 std::unique_ptr<cricket::TransportController> transport_controller, | 472 std::unique_ptr<cricket::TransportController> transport_controller, |
470 std::unique_ptr<cricket::SctpTransportInternalFactory> sctp_factory) | 473 std::unique_ptr<cricket::SctpTransportInternalFactory> sctp_factory) |
471 : network_thread_(network_thread), | 474 : network_thread_(network_thread), |
472 worker_thread_(worker_thread), | 475 worker_thread_(worker_thread), |
473 signaling_thread_(signaling_thread), | 476 signaling_thread_(signaling_thread), |
474 // RFC 3264: The numeric value of the session id and version in the | 477 // RFC 3264: The numeric value of the session id and version in the |
475 // o line MUST be representable with a "64 bit signed integer". | 478 // o line MUST be representable with a "64 bit signed integer". |
476 // Due to this constraint session id |sid_| is max limited to LLONG_MAX. | 479 // Due to this constraint session id |sid_| is max limited to LLONG_MAX. |
477 sid_(rtc::ToString(rtc::CreateRandomId64() & LLONG_MAX)), | 480 sid_(rtc::ToString(rtc::CreateRandomId64() & LLONG_MAX)), |
478 transport_controller_(std::move(transport_controller)), | 481 transport_controller_(std::move(transport_controller)), |
479 sctp_factory_(std::move(sctp_factory)), | 482 sctp_factory_(std::move(sctp_factory)), |
480 media_controller_(media_controller), | 483 media_config_(media_config), |
481 channel_manager_(media_controller_->channel_manager()), | 484 event_log_(event_log), |
| 485 call_(call), |
| 486 channel_manager_(channel_manager), |
482 ice_observer_(NULL), | 487 ice_observer_(NULL), |
483 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), | 488 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), |
484 ice_connection_receiving_(true), | 489 ice_connection_receiving_(true), |
485 older_version_remote_peer_(false), | 490 older_version_remote_peer_(false), |
486 dtls_enabled_(false), | 491 dtls_enabled_(false), |
487 data_channel_type_(cricket::DCT_NONE), | 492 data_channel_type_(cricket::DCT_NONE), |
488 metrics_observer_(NULL) { | 493 metrics_observer_(NULL) { |
489 transport_controller_->SetIceRole(cricket::ICEROLE_CONTROLLED); | 494 transport_controller_->SetIceRole(cricket::ICEROLE_CONTROLLED); |
490 transport_controller_->SignalConnectionState.connect( | 495 transport_controller_->SignalConnectionState.connect( |
491 this, &WebRtcSession::OnTransportControllerConnectionState); | 496 this, &WebRtcSession::OnTransportControllerConnectionState); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 return true; | 628 return true; |
624 } | 629 } |
625 | 630 |
626 void WebRtcSession::Close() { | 631 void WebRtcSession::Close() { |
627 SetState(STATE_CLOSED); | 632 SetState(STATE_CLOSED); |
628 RemoveUnusedChannels(nullptr); | 633 RemoveUnusedChannels(nullptr); |
629 RTC_DCHECK(!voice_channel_); | 634 RTC_DCHECK(!voice_channel_); |
630 RTC_DCHECK(!video_channel_); | 635 RTC_DCHECK(!video_channel_); |
631 RTC_DCHECK(!rtp_data_channel_); | 636 RTC_DCHECK(!rtp_data_channel_); |
632 RTC_DCHECK(!sctp_transport_); | 637 RTC_DCHECK(!sctp_transport_); |
633 media_controller_->Close(); | |
634 } | 638 } |
635 | 639 |
636 cricket::BaseChannel* WebRtcSession::GetChannel( | 640 cricket::BaseChannel* WebRtcSession::GetChannel( |
637 const std::string& content_name) { | 641 const std::string& content_name) { |
638 if (voice_channel() && voice_channel()->content_name() == content_name) { | 642 if (voice_channel() && voice_channel()->content_name() == content_name) { |
639 return voice_channel(); | 643 return voice_channel(); |
640 } | 644 } |
641 if (video_channel() && video_channel()->content_name() == content_name) { | 645 if (video_channel() && video_channel()->content_name() == content_name) { |
642 return video_channel(); | 646 return video_channel(); |
643 } | 647 } |
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1750 cricket::DtlsTransportInternal* rtp_dtls_transport = | 1754 cricket::DtlsTransportInternal* rtp_dtls_transport = |
1751 transport_controller_->CreateDtlsTransport( | 1755 transport_controller_->CreateDtlsTransport( |
1752 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); | 1756 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); |
1753 cricket::DtlsTransportInternal* rtcp_dtls_transport = nullptr; | 1757 cricket::DtlsTransportInternal* rtcp_dtls_transport = nullptr; |
1754 if (!require_rtcp_mux) { | 1758 if (!require_rtcp_mux) { |
1755 rtcp_dtls_transport = transport_controller_->CreateDtlsTransport( | 1759 rtcp_dtls_transport = transport_controller_->CreateDtlsTransport( |
1756 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); | 1760 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); |
1757 } | 1761 } |
1758 | 1762 |
1759 voice_channel_.reset(channel_manager_->CreateVoiceChannel( | 1763 voice_channel_.reset(channel_manager_->CreateVoiceChannel( |
1760 media_controller_, rtp_dtls_transport, rtcp_dtls_transport, | 1764 call_, media_config_, rtp_dtls_transport, rtcp_dtls_transport, |
1761 transport_controller_->signaling_thread(), content->name, SrtpRequired(), | 1765 transport_controller_->signaling_thread(), content->name, SrtpRequired(), |
1762 audio_options_)); | 1766 audio_options_)); |
1763 if (!voice_channel_) { | 1767 if (!voice_channel_) { |
1764 transport_controller_->DestroyDtlsTransport( | 1768 transport_controller_->DestroyDtlsTransport( |
1765 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); | 1769 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); |
1766 if (rtcp_dtls_transport) { | 1770 if (rtcp_dtls_transport) { |
1767 transport_controller_->DestroyDtlsTransport( | 1771 transport_controller_->DestroyDtlsTransport( |
1768 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); | 1772 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); |
1769 } | 1773 } |
1770 return false; | 1774 return false; |
(...skipping 21 matching lines...) Expand all Loading... |
1792 cricket::DtlsTransportInternal* rtp_dtls_transport = | 1796 cricket::DtlsTransportInternal* rtp_dtls_transport = |
1793 transport_controller_->CreateDtlsTransport( | 1797 transport_controller_->CreateDtlsTransport( |
1794 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); | 1798 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); |
1795 cricket::DtlsTransportInternal* rtcp_dtls_transport = nullptr; | 1799 cricket::DtlsTransportInternal* rtcp_dtls_transport = nullptr; |
1796 if (!require_rtcp_mux) { | 1800 if (!require_rtcp_mux) { |
1797 rtcp_dtls_transport = transport_controller_->CreateDtlsTransport( | 1801 rtcp_dtls_transport = transport_controller_->CreateDtlsTransport( |
1798 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); | 1802 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); |
1799 } | 1803 } |
1800 | 1804 |
1801 video_channel_.reset(channel_manager_->CreateVideoChannel( | 1805 video_channel_.reset(channel_manager_->CreateVideoChannel( |
1802 media_controller_, rtp_dtls_transport, rtcp_dtls_transport, | 1806 call_, media_config_, rtp_dtls_transport, rtcp_dtls_transport, |
1803 transport_controller_->signaling_thread(), content->name, SrtpRequired(), | 1807 transport_controller_->signaling_thread(), content->name, SrtpRequired(), |
1804 video_options_)); | 1808 video_options_)); |
1805 | 1809 |
1806 if (!video_channel_) { | 1810 if (!video_channel_) { |
1807 transport_controller_->DestroyDtlsTransport( | 1811 transport_controller_->DestroyDtlsTransport( |
1808 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); | 1812 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); |
1809 if (rtcp_dtls_transport) { | 1813 if (rtcp_dtls_transport) { |
1810 transport_controller_->DestroyDtlsTransport( | 1814 transport_controller_->DestroyDtlsTransport( |
1811 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); | 1815 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); |
1812 } | 1816 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1857 cricket::DtlsTransportInternal* rtp_dtls_transport = | 1861 cricket::DtlsTransportInternal* rtp_dtls_transport = |
1858 transport_controller_->CreateDtlsTransport( | 1862 transport_controller_->CreateDtlsTransport( |
1859 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); | 1863 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); |
1860 cricket::DtlsTransportInternal* rtcp_dtls_transport = nullptr; | 1864 cricket::DtlsTransportInternal* rtcp_dtls_transport = nullptr; |
1861 if (!require_rtcp_mux) { | 1865 if (!require_rtcp_mux) { |
1862 rtcp_dtls_transport = transport_controller_->CreateDtlsTransport( | 1866 rtcp_dtls_transport = transport_controller_->CreateDtlsTransport( |
1863 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); | 1867 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); |
1864 } | 1868 } |
1865 | 1869 |
1866 rtp_data_channel_.reset(channel_manager_->CreateRtpDataChannel( | 1870 rtp_data_channel_.reset(channel_manager_->CreateRtpDataChannel( |
1867 media_controller_, rtp_dtls_transport, rtcp_dtls_transport, | 1871 media_config_, rtp_dtls_transport, rtcp_dtls_transport, |
1868 transport_controller_->signaling_thread(), content->name, | 1872 transport_controller_->signaling_thread(), content->name, |
1869 SrtpRequired())); | 1873 SrtpRequired())); |
1870 | 1874 |
1871 if (!rtp_data_channel_) { | 1875 if (!rtp_data_channel_) { |
1872 transport_controller_->DestroyDtlsTransport( | 1876 transport_controller_->DestroyDtlsTransport( |
1873 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); | 1877 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); |
1874 if (rtcp_dtls_transport) { | 1878 if (rtcp_dtls_transport) { |
1875 transport_controller_->DestroyDtlsTransport( | 1879 transport_controller_->DestroyDtlsTransport( |
1876 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); | 1880 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); |
1877 } | 1881 } |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2306 srtp_crypto_suite); | 2310 srtp_crypto_suite); |
2307 } | 2311 } |
2308 if (ssl_cipher_suite != rtc::TLS_NULL_WITH_NULL_NULL) { | 2312 if (ssl_cipher_suite != rtc::TLS_NULL_WITH_NULL_NULL) { |
2309 metrics_observer_->IncrementSparseEnumCounter(ssl_counter_type, | 2313 metrics_observer_->IncrementSparseEnumCounter(ssl_counter_type, |
2310 ssl_cipher_suite); | 2314 ssl_cipher_suite); |
2311 } | 2315 } |
2312 } | 2316 } |
2313 | 2317 |
2314 void WebRtcSession::OnSentPacket_w(const rtc::SentPacket& sent_packet) { | 2318 void WebRtcSession::OnSentPacket_w(const rtc::SentPacket& sent_packet) { |
2315 RTC_DCHECK(worker_thread()->IsCurrent()); | 2319 RTC_DCHECK(worker_thread()->IsCurrent()); |
2316 media_controller_->call_w()->OnSentPacket(sent_packet); | 2320 call_->OnSentPacket(sent_packet); |
2317 } | 2321 } |
2318 | 2322 |
2319 const std::string WebRtcSession::GetTransportName( | 2323 const std::string WebRtcSession::GetTransportName( |
2320 const std::string& content_name) { | 2324 const std::string& content_name) { |
2321 cricket::BaseChannel* channel = GetChannel(content_name); | 2325 cricket::BaseChannel* channel = GetChannel(content_name); |
2322 if (!channel) { | 2326 if (!channel) { |
2323 #ifdef HAVE_QUIC | 2327 #ifdef HAVE_QUIC |
2324 if (data_channel_type_ == cricket::DCT_QUIC && quic_data_transport_ && | 2328 if (data_channel_type_ == cricket::DCT_QUIC && quic_data_transport_ && |
2325 content_name == quic_data_transport_->transport_name()) { | 2329 content_name == quic_data_transport_->transport_name()) { |
2326 return quic_data_transport_->transport_name(); | 2330 return quic_data_transport_->transport_name(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2384 (rtp_data_channel_->rtcp_dtls_transport() != nullptr); | 2388 (rtp_data_channel_->rtcp_dtls_transport() != nullptr); |
2385 channel_manager_->DestroyRtpDataChannel(rtp_data_channel_.release()); | 2389 channel_manager_->DestroyRtpDataChannel(rtp_data_channel_.release()); |
2386 transport_controller_->DestroyDtlsTransport( | 2390 transport_controller_->DestroyDtlsTransport( |
2387 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); | 2391 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); |
2388 if (need_to_delete_rtcp) { | 2392 if (need_to_delete_rtcp) { |
2389 transport_controller_->DestroyDtlsTransport( | 2393 transport_controller_->DestroyDtlsTransport( |
2390 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); | 2394 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); |
2391 } | 2395 } |
2392 } | 2396 } |
2393 } // namespace webrtc | 2397 } // namespace webrtc |
OLD | NEW |