| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2004 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 235 |
| 236 bool BaseChannel::InitNetwork_n( | 236 bool BaseChannel::InitNetwork_n( |
| 237 DtlsTransportInternal* rtp_dtls_transport, | 237 DtlsTransportInternal* rtp_dtls_transport, |
| 238 DtlsTransportInternal* rtcp_dtls_transport, | 238 DtlsTransportInternal* rtcp_dtls_transport, |
| 239 rtc::PacketTransportInternal* rtp_packet_transport, | 239 rtc::PacketTransportInternal* rtp_packet_transport, |
| 240 rtc::PacketTransportInternal* rtcp_packet_transport) { | 240 rtc::PacketTransportInternal* rtcp_packet_transport) { |
| 241 RTC_DCHECK(network_thread_->IsCurrent()); | 241 RTC_DCHECK(network_thread_->IsCurrent()); |
| 242 SetTransports_n(rtp_dtls_transport, rtcp_dtls_transport, rtp_packet_transport, | 242 SetTransports_n(rtp_dtls_transport, rtcp_dtls_transport, rtp_packet_transport, |
| 243 rtcp_packet_transport); | 243 rtcp_packet_transport); |
| 244 | 244 |
| 245 if (rtp_dtls_transport_ && | |
| 246 !SetDtlsSrtpCryptoSuites_n(rtp_dtls_transport_, false)) { | |
| 247 return false; | |
| 248 } | |
| 249 if (rtcp_dtls_transport_ && | |
| 250 !SetDtlsSrtpCryptoSuites_n(rtcp_dtls_transport_, true)) { | |
| 251 return false; | |
| 252 } | |
| 253 if (rtp_transport_.rtcp_mux_required()) { | 245 if (rtp_transport_.rtcp_mux_required()) { |
| 254 rtcp_mux_filter_.SetActive(); | 246 rtcp_mux_filter_.SetActive(); |
| 255 } | 247 } |
| 256 return true; | 248 return true; |
| 257 } | 249 } |
| 258 | 250 |
| 259 void BaseChannel::Deinit() { | 251 void BaseChannel::Deinit() { |
| 260 RTC_DCHECK(worker_thread_->IsCurrent()); | 252 RTC_DCHECK(worker_thread_->IsCurrent()); |
| 261 media_channel_->SetInterface(NULL); | 253 media_channel_->SetInterface(NULL); |
| 262 // Packets arrive on the network thread, processing packets calls virtual | 254 // Packets arrive on the network thread, processing packets calls virtual |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 break; | 575 break; |
| 584 case ST_RTCP: | 576 case ST_RTCP: |
| 585 transport = rtp_transport_.rtcp_packet_transport(); | 577 transport = rtp_transport_.rtcp_packet_transport(); |
| 586 rtcp_socket_options_.push_back( | 578 rtcp_socket_options_.push_back( |
| 587 std::pair<rtc::Socket::Option, int>(opt, value)); | 579 std::pair<rtc::Socket::Option, int>(opt, value)); |
| 588 break; | 580 break; |
| 589 } | 581 } |
| 590 return transport ? transport->SetOption(opt, value) : -1; | 582 return transport ? transport->SetOption(opt, value) : -1; |
| 591 } | 583 } |
| 592 | 584 |
| 593 bool BaseChannel::SetCryptoOptions(const rtc::CryptoOptions& crypto_options) { | |
| 594 crypto_options_ = crypto_options; | |
| 595 return true; | |
| 596 } | |
| 597 | |
| 598 void BaseChannel::OnWritableState(rtc::PacketTransportInternal* transport) { | 585 void BaseChannel::OnWritableState(rtc::PacketTransportInternal* transport) { |
| 599 RTC_DCHECK(transport == rtp_transport_.rtp_packet_transport() || | 586 RTC_DCHECK(transport == rtp_transport_.rtp_packet_transport() || |
| 600 transport == rtp_transport_.rtcp_packet_transport()); | 587 transport == rtp_transport_.rtcp_packet_transport()); |
| 601 RTC_DCHECK(network_thread_->IsCurrent()); | 588 RTC_DCHECK(network_thread_->IsCurrent()); |
| 602 UpdateWritableState_n(); | 589 UpdateWritableState_n(); |
| 603 } | 590 } |
| 604 | 591 |
| 605 void BaseChannel::OnPacketRead(rtc::PacketTransportInternal* transport, | 592 void BaseChannel::OnPacketRead(rtc::PacketTransportInternal* transport, |
| 606 const char* data, | 593 const char* data, |
| 607 size_t len, | 594 size_t len, |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 invoker_.AsyncInvoke<void>( | 1001 invoker_.AsyncInvoke<void>( |
| 1015 RTC_FROM_HERE, signaling_thread(), | 1002 RTC_FROM_HERE, signaling_thread(), |
| 1016 Bind(&BaseChannel::SignalDtlsSrtpSetupFailure_s, this, rtcp)); | 1003 Bind(&BaseChannel::SignalDtlsSrtpSetupFailure_s, this, rtcp)); |
| 1017 } | 1004 } |
| 1018 | 1005 |
| 1019 void BaseChannel::SignalDtlsSrtpSetupFailure_s(bool rtcp) { | 1006 void BaseChannel::SignalDtlsSrtpSetupFailure_s(bool rtcp) { |
| 1020 RTC_DCHECK(signaling_thread() == rtc::Thread::Current()); | 1007 RTC_DCHECK(signaling_thread() == rtc::Thread::Current()); |
| 1021 SignalDtlsSrtpSetupFailure(this, rtcp); | 1008 SignalDtlsSrtpSetupFailure(this, rtcp); |
| 1022 } | 1009 } |
| 1023 | 1010 |
| 1024 bool BaseChannel::SetDtlsSrtpCryptoSuites_n(DtlsTransportInternal* transport, | |
| 1025 bool rtcp) { | |
| 1026 std::vector<int> crypto_suites; | |
| 1027 // We always use the default SRTP crypto suites for RTCP, but we may use | |
| 1028 // different crypto suites for RTP depending on the media type. | |
| 1029 if (!rtcp) { | |
| 1030 GetSrtpCryptoSuites_n(&crypto_suites); | |
| 1031 } else { | |
| 1032 GetDefaultSrtpCryptoSuites(crypto_options(), &crypto_suites); | |
| 1033 } | |
| 1034 return transport->SetSrtpCryptoSuites(crypto_suites); | |
| 1035 } | |
| 1036 | |
| 1037 bool BaseChannel::ShouldSetupDtlsSrtp_n() const { | 1011 bool BaseChannel::ShouldSetupDtlsSrtp_n() const { |
| 1038 // Since DTLS is applied to all transports, checking RTP should be enough. | 1012 // Since DTLS is applied to all transports, checking RTP should be enough. |
| 1039 return rtp_dtls_transport_ && rtp_dtls_transport_->IsDtlsActive(); | 1013 return rtp_dtls_transport_ && rtp_dtls_transport_->IsDtlsActive(); |
| 1040 } | 1014 } |
| 1041 | 1015 |
| 1042 // This function returns true if either DTLS-SRTP is not in use | 1016 // This function returns true if either DTLS-SRTP is not in use |
| 1043 // *or* DTLS-SRTP is successfully set up. | 1017 // *or* DTLS-SRTP is successfully set up. |
| 1044 bool BaseChannel::SetupDtlsSrtp_n(bool rtcp) { | 1018 bool BaseChannel::SetupDtlsSrtp_n(bool rtcp) { |
| 1045 RTC_DCHECK(network_thread_->IsCurrent()); | 1019 RTC_DCHECK(network_thread_->IsCurrent()); |
| 1046 bool ret = false; | 1020 bool ret = false; |
| (...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1949 VoiceMediaChannel* media_channel, const VoiceMediaInfo& info) { | 1923 VoiceMediaChannel* media_channel, const VoiceMediaInfo& info) { |
| 1950 RTC_DCHECK(media_channel == this->media_channel()); | 1924 RTC_DCHECK(media_channel == this->media_channel()); |
| 1951 SignalMediaMonitor(this, info); | 1925 SignalMediaMonitor(this, info); |
| 1952 } | 1926 } |
| 1953 | 1927 |
| 1954 void VoiceChannel::OnAudioMonitorUpdate(AudioMonitor* monitor, | 1928 void VoiceChannel::OnAudioMonitorUpdate(AudioMonitor* monitor, |
| 1955 const AudioInfo& info) { | 1929 const AudioInfo& info) { |
| 1956 SignalAudioMonitor(this, info); | 1930 SignalAudioMonitor(this, info); |
| 1957 } | 1931 } |
| 1958 | 1932 |
| 1959 void VoiceChannel::GetSrtpCryptoSuites_n( | |
| 1960 std::vector<int>* crypto_suites) const { | |
| 1961 GetSupportedAudioCryptoSuites(crypto_options(), crypto_suites); | |
| 1962 } | |
| 1963 | |
| 1964 VideoChannel::VideoChannel(rtc::Thread* worker_thread, | 1933 VideoChannel::VideoChannel(rtc::Thread* worker_thread, |
| 1965 rtc::Thread* network_thread, | 1934 rtc::Thread* network_thread, |
| 1966 rtc::Thread* signaling_thread, | 1935 rtc::Thread* signaling_thread, |
| 1967 VideoMediaChannel* media_channel, | 1936 VideoMediaChannel* media_channel, |
| 1968 const std::string& content_name, | 1937 const std::string& content_name, |
| 1969 bool rtcp_mux_required, | 1938 bool rtcp_mux_required, |
| 1970 bool srtp_required) | 1939 bool srtp_required) |
| 1971 : BaseChannel(worker_thread, | 1940 : BaseChannel(worker_thread, |
| 1972 network_thread, | 1941 network_thread, |
| 1973 signaling_thread, | 1942 signaling_thread, |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2205 } | 2174 } |
| 2206 | 2175 |
| 2207 // TODO(pthatcher): Look into removing duplicate code between | 2176 // TODO(pthatcher): Look into removing duplicate code between |
| 2208 // audio, video, and data, perhaps by using templates. | 2177 // audio, video, and data, perhaps by using templates. |
| 2209 void VideoChannel::OnMediaMonitorUpdate( | 2178 void VideoChannel::OnMediaMonitorUpdate( |
| 2210 VideoMediaChannel* media_channel, const VideoMediaInfo &info) { | 2179 VideoMediaChannel* media_channel, const VideoMediaInfo &info) { |
| 2211 RTC_DCHECK(media_channel == this->media_channel()); | 2180 RTC_DCHECK(media_channel == this->media_channel()); |
| 2212 SignalMediaMonitor(this, info); | 2181 SignalMediaMonitor(this, info); |
| 2213 } | 2182 } |
| 2214 | 2183 |
| 2215 void VideoChannel::GetSrtpCryptoSuites_n( | |
| 2216 std::vector<int>* crypto_suites) const { | |
| 2217 GetSupportedVideoCryptoSuites(crypto_options(), crypto_suites); | |
| 2218 } | |
| 2219 | |
| 2220 RtpDataChannel::RtpDataChannel(rtc::Thread* worker_thread, | 2184 RtpDataChannel::RtpDataChannel(rtc::Thread* worker_thread, |
| 2221 rtc::Thread* network_thread, | 2185 rtc::Thread* network_thread, |
| 2222 rtc::Thread* signaling_thread, | 2186 rtc::Thread* signaling_thread, |
| 2223 DataMediaChannel* media_channel, | 2187 DataMediaChannel* media_channel, |
| 2224 const std::string& content_name, | 2188 const std::string& content_name, |
| 2225 bool rtcp_mux_required, | 2189 bool rtcp_mux_required, |
| 2226 bool srtp_required) | 2190 bool srtp_required) |
| 2227 : BaseChannel(worker_thread, | 2191 : BaseChannel(worker_thread, |
| 2228 network_thread, | 2192 network_thread, |
| 2229 signaling_thread, | 2193 signaling_thread, |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2480 } | 2444 } |
| 2481 | 2445 |
| 2482 void RtpDataChannel::OnDataChannelReadyToSend(bool writable) { | 2446 void RtpDataChannel::OnDataChannelReadyToSend(bool writable) { |
| 2483 // This is usded for congestion control to indicate that the stream is ready | 2447 // This is usded for congestion control to indicate that the stream is ready |
| 2484 // to send by the MediaChannel, as opposed to OnReadyToSend, which indicates | 2448 // to send by the MediaChannel, as opposed to OnReadyToSend, which indicates |
| 2485 // that the transport channel is ready. | 2449 // that the transport channel is ready. |
| 2486 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA, | 2450 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA, |
| 2487 new DataChannelReadyToSendMessageData(writable)); | 2451 new DataChannelReadyToSendMessageData(writable)); |
| 2488 } | 2452 } |
| 2489 | 2453 |
| 2490 void RtpDataChannel::GetSrtpCryptoSuites_n( | |
| 2491 std::vector<int>* crypto_suites) const { | |
| 2492 GetSupportedDataCryptoSuites(crypto_options(), crypto_suites); | |
| 2493 } | |
| 2494 | |
| 2495 } // namespace cricket | 2454 } // namespace cricket |
| OLD | NEW |