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

Side by Side Diff: content/renderer/media/webrtc/peer_connection_dependency_factory.cc

Issue 1413393003: Change WebRTC IP handling policy from multiple booleans to an enum. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address peter's comments. Created 5 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/webrtc/peer_connection_dependency_factory.h" 5 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/metrics/field_trial.h" 12 #include "base/metrics/field_trial.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "base/synchronization/waitable_event.h" 15 #include "base/synchronization/waitable_event.h"
16 #include "content/common/media/media_stream_messages.h" 16 #include "content/common/media/media_stream_messages.h"
17 #include "content/public/common/content_client.h" 17 #include "content/public/common/content_client.h"
18 #include "content/public/common/content_switches.h" 18 #include "content/public/common/content_switches.h"
19 #include "content/public/common/renderer_preferences.h" 19 #include "content/public/common/renderer_preferences.h"
20 #include "content/public/renderer/content_renderer_client.h" 20 #include "content/public/renderer/content_renderer_client.h"
21 #include "content/public/renderer/webrtc_ip_handling_policy.h"
21 #include "content/renderer/media/media_stream.h" 22 #include "content/renderer/media/media_stream.h"
22 #include "content/renderer/media/media_stream_audio_processor.h" 23 #include "content/renderer/media/media_stream_audio_processor.h"
23 #include "content/renderer/media/media_stream_audio_processor_options.h" 24 #include "content/renderer/media/media_stream_audio_processor_options.h"
24 #include "content/renderer/media/media_stream_audio_source.h" 25 #include "content/renderer/media/media_stream_audio_source.h"
25 #include "content/renderer/media/media_stream_video_source.h" 26 #include "content/renderer/media/media_stream_video_source.h"
26 #include "content/renderer/media/media_stream_video_track.h" 27 #include "content/renderer/media/media_stream_video_track.h"
27 #include "content/renderer/media/peer_connection_identity_store.h" 28 #include "content/renderer/media/peer_connection_identity_store.h"
28 #include "content/renderer/media/rtc_media_constraints.h" 29 #include "content/renderer/media/rtc_media_constraints.h"
29 #include "content/renderer/media/rtc_peer_connection_handler.h" 30 #include "content/renderer/media/rtc_peer_connection_handler.h"
30 #include "content/renderer/media/rtc_video_decoder_factory.h" 31 #include "content/renderer/media/rtc_video_decoder_factory.h"
(...skipping 24 matching lines...) Expand all
55 #include "third_party/WebKit/public/platform/WebURL.h" 56 #include "third_party/WebKit/public/platform/WebURL.h"
56 #include "third_party/WebKit/public/web/WebDocument.h" 57 #include "third_party/WebKit/public/web/WebDocument.h"
57 #include "third_party/WebKit/public/web/WebFrame.h" 58 #include "third_party/WebKit/public/web/WebFrame.h"
58 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface .h" 59 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface .h"
59 #include "third_party/webrtc/base/ssladapter.h" 60 #include "third_party/webrtc/base/ssladapter.h"
60 61
61 #if defined(OS_ANDROID) 62 #if defined(OS_ANDROID)
62 #include "media/base/android/media_codec_bridge.h" 63 #include "media/base/android/media_codec_bridge.h"
63 #endif 64 #endif
64 65
66 namespace {
67
68 enum WebRTCIPHandlingPolicy {
69 DEFAULT,
70 DEFAULT_PUBLIC_INTERFACE_ONLY,
71 DISABLE_NON_PROXIED_UDP,
72 };
73
74 WebRTCIPHandlingPolicy GetWebRTCIPHandlingPolicy(
75 const std::string& preference) {
76 if (preference == content::kWebRTCIPHandlingDefaultPublicInterfaceOnly)
nasko 2015/10/26 15:49:49 This anonymous namespace should go inside content.
guoweis_left_chromium 2015/10/27 20:31:59 Done.
77 return DEFAULT_PUBLIC_INTERFACE_ONLY;
78 if (preference == content::kWebRTCIPHandlingDisableNonProxiedUdp)
79 return DISABLE_NON_PROXIED_UDP;
80 return DEFAULT;
81 }
82
83 } // namespace
84
65 namespace content { 85 namespace content {
66 86
67 // Map of corresponding media constraints and platform effects. 87 // Map of corresponding media constraints and platform effects.
68 struct { 88 struct {
69 const char* constraint; 89 const char* constraint;
70 const media::AudioParameters::PlatformEffectsMask effect; 90 const media::AudioParameters::PlatformEffectsMask effect;
71 } const kConstraintEffectMap[] = { 91 } const kConstraintEffectMap[] = {
72 { webrtc::MediaConstraintsInterface::kGoogEchoCancellation, 92 { webrtc::MediaConstraintsInterface::kGoogEchoCancellation,
73 media::AudioParameters::ECHO_CANCELLER }, 93 media::AudioParameters::ECHO_CANCELLER },
74 }; 94 };
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 VLOG(3) << "WebRTC routing preferences will not be enforced"; 468 VLOG(3) << "WebRTC routing preferences will not be enforced";
449 } else { 469 } else {
450 if (web_frame && web_frame->view()) { 470 if (web_frame && web_frame->view()) {
451 RenderViewImpl* renderer_view_impl = 471 RenderViewImpl* renderer_view_impl =
452 RenderViewImpl::FromWebView(web_frame->view()); 472 RenderViewImpl::FromWebView(web_frame->view());
453 if (renderer_view_impl) { 473 if (renderer_view_impl) {
454 // TODO(guoweis): |enable_multiple_routes| should be renamed to 474 // TODO(guoweis): |enable_multiple_routes| should be renamed to
455 // |request_multiple_routes|. Whether local IP addresses could be 475 // |request_multiple_routes|. Whether local IP addresses could be
456 // collected depends on if mic/camera permission is granted for this 476 // collected depends on if mic/camera permission is granted for this
457 // origin. 477 // origin.
458 port_config.enable_multiple_routes = 478 std::string mode = renderer_view_impl->renderer_preferences()
459 renderer_view_impl->renderer_preferences() 479 .webrtc_ip_handling_policy;
460 .enable_webrtc_multiple_routes; 480 switch (GetWebRTCIPHandlingPolicy(mode)) {
461 port_config.enable_nonproxied_udp = 481 case DEFAULT_PUBLIC_INTERFACE_ONLY:
462 renderer_view_impl->renderer_preferences() 482 port_config.enable_multiple_routes = false;
463 .enable_webrtc_nonproxied_udp; 483 port_config.enable_nonproxied_udp = true;
464 VLOG(3) << "WebRTC routing preferences: multiple_routes: " 484 break;
465 << port_config.enable_multiple_routes 485 case DISABLE_NON_PROXIED_UDP:
486 port_config.enable_multiple_routes = false;
487 port_config.enable_nonproxied_udp = false;
488 default:
nasko 2015/10/26 15:49:49 Why not have a case for DEFAULT return value and h
guoweis_left_chromium 2015/10/27 20:32:00 Done.
489 port_config.enable_multiple_routes = true;
490 port_config.enable_nonproxied_udp = true;
491 break;
492 }
493
494 VLOG(3) << "WebRTC routing preferences: "
495 << "policy: " << mode
496 << ", multiple_routes: " << port_config.enable_multiple_routes
466 << ", nonproxied_udp: " << port_config.enable_nonproxied_udp; 497 << ", nonproxied_udp: " << port_config.enable_nonproxied_udp;
467 } 498 }
468 } 499 }
469 if (port_config.enable_multiple_routes) { 500 if (port_config.enable_multiple_routes) {
470 bool create_media_permission = 501 bool create_media_permission =
471 base::CommandLine::ForCurrentProcess()->HasSwitch( 502 base::CommandLine::ForCurrentProcess()->HasSwitch(
472 switches::kEnforceWebRtcIPPermissionCheck); 503 switches::kEnforceWebRtcIPPermissionCheck);
473 create_media_permission = 504 create_media_permission =
474 create_media_permission || 505 create_media_permission ||
475 StartsWith(base::FieldTrialList::FindFullName( 506 StartsWith(base::FieldTrialList::FindFullName(
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 } 786 }
756 787
757 void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() { 788 void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() {
758 if (audio_device_.get()) 789 if (audio_device_.get())
759 return; 790 return;
760 791
761 audio_device_ = new WebRtcAudioDeviceImpl(); 792 audio_device_ = new WebRtcAudioDeviceImpl();
762 } 793 }
763 794
764 } // namespace content 795 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698