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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 LOG(LS_INFO) << "Remote peer requests ICE restart for " << content_name | 465 LOG(LS_INFO) << "Remote peer requests ICE restart for " << content_name |
466 << "."; | 466 << "."; |
467 return true; | 467 return true; |
468 } | 468 } |
469 return false; | 469 return false; |
470 } | 470 } |
471 | 471 |
472 WebRtcSession::WebRtcSession(webrtc::MediaControllerInterface* media_controller, | 472 WebRtcSession::WebRtcSession(webrtc::MediaControllerInterface* media_controller, |
473 rtc::Thread* signaling_thread, | 473 rtc::Thread* signaling_thread, |
474 rtc::Thread* worker_thread, | 474 rtc::Thread* worker_thread, |
| 475 rtc::Thread* network_thread, |
475 cricket::PortAllocator* port_allocator) | 476 cricket::PortAllocator* port_allocator) |
476 : signaling_thread_(signaling_thread), | 477 : signaling_thread_(signaling_thread), |
477 worker_thread_(worker_thread), | 478 worker_thread_(worker_thread), |
478 port_allocator_(port_allocator), | 479 port_allocator_(port_allocator), |
479 // RFC 3264: The numeric value of the session id and version in the | 480 // RFC 3264: The numeric value of the session id and version in the |
480 // o line MUST be representable with a "64 bit signed integer". | 481 // o line MUST be representable with a "64 bit signed integer". |
481 // Due to this constraint session id |sid_| is max limited to LLONG_MAX. | 482 // Due to this constraint session id |sid_| is max limited to LLONG_MAX. |
482 sid_(rtc::ToString(rtc::CreateRandomId64() & LLONG_MAX)), | 483 sid_(rtc::ToString(rtc::CreateRandomId64() & LLONG_MAX)), |
483 transport_controller_(new cricket::TransportController(signaling_thread, | 484 transport_controller_(new cricket::TransportController(signaling_thread, |
484 worker_thread, | 485 network_thread, |
485 port_allocator)), | 486 port_allocator)), |
486 media_controller_(media_controller), | 487 media_controller_(media_controller), |
487 channel_manager_(media_controller_->channel_manager()), | 488 channel_manager_(media_controller_->channel_manager()), |
488 ice_observer_(NULL), | 489 ice_observer_(NULL), |
489 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), | 490 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), |
490 ice_connection_receiving_(true), | 491 ice_connection_receiving_(true), |
491 older_version_remote_peer_(false), | 492 older_version_remote_peer_(false), |
492 dtls_enabled_(false), | 493 dtls_enabled_(false), |
493 data_channel_type_(cricket::DCT_NONE), | 494 data_channel_type_(cricket::DCT_NONE), |
494 metrics_observer_(NULL) { | 495 metrics_observer_(NULL) { |
(...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1791 audio_options_)); | 1792 audio_options_)); |
1792 if (!voice_channel_) { | 1793 if (!voice_channel_) { |
1793 return false; | 1794 return false; |
1794 } | 1795 } |
1795 | 1796 |
1796 voice_channel_->SignalDtlsSetupFailure.connect( | 1797 voice_channel_->SignalDtlsSetupFailure.connect( |
1797 this, &WebRtcSession::OnDtlsSetupFailure); | 1798 this, &WebRtcSession::OnDtlsSetupFailure); |
1798 | 1799 |
1799 SignalVoiceChannelCreated(); | 1800 SignalVoiceChannelCreated(); |
1800 voice_channel_->transport_channel()->SignalSentPacket.connect( | 1801 voice_channel_->transport_channel()->SignalSentPacket.connect( |
1801 this, &WebRtcSession::OnSentPacket_w); | 1802 this, &WebRtcSession::OnSentPacket_n); |
1802 return true; | 1803 return true; |
1803 } | 1804 } |
1804 | 1805 |
1805 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content) { | 1806 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content) { |
1806 video_channel_.reset(channel_manager_->CreateVideoChannel( | 1807 video_channel_.reset(channel_manager_->CreateVideoChannel( |
1807 media_controller_, transport_controller_.get(), content->name, true, | 1808 media_controller_, transport_controller_.get(), content->name, true, |
1808 video_options_)); | 1809 video_options_)); |
1809 if (!video_channel_) { | 1810 if (!video_channel_) { |
1810 return false; | 1811 return false; |
1811 } | 1812 } |
1812 | 1813 |
1813 video_channel_->SignalDtlsSetupFailure.connect( | 1814 video_channel_->SignalDtlsSetupFailure.connect( |
1814 this, &WebRtcSession::OnDtlsSetupFailure); | 1815 this, &WebRtcSession::OnDtlsSetupFailure); |
1815 | 1816 |
1816 SignalVideoChannelCreated(); | 1817 SignalVideoChannelCreated(); |
1817 video_channel_->transport_channel()->SignalSentPacket.connect( | 1818 video_channel_->transport_channel()->SignalSentPacket.connect( |
1818 this, &WebRtcSession::OnSentPacket_w); | 1819 this, &WebRtcSession::OnSentPacket_n); |
1819 return true; | 1820 return true; |
1820 } | 1821 } |
1821 | 1822 |
1822 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content) { | 1823 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content) { |
1823 bool sctp = (data_channel_type_ == cricket::DCT_SCTP); | 1824 bool sctp = (data_channel_type_ == cricket::DCT_SCTP); |
1824 data_channel_.reset(channel_manager_->CreateDataChannel( | 1825 data_channel_.reset(channel_manager_->CreateDataChannel( |
1825 transport_controller_.get(), content->name, !sctp, data_channel_type_)); | 1826 transport_controller_.get(), content->name, !sctp, data_channel_type_)); |
1826 if (!data_channel_) { | 1827 if (!data_channel_) { |
1827 return false; | 1828 return false; |
1828 } | 1829 } |
1829 | 1830 |
1830 if (sctp) { | 1831 if (sctp) { |
1831 data_channel_->SignalDataReceived.connect( | 1832 data_channel_->SignalDataReceived.connect( |
1832 this, &WebRtcSession::OnDataChannelMessageReceived); | 1833 this, &WebRtcSession::OnDataChannelMessageReceived); |
1833 } | 1834 } |
1834 | 1835 |
1835 data_channel_->SignalDtlsSetupFailure.connect( | 1836 data_channel_->SignalDtlsSetupFailure.connect( |
1836 this, &WebRtcSession::OnDtlsSetupFailure); | 1837 this, &WebRtcSession::OnDtlsSetupFailure); |
1837 | 1838 |
1838 SignalDataChannelCreated(); | 1839 SignalDataChannelCreated(); |
1839 data_channel_->transport_channel()->SignalSentPacket.connect( | 1840 data_channel_->transport_channel()->SignalSentPacket.connect( |
1840 this, &WebRtcSession::OnSentPacket_w); | 1841 this, &WebRtcSession::OnSentPacket_n); |
1841 return true; | 1842 return true; |
1842 } | 1843 } |
1843 | 1844 |
1844 void WebRtcSession::OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp) { | 1845 void WebRtcSession::OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp) { |
1845 SetError(ERROR_TRANSPORT, | 1846 SetError(ERROR_TRANSPORT, |
1846 rtcp ? kDtlsSetupFailureRtcp : kDtlsSetupFailureRtp); | 1847 rtcp ? kDtlsSetupFailureRtcp : kDtlsSetupFailureRtp); |
1847 } | 1848 } |
1848 | 1849 |
1849 void WebRtcSession::OnDataChannelMessageReceived( | 1850 void WebRtcSession::OnDataChannelMessageReceived( |
1850 cricket::DataChannel* channel, | 1851 cricket::DataChannel* channel, |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2148 if (srtp_crypto_suite != rtc::SRTP_INVALID_CRYPTO_SUITE) { | 2149 if (srtp_crypto_suite != rtc::SRTP_INVALID_CRYPTO_SUITE) { |
2149 metrics_observer_->IncrementSparseEnumCounter(srtp_counter_type, | 2150 metrics_observer_->IncrementSparseEnumCounter(srtp_counter_type, |
2150 srtp_crypto_suite); | 2151 srtp_crypto_suite); |
2151 } | 2152 } |
2152 if (ssl_cipher_suite != rtc::TLS_NULL_WITH_NULL_NULL) { | 2153 if (ssl_cipher_suite != rtc::TLS_NULL_WITH_NULL_NULL) { |
2153 metrics_observer_->IncrementSparseEnumCounter(ssl_counter_type, | 2154 metrics_observer_->IncrementSparseEnumCounter(ssl_counter_type, |
2154 ssl_cipher_suite); | 2155 ssl_cipher_suite); |
2155 } | 2156 } |
2156 } | 2157 } |
2157 | 2158 |
2158 void WebRtcSession::OnSentPacket_w(cricket::TransportChannel* channel, | 2159 void WebRtcSession::OnSentPacket_n(cricket::TransportChannel* channel, |
2159 const rtc::SentPacket& sent_packet) { | 2160 const rtc::SentPacket& sent_packet) { |
2160 RTC_DCHECK(worker_thread()->IsCurrent()); | 2161 media_controller_->call()->OnSentPacket(sent_packet); |
2161 media_controller_->call_w()->OnSentPacket(sent_packet); | |
2162 } | 2162 } |
2163 | 2163 |
2164 } // namespace webrtc | 2164 } // namespace webrtc |
OLD | NEW |