OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 const std::string& preference) { | 84 const std::string& preference) { |
85 if (preference == kWebRTCIPHandlingDefaultPublicAndPrivateInterfaces) | 85 if (preference == kWebRTCIPHandlingDefaultPublicAndPrivateInterfaces) |
86 return DEFAULT_PUBLIC_AND_PRIVATE_INTERFACES; | 86 return DEFAULT_PUBLIC_AND_PRIVATE_INTERFACES; |
87 if (preference == kWebRTCIPHandlingDefaultPublicInterfaceOnly) | 87 if (preference == kWebRTCIPHandlingDefaultPublicInterfaceOnly) |
88 return DEFAULT_PUBLIC_INTERFACE_ONLY; | 88 return DEFAULT_PUBLIC_INTERFACE_ONLY; |
89 if (preference == kWebRTCIPHandlingDisableNonProxiedUdp) | 89 if (preference == kWebRTCIPHandlingDisableNonProxiedUdp) |
90 return DISABLE_NON_PROXIED_UDP; | 90 return DISABLE_NON_PROXIED_UDP; |
91 return DEFAULT; | 91 return DEFAULT; |
92 } | 92 } |
93 | 93 |
| 94 bool IsValidPortRange(uint16_t min_port, uint16_t max_port) { |
| 95 DCHECK(min_port <= max_port); |
| 96 return min_port != 0 && max_port != 0; |
| 97 } |
| 98 |
94 } // namespace | 99 } // namespace |
95 | 100 |
96 PeerConnectionDependencyFactory::PeerConnectionDependencyFactory( | 101 PeerConnectionDependencyFactory::PeerConnectionDependencyFactory( |
97 P2PSocketDispatcher* p2p_socket_dispatcher) | 102 P2PSocketDispatcher* p2p_socket_dispatcher) |
98 : network_manager_(NULL), | 103 : network_manager_(NULL), |
99 p2p_socket_dispatcher_(p2p_socket_dispatcher), | 104 p2p_socket_dispatcher_(p2p_socket_dispatcher), |
100 signaling_thread_(NULL), | 105 signaling_thread_(NULL), |
101 worker_thread_(NULL), | 106 worker_thread_(NULL), |
102 chrome_signaling_thread_("Chrome_libJingle_Signaling"), | 107 chrome_signaling_thread_("Chrome_libJingle_Signaling"), |
103 chrome_worker_thread_("Chrome_libJingle_WorkerThread") { | 108 chrome_worker_thread_("Chrome_libJingle_WorkerThread") { |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 const webrtc::PeerConnectionInterface::RTCConfiguration& config, | 295 const webrtc::PeerConnectionInterface::RTCConfiguration& config, |
291 blink::WebFrame* web_frame, | 296 blink::WebFrame* web_frame, |
292 webrtc::PeerConnectionObserver* observer) { | 297 webrtc::PeerConnectionObserver* observer) { |
293 CHECK(web_frame); | 298 CHECK(web_frame); |
294 CHECK(observer); | 299 CHECK(observer); |
295 if (!GetPcFactory().get()) | 300 if (!GetPcFactory().get()) |
296 return NULL; | 301 return NULL; |
297 | 302 |
298 // Copy the flag from Preference associated with this WebFrame. | 303 // Copy the flag from Preference associated with this WebFrame. |
299 P2PPortAllocator::Config port_config; | 304 P2PPortAllocator::Config port_config; |
| 305 uint16_t min_port = 0; |
| 306 uint16_t max_port = 0; |
300 | 307 |
301 // |media_permission| will be called to check mic/camera permission. If at | 308 // |media_permission| will be called to check mic/camera permission. If at |
302 // least one of them is granted, P2PPortAllocator is allowed to gather local | 309 // least one of them is granted, P2PPortAllocator is allowed to gather local |
303 // host IP addresses as ICE candidates. |media_permission| could be nullptr, | 310 // host IP addresses as ICE candidates. |media_permission| could be nullptr, |
304 // which means the permission will be granted automatically. This could be the | 311 // which means the permission will be granted automatically. This could be the |
305 // case when either the experiment is not enabled or the preference is not | 312 // case when either the experiment is not enabled or the preference is not |
306 // enforced. | 313 // enforced. |
307 // | 314 // |
308 // Note on |media_permission| lifetime: |media_permission| is owned by a frame | 315 // Note on |media_permission| lifetime: |media_permission| is owned by a frame |
309 // (RenderFrameImpl). It is also stored as an indirect member of | 316 // (RenderFrameImpl). It is also stored as an indirect member of |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 case DISABLE_NON_PROXIED_UDP: | 353 case DISABLE_NON_PROXIED_UDP: |
347 port_config.enable_multiple_routes = false; | 354 port_config.enable_multiple_routes = false; |
348 port_config.enable_nonproxied_udp = false; | 355 port_config.enable_nonproxied_udp = false; |
349 break; | 356 break; |
350 case DEFAULT: | 357 case DEFAULT: |
351 port_config.enable_multiple_routes = true; | 358 port_config.enable_multiple_routes = true; |
352 port_config.enable_nonproxied_udp = true; | 359 port_config.enable_nonproxied_udp = true; |
353 break; | 360 break; |
354 } | 361 } |
355 | 362 |
| 363 min_port = |
| 364 renderer_view_impl->renderer_preferences().webrtc_udp_min_port; |
| 365 max_port = |
| 366 renderer_view_impl->renderer_preferences().webrtc_udp_max_port; |
| 367 |
356 VLOG(3) << "WebRTC routing preferences: " | 368 VLOG(3) << "WebRTC routing preferences: " |
357 << "policy: " << policy | 369 << "policy: " << policy |
358 << ", multiple_routes: " << port_config.enable_multiple_routes | 370 << ", multiple_routes: " << port_config.enable_multiple_routes |
359 << ", nonproxied_udp: " << port_config.enable_nonproxied_udp; | 371 << ", nonproxied_udp: " << port_config.enable_nonproxied_udp |
| 372 << ", min_udp_port: " << min_port |
| 373 << ", max_udp_port: " << max_port; |
360 } | 374 } |
361 } | 375 } |
362 if (port_config.enable_multiple_routes) { | 376 if (port_config.enable_multiple_routes) { |
363 bool create_media_permission = | 377 bool create_media_permission = |
364 base::CommandLine::ForCurrentProcess()->HasSwitch( | 378 base::CommandLine::ForCurrentProcess()->HasSwitch( |
365 switches::kEnforceWebRtcIPPermissionCheck); | 379 switches::kEnforceWebRtcIPPermissionCheck); |
366 create_media_permission = | 380 create_media_permission = |
367 create_media_permission || | 381 create_media_permission || |
368 !StartsWith(base::FieldTrialList::FindFullName( | 382 !StartsWith(base::FieldTrialList::FindFullName( |
369 "WebRTC-LocalIPPermissionCheck"), | 383 "WebRTC-LocalIPPermissionCheck"), |
(...skipping 16 matching lines...) Expand all Loading... |
386 FilteringNetworkManager* filtering_network_manager = | 400 FilteringNetworkManager* filtering_network_manager = |
387 new FilteringNetworkManager(network_manager_, requesting_origin, | 401 new FilteringNetworkManager(network_manager_, requesting_origin, |
388 media_permission); | 402 media_permission); |
389 network_manager.reset(filtering_network_manager); | 403 network_manager.reset(filtering_network_manager); |
390 } else { | 404 } else { |
391 network_manager.reset(new EmptyNetworkManager(network_manager_)); | 405 network_manager.reset(new EmptyNetworkManager(network_manager_)); |
392 } | 406 } |
393 std::unique_ptr<P2PPortAllocator> port_allocator(new P2PPortAllocator( | 407 std::unique_ptr<P2PPortAllocator> port_allocator(new P2PPortAllocator( |
394 p2p_socket_dispatcher_, std::move(network_manager), socket_factory_.get(), | 408 p2p_socket_dispatcher_, std::move(network_manager), socket_factory_.get(), |
395 port_config, requesting_origin)); | 409 port_config, requesting_origin)); |
| 410 if (IsValidPortRange(min_port, max_port)) |
| 411 port_allocator->SetPortRange(min_port, max_port); |
396 | 412 |
397 return GetPcFactory() | 413 return GetPcFactory() |
398 ->CreatePeerConnection(config, std::move(port_allocator), | 414 ->CreatePeerConnection(config, std::move(port_allocator), |
399 nullptr, observer) | 415 nullptr, observer) |
400 .get(); | 416 .get(); |
401 } | 417 } |
402 | 418 |
403 scoped_refptr<webrtc::MediaStreamInterface> | 419 scoped_refptr<webrtc::MediaStreamInterface> |
404 PeerConnectionDependencyFactory::CreateLocalMediaStream( | 420 PeerConnectionDependencyFactory::CreateLocalMediaStream( |
405 const std::string& label) { | 421 const std::string& label) { |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 | 575 |
560 void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() { | 576 void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() { |
561 DCHECK(CalledOnValidThread()); | 577 DCHECK(CalledOnValidThread()); |
562 if (audio_device_.get()) | 578 if (audio_device_.get()) |
563 return; | 579 return; |
564 | 580 |
565 audio_device_ = new WebRtcAudioDeviceImpl(); | 581 audio_device_ = new WebRtcAudioDeviceImpl(); |
566 } | 582 } |
567 | 583 |
568 } // namespace content | 584 } // namespace content |
OLD | NEW |