| OLD | NEW |
| 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/media_stream_dependency_factory.h" | 5 #include "content/renderer/media/media_stream_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/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
| 13 #include "content/renderer/media/media_stream_source_extra_data.h" | 13 #include "content/renderer/media/media_stream_source_extra_data.h" |
| 14 #include "content/renderer/media/rtc_media_constraints.h" | 14 #include "content/renderer/media/rtc_media_constraints.h" |
| 15 #include "content/renderer/media/rtc_peer_connection_handler.h" | 15 #include "content/renderer/media/rtc_peer_connection_handler.h" |
| 16 #include "content/renderer/media/rtc_video_capturer.h" | 16 #include "content/renderer/media/rtc_video_capturer.h" |
| 17 #include "content/renderer/media/video_capture_impl_manager.h" | 17 #include "content/renderer/media/video_capture_impl_manager.h" |
| 18 #include "content/renderer/media/webaudio_capturer_source.h" | 18 #include "content/renderer/media/webaudio_capturer_source.h" |
| 19 #include "content/renderer/media/webrtc_audio_device_impl.h" | 19 #include "content/renderer/media/webrtc_audio_device_impl.h" |
| 20 #include "content/renderer/media/webrtc_local_audio_track.h" | 20 #include "content/renderer/media/webrtc_local_audio_track.h" |
| 21 #include "content/renderer/media/webrtc_logging_handler_impl.h" | 21 #include "content/renderer/media/webrtc_logging_initializer_impl.h" |
| 22 #include "content/renderer/media/webrtc_logging_message_filter.h" | |
| 23 #include "content/renderer/media/webrtc_uma_histograms.h" | 22 #include "content/renderer/media/webrtc_uma_histograms.h" |
| 24 #include "content/renderer/p2p/ipc_network_manager.h" | 23 #include "content/renderer/p2p/ipc_network_manager.h" |
| 25 #include "content/renderer/p2p/ipc_socket_factory.h" | 24 #include "content/renderer/p2p/ipc_socket_factory.h" |
| 26 #include "content/renderer/p2p/port_allocator.h" | 25 #include "content/renderer/p2p/port_allocator.h" |
| 27 #include "content/renderer/render_thread_impl.h" | 26 #include "content/renderer/render_thread_impl.h" |
| 28 #include "jingle/glue/thread_wrapper.h" | 27 #include "jingle/glue/thread_wrapper.h" |
| 29 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaConstraints
.h" | 28 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaConstraints
.h" |
| 30 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStream.h" | 29 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStream.h" |
| 31 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamSourc
e.h" | 30 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamSourc
e.h" |
| 32 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamTrack
.h" | 31 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamTrack
.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 }; | 209 }; |
| 211 | 210 |
| 212 MediaStreamDependencyFactory::MediaStreamDependencyFactory( | 211 MediaStreamDependencyFactory::MediaStreamDependencyFactory( |
| 213 VideoCaptureImplManager* vc_manager, | 212 VideoCaptureImplManager* vc_manager, |
| 214 P2PSocketDispatcher* p2p_socket_dispatcher) | 213 P2PSocketDispatcher* p2p_socket_dispatcher) |
| 215 : network_manager_(NULL), | 214 : network_manager_(NULL), |
| 216 vc_manager_(vc_manager), | 215 vc_manager_(vc_manager), |
| 217 p2p_socket_dispatcher_(p2p_socket_dispatcher), | 216 p2p_socket_dispatcher_(p2p_socket_dispatcher), |
| 218 signaling_thread_(NULL), | 217 signaling_thread_(NULL), |
| 219 worker_thread_(NULL), | 218 worker_thread_(NULL), |
| 220 chrome_worker_thread_("Chrome_libJingle_WorkerThread"), | 219 chrome_worker_thread_("Chrome_libJingle_WorkerThread") { |
| 221 webrtc_log_open_(false) { | |
| 222 } | 220 } |
| 223 | 221 |
| 224 MediaStreamDependencyFactory::~MediaStreamDependencyFactory() { | 222 MediaStreamDependencyFactory::~MediaStreamDependencyFactory() { |
| 225 CleanupPeerConnectionFactory(); | 223 CleanupPeerConnectionFactory(); |
| 226 } | 224 } |
| 227 | 225 |
| 228 WebKit::WebRTCPeerConnectionHandler* | 226 WebKit::WebRTCPeerConnectionHandler* |
| 229 MediaStreamDependencyFactory::CreateRTCPeerConnectionHandler( | 227 MediaStreamDependencyFactory::CreateRTCPeerConnectionHandler( |
| 230 WebKit::WebRTCPeerConnectionHandlerClient* client) { | 228 WebKit::WebRTCPeerConnectionHandlerClient* client) { |
| 231 // Save histogram data so we can see how much PeerConnetion is used. | 229 // Save histogram data so we can see how much PeerConnetion is used. |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 const webrtc::PeerConnectionInterface::IceServers& ice_servers, | 497 const webrtc::PeerConnectionInterface::IceServers& ice_servers, |
| 500 const webrtc::MediaConstraintsInterface* constraints, | 498 const webrtc::MediaConstraintsInterface* constraints, |
| 501 WebKit::WebFrame* web_frame, | 499 WebKit::WebFrame* web_frame, |
| 502 webrtc::PeerConnectionObserver* observer) { | 500 webrtc::PeerConnectionObserver* observer) { |
| 503 CHECK(web_frame); | 501 CHECK(web_frame); |
| 504 CHECK(observer); | 502 CHECK(observer); |
| 505 | 503 |
| 506 webrtc::MediaConstraintsInterface::Constraints optional_constraints = | 504 webrtc::MediaConstraintsInterface::Constraints optional_constraints = |
| 507 constraints->GetOptional(); | 505 constraints->GetOptional(); |
| 508 std::string constraint_value; | 506 std::string constraint_value; |
| 509 if (!webrtc_log_open_ && | 507 if (optional_constraints.FindFirst(kWebRtcLoggingConstraint, |
| 510 optional_constraints.FindFirst(kWebRtcLoggingConstraint, | |
| 511 &constraint_value)) { | 508 &constraint_value)) { |
| 512 webrtc_log_open_ = true; | |
| 513 std::string url = web_frame->document().url().spec(); | 509 std::string url = web_frame->document().url().spec(); |
| 514 | |
| 515 RenderThreadImpl::current()->GetIOMessageLoopProxy()->PostTask( | 510 RenderThreadImpl::current()->GetIOMessageLoopProxy()->PostTask( |
| 516 FROM_HERE, base::Bind( | 511 FROM_HERE, base::Bind( |
| 517 &MediaStreamDependencyFactory::CreateWebRtcLoggingHandler, | 512 &InitWebRtcLogging, |
| 518 base::Unretained(this), | |
| 519 RenderThreadImpl::current()->webrtc_logging_message_filter(), | |
| 520 constraint_value, | 513 constraint_value, |
| 521 url)); | 514 url)); |
| 522 } | 515 } |
| 523 | 516 |
| 524 scoped_refptr<P2PPortAllocatorFactory> pa_factory = | 517 scoped_refptr<P2PPortAllocatorFactory> pa_factory = |
| 525 new talk_base::RefCountedObject<P2PPortAllocatorFactory>( | 518 new talk_base::RefCountedObject<P2PPortAllocatorFactory>( |
| 526 p2p_socket_dispatcher_.get(), | 519 p2p_socket_dispatcher_.get(), |
| 527 network_manager_, | 520 network_manager_, |
| 528 socket_factory_.get(), | 521 socket_factory_.get(), |
| 529 web_frame); | 522 web_frame); |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 // Stopping the thread will wait until all tasks have been | 777 // Stopping the thread will wait until all tasks have been |
| 785 // processed before returning. We wait for the above task to finish before | 778 // processed before returning. We wait for the above task to finish before |
| 786 // letting the the function continue to avoid any potential race issues. | 779 // letting the the function continue to avoid any potential race issues. |
| 787 chrome_worker_thread_.Stop(); | 780 chrome_worker_thread_.Stop(); |
| 788 } else { | 781 } else { |
| 789 NOTREACHED() << "Worker thread not running."; | 782 NOTREACHED() << "Worker thread not running."; |
| 790 } | 783 } |
| 791 } | 784 } |
| 792 } | 785 } |
| 793 | 786 |
| 794 void MediaStreamDependencyFactory::CreateWebRtcLoggingHandler( | |
| 795 WebRtcLoggingMessageFilter* filter, | |
| 796 const std::string& app_session_id, | |
| 797 const std::string& app_url) { | |
| 798 WebRtcLoggingHandlerImpl* handler = | |
| 799 new WebRtcLoggingHandlerImpl(filter->io_message_loop()); | |
| 800 filter->InitLogging(handler, app_session_id, app_url); | |
| 801 } | |
| 802 | |
| 803 } // namespace content | 787 } // namespace content |
| OLD | NEW |