OLD | NEW |
---|---|
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTCP); | 211 transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTCP); |
212 } | 212 } |
213 LOG(LS_INFO) << "Destroyed channel"; | 213 LOG(LS_INFO) << "Destroyed channel"; |
214 } | 214 } |
215 | 215 |
216 bool BaseChannel::Init() { | 216 bool BaseChannel::Init() { |
217 if (!SetTransport(content_name())) { | 217 if (!SetTransport(content_name())) { |
218 return false; | 218 return false; |
219 } | 219 } |
220 | 220 |
221 if (!SetDtlsSrtpCiphers(transport_channel(), false)) { | 221 if (!SetDtlsSrtpCryptoSuites(transport_channel(), false)) { |
222 return false; | 222 return false; |
223 } | 223 } |
224 if (rtcp_transport_enabled() && | 224 if (rtcp_transport_enabled() && |
225 !SetDtlsSrtpCiphers(rtcp_transport_channel(), true)) { | 225 !SetDtlsSrtpCryptoSuites(rtcp_transport_channel(), true)) { |
226 return false; | 226 return false; |
227 } | 227 } |
228 | 228 |
229 // Both RTP and RTCP channels are set, we can call SetInterface on | 229 // Both RTP and RTCP channels are set, we can call SetInterface on |
230 // media channel and it can set network options. | 230 // media channel and it can set network options. |
231 media_channel_->SetInterface(this); | 231 media_channel_->SetInterface(this); |
232 return true; | 232 return true; |
233 } | 233 } |
234 | 234 |
235 void BaseChannel::Deinit() { | 235 void BaseChannel::Deinit() { |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
799 ASSERT(worker_thread() == rtc::Thread::Current()); | 799 ASSERT(worker_thread() == rtc::Thread::Current()); |
800 signaling_thread()->Invoke<void>(Bind( | 800 signaling_thread()->Invoke<void>(Bind( |
801 &BaseChannel::SignalDtlsSetupFailure_s, this, rtcp)); | 801 &BaseChannel::SignalDtlsSetupFailure_s, this, rtcp)); |
802 } | 802 } |
803 | 803 |
804 void BaseChannel::SignalDtlsSetupFailure_s(bool rtcp) { | 804 void BaseChannel::SignalDtlsSetupFailure_s(bool rtcp) { |
805 ASSERT(signaling_thread() == rtc::Thread::Current()); | 805 ASSERT(signaling_thread() == rtc::Thread::Current()); |
806 SignalDtlsSetupFailure(this, rtcp); | 806 SignalDtlsSetupFailure(this, rtcp); |
807 } | 807 } |
808 | 808 |
809 bool BaseChannel::SetDtlsSrtpCiphers(TransportChannel *tc, bool rtcp) { | 809 bool BaseChannel::SetDtlsSrtpCryptoSuites(TransportChannel* tc, bool rtcp) { |
810 std::vector<std::string> ciphers; | 810 std::vector<int> ciphers; |
pthatcher1
2015/11/11 19:59:40
Similarly here, with crypto_suites?
guoweis_webrtc
2015/11/17 01:21:15
Done.
| |
811 // We always use the default SRTP ciphers for RTCP, but we may use different | 811 // We always use the default SRTP ciphers for RTCP, but we may use different |
812 // ciphers for RTP depending on the media type. | 812 // ciphers for RTP depending on the media type. |
813 if (!rtcp) { | 813 if (!rtcp) { |
814 GetSrtpCryptoSuiteNames(&ciphers); | 814 GetSrtpCryptoSuites(&ciphers); |
815 } else { | 815 } else { |
816 GetDefaultSrtpCryptoSuiteNames(&ciphers); | 816 GetDefaultSrtpCryptoSuites(&ciphers); |
817 } | 817 } |
818 return tc->SetSrtpCiphers(ciphers); | 818 return tc->SetSrtpCryptoSuites(ciphers); |
819 } | 819 } |
820 | 820 |
821 bool BaseChannel::ShouldSetupDtlsSrtp() const { | 821 bool BaseChannel::ShouldSetupDtlsSrtp() const { |
822 return true; | 822 return true; |
823 } | 823 } |
824 | 824 |
825 // This function returns true if either DTLS-SRTP is not in use | 825 // This function returns true if either DTLS-SRTP is not in use |
826 // *or* DTLS-SRTP is successfully set up. | 826 // *or* DTLS-SRTP is successfully set up. |
827 bool BaseChannel::SetupDtlsSrtp(bool rtcp_channel) { | 827 bool BaseChannel::SetupDtlsSrtp(bool rtcp_channel) { |
828 bool ret = false; | 828 bool ret = false; |
829 | 829 |
830 TransportChannel* channel = | 830 TransportChannel* channel = |
831 rtcp_channel ? rtcp_transport_channel_ : transport_channel_; | 831 rtcp_channel ? rtcp_transport_channel_ : transport_channel_; |
832 | 832 |
833 // No DTLS | 833 // No DTLS |
834 if (!channel->IsDtlsActive()) | 834 if (!channel->IsDtlsActive()) |
835 return true; | 835 return true; |
836 | 836 |
837 std::string selected_cipher; | 837 int selected_cipher; |
pthatcher1
2015/11/11 19:59:40
And here with selected_crypto_suite?
guoweis_webrtc
2015/11/17 01:21:15
Done.
| |
838 | 838 |
839 if (!channel->GetSrtpCryptoSuite(&selected_cipher)) { | 839 if (!channel->GetSrtpCryptoSuite(&selected_cipher)) { |
840 LOG(LS_ERROR) << "No DTLS-SRTP selected cipher"; | 840 LOG(LS_ERROR) << "No DTLS-SRTP selected cipher"; |
841 return false; | 841 return false; |
842 } | 842 } |
843 | 843 |
844 LOG(LS_INFO) << "Installing keys from DTLS-SRTP on " | 844 LOG(LS_INFO) << "Installing keys from DTLS-SRTP on " |
845 << content_name() << " " | 845 << content_name() << " " |
846 << PacketType(rtcp_channel); | 846 << PacketType(rtcp_channel); |
847 | 847 |
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1574 VoiceMediaChannel* media_channel, const VoiceMediaInfo& info) { | 1574 VoiceMediaChannel* media_channel, const VoiceMediaInfo& info) { |
1575 ASSERT(media_channel == this->media_channel()); | 1575 ASSERT(media_channel == this->media_channel()); |
1576 SignalMediaMonitor(this, info); | 1576 SignalMediaMonitor(this, info); |
1577 } | 1577 } |
1578 | 1578 |
1579 void VoiceChannel::OnAudioMonitorUpdate(AudioMonitor* monitor, | 1579 void VoiceChannel::OnAudioMonitorUpdate(AudioMonitor* monitor, |
1580 const AudioInfo& info) { | 1580 const AudioInfo& info) { |
1581 SignalAudioMonitor(this, info); | 1581 SignalAudioMonitor(this, info); |
1582 } | 1582 } |
1583 | 1583 |
1584 void VoiceChannel::GetSrtpCryptoSuiteNames( | 1584 void VoiceChannel::GetSrtpCryptoSuites(std::vector<int>* ciphers) const { |
1585 std::vector<std::string>* ciphers) const { | |
1586 GetSupportedAudioCryptoSuites(ciphers); | 1585 GetSupportedAudioCryptoSuites(ciphers); |
1587 } | 1586 } |
1588 | 1587 |
1589 VideoChannel::VideoChannel(rtc::Thread* thread, | 1588 VideoChannel::VideoChannel(rtc::Thread* thread, |
1590 VideoMediaChannel* media_channel, | 1589 VideoMediaChannel* media_channel, |
1591 TransportController* transport_controller, | 1590 TransportController* transport_controller, |
1592 const std::string& content_name, | 1591 const std::string& content_name, |
1593 bool rtcp) | 1592 bool rtcp) |
1594 : BaseChannel(thread, | 1593 : BaseChannel(thread, |
1595 media_channel, | 1594 media_channel, |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1964 for (ScreencastMap::iterator iter = screencast_capturers_.begin(); | 1963 for (ScreencastMap::iterator iter = screencast_capturers_.begin(); |
1965 iter != screencast_capturers_.end(); ++iter) { | 1964 iter != screencast_capturers_.end(); ++iter) { |
1966 if (iter->second == capturer) { | 1965 if (iter->second == capturer) { |
1967 *ssrc = iter->first; | 1966 *ssrc = iter->first; |
1968 return true; | 1967 return true; |
1969 } | 1968 } |
1970 } | 1969 } |
1971 return false; | 1970 return false; |
1972 } | 1971 } |
1973 | 1972 |
1974 void VideoChannel::GetSrtpCryptoSuiteNames( | 1973 void VideoChannel::GetSrtpCryptoSuites(std::vector<int>* ciphers) const { |
1975 std::vector<std::string>* ciphers) const { | |
1976 GetSupportedVideoCryptoSuites(ciphers); | 1974 GetSupportedVideoCryptoSuites(ciphers); |
1977 } | 1975 } |
1978 | 1976 |
1979 DataChannel::DataChannel(rtc::Thread* thread, | 1977 DataChannel::DataChannel(rtc::Thread* thread, |
1980 DataMediaChannel* media_channel, | 1978 DataMediaChannel* media_channel, |
1981 TransportController* transport_controller, | 1979 TransportController* transport_controller, |
1982 const std::string& content_name, | 1980 const std::string& content_name, |
1983 bool rtcp) | 1981 bool rtcp) |
1984 : BaseChannel(thread, | 1982 : BaseChannel(thread, |
1985 media_channel, | 1983 media_channel, |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2272 } | 2270 } |
2273 | 2271 |
2274 void DataChannel::OnDataChannelReadyToSend(bool writable) { | 2272 void DataChannel::OnDataChannelReadyToSend(bool writable) { |
2275 // This is usded for congestion control to indicate that the stream is ready | 2273 // This is usded for congestion control to indicate that the stream is ready |
2276 // to send by the MediaChannel, as opposed to OnReadyToSend, which indicates | 2274 // to send by the MediaChannel, as opposed to OnReadyToSend, which indicates |
2277 // that the transport channel is ready. | 2275 // that the transport channel is ready. |
2278 signaling_thread()->Post(this, MSG_READYTOSENDDATA, | 2276 signaling_thread()->Post(this, MSG_READYTOSENDDATA, |
2279 new DataChannelReadyToSendMessageData(writable)); | 2277 new DataChannelReadyToSendMessageData(writable)); |
2280 } | 2278 } |
2281 | 2279 |
2282 void DataChannel::GetSrtpCryptoSuiteNames( | 2280 void DataChannel::GetSrtpCryptoSuites(std::vector<int>* ciphers) const { |
2283 std::vector<std::string>* ciphers) const { | |
2284 GetSupportedDataCryptoSuites(ciphers); | 2281 GetSupportedDataCryptoSuites(ciphers); |
2285 } | 2282 } |
2286 | 2283 |
2287 bool DataChannel::ShouldSetupDtlsSrtp() const { | 2284 bool DataChannel::ShouldSetupDtlsSrtp() const { |
2288 return (data_channel_type_ == DCT_RTP); | 2285 return (data_channel_type_ == DCT_RTP); |
2289 } | 2286 } |
2290 | 2287 |
2291 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { | 2288 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { |
2292 rtc::TypedMessageData<uint32_t>* message = | 2289 rtc::TypedMessageData<uint32_t>* message = |
2293 new rtc::TypedMessageData<uint32_t>(sid); | 2290 new rtc::TypedMessageData<uint32_t>(sid); |
2294 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message); | 2291 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message); |
2295 } | 2292 } |
2296 | 2293 |
2297 } // namespace cricket | 2294 } // namespace cricket |
OLD | NEW |