Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: talk/session/media/channel.cc

Issue 1455233005: Revert of Convert internal representation of Srtp cryptos from string to int. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « talk/session/media/channel.h ('k') | talk/session/media/mediasession.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 (!SetDtlsSrtpCryptoSuites(transport_channel(), false)) { 221 if (!SetDtlsSrtpCiphers(transport_channel(), false)) {
222 return false; 222 return false;
223 } 223 }
224 if (rtcp_transport_enabled() && 224 if (rtcp_transport_enabled() &&
225 !SetDtlsSrtpCryptoSuites(rtcp_transport_channel(), true)) { 225 !SetDtlsSrtpCiphers(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 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 ASSERT(worker_thread() == rtc::Thread::Current()); 802 ASSERT(worker_thread() == rtc::Thread::Current());
803 signaling_thread()->Invoke<void>(Bind( 803 signaling_thread()->Invoke<void>(Bind(
804 &BaseChannel::SignalDtlsSetupFailure_s, this, rtcp)); 804 &BaseChannel::SignalDtlsSetupFailure_s, this, rtcp));
805 } 805 }
806 806
807 void BaseChannel::SignalDtlsSetupFailure_s(bool rtcp) { 807 void BaseChannel::SignalDtlsSetupFailure_s(bool rtcp) {
808 ASSERT(signaling_thread() == rtc::Thread::Current()); 808 ASSERT(signaling_thread() == rtc::Thread::Current());
809 SignalDtlsSetupFailure(this, rtcp); 809 SignalDtlsSetupFailure(this, rtcp);
810 } 810 }
811 811
812 bool BaseChannel::SetDtlsSrtpCryptoSuites(TransportChannel* tc, bool rtcp) { 812 bool BaseChannel::SetDtlsSrtpCiphers(TransportChannel *tc, bool rtcp) {
813 std::vector<int> crypto_suites; 813 std::vector<std::string> ciphers;
814 // We always use the default SRTP crypto suites for RTCP, but we may use 814 // We always use the default SRTP ciphers for RTCP, but we may use different
815 // different crypto suites for RTP depending on the media type. 815 // ciphers for RTP depending on the media type.
816 if (!rtcp) { 816 if (!rtcp) {
817 GetSrtpCryptoSuites(&crypto_suites); 817 GetSrtpCryptoSuiteNames(&ciphers);
818 } else { 818 } else {
819 GetDefaultSrtpCryptoSuites(&crypto_suites); 819 GetDefaultSrtpCryptoSuiteNames(&ciphers);
820 } 820 }
821 return tc->SetSrtpCryptoSuites(crypto_suites); 821 return tc->SetSrtpCiphers(ciphers);
822 } 822 }
823 823
824 bool BaseChannel::ShouldSetupDtlsSrtp() const { 824 bool BaseChannel::ShouldSetupDtlsSrtp() const {
825 return true; 825 return true;
826 } 826 }
827 827
828 // This function returns true if either DTLS-SRTP is not in use 828 // This function returns true if either DTLS-SRTP is not in use
829 // *or* DTLS-SRTP is successfully set up. 829 // *or* DTLS-SRTP is successfully set up.
830 bool BaseChannel::SetupDtlsSrtp(bool rtcp_channel) { 830 bool BaseChannel::SetupDtlsSrtp(bool rtcp_channel) {
831 bool ret = false; 831 bool ret = false;
832 832
833 TransportChannel* channel = 833 TransportChannel* channel =
834 rtcp_channel ? rtcp_transport_channel_ : transport_channel_; 834 rtcp_channel ? rtcp_transport_channel_ : transport_channel_;
835 835
836 // No DTLS 836 // No DTLS
837 if (!channel->IsDtlsActive()) 837 if (!channel->IsDtlsActive())
838 return true; 838 return true;
839 839
840 int selected_crypto_suite; 840 std::string selected_cipher;
841 841
842 if (!channel->GetSrtpCryptoSuite(&selected_crypto_suite)) { 842 if (!channel->GetSrtpCryptoSuite(&selected_cipher)) {
843 LOG(LS_ERROR) << "No DTLS-SRTP selected crypto suite"; 843 LOG(LS_ERROR) << "No DTLS-SRTP selected cipher";
844 return false; 844 return false;
845 } 845 }
846 846
847 LOG(LS_INFO) << "Installing keys from DTLS-SRTP on " 847 LOG(LS_INFO) << "Installing keys from DTLS-SRTP on "
848 << content_name() << " " 848 << content_name() << " "
849 << PacketType(rtcp_channel); 849 << PacketType(rtcp_channel);
850 850
851 // OK, we're now doing DTLS (RFC 5764) 851 // OK, we're now doing DTLS (RFC 5764)
852 std::vector<unsigned char> dtls_buffer(SRTP_MASTER_KEY_KEY_LEN * 2 + 852 std::vector<unsigned char> dtls_buffer(SRTP_MASTER_KEY_KEY_LEN * 2 +
853 SRTP_MASTER_KEY_SALT_LEN * 2); 853 SRTP_MASTER_KEY_SALT_LEN * 2);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 889
890 if (role == rtc::SSL_SERVER) { 890 if (role == rtc::SSL_SERVER) {
891 send_key = &server_write_key; 891 send_key = &server_write_key;
892 recv_key = &client_write_key; 892 recv_key = &client_write_key;
893 } else { 893 } else {
894 send_key = &client_write_key; 894 send_key = &client_write_key;
895 recv_key = &server_write_key; 895 recv_key = &server_write_key;
896 } 896 }
897 897
898 if (rtcp_channel) { 898 if (rtcp_channel) {
899 ret = srtp_filter_.SetRtcpParams(selected_crypto_suite, &(*send_key)[0], 899 ret = srtp_filter_.SetRtcpParams(
900 static_cast<int>(send_key->size()), 900 selected_cipher,
901 selected_crypto_suite, &(*recv_key)[0], 901 &(*send_key)[0],
902 static_cast<int>(recv_key->size())); 902 static_cast<int>(send_key->size()),
903 selected_cipher,
904 &(*recv_key)[0],
905 static_cast<int>(recv_key->size()));
903 } else { 906 } else {
904 ret = srtp_filter_.SetRtpParams(selected_crypto_suite, &(*send_key)[0], 907 ret = srtp_filter_.SetRtpParams(
905 static_cast<int>(send_key->size()), 908 selected_cipher,
906 selected_crypto_suite, &(*recv_key)[0], 909 &(*send_key)[0],
907 static_cast<int>(recv_key->size())); 910 static_cast<int>(send_key->size()),
911 selected_cipher,
912 &(*recv_key)[0],
913 static_cast<int>(recv_key->size()));
908 } 914 }
909 915
910 if (!ret) 916 if (!ret)
911 LOG(LS_WARNING) << "DTLS-SRTP key installation failed"; 917 LOG(LS_WARNING) << "DTLS-SRTP key installation failed";
912 else 918 else
913 dtls_keyed_ = true; 919 dtls_keyed_ = true;
914 920
915 return ret; 921 return ret;
916 } 922 }
917 923
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 VoiceMediaChannel* media_channel, const VoiceMediaInfo& info) { 1573 VoiceMediaChannel* media_channel, const VoiceMediaInfo& info) {
1568 ASSERT(media_channel == this->media_channel()); 1574 ASSERT(media_channel == this->media_channel());
1569 SignalMediaMonitor(this, info); 1575 SignalMediaMonitor(this, info);
1570 } 1576 }
1571 1577
1572 void VoiceChannel::OnAudioMonitorUpdate(AudioMonitor* monitor, 1578 void VoiceChannel::OnAudioMonitorUpdate(AudioMonitor* monitor,
1573 const AudioInfo& info) { 1579 const AudioInfo& info) {
1574 SignalAudioMonitor(this, info); 1580 SignalAudioMonitor(this, info);
1575 } 1581 }
1576 1582
1577 void VoiceChannel::GetSrtpCryptoSuites(std::vector<int>* crypto_suites) const { 1583 void VoiceChannel::GetSrtpCryptoSuiteNames(
1578 GetSupportedAudioCryptoSuites(crypto_suites); 1584 std::vector<std::string>* ciphers) const {
1585 GetSupportedAudioCryptoSuites(ciphers);
1579 } 1586 }
1580 1587
1581 VideoChannel::VideoChannel(rtc::Thread* thread, 1588 VideoChannel::VideoChannel(rtc::Thread* thread,
1582 VideoMediaChannel* media_channel, 1589 VideoMediaChannel* media_channel,
1583 TransportController* transport_controller, 1590 TransportController* transport_controller,
1584 const std::string& content_name, 1591 const std::string& content_name,
1585 bool rtcp) 1592 bool rtcp)
1586 : BaseChannel(thread, 1593 : BaseChannel(thread,
1587 media_channel, 1594 media_channel,
1588 transport_controller, 1595 transport_controller,
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1956 for (ScreencastMap::iterator iter = screencast_capturers_.begin(); 1963 for (ScreencastMap::iterator iter = screencast_capturers_.begin();
1957 iter != screencast_capturers_.end(); ++iter) { 1964 iter != screencast_capturers_.end(); ++iter) {
1958 if (iter->second == capturer) { 1965 if (iter->second == capturer) {
1959 *ssrc = iter->first; 1966 *ssrc = iter->first;
1960 return true; 1967 return true;
1961 } 1968 }
1962 } 1969 }
1963 return false; 1970 return false;
1964 } 1971 }
1965 1972
1966 void VideoChannel::GetSrtpCryptoSuites(std::vector<int>* crypto_suites) const { 1973 void VideoChannel::GetSrtpCryptoSuiteNames(
1967 GetSupportedVideoCryptoSuites(crypto_suites); 1974 std::vector<std::string>* ciphers) const {
1975 GetSupportedVideoCryptoSuites(ciphers);
1968 } 1976 }
1969 1977
1970 DataChannel::DataChannel(rtc::Thread* thread, 1978 DataChannel::DataChannel(rtc::Thread* thread,
1971 DataMediaChannel* media_channel, 1979 DataMediaChannel* media_channel,
1972 TransportController* transport_controller, 1980 TransportController* transport_controller,
1973 const std::string& content_name, 1981 const std::string& content_name,
1974 bool rtcp) 1982 bool rtcp)
1975 : BaseChannel(thread, 1983 : BaseChannel(thread,
1976 media_channel, 1984 media_channel,
1977 transport_controller, 1985 transport_controller,
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
2263 } 2271 }
2264 2272
2265 void DataChannel::OnDataChannelReadyToSend(bool writable) { 2273 void DataChannel::OnDataChannelReadyToSend(bool writable) {
2266 // This is usded for congestion control to indicate that the stream is ready 2274 // This is usded for congestion control to indicate that the stream is ready
2267 // to send by the MediaChannel, as opposed to OnReadyToSend, which indicates 2275 // to send by the MediaChannel, as opposed to OnReadyToSend, which indicates
2268 // that the transport channel is ready. 2276 // that the transport channel is ready.
2269 signaling_thread()->Post(this, MSG_READYTOSENDDATA, 2277 signaling_thread()->Post(this, MSG_READYTOSENDDATA,
2270 new DataChannelReadyToSendMessageData(writable)); 2278 new DataChannelReadyToSendMessageData(writable));
2271 } 2279 }
2272 2280
2273 void DataChannel::GetSrtpCryptoSuites(std::vector<int>* crypto_suites) const { 2281 void DataChannel::GetSrtpCryptoSuiteNames(
2274 GetSupportedDataCryptoSuites(crypto_suites); 2282 std::vector<std::string>* ciphers) const {
2283 GetSupportedDataCryptoSuites(ciphers);
2275 } 2284 }
2276 2285
2277 bool DataChannel::ShouldSetupDtlsSrtp() const { 2286 bool DataChannel::ShouldSetupDtlsSrtp() const {
2278 return (data_channel_type_ == DCT_RTP); 2287 return (data_channel_type_ == DCT_RTP);
2279 } 2288 }
2280 2289
2281 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { 2290 void DataChannel::OnStreamClosedRemotely(uint32_t sid) {
2282 rtc::TypedMessageData<uint32_t>* message = 2291 rtc::TypedMessageData<uint32_t>* message =
2283 new rtc::TypedMessageData<uint32_t>(sid); 2292 new rtc::TypedMessageData<uint32_t>(sid);
2284 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message); 2293 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message);
2285 } 2294 }
2286 2295
2287 } // namespace cricket 2296 } // namespace cricket
OLDNEW
« no previous file with comments | « talk/session/media/channel.h ('k') | talk/session/media/mediasession.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698