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

Unified 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: Rebased to latest codec base. 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/media_stream_dependency_factory.h
diff --git a/content/renderer/media/media_stream_dependency_factory.h b/content/renderer/media/media_stream_dependency_factory.h
index 7eb1ab68a1211a090ed3ce070cf33a8a05538141..530e9524706503daf78545fe44191932f2b21809 100644
--- a/content/renderer/media/media_stream_dependency_factory.h
+++ b/content/renderer/media/media_stream_dependency_factory.h
@@ -9,17 +9,18 @@
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
+#include "base/threading/thread.h"
#include "content/common/content_export.h"
+#include "content/renderer/p2p/socket_dispatcher.h"
#include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h"
+namespace base {
+class WaitableEvent;
+}
+
namespace content {
class IpcNetworkManager;
class IpcPacketSocketFactory;
-class P2PSocketDispatcher;
-}
-
-namespace cricket {
-class PortAllocator;
}
namespace talk_base {
@@ -30,35 +31,55 @@ class Thread;
namespace webrtc {
class PeerConnection;
-class VideoCaptureModule;
}
-class VideoCaptureImplManager;
+namespace WebKit {
+class WebMediaStreamDescriptor;
+class WebPeerConnection00Handler;
+class WebPeerConnection00HandlerClient;
+}
+
class WebRtcAudioDeviceImpl;
+class VideoCaptureImplManager;
-// Object factory for MediaStreamImpl and PeerConnectionHandler.
-class CONTENT_EXPORT MediaStreamDependencyFactory {
+// Object factory for RTC MediaStreams and RTC PeerConnections.
+class CONTENT_EXPORT MediaStreamDependencyFactory
+ : NON_EXPORTED_BASE(public base::NonThreadSafe) {
public:
- explicit MediaStreamDependencyFactory(VideoCaptureImplManager* vc_manager);
+ MediaStreamDependencyFactory(
+ VideoCaptureImplManager* vc_manager,
+ content::P2PSocketDispatcher* p2p_socket_dispatcher);
virtual ~MediaStreamDependencyFactory();
- // Creates and deletes |pc_factory_|, which in turn is used for
- // creating PeerConnection objects.
- virtual bool CreatePeerConnectionFactory(
- talk_base::Thread* worker_thread,
- talk_base::Thread* signaling_thread,
- content::P2PSocketDispatcher* socket_dispatcher,
- talk_base::NetworkManager* network_manager,
- talk_base::PacketSocketFactory* socket_factory);
- virtual void ReleasePeerConnectionFactory();
- virtual bool PeerConnectionFactoryCreated();
+ // Create a a PeerConnectionHandlerJsep object that implements the
+ // WebKit WebPeerConnection00Handler interface.
+ WebKit::WebPeerConnection00Handler* CreatePeerConnectionHandlerJsep(
+ WebKit::WebPeerConnection00HandlerClient* client);
- // Asks the PeerConnection factory to create a PeerConnection object.
+ // Creates a libjingle representation of a MediaStream and stores
+ // it in the extra data field of |description|
+ bool CreateNativeLocalMediaStream(
+ WebKit::WebMediaStreamDescriptor* description);
+
+ // Asks the libjingle PeerConnection factory to create a libjingle
+ // PeerConnection object.
// The PeerConnection object is owned by PeerConnectionHandler.
virtual talk_base::scoped_refptr<webrtc::PeerConnectionInterface>
CreatePeerConnection(const std::string& config,
webrtc::PeerConnectionObserver* observer);
+ // Creates a libjingle representation of a Session description.
+ virtual webrtc::SessionDescriptionInterface* CreateSessionDescription(
+ const std::string& sdp);
+
+ // Creates a libjingle representation of an ice candidate.
+ virtual webrtc::IceCandidateInterface* CreateIceCandidate(
+ const std::string& sdp_mid,
+ int sdp_mline_index,
+ const std::string& sdp);
+
tommi (sloooow) - chröme 2012/09/12 13:10:24 only one space
perkj_chrome 2012/09/12 13:54:39 Done.
+
+ protected:
// Asks the PeerConnection factory to create a Local MediaStream object.
virtual talk_base::scoped_refptr<webrtc::LocalMediaStreamInterface>
CreateLocalMediaStream(const std::string& label);
@@ -73,20 +94,44 @@ class CONTENT_EXPORT MediaStreamDependencyFactory {
CreateLocalAudioTrack(const std::string& label,
webrtc::AudioDeviceModule* audio_device);
- virtual webrtc::SessionDescriptionInterface* CreateSessionDescription(
- const std::string& sdp);
- virtual webrtc::IceCandidateInterface* CreateIceCandidate(
- const std::string& sdp_mid,
- int sdp_mline_index,
- const std::string& sdp);
-
+ virtual bool EnsurePeerConnectionFactory();
virtual void SetAudioDeviceSessionId(int session_id);
private:
+ // Creates and deletes |pc_factory_|, which in turn is used for
+ // creating PeerConnection objects.
+ bool CreatePeerConnectionFactory(
+ talk_base::Thread* worker_thread,
+ talk_base::Thread* signaling_thread,
+ content::P2PSocketDispatcher* socket_dispatcher,
+ talk_base::NetworkManager* network_manager,
+ talk_base::PacketSocketFactory* socket_factory);
+ bool PeerConnectionFactoryCreated();
+
+ void InitializeWorkerThread(talk_base::Thread** thread,
+ base::WaitableEvent* event);
+
+ void CreateIpcNetworkManagerOnWorkerThread(base::WaitableEvent* event);
+ void DeleteIpcNetworkManager();
+ void CleanupPeerConnectionFactory();
+
+ // We own network_manager_, must be deleted on the worker thread.
+ // The network manager uses |p2p_socket_dispatcher_|.
+ content::IpcNetworkManager* network_manager_;
+ scoped_ptr<content::IpcPacketSocketFactory> socket_factory_;
+
talk_base::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory_;
+
scoped_refptr<VideoCaptureImplManager> vc_manager_;
+ scoped_refptr<content::P2PSocketDispatcher> p2p_socket_dispatcher_;
tommi (sloooow) - chröme 2012/09/12 13:10:24 can we always fetch this from the render thread pe
perkj_chrome 2012/09/12 13:54:39 It would be hard to test using the mock_dependency
scoped_refptr<WebRtcAudioDeviceImpl> audio_device_;
+ // PeerConnection threads. signaling_thread_ is created from the
+ // "current" chrome thread.
+ talk_base::Thread* signaling_thread_;
+ talk_base::Thread* worker_thread_;
+ base::Thread chrome_worker_thread_;
+
DISALLOW_COPY_AND_ASSIGN(MediaStreamDependencyFactory);
};

Powered by Google App Engine
This is Rietveld 408576698