OLD | NEW |
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 // Delegate calls from WebCore::MediaPlayerPrivate to Chrome's video player. | 5 // Delegate calls from WebCore::MediaPlayerPrivate to Chrome's video player. |
6 // It contains Pipeline which is the actual media player pipeline, it glues | 6 // It contains Pipeline which is the actual media player pipeline, it glues |
7 // the media player pipeline, data source, audio renderer and renderer. | 7 // the media player pipeline, data source, audio renderer and renderer. |
8 // Pipeline would creates multiple threads and access some public methods | 8 // Pipeline would creates multiple threads and access some public methods |
9 // of this class, so we need to be extra careful about concurrent access of | 9 // of this class, so we need to be extra careful about concurrent access of |
10 // methods and members. | 10 // methods and members. |
11 // | 11 // |
12 // Other issues: | 12 // Other issues: |
13 // During tear down of the whole browser or a tab, the DOM tree may not be | 13 // During tear down of the whole browser or a tab, the DOM tree may not be |
14 // destructed nicely, and there will be some dangling media threads trying to | 14 // destructed nicely, and there will be some dangling media threads trying to |
15 // the main thread, so we need this class to listen to destruction event of the | 15 // the main thread, so we need this class to listen to destruction event of the |
16 // main thread and cleanup the media threads when the even is received. Also | 16 // main thread and cleanup the media threads when the even is received. Also |
17 // at destruction of this class we will need to unhook it from destruction event | 17 // at destruction of this class we will need to unhook it from destruction event |
18 // list of the main thread. | 18 // list of the main thread. |
19 | 19 |
20 #ifndef CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ | 20 #ifndef CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ |
21 #define CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ | 21 #define CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ |
22 | 22 |
| 23 #include <map> |
23 #include <string> | 24 #include <string> |
24 #include <vector> | 25 #include <vector> |
25 | 26 |
26 #include "base/basictypes.h" | 27 #include "base/basictypes.h" |
27 #include "base/memory/ref_counted.h" | 28 #include "base/memory/ref_counted.h" |
28 #include "base/memory/scoped_ptr.h" | 29 #include "base/memory/scoped_ptr.h" |
29 #include "base/memory/weak_ptr.h" | 30 #include "base/memory/weak_ptr.h" |
30 #include "base/threading/thread.h" | 31 #include "base/threading/thread.h" |
31 #include "cc/layers/video_frame_provider.h" | 32 #include "cc/layers/video_frame_provider.h" |
32 #include "content/renderer/media/crypto/proxy_decryptor.h" | 33 #include "content/renderer/media/crypto/proxy_decryptor.h" |
(...skipping 15 matching lines...) Expand all Loading... |
48 namespace WebKit { | 49 namespace WebKit { |
49 class WebFrame; | 50 class WebFrame; |
50 } | 51 } |
51 | 52 |
52 namespace base { | 53 namespace base { |
53 class MessageLoopProxy; | 54 class MessageLoopProxy; |
54 } | 55 } |
55 | 56 |
56 namespace media { | 57 namespace media { |
57 class ChunkDemuxer; | 58 class ChunkDemuxer; |
58 class FFmpegDemuxer; | 59 class DemuxerStream; |
59 class GpuVideoAcceleratorFactories; | 60 class GpuVideoAcceleratorFactories; |
60 class MediaLog; | 61 class MediaLog; |
| 62 class TextCue; |
61 } | 63 } |
62 | 64 |
63 namespace webkit { | 65 namespace webkit { |
64 class WebLayerImpl; | 66 class WebLayerImpl; |
65 } | 67 } |
66 | 68 |
67 namespace content { | 69 namespace content { |
68 class BufferedDataSource; | 70 class BufferedDataSource; |
69 class WebAudioSourceProviderImpl; | 71 class WebAudioSourceProviderImpl; |
70 class WebMediaPlayerDelegate; | 72 class WebMediaPlayerDelegate; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 void OnKeyAdded(const std::string& session_id); | 192 void OnKeyAdded(const std::string& session_id); |
191 void OnKeyError(const std::string& session_id, | 193 void OnKeyError(const std::string& session_id, |
192 media::MediaKeys::KeyError error_code, | 194 media::MediaKeys::KeyError error_code, |
193 int system_code); | 195 int system_code); |
194 void OnKeyMessage(const std::string& session_id, | 196 void OnKeyMessage(const std::string& session_id, |
195 const std::vector<uint8>& message, | 197 const std::vector<uint8>& message, |
196 const std::string& default_url); | 198 const std::string& default_url); |
197 void OnNeedKey(const std::string& type, | 199 void OnNeedKey(const std::string& type, |
198 const std::string& session_id, | 200 const std::string& session_id, |
199 const std::vector<uint8>& init_data); | 201 const std::vector<uint8>& init_data); |
| 202 // TODO(matthewjheaney): Once we're satisfied that we have the threading model |
| 203 // correct for handling text cues, move the media source from OnTextTrack over |
| 204 // to AddTextStream. |
200 scoped_ptr<media::TextTrack> OnTextTrack(media::TextKind kind, | 205 scoped_ptr<media::TextTrack> OnTextTrack(media::TextKind kind, |
201 const std::string& label, | 206 const std::string& label, |
202 const std::string& language); | 207 const std::string& language); |
| 208 void AddTextStream(media::DemuxerStream* stream, |
| 209 media::TextKind kind, |
| 210 const std::string& label, |
| 211 const std::string& language); |
203 void SetOpaque(bool); | 212 void SetOpaque(bool); |
204 | 213 |
205 private: | 214 private: |
206 // Called after |defer_load_cb_| has decided to allow the load. If | 215 // Called after |defer_load_cb_| has decided to allow the load. If |
207 // |defer_load_cb_| is null this is called immediately. | 216 // |defer_load_cb_| is null this is called immediately. |
208 void DoLoad(LoadType load_type, | 217 void DoLoad(LoadType load_type, |
209 const WebKit::WebURL& url, | 218 const WebKit::WebURL& url, |
210 CORSMode cors_mode); | 219 CORSMode cors_mode); |
211 | 220 |
212 // Called after asynchronous initialization of a data source completed. | 221 // Called after asynchronous initialization of a data source completed. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 // Gets the duration value reported by the pipeline. | 260 // Gets the duration value reported by the pipeline. |
252 double GetPipelineDuration() const; | 261 double GetPipelineDuration() const; |
253 | 262 |
254 // Notifies WebKit of the duration change. | 263 // Notifies WebKit of the duration change. |
255 void OnDurationChange(); | 264 void OnDurationChange(); |
256 | 265 |
257 // Called by VideoRendererBase on its internal thread with the new frame to be | 266 // Called by VideoRendererBase on its internal thread with the new frame to be |
258 // painted. | 267 // painted. |
259 void FrameReady(const scoped_refptr<media::VideoFrame>& frame); | 268 void FrameReady(const scoped_refptr<media::VideoFrame>& frame); |
260 | 269 |
| 270 // Called by the TextRenderer when a decoded cue has been delivered on |
| 271 // |text_stream|, and hence that it be added to the cue list for its |
| 272 // associated text track. |
| 273 void CueReady(media::DemuxerStream* text_stream, |
| 274 const scoped_refptr<media::TextCue>& text_cue); |
| 275 |
261 WebKit::WebFrame* frame_; | 276 WebKit::WebFrame* frame_; |
262 | 277 |
263 // TODO(hclam): get rid of these members and read from the pipeline directly. | 278 // TODO(hclam): get rid of these members and read from the pipeline directly. |
264 WebKit::WebMediaPlayer::NetworkState network_state_; | 279 WebKit::WebMediaPlayer::NetworkState network_state_; |
265 WebKit::WebMediaPlayer::ReadyState ready_state_; | 280 WebKit::WebMediaPlayer::ReadyState ready_state_; |
266 | 281 |
267 // Keep a list of buffered time ranges. | 282 // Keep a list of buffered time ranges. |
268 WebKit::WebTimeRanges buffered_; | 283 WebKit::WebTimeRanges buffered_; |
269 | 284 |
270 // Message loops for posting tasks on Chrome's main thread. Also used | 285 // Message loops for posting tasks on Chrome's main thread. Also used |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 // playback. | 375 // playback. |
361 scoped_ptr<webkit::WebLayerImpl> video_weblayer_; | 376 scoped_ptr<webkit::WebLayerImpl> video_weblayer_; |
362 | 377 |
363 // A pointer back to the compositor to inform it about state changes. This is | 378 // A pointer back to the compositor to inform it about state changes. This is |
364 // not NULL while the compositor is actively using this webmediaplayer. | 379 // not NULL while the compositor is actively using this webmediaplayer. |
365 cc::VideoFrameProvider::Client* video_frame_provider_client_; | 380 cc::VideoFrameProvider::Client* video_frame_provider_client_; |
366 | 381 |
367 // Text track objects get a unique index value when they're created. | 382 // Text track objects get a unique index value when they're created. |
368 int text_track_index_; | 383 int text_track_index_; |
369 | 384 |
| 385 // Manipulation of TextTrack objects must be done on the main loop, not the |
| 386 // media loop, so we declare this cache here. Objects in the pipeline |
| 387 // dispatch callbacks to player (using DemuxerStream as the key), the |
| 388 // player looks up the associated TextTrack, and then it manipulates the |
| 389 // TextTrack object as necessary. |
| 390 typedef std::map<media::DemuxerStream*, media::TextTrack*> TextTrackMap; |
| 391 TextTrackMap text_track_map_; |
| 392 |
370 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); | 393 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); |
371 }; | 394 }; |
372 | 395 |
373 } // namespace content | 396 } // namespace content |
374 | 397 |
375 #endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ | 398 #endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ |
OLD | NEW |