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

Side by Side Diff: content/renderer/media/media_stream_dependency_factory.h

Issue 10919122: Move creation of PeerConnection from the RenderView to the RenderThreadImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: #if defined(ENABLE_WEBRTC) in RendererWebKitPlatformSupportImpl::createPeerConnection00Handler to b… Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
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 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DEPENDENCY_FACTORY_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DEPENDENCY_FACTORY_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DEPENDENCY_FACTORY_H_ 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_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/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/threading/thread.h"
12 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
14 #include "content/renderer/p2p/socket_dispatcher.h"
13 #include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h " 15 #include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h "
14 16
17 namespace base {
18 class WaitableEvent;
19 }
20
15 namespace content { 21 namespace content {
16 class IpcNetworkManager; 22 class IpcNetworkManager;
17 class IpcPacketSocketFactory; 23 class IpcPacketSocketFactory;
18 class P2PSocketDispatcher;
19 }
20
21 namespace cricket {
22 class PortAllocator;
23 } 24 }
24 25
25 namespace talk_base { 26 namespace talk_base {
26 class NetworkManager; 27 class NetworkManager;
27 class PacketSocketFactory; 28 class PacketSocketFactory;
28 class Thread; 29 class Thread;
29 } 30 }
30 31
31 namespace webrtc { 32 namespace webrtc {
32 class PeerConnection; 33 class PeerConnection;
33 class VideoCaptureModule;
34 } 34 }
35 35
36 namespace WebKit {
37 class WebMediaStreamDescriptor;
38 class WebPeerConnection00Handler;
39 class WebPeerConnection00HandlerClient;
40 }
41
42 class WebRtcAudioDeviceImpl;
36 class VideoCaptureImplManager; 43 class VideoCaptureImplManager;
37 class WebRtcAudioDeviceImpl;
38 44
39 // Object factory for MediaStreamImpl and PeerConnectionHandler. 45 // Object factory for RTC MediaStreams and RTC PeerConnections.
40 class CONTENT_EXPORT MediaStreamDependencyFactory { 46 class CONTENT_EXPORT MediaStreamDependencyFactory
47 : NON_EXPORTED_BASE(public base::NonThreadSafe) {
41 public: 48 public:
42 explicit MediaStreamDependencyFactory(VideoCaptureImplManager* vc_manager); 49 MediaStreamDependencyFactory(
50 VideoCaptureImplManager* vc_manager,
51 content::P2PSocketDispatcher* p2p_socket_dispatcher);
43 virtual ~MediaStreamDependencyFactory(); 52 virtual ~MediaStreamDependencyFactory();
44 53
45 // Creates and deletes |pc_factory_|, which in turn is used for 54 // Create a a PeerConnectionHandlerJsep object that implements the
46 // creating PeerConnection objects. 55 // WebKit WebPeerConnection00Handler interface.
47 virtual bool CreatePeerConnectionFactory( 56 WebKit::WebPeerConnection00Handler* CreatePeerConnectionHandlerJsep(
48 talk_base::Thread* worker_thread, 57 WebKit::WebPeerConnection00HandlerClient* client);
49 talk_base::Thread* signaling_thread,
50 content::P2PSocketDispatcher* socket_dispatcher,
51 talk_base::NetworkManager* network_manager,
52 talk_base::PacketSocketFactory* socket_factory);
53 virtual void ReleasePeerConnectionFactory();
54 virtual bool PeerConnectionFactoryCreated();
55 58
56 // Asks the PeerConnection factory to create a PeerConnection object. 59 // Creates a libjingle representation of a MediaStream and stores
60 // it in the extra data field of |description|
61 bool CreateNativeLocalMediaStream(
62 WebKit::WebMediaStreamDescriptor* description);
63
64 // Asks the libjingle PeerConnection factory to create a libjingle
65 // PeerConnection object.
57 // The PeerConnection object is owned by PeerConnectionHandler. 66 // The PeerConnection object is owned by PeerConnectionHandler.
58 virtual talk_base::scoped_refptr<webrtc::PeerConnectionInterface> 67 virtual talk_base::scoped_refptr<webrtc::PeerConnectionInterface>
59 CreatePeerConnection(const std::string& config, 68 CreatePeerConnection(const std::string& config,
60 webrtc::PeerConnectionObserver* observer); 69 webrtc::PeerConnectionObserver* observer);
61 70
71 // Creates a libjingle representation of a Session description.
72 virtual webrtc::SessionDescriptionInterface* CreateSessionDescription(
73 const std::string& sdp);
74
75 // Creates a libjingle representation of an ice candidate.
76 virtual webrtc::IceCandidateInterface* CreateIceCandidate(
77 const std::string& sdp_mid,
78 int sdp_mline_index,
79 const std::string& sdp);
80
81 protected:
62 // Asks the PeerConnection factory to create a Local MediaStream object. 82 // Asks the PeerConnection factory to create a Local MediaStream object.
63 virtual talk_base::scoped_refptr<webrtc::LocalMediaStreamInterface> 83 virtual talk_base::scoped_refptr<webrtc::LocalMediaStreamInterface>
64 CreateLocalMediaStream(const std::string& label); 84 CreateLocalMediaStream(const std::string& label);
65 85
66 // Asks the PeerConnection factory to create a Local VideoTrack object. 86 // Asks the PeerConnection factory to create a Local VideoTrack object.
67 virtual talk_base::scoped_refptr<webrtc::LocalVideoTrackInterface> 87 virtual talk_base::scoped_refptr<webrtc::LocalVideoTrackInterface>
68 CreateLocalVideoTrack(const std::string& label, 88 CreateLocalVideoTrack(const std::string& label,
69 int video_session_id); 89 int video_session_id);
70 90
71 // Asks the PeerConnection factory to create a Local AudioTrack object. 91 // Asks the PeerConnection factory to create a Local AudioTrack object.
72 virtual talk_base::scoped_refptr<webrtc::LocalAudioTrackInterface> 92 virtual talk_base::scoped_refptr<webrtc::LocalAudioTrackInterface>
73 CreateLocalAudioTrack(const std::string& label, 93 CreateLocalAudioTrack(const std::string& label,
74 webrtc::AudioDeviceModule* audio_device); 94 webrtc::AudioDeviceModule* audio_device);
75 95
76 virtual webrtc::SessionDescriptionInterface* CreateSessionDescription( 96 virtual bool EnsurePeerConnectionFactory();
77 const std::string& sdp);
78 virtual webrtc::IceCandidateInterface* CreateIceCandidate(
79 const std::string& sdp_mid,
80 int sdp_mline_index,
81 const std::string& sdp);
82
83 virtual void SetAudioDeviceSessionId(int session_id); 97 virtual void SetAudioDeviceSessionId(int session_id);
84 98
85 private: 99 private:
100 // Creates and deletes |pc_factory_|, which in turn is used for
101 // creating PeerConnection objects.
102 bool CreatePeerConnectionFactory(
103 talk_base::Thread* worker_thread,
104 talk_base::Thread* signaling_thread,
105 content::P2PSocketDispatcher* socket_dispatcher,
106 talk_base::NetworkManager* network_manager,
107 talk_base::PacketSocketFactory* socket_factory);
108 bool PeerConnectionFactoryCreated();
109
110 void InitializeWorkerThread(talk_base::Thread** thread,
111 base::WaitableEvent* event);
112
113 void CreateIpcNetworkManagerOnWorkerThread(base::WaitableEvent* event);
114 void DeleteIpcNetworkManager();
115 void CleanupPeerConnectionFactory();
116
117 // We own network_manager_, must be deleted on the worker thread.
118 // The network manager uses |p2p_socket_dispatcher_|.
119 content::IpcNetworkManager* network_manager_;
120 scoped_ptr<content::IpcPacketSocketFactory> socket_factory_;
121
86 talk_base::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory_; 122 talk_base::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory_;
123
87 scoped_refptr<VideoCaptureImplManager> vc_manager_; 124 scoped_refptr<VideoCaptureImplManager> vc_manager_;
125 scoped_refptr<content::P2PSocketDispatcher> p2p_socket_dispatcher_;
88 scoped_refptr<WebRtcAudioDeviceImpl> audio_device_; 126 scoped_refptr<WebRtcAudioDeviceImpl> audio_device_;
89 127
128 // PeerConnection threads. signaling_thread_ is created from the
129 // "current" chrome thread.
130 talk_base::Thread* signaling_thread_;
131 talk_base::Thread* worker_thread_;
132 base::Thread chrome_worker_thread_;
133
90 DISALLOW_COPY_AND_ASSIGN(MediaStreamDependencyFactory); 134 DISALLOW_COPY_AND_ASSIGN(MediaStreamDependencyFactory);
91 }; 135 };
92 136
93 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DEPENDENCY_FACTORY_H_ 137 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DEPENDENCY_FACTORY_H_
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_center.cc ('k') | content/renderer/media/media_stream_dependency_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698