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

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: update GYP file with right order. 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 | « content/public/common/webrtc_ip_handling_policy.cc ('k') | content/shell/browser/shell.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/common/webrtc_ip_handling_policy.h"
20 #include "content/public/renderer/content_renderer_client.h" 21 #include "content/public/renderer/content_renderer_client.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"
(...skipping 27 matching lines...) Expand all
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
65 namespace content { 66 namespace content {
66 67
68 namespace {
69
70 enum WebRTCIPHandlingPolicy {
71 DEFAULT,
72 DEFAULT_PUBLIC_AND_PRIVATE_INTERFACES,
73 DEFAULT_PUBLIC_INTERFACE_ONLY,
74 DISABLE_NON_PROXIED_UDP,
75 };
76
77 WebRTCIPHandlingPolicy GetWebRTCIPHandlingPolicy(
78 const std::string& preference) {
79 if (preference == kWebRTCIPHandlingDefaultPublicAndPrivateInterfaces)
80 return DEFAULT_PUBLIC_AND_PRIVATE_INTERFACES;
81 if (preference == kWebRTCIPHandlingDefaultPublicInterfaceOnly)
82 return DEFAULT_PUBLIC_INTERFACE_ONLY;
83 if (preference == kWebRTCIPHandlingDisableNonProxiedUdp)
84 return DISABLE_NON_PROXIED_UDP;
85 return DEFAULT;
86 }
87
88 } // namespace
89
67 // Map of corresponding media constraints and platform effects. 90 // Map of corresponding media constraints and platform effects.
68 struct { 91 struct {
69 const char* constraint; 92 const char* constraint;
70 const media::AudioParameters::PlatformEffectsMask effect; 93 const media::AudioParameters::PlatformEffectsMask effect;
71 } const kConstraintEffectMap[] = { 94 } const kConstraintEffectMap[] = {
72 { webrtc::MediaConstraintsInterface::kGoogEchoCancellation, 95 { webrtc::MediaConstraintsInterface::kGoogEchoCancellation,
73 media::AudioParameters::ECHO_CANCELLER }, 96 media::AudioParameters::ECHO_CANCELLER },
74 }; 97 };
75 98
76 // If any platform effects are available, check them against the constraints. 99 // If any platform effects are available, check them against the constraints.
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 VLOG(3) << "WebRTC routing preferences will not be enforced"; 471 VLOG(3) << "WebRTC routing preferences will not be enforced";
449 } else { 472 } else {
450 if (web_frame && web_frame->view()) { 473 if (web_frame && web_frame->view()) {
451 RenderViewImpl* renderer_view_impl = 474 RenderViewImpl* renderer_view_impl =
452 RenderViewImpl::FromWebView(web_frame->view()); 475 RenderViewImpl::FromWebView(web_frame->view());
453 if (renderer_view_impl) { 476 if (renderer_view_impl) {
454 // TODO(guoweis): |enable_multiple_routes| should be renamed to 477 // TODO(guoweis): |enable_multiple_routes| should be renamed to
455 // |request_multiple_routes|. Whether local IP addresses could be 478 // |request_multiple_routes|. Whether local IP addresses could be
456 // collected depends on if mic/camera permission is granted for this 479 // collected depends on if mic/camera permission is granted for this
457 // origin. 480 // origin.
458 port_config.enable_multiple_routes = 481 std::string mode = renderer_view_impl->renderer_preferences()
459 renderer_view_impl->renderer_preferences() 482 .webrtc_ip_handling_policy;
460 .enable_webrtc_multiple_routes; 483 switch (GetWebRTCIPHandlingPolicy(mode)) {
461 port_config.enable_nonproxied_udp = 484 // TODO(guoweis): specify the flag of disabling local candidate
462 renderer_view_impl->renderer_preferences() 485 // collection when webrtc is updated.
463 .enable_webrtc_nonproxied_udp; 486 case DEFAULT_PUBLIC_INTERFACE_ONLY:
464 VLOG(3) << "WebRTC routing preferences: multiple_routes: " 487 case DEFAULT_PUBLIC_AND_PRIVATE_INTERFACES:
465 << port_config.enable_multiple_routes 488 port_config.enable_multiple_routes = false;
489 port_config.enable_nonproxied_udp = true;
490 break;
491 case DISABLE_NON_PROXIED_UDP:
492 port_config.enable_multiple_routes = false;
493 port_config.enable_nonproxied_udp = false;
494 break;
495 case DEFAULT:
496 port_config.enable_multiple_routes = true;
497 port_config.enable_nonproxied_udp = true;
498 break;
499 default:
500 NOTREACHED();
501 break;
502 }
503
504 VLOG(3) << "WebRTC routing preferences: "
505 << "policy: " << mode
506 << ", multiple_routes: " << port_config.enable_multiple_routes
466 << ", nonproxied_udp: " << port_config.enable_nonproxied_udp; 507 << ", nonproxied_udp: " << port_config.enable_nonproxied_udp;
467 } 508 }
468 } 509 }
469 if (port_config.enable_multiple_routes) { 510 if (port_config.enable_multiple_routes) {
470 bool create_media_permission = 511 bool create_media_permission =
471 base::CommandLine::ForCurrentProcess()->HasSwitch( 512 base::CommandLine::ForCurrentProcess()->HasSwitch(
472 switches::kEnforceWebRtcIPPermissionCheck); 513 switches::kEnforceWebRtcIPPermissionCheck);
473 create_media_permission = 514 create_media_permission =
474 create_media_permission || 515 create_media_permission ||
475 StartsWith(base::FieldTrialList::FindFullName( 516 StartsWith(base::FieldTrialList::FindFullName(
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 } 796 }
756 797
757 void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() { 798 void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() {
758 if (audio_device_.get()) 799 if (audio_device_.get())
759 return; 800 return;
760 801
761 audio_device_ = new WebRtcAudioDeviceImpl(); 802 audio_device_ = new WebRtcAudioDeviceImpl();
762 } 803 }
763 804
764 } // namespace content 805 } // namespace content
OLDNEW
« no previous file with comments | « content/public/common/webrtc_ip_handling_policy.cc ('k') | content/shell/browser/shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698