| 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 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_PEER_CONNECTION_DEPENDENCY_FACTORY_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_PEER_CONNECTION_DEPENDENCY_FACTORY_H_ | 
| 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_PEER_CONNECTION_DEPENDENCY_FACTORY_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_PEER_CONNECTION_DEPENDENCY_FACTORY_H_ | 
| 7 | 7 | 
| 8 #include <string> | 8 #include <string> | 
| 9 | 9 | 
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" | 
| 11 #include "base/files/file.h" | 11 #include "base/files/file.h" | 
| 12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" | 
| 13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" | 
| 14 #include "content/public/renderer/render_process_observer.h" | 14 #include "content/public/renderer/render_process_observer.h" | 
|  | 15 #include "content/renderer/media/aec_dump_message_filter.h" | 
| 15 #include "content/renderer/p2p/socket_dispatcher.h" | 16 #include "content/renderer/p2p/socket_dispatcher.h" | 
| 16 #include "ipc/ipc_platform_file.h" | 17 #include "ipc/ipc_platform_file.h" | 
| 17 #include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h
     " | 18 #include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h
     " | 
| 18 #include "third_party/libjingle/source/talk/app/webrtc/videosourceinterface.h" | 19 #include "third_party/libjingle/source/talk/app/webrtc/videosourceinterface.h" | 
| 19 | 20 | 
| 20 namespace base { | 21 namespace base { | 
| 21 class WaitableEvent; | 22 class WaitableEvent; | 
| 22 } | 23 } | 
| 23 | 24 | 
| 24 namespace talk_base { | 25 namespace talk_base { | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
| 48 class WebRtcAudioDeviceImpl; | 49 class WebRtcAudioDeviceImpl; | 
| 49 class WebRtcLocalAudioTrack; | 50 class WebRtcLocalAudioTrack; | 
| 50 class WebRtcLoggingHandlerImpl; | 51 class WebRtcLoggingHandlerImpl; | 
| 51 class WebRtcLoggingMessageFilter; | 52 class WebRtcLoggingMessageFilter; | 
| 52 class WebRtcVideoCapturerAdapter; | 53 class WebRtcVideoCapturerAdapter; | 
| 53 struct StreamDeviceInfo; | 54 struct StreamDeviceInfo; | 
| 54 | 55 | 
| 55 // Object factory for RTC PeerConnections. | 56 // Object factory for RTC PeerConnections. | 
| 56 class CONTENT_EXPORT PeerConnectionDependencyFactory | 57 class CONTENT_EXPORT PeerConnectionDependencyFactory | 
| 57     : NON_EXPORTED_BASE(public base::NonThreadSafe), | 58     : NON_EXPORTED_BASE(public base::NonThreadSafe), | 
| 58       public RenderProcessObserver { | 59       NON_EXPORTED_BASE(public AecDumpMessageFilter::AecDumpDelegate) { | 
| 59  public: | 60  public: | 
| 60   PeerConnectionDependencyFactory( | 61   PeerConnectionDependencyFactory( | 
| 61       P2PSocketDispatcher* p2p_socket_dispatcher); | 62       P2PSocketDispatcher* p2p_socket_dispatcher); | 
| 62   virtual ~PeerConnectionDependencyFactory(); | 63   virtual ~PeerConnectionDependencyFactory(); | 
| 63 | 64 | 
| 64   // Create a RTCPeerConnectionHandler object that implements the | 65   // Create a RTCPeerConnectionHandler object that implements the | 
| 65   // WebKit WebRTCPeerConnectionHandler interface. | 66   // WebKit WebRTCPeerConnectionHandler interface. | 
| 66   blink::WebRTCPeerConnectionHandler* CreateRTCPeerConnectionHandler( | 67   blink::WebRTCPeerConnectionHandler* CreateRTCPeerConnectionHandler( | 
| 67       blink::WebRTCPeerConnectionHandlerClient* client); | 68       blink::WebRTCPeerConnectionHandlerClient* client); | 
| 68 | 69 | 
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 122 | 123 | 
| 123   WebRtcAudioDeviceImpl* GetWebRtcAudioDevice(); | 124   WebRtcAudioDeviceImpl* GetWebRtcAudioDevice(); | 
| 124 | 125 | 
| 125   static void AddNativeAudioTrackToBlinkTrack( | 126   static void AddNativeAudioTrackToBlinkTrack( | 
| 126       webrtc::MediaStreamTrackInterface* native_track, | 127       webrtc::MediaStreamTrackInterface* native_track, | 
| 127       const blink::WebMediaStreamTrack& webkit_track, | 128       const blink::WebMediaStreamTrack& webkit_track, | 
| 128       bool is_local_track); | 129       bool is_local_track); | 
| 129 | 130 | 
| 130   scoped_refptr<base::MessageLoopProxy> GetWebRtcWorkerThread() const; | 131   scoped_refptr<base::MessageLoopProxy> GetWebRtcWorkerThread() const; | 
| 131 | 132 | 
|  | 133   // AecDumpMessageFilter::AecDumpDelegate implementation. | 
|  | 134   // TODO(xians): Remove when option to disable audio track processing is | 
|  | 135   // removed. | 
|  | 136   virtual void OnAecDumpFile( | 
|  | 137       const IPC::PlatformFileForTransit& file_handle) OVERRIDE; | 
|  | 138   virtual void OnDisableAecDump() OVERRIDE; | 
|  | 139   virtual void OnIpcClosing() OVERRIDE; | 
|  | 140 | 
| 132  protected: | 141  protected: | 
| 133   // Asks the PeerConnection factory to create a Local Audio Source. | 142   // Asks the PeerConnection factory to create a Local Audio Source. | 
| 134   virtual scoped_refptr<webrtc::AudioSourceInterface> | 143   virtual scoped_refptr<webrtc::AudioSourceInterface> | 
| 135       CreateLocalAudioSource( | 144       CreateLocalAudioSource( | 
| 136           const webrtc::MediaConstraintsInterface* constraints); | 145           const webrtc::MediaConstraintsInterface* constraints); | 
| 137 | 146 | 
| 138   // Creates a media::AudioCapturerSource with an implementation that is | 147   // Creates a media::AudioCapturerSource with an implementation that is | 
| 139   // specific for a WebAudio source. The created WebAudioCapturerSource | 148   // specific for a WebAudio source. The created WebAudioCapturerSource | 
| 140   // instance will function as audio source instead of the default | 149   // instance will function as audio source instead of the default | 
| 141   // WebRtcAudioCapturer. | 150   // WebRtcAudioCapturer. | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
| 170   // creating PeerConnection objects. | 179   // creating PeerConnection objects. | 
| 171   void CreatePeerConnectionFactory(); | 180   void CreatePeerConnectionFactory(); | 
| 172 | 181 | 
| 173   void InitializeWorkerThread(talk_base::Thread** thread, | 182   void InitializeWorkerThread(talk_base::Thread** thread, | 
| 174                               base::WaitableEvent* event); | 183                               base::WaitableEvent* event); | 
| 175 | 184 | 
| 176   void CreateIpcNetworkManagerOnWorkerThread(base::WaitableEvent* event); | 185   void CreateIpcNetworkManagerOnWorkerThread(base::WaitableEvent* event); | 
| 177   void DeleteIpcNetworkManager(); | 186   void DeleteIpcNetworkManager(); | 
| 178   void CleanupPeerConnectionFactory(); | 187   void CleanupPeerConnectionFactory(); | 
| 179 | 188 | 
| 180   // RenderProcessObserver implementation. |  | 
| 181   virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; |  | 
| 182 |  | 
| 183   void OnAecDumpFile(IPC::PlatformFileForTransit file_handle); |  | 
| 184   void OnDisableAecDump(); |  | 
| 185 |  | 
| 186   void StartAecDump(base::File aec_dump_file); |  | 
| 187 |  | 
| 188   // Helper method to create a WebRtcAudioDeviceImpl. | 189   // Helper method to create a WebRtcAudioDeviceImpl. | 
| 189   void EnsureWebRtcAudioDeviceImpl(); | 190   void EnsureWebRtcAudioDeviceImpl(); | 
| 190 | 191 | 
| 191   // We own network_manager_, must be deleted on the worker thread. | 192   // We own network_manager_, must be deleted on the worker thread. | 
| 192   // The network manager uses |p2p_socket_dispatcher_|. | 193   // The network manager uses |p2p_socket_dispatcher_|. | 
| 193   IpcNetworkManager* network_manager_; | 194   IpcNetworkManager* network_manager_; | 
| 194   scoped_ptr<IpcPacketSocketFactory> socket_factory_; | 195   scoped_ptr<IpcPacketSocketFactory> socket_factory_; | 
| 195 | 196 | 
| 196   scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory_; | 197   scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory_; | 
| 197 | 198 | 
| 198   scoped_refptr<P2PSocketDispatcher> p2p_socket_dispatcher_; | 199   scoped_refptr<P2PSocketDispatcher> p2p_socket_dispatcher_; | 
| 199   scoped_refptr<WebRtcAudioDeviceImpl> audio_device_; | 200   scoped_refptr<WebRtcAudioDeviceImpl> audio_device_; | 
| 200 | 201 | 
|  | 202   // This is only used if audio track processing is disabled. | 
|  | 203   // TODO(xians): Remove when option to disable audio track processing is | 
|  | 204   // removed. | 
|  | 205   scoped_refptr<AecDumpMessageFilter> aec_dump_message_filter_; | 
|  | 206 | 
| 201   // PeerConnection threads. signaling_thread_ is created from the | 207   // PeerConnection threads. signaling_thread_ is created from the | 
| 202   // "current" chrome thread. | 208   // "current" chrome thread. | 
| 203   talk_base::Thread* signaling_thread_; | 209   talk_base::Thread* signaling_thread_; | 
| 204   talk_base::Thread* worker_thread_; | 210   talk_base::Thread* worker_thread_; | 
| 205   base::Thread chrome_worker_thread_; | 211   base::Thread chrome_worker_thread_; | 
| 206 | 212 | 
| 207   base::File aec_dump_file_; |  | 
| 208 |  | 
| 209   DISALLOW_COPY_AND_ASSIGN(PeerConnectionDependencyFactory); | 213   DISALLOW_COPY_AND_ASSIGN(PeerConnectionDependencyFactory); | 
| 210 }; | 214 }; | 
| 211 | 215 | 
| 212 }  // namespace content | 216 }  // namespace content | 
| 213 | 217 | 
| 214 #endif  // CONTENT_RENDERER_MEDIA_WEBRTC_PEER_CONNECTION_DEPENDENCY_FACTORY_H_ | 218 #endif  // CONTENT_RENDERER_MEDIA_WEBRTC_PEER_CONNECTION_DEPENDENCY_FACTORY_H_ | 
| OLD | NEW | 
|---|