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

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

Issue 9699069: Adding JSEP PeerConnection glue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed missing export. Created 8 years, 8 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_IMPL_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_ 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 #include <utility>
11 12
12 #include "base/basictypes.h" 13 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
14 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
15 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
18 #include "base/message_loop_proxy.h" 19 #include "base/message_loop_proxy.h"
19 #include "base/threading/non_thread_safe.h" 20 #include "base/threading/non_thread_safe.h"
20 #include "base/threading/thread.h" 21 #include "base/threading/thread.h"
(...skipping 14 matching lines...) Expand all
35 class IpcNetworkManager; 36 class IpcNetworkManager;
36 class IpcPacketSocketFactory; 37 class IpcPacketSocketFactory;
37 class P2PSocketDispatcher; 38 class P2PSocketDispatcher;
38 } 39 }
39 40
40 namespace talk_base { 41 namespace talk_base {
41 class Thread; 42 class Thread;
42 } 43 }
43 44
44 namespace WebKit { 45 namespace WebKit {
46 class WebPeerConnection00Handler;
47 class WebPeerConnection00HandlerClient;
45 class WebPeerConnectionHandler; 48 class WebPeerConnectionHandler;
46 class WebPeerConnectionHandlerClient; 49 class WebPeerConnectionHandlerClient;
47 } 50 }
48 51
49 class MediaStreamDispatcher; 52 class MediaStreamDispatcher;
50 class MediaStreamDependencyFactory; 53 class MediaStreamDependencyFactory;
51 class PeerConnectionHandler; 54 class PeerConnectionHandlerBase;
52 class VideoCaptureImplManager; 55 class VideoCaptureImplManager;
53 class RTCVideoDecoder; 56 class RTCVideoDecoder;
54 57
55 // MediaStreamImpl is a delegate for the Media Stream API messages used by 58 // MediaStreamImpl is a delegate for the Media Stream API messages used by
56 // WebKit. It ties together WebKit, native PeerConnection in libjingle and 59 // WebKit. It ties together WebKit, native PeerConnection in libjingle and
57 // MediaStreamManager (via MediaStreamDispatcher and MediaStreamDispatcherHost) 60 // MediaStreamManager (via MediaStreamDispatcher and MediaStreamDispatcherHost)
58 // in the browser process. It must be created, called and destroyed on the 61 // in the browser process. It must be created, called and destroyed on the
59 // render thread. 62 // render thread.
60 class CONTENT_EXPORT MediaStreamImpl 63 class CONTENT_EXPORT MediaStreamImpl
61 : NON_EXPORTED_BASE(public WebKit::WebUserMediaClient), 64 : NON_EXPORTED_BASE(public WebKit::WebUserMediaClient),
62 NON_EXPORTED_BASE(public webkit_media::MediaStreamClient), 65 NON_EXPORTED_BASE(public webkit_media::MediaStreamClient),
63 public MediaStreamDispatcherEventHandler, 66 public MediaStreamDispatcherEventHandler,
64 NON_EXPORTED_BASE(public base::NonThreadSafe), 67 NON_EXPORTED_BASE(public base::NonThreadSafe),
65 public base::RefCountedThreadSafe<MediaStreamImpl>, 68 public base::RefCountedThreadSafe<MediaStreamImpl>,
66 public base::SupportsWeakPtr<MediaStreamImpl> { 69 public base::SupportsWeakPtr<MediaStreamImpl> {
67 public: 70 public:
68 MediaStreamImpl( 71 MediaStreamImpl(
69 MediaStreamDispatcher* media_stream_dispatcher, 72 MediaStreamDispatcher* media_stream_dispatcher,
70 content::P2PSocketDispatcher* p2p_socket_dispatcher, 73 content::P2PSocketDispatcher* p2p_socket_dispatcher,
71 VideoCaptureImplManager* vc_manager, 74 VideoCaptureImplManager* vc_manager,
72 MediaStreamDependencyFactory* dependency_factory); 75 MediaStreamDependencyFactory* dependency_factory);
73 virtual ~MediaStreamImpl(); 76 virtual ~MediaStreamImpl();
74 77
75 virtual WebKit::WebPeerConnectionHandler* CreatePeerConnectionHandler( 78 virtual WebKit::WebPeerConnectionHandler* CreatePeerConnectionHandler(
76 WebKit::WebPeerConnectionHandlerClient* client); 79 WebKit::WebPeerConnectionHandlerClient* client);
77 virtual void ClosePeerConnection(); 80 virtual WebKit::WebPeerConnection00Handler* CreatePeerConnectionHandlerJsep(
81 WebKit::WebPeerConnection00HandlerClient* client);
82 virtual void ClosePeerConnection(PeerConnectionHandlerBase* pc_handler);
78 virtual webrtc::MediaStreamTrackInterface* GetLocalMediaStreamTrack( 83 virtual webrtc::MediaStreamTrackInterface* GetLocalMediaStreamTrack(
79 const std::string& label); 84 const std::string& label);
80 85
81 // WebKit::WebUserMediaClient implementation 86 // WebKit::WebUserMediaClient implementation
82 virtual void requestUserMedia( 87 virtual void requestUserMedia(
83 const WebKit::WebUserMediaRequest& user_media_request, 88 const WebKit::WebUserMediaRequest& user_media_request,
84 const WebKit::WebVector<WebKit::WebMediaStreamSource>& audio_sources, 89 const WebKit::WebVector<WebKit::WebMediaStreamSource>& audio_sources,
85 const WebKit::WebVector<WebKit::WebMediaStreamSource>& video_sources) 90 const WebKit::WebVector<WebKit::WebMediaStreamSource>& video_sources)
86 OVERRIDE; 91 OVERRIDE;
87 virtual void cancelUserMediaRequest( 92 virtual void cancelUserMediaRequest(
(...skipping 22 matching lines...) Expand all
110 const media_stream::StreamDeviceInfoArray& device_array) OVERRIDE; 115 const media_stream::StreamDeviceInfoArray& device_array) OVERRIDE;
111 virtual void OnDevicesEnumerationFailed(int request_id) OVERRIDE; 116 virtual void OnDevicesEnumerationFailed(int request_id) OVERRIDE;
112 virtual void OnDeviceOpened( 117 virtual void OnDeviceOpened(
113 int request_id, 118 int request_id,
114 const std::string& label, 119 const std::string& label,
115 const media_stream::StreamDeviceInfo& device_info) OVERRIDE; 120 const media_stream::StreamDeviceInfo& device_info) OVERRIDE;
116 virtual void OnDeviceOpenFailed(int request_id) OVERRIDE; 121 virtual void OnDeviceOpenFailed(int request_id) OVERRIDE;
117 122
118 private: 123 private:
119 FRIEND_TEST_ALL_PREFIXES(MediaStreamImplTest, Basic); 124 FRIEND_TEST_ALL_PREFIXES(MediaStreamImplTest, Basic);
125 FRIEND_TEST_ALL_PREFIXES(MediaStreamImplTest, MultiplePeerConnections);
120 126
121 class VideoRendererWrapper : public webrtc::VideoRendererWrapperInterface { 127 class VideoRendererWrapper : public webrtc::VideoRendererWrapperInterface {
122 public: 128 public:
123 VideoRendererWrapper(); 129 VideoRendererWrapper();
124 virtual cricket::VideoRenderer* renderer() OVERRIDE { 130 virtual cricket::VideoRenderer* renderer() OVERRIDE {
125 return rtc_video_decoder_.get(); 131 return rtc_video_decoder_.get();
126 } 132 }
127 void SetVideoDecoder(RTCVideoDecoder* decoder); 133 void SetVideoDecoder(RTCVideoDecoder* decoder);
128 134
129 protected: 135 protected:
(...skipping 22 matching lines...) Expand all
152 // for the lifetime of RenderView. 158 // for the lifetime of RenderView.
153 content::P2PSocketDispatcher* p2p_socket_dispatcher_; 159 content::P2PSocketDispatcher* p2p_socket_dispatcher_;
154 160
155 // We own network_manager_, must be deleted on the worker thread. 161 // We own network_manager_, must be deleted on the worker thread.
156 content::IpcNetworkManager* network_manager_; 162 content::IpcNetworkManager* network_manager_;
157 163
158 scoped_ptr<content::IpcPacketSocketFactory> socket_factory_; 164 scoped_ptr<content::IpcPacketSocketFactory> socket_factory_;
159 165
160 scoped_refptr<VideoCaptureImplManager> vc_manager_; 166 scoped_refptr<VideoCaptureImplManager> vc_manager_;
161 167
162 // peer_connection_handler_ is a weak reference, owned by WebKit. It's valid 168 // peer_connection_handlers_ contains raw references, owned by WebKit. A
163 // until stop is called on it (which will call ClosePeerConnection on us). 169 // pointer is valid until stop is called on the object (which will call
164 // TODO(grunell): Support several PeerConnectionsHandlers. 170 // ClosePeerConnection on us and we remove the pointer).
165 PeerConnectionHandler* peer_connection_handler_; 171 std::list<PeerConnectionHandlerBase*> peer_connection_handlers_;
166 172
167 // We keep a list of the generated local tracks, so that we can add capture 173 // We keep a list of the generated local tracks, so that we can add capture
168 // devices when generated and also use them for recording. 174 // devices when generated and also use them for recording.
169 typedef talk_base::scoped_refptr<webrtc::MediaStreamTrackInterface> 175 typedef talk_base::scoped_refptr<webrtc::MediaStreamTrackInterface>
170 MediaStreamTrackPtr; 176 MediaStreamTrackPtr;
171 typedef std::map<std::string, MediaStreamTrackPtr> MediaStreamTrackPtrMap; 177 typedef std::map<std::string, MediaStreamTrackPtr> MediaStreamTrackPtrMap;
172 MediaStreamTrackPtrMap local_tracks_; 178 MediaStreamTrackPtrMap local_tracks_;
173 179
174 talk_base::scoped_refptr<VideoRendererWrapper> video_renderer_; 180 // Native PeerConnection only supports 1:1 mapping between MediaStream and
175 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; 181 // video tag/renderer, so we restrict to this too. The key in
182 // VideoRendererMap is the stream label.
183 typedef talk_base::scoped_refptr<VideoRendererWrapper> VideoRendererPtr;
184 typedef std::pair<VideoRendererPtr, PeerConnectionHandlerBase*>
185 VideoRendererPair;
186 typedef std::map<std::string, VideoRendererPair> VideoRendererMap;
187 VideoRendererMap video_renderers_;
176 188
177 // PeerConnection threads. signaling_thread_ is created from the 189 // PeerConnection threads. signaling_thread_ is created from the
178 // "current" chrome thread. 190 // "current" chrome thread.
179 talk_base::Thread* signaling_thread_; 191 talk_base::Thread* signaling_thread_;
180 talk_base::Thread* worker_thread_; 192 talk_base::Thread* worker_thread_;
181 base::Thread chrome_worker_thread_; 193 base::Thread chrome_worker_thread_;
182 194
183 static int next_request_id_; 195 static int next_request_id_;
184 typedef std::map<int, WebKit::WebUserMediaRequest> MediaRequestMap; 196 typedef std::map<int, WebKit::WebUserMediaRequest> MediaRequestMap;
185 MediaRequestMap user_media_requests_; 197 MediaRequestMap user_media_requests_;
186 198
187 DISALLOW_COPY_AND_ASSIGN(MediaStreamImpl); 199 DISALLOW_COPY_AND_ASSIGN(MediaStreamImpl);
188 }; 200 };
189 201
190 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_ 202 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_dependency_factory.cc ('k') | content/renderer/media/media_stream_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698