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

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

Issue 501473003: Move EME code out of WebMediaPlayerImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address CR comments Created 6 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_WEBMEDIAPLAYER_IMPL_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_
6 #define CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ 6 #define CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
16 #include "content/renderer/media/buffered_data_source_host_impl.h" 16 #include "content/renderer/media/buffered_data_source_host_impl.h"
17 #include "content/renderer/media/crypto/proxy_decryptor.h"
18 #include "content/renderer/media/video_frame_compositor.h" 17 #include "content/renderer/media/video_frame_compositor.h"
19 #include "media/base/audio_renderer_sink.h" 18 #include "media/base/audio_renderer_sink.h"
20 #include "media/base/decryptor.h"
21 // TODO(xhwang): Remove when we remove prefixed EME implementation. 19 // TODO(xhwang): Remove when we remove prefixed EME implementation.
22 #include "media/base/media_keys.h" 20 #include "media/base/media_keys.h"
23 #include "media/base/pipeline.h" 21 #include "media/base/pipeline.h"
24 #include "media/base/text_track.h" 22 #include "media/base/text_track.h"
25 #include "media/filters/skcanvas_video_renderer.h" 23 #include "media/filters/skcanvas_video_renderer.h"
26 #include "skia/ext/platform_canvas.h" 24 #include "skia/ext/platform_canvas.h"
27 #include "third_party/WebKit/public/platform/WebAudioSourceProvider.h" 25 #include "third_party/WebKit/public/platform/WebAudioSourceProvider.h"
26 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"
28 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" 27 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
29 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" 28 #include "third_party/WebKit/public/platform/WebMediaPlayer.h"
30 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" 29 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h"
31 #include "url/gurl.h" 30 #include "url/gurl.h"
32 31
33 class RenderAudioSourceProvider;
34
35 namespace blink { 32 namespace blink {
36 class WebContentDecryptionModule;
37 class WebContentDecryptionModuleResult;
38 class WebLocalFrame; 33 class WebLocalFrame;
39 } 34 }
40 35
41 namespace base { 36 namespace base {
42 class MessageLoopProxy; 37 class MessageLoopProxy;
43 } 38 }
44 39
45 namespace cc_blink { 40 namespace cc_blink {
46 class WebLayerImpl; 41 class WebLayerImpl;
47 } 42 }
48 43
49 namespace media { 44 namespace media {
50 class ChunkDemuxer; 45 class ChunkDemuxer;
51 class GpuVideoAcceleratorFactories; 46 class GpuVideoAcceleratorFactories;
52 class MediaLog; 47 class MediaLog;
53 } 48 }
54 49
55 50
56 namespace content { 51 namespace content {
57 class BufferedDataSource; 52 class BufferedDataSource;
53 class EncryptedMediaPlayerSupport;
58 class VideoFrameCompositor; 54 class VideoFrameCompositor;
59 class WebAudioSourceProviderImpl; 55 class WebAudioSourceProviderImpl;
60 class WebContentDecryptionModuleImpl;
61 class WebMediaPlayerDelegate; 56 class WebMediaPlayerDelegate;
62 class WebMediaPlayerParams; 57 class WebMediaPlayerParams;
63 class WebTextTrackImpl; 58 class WebTextTrackImpl;
64 59
65 // The canonical implementation of blink::WebMediaPlayer that's backed by 60 // The canonical implementation of blink::WebMediaPlayer that's backed by
66 // media::Pipeline. Handles normal resource loading, Media Source, and 61 // media::Pipeline. Handles normal resource loading, Media Source, and
67 // Encrypted Media. 62 // Encrypted Media.
68 class WebMediaPlayerImpl 63 class WebMediaPlayerImpl
69 : public blink::WebMediaPlayer, 64 : public blink::WebMediaPlayer,
70 public base::SupportsWeakPtr<WebMediaPlayerImpl> { 65 public base::SupportsWeakPtr<WebMediaPlayerImpl> {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 blink::WebContentDecryptionModuleResult result); 160 blink::WebContentDecryptionModuleResult result);
166 virtual void setContentDecryptionModuleSync( 161 virtual void setContentDecryptionModuleSync(
167 blink::WebContentDecryptionModule* cdm); 162 blink::WebContentDecryptionModule* cdm);
168 163
169 void OnPipelineSeeked(bool time_changed, media::PipelineStatus status); 164 void OnPipelineSeeked(bool time_changed, media::PipelineStatus status);
170 void OnPipelineEnded(); 165 void OnPipelineEnded();
171 void OnPipelineError(media::PipelineStatus error); 166 void OnPipelineError(media::PipelineStatus error);
172 void OnPipelineMetadata(media::PipelineMetadata metadata); 167 void OnPipelineMetadata(media::PipelineMetadata metadata);
173 void OnPipelineBufferingStateChanged(media::BufferingState buffering_state); 168 void OnPipelineBufferingStateChanged(media::BufferingState buffering_state);
174 void OnDemuxerOpened(); 169 void OnDemuxerOpened();
175 void OnKeyAdded(const std::string& session_id);
176 void OnKeyError(const std::string& session_id,
177 media::MediaKeys::KeyError error_code,
178 uint32 system_code);
179 void OnKeyMessage(const std::string& session_id,
180 const std::vector<uint8>& message,
181 const GURL& destination_url);
182 void OnNeedKey(const std::string& type,
183 const std::vector<uint8>& init_data);
184 void OnAddTextTrack(const media::TextTrackConfig& config, 170 void OnAddTextTrack(const media::TextTrackConfig& config,
185 const media::AddTextTrackDoneCB& done_cb); 171 const media::AddTextTrackDoneCB& done_cb);
186 172
187 private: 173 private:
188 // Called after |defer_load_cb_| has decided to allow the load. If 174 // Called after |defer_load_cb_| has decided to allow the load. If
189 // |defer_load_cb_| is null this is called immediately. 175 // |defer_load_cb_| is null this is called immediately.
190 void DoLoad(LoadType load_type, 176 void DoLoad(LoadType load_type,
191 const blink::WebURL& url, 177 const blink::WebURL& url,
192 CORSMode cors_mode); 178 CORSMode cors_mode);
193 179
194 // Called after asynchronous initialization of a data source completed. 180 // Called after asynchronous initialization of a data source completed.
195 void DataSourceInitialized(bool success); 181 void DataSourceInitialized(bool success);
196 182
197 // Called when the data source is downloading or paused. 183 // Called when the data source is downloading or paused.
198 void NotifyDownloading(bool is_downloading); 184 void NotifyDownloading(bool is_downloading);
199 185
200 // Finishes starting the pipeline due to a call to load(). 186 // Finishes starting the pipeline due to a call to load().
201 void StartPipeline(); 187 void StartPipeline();
202 188
203 // Helpers that set the network/ready state and notifies the client if 189 // Helpers that set the network/ready state and notifies the client if
204 // they've changed. 190 // they've changed.
205 void SetNetworkState(blink::WebMediaPlayer::NetworkState state); 191 void SetNetworkState(blink::WebMediaPlayer::NetworkState state);
206 void SetReadyState(blink::WebMediaPlayer::ReadyState state); 192 void SetReadyState(blink::WebMediaPlayer::ReadyState state);
207 193
208 // Lets V8 know that player uses extra resources not managed by V8. 194 // Lets V8 know that player uses extra resources not managed by V8.
209 void IncrementExternallyAllocatedMemory(); 195 void IncrementExternallyAllocatedMemory();
210 196
211 // Actually do the work for generateKeyRequest/addKey so they can easily
212 // report results to UMA.
213 MediaKeyException GenerateKeyRequestInternal(const std::string& key_system,
214 const unsigned char* init_data,
215 unsigned init_data_length);
216 MediaKeyException AddKeyInternal(const std::string& key_system,
217 const unsigned char* key,
218 unsigned key_length,
219 const unsigned char* init_data,
220 unsigned init_data_length,
221 const std::string& session_id);
222 MediaKeyException CancelKeyRequestInternal(const std::string& key_system,
223 const std::string& session_id);
224
225 // Gets the duration value reported by the pipeline. 197 // Gets the duration value reported by the pipeline.
226 double GetPipelineDuration() const; 198 double GetPipelineDuration() const;
227 199
228 // Callbacks from |pipeline_| that are forwarded to |client_|. 200 // Callbacks from |pipeline_| that are forwarded to |client_|.
229 void OnDurationChanged(); 201 void OnDurationChanged();
230 void OnNaturalSizeChanged(gfx::Size size); 202 void OnNaturalSizeChanged(gfx::Size size);
231 void OnOpacityChanged(bool opaque); 203 void OnOpacityChanged(bool opaque);
232 204
233 // Called by VideoRendererImpl on its internal thread with the new frame to be 205 // Called by VideoRendererImpl on its internal thread with the new frame to be
234 // painted. 206 // painted.
235 void FrameReady(const scoped_refptr<media::VideoFrame>& frame); 207 void FrameReady(const scoped_refptr<media::VideoFrame>& frame);
236 208
237 // Requests that this object notifies when a decryptor is ready through the
238 // |decryptor_ready_cb| provided.
239 // If |decryptor_ready_cb| is null, the existing callback will be fired with
240 // NULL immediately and reset.
241 void SetDecryptorReadyCB(const media::DecryptorReadyCB& decryptor_ready_cb);
242
243 // Called when the ContentDecryptionModule has been attached to the 209 // Called when the ContentDecryptionModule has been attached to the
244 // pipeline/decoders. 210 // pipeline/decoders.
245 void ContentDecryptionModuleAttached( 211 void ContentDecryptionModuleAttached(
246 blink::WebContentDecryptionModuleResult result, 212 blink::WebContentDecryptionModuleResult result,
247 bool success); 213 bool success);
248 214
249 // Returns the current video frame from |compositor_|. Blocks until the 215 // Returns the current video frame from |compositor_|. Blocks until the
250 // compositor can return the frame. 216 // compositor can return the frame.
251 scoped_refptr<media::VideoFrame> GetCurrentFrameFromCompositor(); 217 scoped_refptr<media::VideoFrame> GetCurrentFrameFromCompositor();
252 218
253 blink::WebLocalFrame* frame_; 219 blink::WebLocalFrame* frame_;
254 220
255 // TODO(hclam): get rid of these members and read from the pipeline directly. 221 // TODO(hclam): get rid of these members and read from the pipeline directly.
256 blink::WebMediaPlayer::NetworkState network_state_; 222 blink::WebMediaPlayer::NetworkState network_state_;
257 blink::WebMediaPlayer::ReadyState ready_state_; 223 blink::WebMediaPlayer::ReadyState ready_state_;
258 224
259 // Preload state for when |data_source_| is created after setPreload(). 225 // Preload state for when |data_source_| is created after setPreload().
260 content::Preload preload_; 226 content::Preload preload_;
261 227
262 // Message loops for posting tasks on Chrome's main thread. Also used 228 // Message loops for posting tasks on Chrome's main thread. Also used
263 // for DCHECKs so methods calls won't execute in the wrong thread. 229 // for DCHECKs so methods calls won't execute in the wrong thread.
264 const scoped_refptr<base::MessageLoopProxy> main_loop_; 230 const scoped_refptr<base::MessageLoopProxy> main_loop_;
265 231
266 scoped_refptr<base::MessageLoopProxy> media_loop_; 232 scoped_refptr<base::MessageLoopProxy> media_loop_;
267 scoped_refptr<media::MediaLog> media_log_; 233 scoped_refptr<media::MediaLog> media_log_;
268 media::Pipeline pipeline_; 234 media::Pipeline pipeline_;
269 235
270 // The currently selected key system. Empty string means that no key system
271 // has been selected.
272 std::string current_key_system_;
273
274 // The LoadType passed in the |load_type| parameter of the load() call. 236 // The LoadType passed in the |load_type| parameter of the load() call.
275 LoadType load_type_; 237 LoadType load_type_;
276 238
277 // Cache of metadata for answering hasAudio(), hasVideo(), and naturalSize(). 239 // Cache of metadata for answering hasAudio(), hasVideo(), and naturalSize().
278 media::PipelineMetadata pipeline_metadata_; 240 media::PipelineMetadata pipeline_metadata_;
279 241
280 // Whether the video is known to be opaque or not. 242 // Whether the video is known to be opaque or not.
281 bool opaque_; 243 bool opaque_;
282 244
283 // Playback state. 245 // Playback state.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 // |chunk_demuxer_| is used for Media Source resource loads. 289 // |chunk_demuxer_| is used for Media Source resource loads.
328 // 290 //
329 // |demuxer_| will contain the appropriate demuxer based on which resource 291 // |demuxer_| will contain the appropriate demuxer based on which resource
330 // load strategy we're using. 292 // load strategy we're using.
331 scoped_ptr<BufferedDataSource> data_source_; 293 scoped_ptr<BufferedDataSource> data_source_;
332 scoped_ptr<media::Demuxer> demuxer_; 294 scoped_ptr<media::Demuxer> demuxer_;
333 media::ChunkDemuxer* chunk_demuxer_; 295 media::ChunkDemuxer* chunk_demuxer_;
334 296
335 BufferedDataSourceHostImpl buffered_data_source_host_; 297 BufferedDataSourceHostImpl buffered_data_source_host_;
336 298
337 // Temporary for EME v0.1. In the future the init data type should be passed
338 // through GenerateKeyRequest() directly from WebKit.
339 std::string init_data_type_;
340
341 // Video rendering members. 299 // Video rendering members.
342 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; 300 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
343 VideoFrameCompositor* compositor_; // Deleted on |compositor_task_runner_|. 301 VideoFrameCompositor* compositor_; // Deleted on |compositor_task_runner_|.
344 media::SkCanvasVideoRenderer skcanvas_video_renderer_; 302 media::SkCanvasVideoRenderer skcanvas_video_renderer_;
345 303
346 // The compositor layer for displaying the video content when using composited 304 // The compositor layer for displaying the video content when using composited
347 // playback. 305 // playback.
348 scoped_ptr<cc_blink::WebLayerImpl> video_weblayer_; 306 scoped_ptr<cc_blink::WebLayerImpl> video_weblayer_;
349 307
350 // Text track objects get a unique index value when they're created. 308 // Text track objects get a unique index value when they're created.
351 int text_track_index_; 309 int text_track_index_;
352 310
353 // Manages decryption keys and decrypts encrypted frames. 311 scoped_ptr<EncryptedMediaPlayerSupport> encrypted_media_support_;
354 scoped_ptr<ProxyDecryptor> proxy_decryptor_;
355
356 // Non-owned pointer to the CDM. Updated via calls to
357 // setContentDecryptionModule().
358 WebContentDecryptionModuleImpl* web_cdm_;
359
360 media::DecryptorReadyCB decryptor_ready_cb_;
361 312
362 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); 313 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl);
363 }; 314 };
364 315
365 } // namespace content 316 } // namespace content
366 317
367 #endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ 318 #endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698