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

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

Issue 9139010: Revert 117187 - Adding support for MediaStream and PeerConnection functionality. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 11 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) 2011 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_STREAM_MEDIA_STREAM_IMPL_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_ 6 #define CONTENT_RENDERER_MEDIA_STREAM_MEDIA_STREAM_IMPL_H_
7
8 #include <list>
9 #include <map>
10 #include <string>
11 7
12 #include "base/basictypes.h" 8 #include "base/basictypes.h"
13 #include "base/gtest_prod_util.h"
14 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/message_loop_proxy.h"
17 #include "base/threading/non_thread_safe.h"
18 #include "base/threading/thread.h"
19 #include "content/common/content_export.h"
20 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h"
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaClient.h"
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaRequest.h "
23 #include "webkit/media/media_stream_client.h" 10 #include "webkit/media/media_stream_client.h"
24 11
25 namespace base { 12 class VideoCaptureImplManager;
26 class WaitableEvent;
27 }
28 13
29 namespace content { 14 // A implementation of StreamClient to provide supporting functions, such as
30 class IpcNetworkManager; 15 // GetVideoDecoder.
31 class IpcPacketSocketFactory; 16 class MediaStreamImpl
32 class P2PSocketDispatcher; 17 : public webkit_media::MediaStreamClient,
33 }
34
35 namespace cricket {
36 class WebRtcMediaEngine;
37 }
38
39 namespace talk_base {
40 class Thread;
41 }
42
43 namespace WebKit {
44 class WebPeerConnectionHandler;
45 class WebPeerConnectionHandlerClient;
46 }
47
48 class MediaStreamDispatcher;
49 class MediaStreamDependencyFactory;
50 class PeerConnectionHandler;
51 class VideoCaptureImplManager;
52 class RTCVideoDecoder;
53
54 // MediaStreamImpl is a delegate for the Media Stream API messages used by
55 // WebKit. It ties together WebKit, native PeerConnection in libjingle and
56 // MediaStreamManager (via MediaStreamDispatcher and MediaStreamDispatcherHost)
57 // in the browser process. It must be created, called and destroyed on the
58 // render thread.
59 class CONTENT_EXPORT MediaStreamImpl
60 : public WebKit::WebUserMediaClient,
61 public webkit_media::MediaStreamClient,
62 public MediaStreamDispatcherEventHandler,
63 public base::NonThreadSafe,
64 public base::RefCountedThreadSafe<MediaStreamImpl> { 18 public base::RefCountedThreadSafe<MediaStreamImpl> {
65 public: 19 public:
66 MediaStreamImpl( 20 explicit MediaStreamImpl(VideoCaptureImplManager* vc_manager);
67 MediaStreamDispatcher* media_stream_dispatcher,
68 content::P2PSocketDispatcher* p2p_socket_dispatcher,
69 VideoCaptureImplManager* vc_manager,
70 MediaStreamDependencyFactory* dependency_factory);
71 virtual ~MediaStreamImpl(); 21 virtual ~MediaStreamImpl();
72 22
73 virtual WebKit::WebPeerConnectionHandler* CreatePeerConnectionHandler( 23 // Implement webkit_media::StreamClient.
74 WebKit::WebPeerConnectionHandlerClient* client);
75 virtual void ClosePeerConnection();
76
77 // Returns true if created successfully or already exists, false otherwise.
78 virtual bool SetVideoCaptureModule(const std::string& label);
79
80 // WebKit::WebUserMediaClient implementation
81 virtual void requestUserMedia(
82 const WebKit::WebUserMediaRequest& user_media_request,
83 const WebKit::WebVector<WebKit::WebMediaStreamSource>&
84 media_stream_source_vector) OVERRIDE;
85 virtual void cancelUserMediaRequest(
86 const WebKit::WebUserMediaRequest& user_media_request) OVERRIDE;
87
88 // webkit_media::MediaStreamClient implementation.
89 virtual scoped_refptr<media::VideoDecoder> GetVideoDecoder( 24 virtual scoped_refptr<media::VideoDecoder> GetVideoDecoder(
90 const GURL& url, 25 const GURL& url,
91 media::MessageLoopFactory* message_loop_factory) OVERRIDE; 26 media::MessageLoopFactory* message_loop_factory) OVERRIDE;
92 27
93 // MediaStreamDispatcherEventHandler implementation.
94 virtual void OnStreamGenerated(
95 int request_id,
96 const std::string& label,
97 const media_stream::StreamDeviceInfoArray& audio_array,
98 const media_stream::StreamDeviceInfoArray& video_array) OVERRIDE;
99 virtual void OnStreamGenerationFailed(int request_id) OVERRIDE;
100 virtual void OnVideoDeviceFailed(
101 const std::string& label,
102 int index) OVERRIDE;
103 virtual void OnAudioDeviceFailed(
104 const std::string& label,
105 int index) OVERRIDE;
106
107 private: 28 private:
108 FRIEND_TEST_ALL_PREFIXES(MediaStreamImplTest, Basic);
109
110 void InitializeWorkerThread(
111 talk_base::Thread** thread,
112 base::WaitableEvent* event);
113 void DeleteIpcNetworkManager();
114
115 scoped_ptr<MediaStreamDependencyFactory> dependency_factory_;
116
117 // media_stream_dispatcher_ is a weak reference, owned by RenderView. It's
118 // valid for the lifetime of RenderView.
119 MediaStreamDispatcher* media_stream_dispatcher_;
120
121 // media_engine_ is owned by PeerConnectionFactory (which is owned by
122 // dependency_factory_) and is valid for the lifetime of
123 // PeerConnectionFactory.
124 cricket::WebRtcMediaEngine* media_engine_;
125
126 // p2p_socket_dispatcher_ is a weak reference, owned by RenderView. It's valid
127 // for the lifetime of RenderView.
128 content::P2PSocketDispatcher* p2p_socket_dispatcher_;
129
130 // We own network_manager_, must be deleted on the worker thread.
131 content::IpcNetworkManager* network_manager_;
132
133 scoped_ptr<content::IpcPacketSocketFactory> socket_factory_;
134
135 scoped_refptr<VideoCaptureImplManager> vc_manager_; 29 scoped_refptr<VideoCaptureImplManager> vc_manager_;
136 30
137 // peer_connection_handler_ is a weak reference, owned by WebKit. It's valid
138 // until stop is called on it (which will call ClosePeerConnection on us).
139 // TODO(grunell): Support several PeerConnectionsHandlers.
140 PeerConnectionHandler* peer_connection_handler_;
141
142 scoped_refptr<RTCVideoDecoder> rtc_video_decoder_;
143 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
144
145 // PeerConnection threads. signaling_thread_ is created from the
146 // "current" chrome thread.
147 talk_base::Thread* signaling_thread_;
148 talk_base::Thread* worker_thread_;
149 base::Thread chrome_worker_thread_;
150
151 static int next_request_id_;
152 typedef std::map<int, WebKit::WebUserMediaRequest> MediaRequestMap;
153 MediaRequestMap user_media_requests_;
154
155 std::list<std::string> stream_labels_;
156
157 // Make sure we only create the video capture module once. This is also
158 // temporary and will be handled differently when several PeerConnections
159 // and/or streams is supported.
160 // TODO(grunell): This shall be removed or changed when native PeerConnection
161 // has been updated to closer follow the specification.
162 bool vcm_created_;
163
164 DISALLOW_COPY_AND_ASSIGN(MediaStreamImpl); 31 DISALLOW_COPY_AND_ASSIGN(MediaStreamImpl);
165 }; 32 };
166 33
167 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_ 34 #endif // CONTENT_RENDERER_MEDIA_STREAM_MEDIA_STREAM_IMPL_H_
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_dispatcher.h ('k') | content/renderer/media/media_stream_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698