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 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 void BaseChannel::SignalDtlsSetupFailure_s(bool rtcp) { | 809 void BaseChannel::SignalDtlsSetupFailure_s(bool rtcp) { |
810 ASSERT(signaling_thread() == rtc::Thread::Current()); | 810 ASSERT(signaling_thread() == rtc::Thread::Current()); |
811 SignalDtlsSetupFailure(this, rtcp); | 811 SignalDtlsSetupFailure(this, rtcp); |
812 } | 812 } |
813 | 813 |
814 bool BaseChannel::SetDtlsSrtpCiphers(TransportChannel *tc, bool rtcp) { | 814 bool BaseChannel::SetDtlsSrtpCiphers(TransportChannel *tc, bool rtcp) { |
815 std::vector<std::string> ciphers; | 815 std::vector<std::string> ciphers; |
816 // We always use the default SRTP ciphers for RTCP, but we may use different | 816 // We always use the default SRTP ciphers for RTCP, but we may use different |
817 // ciphers for RTP depending on the media type. | 817 // ciphers for RTP depending on the media type. |
818 if (!rtcp) { | 818 if (!rtcp) { |
819 GetSrtpCryptoSuiteNames(&ciphers); | 819 GetSrtpCiphers(&ciphers); |
820 } else { | 820 } else { |
821 GetDefaultSrtpCryptoSuiteNames(&ciphers); | 821 GetSupportedDefaultCryptoSuites(&ciphers); |
822 } | 822 } |
823 return tc->SetSrtpCiphers(ciphers); | 823 return tc->SetSrtpCiphers(ciphers); |
824 } | 824 } |
825 | 825 |
826 bool BaseChannel::ShouldSetupDtlsSrtp() const { | 826 bool BaseChannel::ShouldSetupDtlsSrtp() const { |
827 return true; | 827 return true; |
828 } | 828 } |
829 | 829 |
830 // This function returns true if either DTLS-SRTP is not in use | 830 // This function returns true if either DTLS-SRTP is not in use |
831 // *or* DTLS-SRTP is successfully set up. | 831 // *or* DTLS-SRTP is successfully set up. |
832 bool BaseChannel::SetupDtlsSrtp(bool rtcp_channel) { | 832 bool BaseChannel::SetupDtlsSrtp(bool rtcp_channel) { |
833 bool ret = false; | 833 bool ret = false; |
834 | 834 |
835 TransportChannel* channel = | 835 TransportChannel* channel = |
836 rtcp_channel ? rtcp_transport_channel_ : transport_channel_; | 836 rtcp_channel ? rtcp_transport_channel_ : transport_channel_; |
837 | 837 |
838 // No DTLS | 838 // No DTLS |
839 if (!channel->IsDtlsActive()) | 839 if (!channel->IsDtlsActive()) |
840 return true; | 840 return true; |
841 | 841 |
842 std::string selected_cipher; | 842 std::string selected_cipher; |
843 | 843 |
844 if (!channel->GetSrtpCryptoSuite(&selected_cipher)) { | 844 if (!channel->GetSrtpCipher(&selected_cipher)) { |
845 LOG(LS_ERROR) << "No DTLS-SRTP selected cipher"; | 845 LOG(LS_ERROR) << "No DTLS-SRTP selected cipher"; |
846 return false; | 846 return false; |
847 } | 847 } |
848 | 848 |
849 LOG(LS_INFO) << "Installing keys from DTLS-SRTP on " | 849 LOG(LS_INFO) << "Installing keys from DTLS-SRTP on " |
850 << content_name() << " " | 850 << content_name() << " " |
851 << PacketType(rtcp_channel); | 851 << PacketType(rtcp_channel); |
852 | 852 |
853 // OK, we're now doing DTLS (RFC 5764) | 853 // OK, we're now doing DTLS (RFC 5764) |
854 std::vector<unsigned char> dtls_buffer(SRTP_MASTER_KEY_KEY_LEN * 2 + | 854 std::vector<unsigned char> dtls_buffer(SRTP_MASTER_KEY_KEY_LEN * 2 + |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1620 case SrtpFilter::ERROR_REPLAY: | 1620 case SrtpFilter::ERROR_REPLAY: |
1621 // Only receving channel should have this error. | 1621 // Only receving channel should have this error. |
1622 ASSERT(mode == SrtpFilter::UNPROTECT); | 1622 ASSERT(mode == SrtpFilter::UNPROTECT); |
1623 OnVoiceChannelError(ssrc, VoiceMediaChannel::ERROR_PLAY_SRTP_REPLAY); | 1623 OnVoiceChannelError(ssrc, VoiceMediaChannel::ERROR_PLAY_SRTP_REPLAY); |
1624 break; | 1624 break; |
1625 default: | 1625 default: |
1626 break; | 1626 break; |
1627 } | 1627 } |
1628 } | 1628 } |
1629 | 1629 |
1630 void VoiceChannel::GetSrtpCryptoSuiteNames( | 1630 void VoiceChannel::GetSrtpCiphers(std::vector<std::string>* ciphers) const { |
1631 std::vector<std::string>* ciphers) const { | |
1632 GetSupportedAudioCryptoSuites(ciphers); | 1631 GetSupportedAudioCryptoSuites(ciphers); |
1633 } | 1632 } |
1634 | 1633 |
1635 VideoChannel::VideoChannel(rtc::Thread* thread, | 1634 VideoChannel::VideoChannel(rtc::Thread* thread, |
1636 VideoMediaChannel* media_channel, | 1635 VideoMediaChannel* media_channel, |
1637 TransportController* transport_controller, | 1636 TransportController* transport_controller, |
1638 const std::string& content_name, | 1637 const std::string& content_name, |
1639 bool rtcp) | 1638 bool rtcp) |
1640 : BaseChannel(thread, | 1639 : BaseChannel(thread, |
1641 media_channel, | 1640 media_channel, |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2054 ASSERT(mode == SrtpFilter::UNPROTECT); | 2053 ASSERT(mode == SrtpFilter::UNPROTECT); |
2055 // TODO(gangji): Turn on the signaling of replay error once we have | 2054 // TODO(gangji): Turn on the signaling of replay error once we have |
2056 // switched to the new mechanism for doing video retransmissions. | 2055 // switched to the new mechanism for doing video retransmissions. |
2057 // OnVideoChannelError(ssrc, VideoMediaChannel::ERROR_PLAY_SRTP_REPLAY); | 2056 // OnVideoChannelError(ssrc, VideoMediaChannel::ERROR_PLAY_SRTP_REPLAY); |
2058 break; | 2057 break; |
2059 default: | 2058 default: |
2060 break; | 2059 break; |
2061 } | 2060 } |
2062 } | 2061 } |
2063 | 2062 |
2064 void VideoChannel::GetSrtpCryptoSuiteNames( | 2063 void VideoChannel::GetSrtpCiphers(std::vector<std::string>* ciphers) const { |
2065 std::vector<std::string>* ciphers) const { | |
2066 GetSupportedVideoCryptoSuites(ciphers); | 2064 GetSupportedVideoCryptoSuites(ciphers); |
2067 } | 2065 } |
2068 | 2066 |
2069 DataChannel::DataChannel(rtc::Thread* thread, | 2067 DataChannel::DataChannel(rtc::Thread* thread, |
2070 DataMediaChannel* media_channel, | 2068 DataMediaChannel* media_channel, |
2071 TransportController* transport_controller, | 2069 TransportController* transport_controller, |
2072 const std::string& content_name, | 2070 const std::string& content_name, |
2073 bool rtcp) | 2071 bool rtcp) |
2074 : BaseChannel(thread, | 2072 : BaseChannel(thread, |
2075 media_channel, | 2073 media_channel, |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2390 case SrtpFilter::ERROR_REPLAY: | 2388 case SrtpFilter::ERROR_REPLAY: |
2391 // Only receving channel should have this error. | 2389 // Only receving channel should have this error. |
2392 ASSERT(mode == SrtpFilter::UNPROTECT); | 2390 ASSERT(mode == SrtpFilter::UNPROTECT); |
2393 OnDataChannelError(ssrc, DataMediaChannel::ERROR_RECV_SRTP_REPLAY); | 2391 OnDataChannelError(ssrc, DataMediaChannel::ERROR_RECV_SRTP_REPLAY); |
2394 break; | 2392 break; |
2395 default: | 2393 default: |
2396 break; | 2394 break; |
2397 } | 2395 } |
2398 } | 2396 } |
2399 | 2397 |
2400 void DataChannel::GetSrtpCryptoSuiteNames( | 2398 void DataChannel::GetSrtpCiphers(std::vector<std::string>* ciphers) const { |
2401 std::vector<std::string>* ciphers) const { | |
2402 GetSupportedDataCryptoSuites(ciphers); | 2399 GetSupportedDataCryptoSuites(ciphers); |
2403 } | 2400 } |
2404 | 2401 |
2405 bool DataChannel::ShouldSetupDtlsSrtp() const { | 2402 bool DataChannel::ShouldSetupDtlsSrtp() const { |
2406 return (data_channel_type_ == DCT_RTP); | 2403 return (data_channel_type_ == DCT_RTP); |
2407 } | 2404 } |
2408 | 2405 |
2409 void DataChannel::OnStreamClosedRemotely(uint32 sid) { | 2406 void DataChannel::OnStreamClosedRemotely(uint32 sid) { |
2410 rtc::TypedMessageData<uint32>* message = | 2407 rtc::TypedMessageData<uint32>* message = |
2411 new rtc::TypedMessageData<uint32>(sid); | 2408 new rtc::TypedMessageData<uint32>(sid); |
2412 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message); | 2409 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message); |
2413 } | 2410 } |
2414 | 2411 |
2415 } // namespace cricket | 2412 } // namespace cricket |
OLD | NEW |