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

Side by Side Diff: webrtc/pc/srtpfilter.cc

Issue 2729373002: Remove HAVE_SRTP define and unmaintained code. (Closed)
Patch Set: Created 3 years, 9 months 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 | « webrtc/pc/mediasession_unittest.cc ('k') | no next file » | 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 * Copyright 2009 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2009 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 11 matching lines...) Expand all
22 #include "webrtc/base/checks.h" 22 #include "webrtc/base/checks.h"
23 #include "webrtc/base/logging.h" 23 #include "webrtc/base/logging.h"
24 #include "webrtc/base/sslstreamadapter.h" 24 #include "webrtc/base/sslstreamadapter.h"
25 #include "webrtc/base/stringencode.h" 25 #include "webrtc/base/stringencode.h"
26 #include "webrtc/base/timeutils.h" 26 #include "webrtc/base/timeutils.h"
27 #include "webrtc/media/base/rtputils.h" 27 #include "webrtc/media/base/rtputils.h"
28 #include "webrtc/pc/externalhmac.h" 28 #include "webrtc/pc/externalhmac.h"
29 29
30 namespace cricket { 30 namespace cricket {
31 31
32 #ifndef HAVE_SRTP
33
34 // This helper function is used on systems that don't (yet) have SRTP,
35 // to log that the functions that require it won't do anything.
36 namespace {
37 bool SrtpNotAvailable(const char *func) {
38 LOG(LS_ERROR) << func << ": SRTP is not available on your system.";
39 return false;
40 }
41 } // anonymous namespace
42
43 #endif // !HAVE_SRTP
44
45 // NOTE: This is called from ChannelManager D'tor. 32 // NOTE: This is called from ChannelManager D'tor.
46 void ShutdownSrtp() { 33 void ShutdownSrtp() {
47 #ifdef HAVE_SRTP
48 // If srtp_dealloc is not executed then this will clear all existing sessions. 34 // If srtp_dealloc is not executed then this will clear all existing sessions.
49 // This should be called when application is shutting down. 35 // This should be called when application is shutting down.
50 SrtpSession::Terminate(); 36 SrtpSession::Terminate();
51 #endif
52 } 37 }
53 38
54 SrtpFilter::SrtpFilter() { 39 SrtpFilter::SrtpFilter() {
55 } 40 }
56 41
57 SrtpFilter::~SrtpFilter() { 42 SrtpFilter::~SrtpFilter() {
58 } 43 }
59 44
60 bool SrtpFilter::IsActive() const { 45 bool SrtpFilter::IsActive() const {
61 return state_ >= ST_ACTIVE; 46 return state_ >= ST_ACTIVE;
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 return false; 454 return false;
470 } 455 }
471 456
472 memcpy(key, key_str.c_str(), len); 457 memcpy(key, key_str.c_str(), len);
473 return true; 458 return true;
474 } 459 }
475 460
476 /////////////////////////////////////////////////////////////////////////////// 461 ///////////////////////////////////////////////////////////////////////////////
477 // SrtpSession 462 // SrtpSession
478 463
479 #ifdef HAVE_SRTP
480
481 bool SrtpSession::inited_ = false; 464 bool SrtpSession::inited_ = false;
482 465
483 // This lock protects SrtpSession::inited_. 466 // This lock protects SrtpSession::inited_.
484 rtc::GlobalLockPod SrtpSession::lock_; 467 rtc::GlobalLockPod SrtpSession::lock_;
485 468
486 SrtpSession::SrtpSession() : srtp_stat_(new SrtpStat()) { 469 SrtpSession::SrtpSession() : srtp_stat_(new SrtpStat()) {
487 SignalSrtpError.repeat(srtp_stat_->SignalSrtpError); 470 SignalSrtpError.repeat(srtp_stat_->SignalSrtpError);
488 } 471 }
489 472
490 SrtpSession::~SrtpSession() { 473 SrtpSession::~SrtpSession() {
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 void SrtpSession::HandleEventThunk(srtp_event_data_t* ev) { 800 void SrtpSession::HandleEventThunk(srtp_event_data_t* ev) {
818 // Callback will be executed from same thread that calls the "srtp_protect" 801 // Callback will be executed from same thread that calls the "srtp_protect"
819 // and "srtp_unprotect" functions. 802 // and "srtp_unprotect" functions.
820 SrtpSession* session = static_cast<SrtpSession*>( 803 SrtpSession* session = static_cast<SrtpSession*>(
821 srtp_get_user_data(ev->session)); 804 srtp_get_user_data(ev->session));
822 if (session) { 805 if (session) {
823 session->HandleEvent(ev); 806 session->HandleEvent(ev);
824 } 807 }
825 } 808 }
826 809
827 #else // !HAVE_SRTP
828
829 // On some systems, SRTP is not (yet) available.
830
831 SrtpSession::SrtpSession() {
832 LOG(WARNING) << "SRTP implementation is missing.";
833 }
834
835 SrtpSession::~SrtpSession() {
836 }
837
838 bool SrtpSession::SetSend(const std::string& cs, const uint8_t* key, int len) {
839 return SrtpNotAvailable(__FUNCTION__);
840 }
841
842 bool SrtpSession::SetRecv(const std::string& cs, const uint8_t* key, int len) {
843 return SrtpNotAvailable(__FUNCTION__);
844 }
845
846 bool SrtpSession::ProtectRtp(void* data, int in_len, int max_len,
847 int* out_len) {
848 return SrtpNotAvailable(__FUNCTION__);
849 }
850
851 bool SrtpSession::ProtectRtcp(void* data, int in_len, int max_len,
852 int* out_len) {
853 return SrtpNotAvailable(__FUNCTION__);
854 }
855
856 bool SrtpSession::UnprotectRtp(void* data, int in_len, int* out_len) {
857 return SrtpNotAvailable(__FUNCTION__);
858 }
859
860 bool SrtpSession::UnprotectRtcp(void* data, int in_len, int* out_len) {
861 return SrtpNotAvailable(__FUNCTION__);
862 }
863
864 void SrtpSession::set_signal_silent_time(uint32_t signal_silent_time) {
865 // Do nothing.
866 }
867
868 #endif // HAVE_SRTP
869
870 /////////////////////////////////////////////////////////////////////////////// 810 ///////////////////////////////////////////////////////////////////////////////
871 // SrtpStat 811 // SrtpStat
872 812
873 #ifdef HAVE_SRTP
874
875 SrtpStat::SrtpStat() 813 SrtpStat::SrtpStat()
876 : signal_silent_time_(1000) { 814 : signal_silent_time_(1000) {
877 } 815 }
878 816
879 void SrtpStat::AddProtectRtpResult(uint32_t ssrc, int result) { 817 void SrtpStat::AddProtectRtpResult(uint32_t ssrc, int result) {
880 FailureKey key; 818 FailureKey key;
881 key.ssrc = ssrc; 819 key.ssrc = ssrc;
882 key.mode = SrtpFilter::PROTECT; 820 key.mode = SrtpFilter::PROTECT;
883 switch (result) { 821 switch (result) {
884 case srtp_err_status_ok: 822 case srtp_err_status_ok:
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 int64_t current_time = rtc::TimeMillis(); 870 int64_t current_time = rtc::TimeMillis();
933 if (stat->last_signal_time == 0 || 871 if (stat->last_signal_time == 0 ||
934 rtc::TimeDiff(current_time, stat->last_signal_time) > 872 rtc::TimeDiff(current_time, stat->last_signal_time) >
935 signal_silent_time_) { 873 signal_silent_time_) {
936 SignalSrtpError(key.ssrc, key.mode, key.error); 874 SignalSrtpError(key.ssrc, key.mode, key.error);
937 stat->last_signal_time = current_time; 875 stat->last_signal_time = current_time;
938 } 876 }
939 } 877 }
940 } 878 }
941 879
942 #else // !HAVE_SRTP
943
944 // On some systems, SRTP is not (yet) available.
945
946 SrtpStat::SrtpStat()
947 : signal_silent_time_(1000) {
948 LOG(WARNING) << "SRTP implementation is missing.";
949 }
950
951 void SrtpStat::AddProtectRtpResult(uint32_t ssrc, int result) {
952 SrtpNotAvailable(__FUNCTION__);
953 }
954
955 void SrtpStat::AddUnprotectRtpResult(uint32_t ssrc, int result) {
956 SrtpNotAvailable(__FUNCTION__);
957 }
958
959 void SrtpStat::AddProtectRtcpResult(int result) {
960 SrtpNotAvailable(__FUNCTION__);
961 }
962
963 void SrtpStat::AddUnprotectRtcpResult(int result) {
964 SrtpNotAvailable(__FUNCTION__);
965 }
966
967 void SrtpStat::HandleSrtpResult(const SrtpStat::FailureKey& key) {
968 SrtpNotAvailable(__FUNCTION__);
969 }
970
971 #endif // HAVE_SRTP
972
973 } // namespace cricket 880 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/pc/mediasession_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698