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 #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> |
(...skipping 23 matching lines...) Expand all Loading... |
34 class IpcNetworkManager; | 34 class IpcNetworkManager; |
35 class IpcPacketSocketFactory; | 35 class IpcPacketSocketFactory; |
36 class P2PSocketDispatcher; | 36 class P2PSocketDispatcher; |
37 } | 37 } |
38 | 38 |
39 namespace talk_base { | 39 namespace talk_base { |
40 class Thread; | 40 class Thread; |
41 } | 41 } |
42 | 42 |
43 namespace WebKit { | 43 namespace WebKit { |
| 44 class WebMediaStreamCenter; |
| 45 class WebMediaStreamCenterClient; |
44 class WebPeerConnectionHandler; | 46 class WebPeerConnectionHandler; |
45 class WebPeerConnectionHandlerClient; | 47 class WebPeerConnectionHandlerClient; |
46 } | 48 } |
47 | 49 |
| 50 namespace content { |
| 51 class MediaStreamCenter; |
| 52 } |
| 53 |
48 class MediaStreamDispatcher; | 54 class MediaStreamDispatcher; |
49 class MediaStreamDependencyFactory; | 55 class MediaStreamDependencyFactory; |
50 class PeerConnectionHandler; | 56 class PeerConnectionHandler; |
51 class VideoCaptureImplManager; | 57 class VideoCaptureImplManager; |
52 class RTCVideoDecoder; | 58 class RTCVideoDecoder; |
53 | 59 |
54 // MediaStreamImpl is a delegate for the Media Stream API messages used by | 60 // MediaStreamImpl is a delegate for the Media Stream API messages used by |
55 // WebKit. It ties together WebKit, native PeerConnection in libjingle and | 61 // WebKit. It ties together WebKit, native PeerConnection in libjingle and |
56 // MediaStreamManager (via MediaStreamDispatcher and MediaStreamDispatcherHost) | 62 // MediaStreamManager (via MediaStreamDispatcher and MediaStreamDispatcherHost) |
57 // in the browser process. It must be created, called and destroyed on the | 63 // in the browser process. It must be created, called and destroyed on the |
58 // render thread. | 64 // render thread. |
59 class CONTENT_EXPORT MediaStreamImpl | 65 class CONTENT_EXPORT MediaStreamImpl |
60 : NON_EXPORTED_BASE(public WebKit::WebUserMediaClient), | 66 : NON_EXPORTED_BASE(public WebKit::WebUserMediaClient), |
61 NON_EXPORTED_BASE(public webkit_media::MediaStreamClient), | 67 NON_EXPORTED_BASE(public webkit_media::MediaStreamClient), |
62 public MediaStreamDispatcherEventHandler, | 68 public MediaStreamDispatcherEventHandler, |
63 NON_EXPORTED_BASE(public base::NonThreadSafe), | 69 NON_EXPORTED_BASE(public base::NonThreadSafe), |
64 public base::RefCountedThreadSafe<MediaStreamImpl> { | 70 public base::RefCountedThreadSafe<MediaStreamImpl> { |
65 public: | 71 public: |
66 MediaStreamImpl( | 72 MediaStreamImpl( |
67 MediaStreamDispatcher* media_stream_dispatcher, | 73 MediaStreamDispatcher* media_stream_dispatcher, |
68 content::P2PSocketDispatcher* p2p_socket_dispatcher, | 74 content::P2PSocketDispatcher* p2p_socket_dispatcher, |
69 VideoCaptureImplManager* vc_manager, | 75 VideoCaptureImplManager* vc_manager, |
70 MediaStreamDependencyFactory* dependency_factory); | 76 MediaStreamDependencyFactory* dependency_factory); |
71 virtual ~MediaStreamImpl(); | 77 virtual ~MediaStreamImpl(); |
72 | 78 |
73 virtual WebKit::WebPeerConnectionHandler* CreatePeerConnectionHandler( | 79 virtual WebKit::WebPeerConnectionHandler* CreatePeerConnectionHandler( |
74 WebKit::WebPeerConnectionHandlerClient* client); | 80 WebKit::WebPeerConnectionHandlerClient* client); |
| 81 virtual WebKit::WebMediaStreamCenter* CreateMediaStreamCenter( |
| 82 WebKit::WebMediaStreamCenterClient* client); |
75 virtual void ClosePeerConnection(); | 83 virtual void ClosePeerConnection(); |
76 virtual webrtc::MediaStreamTrackInterface* GetLocalMediaStreamTrack( | 84 virtual webrtc::MediaStreamTrackInterface* GetLocalMediaStreamTrack( |
77 const std::string& label); | 85 const std::string& label); |
78 | 86 |
79 // WebKit::WebUserMediaClient implementation | 87 // WebKit::WebUserMediaClient implementation |
80 virtual void requestUserMedia( | 88 virtual void requestUserMedia( |
81 const WebKit::WebUserMediaRequest& user_media_request, | 89 const WebKit::WebUserMediaRequest& user_media_request, |
82 const WebKit::WebVector<WebKit::WebMediaStreamSource>& | 90 const WebKit::WebVector<WebKit::WebMediaStreamSource>& |
83 media_stream_source_vector) OVERRIDE; | 91 media_stream_source_vector) OVERRIDE; |
84 virtual void cancelUserMediaRequest( | 92 virtual void cancelUserMediaRequest( |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 159 |
152 scoped_ptr<content::IpcPacketSocketFactory> socket_factory_; | 160 scoped_ptr<content::IpcPacketSocketFactory> socket_factory_; |
153 | 161 |
154 scoped_refptr<VideoCaptureImplManager> vc_manager_; | 162 scoped_refptr<VideoCaptureImplManager> vc_manager_; |
155 | 163 |
156 // peer_connection_handler_ is a weak reference, owned by WebKit. It's valid | 164 // peer_connection_handler_ is a weak reference, owned by WebKit. It's valid |
157 // until stop is called on it (which will call ClosePeerConnection on us). | 165 // until stop is called on it (which will call ClosePeerConnection on us). |
158 // TODO(grunell): Support several PeerConnectionsHandlers. | 166 // TODO(grunell): Support several PeerConnectionsHandlers. |
159 PeerConnectionHandler* peer_connection_handler_; | 167 PeerConnectionHandler* peer_connection_handler_; |
160 | 168 |
| 169 // media_stream_center_ is a raw pointer, owned by WebKit. It's valid for |
| 170 // the lifetime of RenderView. |
| 171 content::MediaStreamCenter* media_stream_center_; |
| 172 |
161 // 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 |
162 // devices when generated and also use them for recording. | 174 // devices when generated and also use them for recording. |
163 typedef talk_base::scoped_refptr<webrtc::MediaStreamTrackInterface> | 175 typedef talk_base::scoped_refptr<webrtc::MediaStreamTrackInterface> |
164 MediaStreamTrackPtr; | 176 MediaStreamTrackPtr; |
165 typedef std::map<std::string, MediaStreamTrackPtr> MediaStreamTrackPtrMap; | 177 typedef std::map<std::string, MediaStreamTrackPtr> MediaStreamTrackPtrMap; |
166 MediaStreamTrackPtrMap local_tracks_; | 178 MediaStreamTrackPtrMap local_tracks_; |
167 | 179 |
168 talk_base::scoped_refptr<VideoRendererWrapper> video_renderer_; | 180 talk_base::scoped_refptr<VideoRendererWrapper> video_renderer_; |
169 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | 181 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
170 | 182 |
171 // PeerConnection threads. signaling_thread_ is created from the | 183 // PeerConnection threads. signaling_thread_ is created from the |
172 // "current" chrome thread. | 184 // "current" chrome thread. |
173 talk_base::Thread* signaling_thread_; | 185 talk_base::Thread* signaling_thread_; |
174 talk_base::Thread* worker_thread_; | 186 talk_base::Thread* worker_thread_; |
175 base::Thread chrome_worker_thread_; | 187 base::Thread chrome_worker_thread_; |
176 | 188 |
177 static int next_request_id_; | 189 static int next_request_id_; |
178 typedef std::map<int, WebKit::WebUserMediaRequest> MediaRequestMap; | 190 typedef std::map<int, WebKit::WebUserMediaRequest> MediaRequestMap; |
179 MediaRequestMap user_media_requests_; | 191 MediaRequestMap user_media_requests_; |
180 | 192 |
181 DISALLOW_COPY_AND_ASSIGN(MediaStreamImpl); | 193 DISALLOW_COPY_AND_ASSIGN(MediaStreamImpl); |
182 }; | 194 }; |
183 | 195 |
184 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_ | 196 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_ |
OLD | NEW |