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

Side by Side Diff: content/renderer/media/rtc_peer_connection_handler.cc

Issue 1972853003: content::RTCCertificateGenerator and WebRTC-EnableWebRtcEcdsa update. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reverted unnecessary CONTENT_EXPORT change and updated comment (no need to re-run trybots yet) Created 4 years, 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/rtc_peer_connection_handler.h" 5 #include "content/renderer/media/rtc_peer_connection_handler.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 10 matching lines...) Expand all
21 #include "base/threading/thread_task_runner_handle.h" 21 #include "base/threading/thread_task_runner_handle.h"
22 #include "base/trace_event/trace_event.h" 22 #include "base/trace_event/trace_event.h"
23 #include "content/public/common/content_features.h" 23 #include "content/public/common/content_features.h"
24 #include "content/public/common/content_switches.h" 24 #include "content/public/common/content_switches.h"
25 #include "content/renderer/media/media_stream_audio_track.h" 25 #include "content/renderer/media/media_stream_audio_track.h"
26 #include "content/renderer/media/media_stream_constraints_util.h" 26 #include "content/renderer/media/media_stream_constraints_util.h"
27 #include "content/renderer/media/media_stream_track.h" 27 #include "content/renderer/media/media_stream_track.h"
28 #include "content/renderer/media/peer_connection_tracker.h" 28 #include "content/renderer/media/peer_connection_tracker.h"
29 #include "content/renderer/media/remote_media_stream_impl.h" 29 #include "content/renderer/media/remote_media_stream_impl.h"
30 #include "content/renderer/media/rtc_certificate.h" 30 #include "content/renderer/media/rtc_certificate.h"
31 #include "content/renderer/media/rtc_certificate_generator.h"
31 #include "content/renderer/media/rtc_data_channel_handler.h" 32 #include "content/renderer/media/rtc_data_channel_handler.h"
32 #include "content/renderer/media/rtc_dtmf_sender_handler.h" 33 #include "content/renderer/media/rtc_dtmf_sender_handler.h"
33 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" 34 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h"
34 #include "content/renderer/media/webrtc/webrtc_media_stream_adapter.h" 35 #include "content/renderer/media/webrtc/webrtc_media_stream_adapter.h"
35 #include "content/renderer/media/webrtc_audio_capturer.h" 36 #include "content/renderer/media/webrtc_audio_capturer.h"
36 #include "content/renderer/media/webrtc_audio_device_impl.h" 37 #include "content/renderer/media/webrtc_audio_device_impl.h"
37 #include "content/renderer/media/webrtc_uma_histograms.h" 38 #include "content/renderer/media/webrtc_uma_histograms.h"
38 #include "content/renderer/render_thread_impl.h" 39 #include "content/renderer/render_thread_impl.h"
39 #include "media/base/media_switches.h" 40 #include "media/base/media_switches.h"
40 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" 41 #include "third_party/WebKit/public/platform/WebMediaConstraints.h"
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 constraints, &blink::WebMediaTrackConstraintSet::voiceActivityDetection, 718 constraints, &blink::WebMediaTrackConstraintSet::voiceActivityDetection,
718 &output->voice_activity_detection); 719 &output->voice_activity_detection);
719 GetConstraintValueAsBoolean(constraints, 720 GetConstraintValueAsBoolean(constraints,
720 &blink::WebMediaTrackConstraintSet::iceRestart, 721 &blink::WebMediaTrackConstraintSet::iceRestart,
721 &output->ice_restart); 722 &output->ice_restart);
722 } 723 }
723 724
724 base::LazyInstance<std::set<RTCPeerConnectionHandler*> >::Leaky 725 base::LazyInstance<std::set<RTCPeerConnectionHandler*> >::Leaky
725 g_peer_connection_handlers = LAZY_INSTANCE_INITIALIZER; 726 g_peer_connection_handlers = LAZY_INSTANCE_INITIALIZER;
726 727
728 void OverrideDefaultCertificateBasedOnExperiment(
729 webrtc::PeerConnectionInterface::RTCConfiguration* config) {
730 if (!config->certificates.empty())
731 return; // A certificate has already been set up to override the default.
732 rtc::KeyType key_type;
733 if (base::FeatureList::IsEnabled(features::kWebRtcEcdsaDefault)) {
734 key_type = rtc::KT_ECDSA;
735 } else {
736 key_type = rtc::KT_RSA;
737 }
738 if (key_type != rtc::KT_DEFAULT) {
tommi (sloooow) - chröme 2016/05/12 12:42:56 Can you add a static assert that ensure that KT_DE
hbos_chromium 2016/05/12 14:28:00 As discussed, that is not necessary. We should mak
739 rtc::scoped_refptr<rtc::RTCCertificate> certificate =
tommi (sloooow) - chröme 2016/05/12 12:42:56 avoid rtc:: types
hbos_chromium 2016/05/12 14:28:00 Done.
740 RTCCertificateGenerator::generateCertificateAndWait(
741 rtc::KeyParams(key_type), rtc::Optional<uint64_t>());
742 if (!certificate) {
743 // This should not happen, but if it does it is better than crashing.
744 LOG(WARNING) << "Failed to generate certificate, will rely on default "
745 "instead.";
746 } else {
747 config->certificates.push_back(certificate);
748 }
749 }
750 }
751
727 } // namespace 752 } // namespace
728 753
729 // Implementation of LocalRTCStatsRequest. 754 // Implementation of LocalRTCStatsRequest.
730 LocalRTCStatsRequest::LocalRTCStatsRequest(blink::WebRTCStatsRequest impl) 755 LocalRTCStatsRequest::LocalRTCStatsRequest(blink::WebRTCStatsRequest impl)
731 : impl_(impl) { 756 : impl_(impl) {
732 } 757 }
733 758
734 LocalRTCStatsRequest::LocalRTCStatsRequest() {} 759 LocalRTCStatsRequest::LocalRTCStatsRequest() {}
735 LocalRTCStatsRequest::~LocalRTCStatsRequest() {} 760 LocalRTCStatsRequest::~LocalRTCStatsRequest() {}
736 761
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 const blink::WebRTCConfiguration& server_configuration, 972 const blink::WebRTCConfiguration& server_configuration,
948 const blink::WebMediaConstraints& options) { 973 const blink::WebMediaConstraints& options) {
949 DCHECK(thread_checker_.CalledOnValidThread()); 974 DCHECK(thread_checker_.CalledOnValidThread());
950 DCHECK(frame_); 975 DCHECK(frame_);
951 976
952 peer_connection_tracker_ = 977 peer_connection_tracker_ =
953 RenderThreadImpl::current()->peer_connection_tracker()->AsWeakPtr(); 978 RenderThreadImpl::current()->peer_connection_tracker()->AsWeakPtr();
954 979
955 webrtc::PeerConnectionInterface::RTCConfiguration config; 980 webrtc::PeerConnectionInterface::RTCConfiguration config;
956 GetNativeRtcConfiguration(server_configuration, &config); 981 GetNativeRtcConfiguration(server_configuration, &config);
957 982 OverrideDefaultCertificateBasedOnExperiment(&config);
958 if (base::FeatureList::IsEnabled(features::kWebRtcEcdsaDefault)) {
959 if (config.certificates.empty()) {
960 rtc::scoped_refptr<rtc::RTCCertificate> certificate =
961 PeerConnectionDependencyFactory::GenerateDefaultCertificate();
962 config.certificates.push_back(certificate);
963 }
964 }
965 983
966 // Choose between RTC smoothness algorithm and prerenderer smoothing. 984 // Choose between RTC smoothness algorithm and prerenderer smoothing.
967 // Prerenderer smoothing is turned on if RTC smoothness is turned off. 985 // Prerenderer smoothing is turned on if RTC smoothness is turned off.
968 config.set_prerenderer_smoothing( 986 config.set_prerenderer_smoothing(
969 base::CommandLine::ForCurrentProcess()->HasSwitch( 987 base::CommandLine::ForCurrentProcess()->HasSwitch(
970 switches::kDisableRTCSmoothnessAlgorithm)); 988 switches::kDisableRTCSmoothnessAlgorithm));
971 989
972 // Copy all the relevant constraints into |config|. 990 // Copy all the relevant constraints into |config|.
973 CopyConstraintsIntoRtcConfiguration(options, &config); 991 CopyConstraintsIntoRtcConfiguration(options, &config);
974 992
(...skipping 16 matching lines...) Expand all
991 return true; 1009 return true;
992 } 1010 }
993 1011
994 bool RTCPeerConnectionHandler::InitializeForTest( 1012 bool RTCPeerConnectionHandler::InitializeForTest(
995 const blink::WebRTCConfiguration& server_configuration, 1013 const blink::WebRTCConfiguration& server_configuration,
996 const blink::WebMediaConstraints& options, 1014 const blink::WebMediaConstraints& options,
997 const base::WeakPtr<PeerConnectionTracker>& peer_connection_tracker) { 1015 const base::WeakPtr<PeerConnectionTracker>& peer_connection_tracker) {
998 DCHECK(thread_checker_.CalledOnValidThread()); 1016 DCHECK(thread_checker_.CalledOnValidThread());
999 webrtc::PeerConnectionInterface::RTCConfiguration config; 1017 webrtc::PeerConnectionInterface::RTCConfiguration config;
1000 GetNativeRtcConfiguration(server_configuration, &config); 1018 GetNativeRtcConfiguration(server_configuration, &config);
1001 1019 OverrideDefaultCertificateBasedOnExperiment(&config);
1002 if (base::FeatureList::IsEnabled(features::kWebRtcEcdsaDefault)) {
1003 if (config.certificates.empty()) {
1004 rtc::scoped_refptr<rtc::RTCCertificate> certificate =
1005 PeerConnectionDependencyFactory::GenerateDefaultCertificate();
1006 config.certificates.push_back(certificate);
1007 }
1008 }
1009 1020
1010 peer_connection_observer_ = new Observer(weak_factory_.GetWeakPtr()); 1021 peer_connection_observer_ = new Observer(weak_factory_.GetWeakPtr());
1011 CopyConstraintsIntoRtcConfiguration(options, &config); 1022 CopyConstraintsIntoRtcConfiguration(options, &config);
1012 1023
1013 native_peer_connection_ = dependency_factory_->CreatePeerConnection( 1024 native_peer_connection_ = dependency_factory_->CreatePeerConnection(
1014 config, nullptr, peer_connection_observer_.get()); 1025 config, nullptr, peer_connection_observer_.get());
1015 if (!native_peer_connection_.get()) { 1026 if (!native_peer_connection_.get()) {
1016 LOG(ERROR) << "Failed to initialize native PeerConnection."; 1027 LOG(ERROR) << "Failed to initialize native PeerConnection.";
1017 return false; 1028 return false;
1018 } 1029 }
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 } 1806 }
1796 1807
1797 void RTCPeerConnectionHandler::ResetUMAStats() { 1808 void RTCPeerConnectionHandler::ResetUMAStats() {
1798 DCHECK(thread_checker_.CalledOnValidThread()); 1809 DCHECK(thread_checker_.CalledOnValidThread());
1799 num_local_candidates_ipv6_ = 0; 1810 num_local_candidates_ipv6_ = 0;
1800 num_local_candidates_ipv4_ = 0; 1811 num_local_candidates_ipv4_ = 0;
1801 ice_connection_checking_start_ = base::TimeTicks(); 1812 ice_connection_checking_start_ = base::TimeTicks();
1802 memset(ice_state_seen_, 0, sizeof(ice_state_seen_)); 1813 memset(ice_state_seen_, 0, sizeof(ice_state_seen_));
1803 } 1814 }
1804 } // namespace content 1815 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698