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

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

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