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 MEDIA_BASE_PIPELINE_H_ | 5 #ifndef MEDIA_BASE_PIPELINE_H_ |
6 #define MEDIA_BASE_PIPELINE_H_ | 6 #define MEDIA_BASE_PIPELINE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 namespace base { | 23 namespace base { |
24 class MessageLoopProxy; | 24 class MessageLoopProxy; |
25 class TimeDelta; | 25 class TimeDelta; |
26 } | 26 } |
27 | 27 |
28 namespace media { | 28 namespace media { |
29 | 29 |
30 class Clock; | 30 class Clock; |
31 class FilterCollection; | 31 class FilterCollection; |
32 class MediaLog; | 32 class MediaLog; |
| 33 class TextRenderer; |
33 class VideoRenderer; | 34 class VideoRenderer; |
34 | 35 |
35 // Pipeline runs the media pipeline. Filters are created and called on the | 36 // Pipeline runs the media pipeline. Filters are created and called on the |
36 // message loop injected into this object. Pipeline works like a state | 37 // message loop injected into this object. Pipeline works like a state |
37 // machine to perform asynchronous initialization, pausing, seeking and playing. | 38 // machine to perform asynchronous initialization, pausing, seeking and playing. |
38 // | 39 // |
39 // Here's a state diagram that describes the lifetime of this object. | 40 // Here's a state diagram that describes the lifetime of this object. |
40 // | 41 // |
41 // [ *Created ] [ Any State ] | 42 // [ *Created ] [ Any State ] |
42 // | Start() | Stop() / SetError() | 43 // | Start() | Stop() / SetError() |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 226 |
226 // DataSourceHost (by way of DemuxerHost) implementation. | 227 // DataSourceHost (by way of DemuxerHost) implementation. |
227 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; | 228 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; |
228 virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE; | 229 virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE; |
229 virtual void AddBufferedTimeRange(base::TimeDelta start, | 230 virtual void AddBufferedTimeRange(base::TimeDelta start, |
230 base::TimeDelta end) OVERRIDE; | 231 base::TimeDelta end) OVERRIDE; |
231 | 232 |
232 // DemuxerHost implementaion. | 233 // DemuxerHost implementaion. |
233 virtual void SetDuration(base::TimeDelta duration) OVERRIDE; | 234 virtual void SetDuration(base::TimeDelta duration) OVERRIDE; |
234 virtual void OnDemuxerError(PipelineStatus error) OVERRIDE; | 235 virtual void OnDemuxerError(PipelineStatus error) OVERRIDE; |
| 236 virtual void AddTextStream(DemuxerStream* text_stream, |
| 237 TextKind kind, |
| 238 const std::string& label, |
| 239 const std::string& language) OVERRIDE; |
235 | 240 |
236 // Initiates teardown sequence in response to a runtime error. | 241 // Initiates teardown sequence in response to a runtime error. |
237 // | 242 // |
238 // Safe to call from any thread. | 243 // Safe to call from any thread. |
239 void SetError(PipelineStatus error); | 244 void SetError(PipelineStatus error); |
240 | 245 |
241 // Callback executed when the natural size of the video has changed. | 246 // Callback executed when the natural size of the video has changed. |
242 void OnNaturalVideoSizeChanged(const gfx::Size& size); | 247 void OnNaturalVideoSizeChanged(const gfx::Size& size); |
243 | 248 |
244 // Callbacks executed when a renderer has ended. | 249 // Callbacks executed when a renderer has ended. |
245 void OnAudioRendererEnded(); | 250 void OnAudioRendererEnded(); |
246 void OnVideoRendererEnded(); | 251 void OnVideoRendererEnded(); |
| 252 void OnTextRendererEnded(); |
247 | 253 |
248 // Callback executed by filters to update statistics. | 254 // Callback executed by filters to update statistics. |
249 void OnUpdateStatistics(const PipelineStatistics& stats); | 255 void OnUpdateStatistics(const PipelineStatistics& stats); |
250 | 256 |
251 // Callback executed by audio renderer when it has been disabled. | 257 // Callback executed by audio renderer when it has been disabled. |
252 void OnAudioDisabled(); | 258 void OnAudioDisabled(); |
253 | 259 |
254 // Callback executed by audio renderer to update clock time. | 260 // Callback executed by audio renderer to update clock time. |
255 void OnAudioTimeUpdate(base::TimeDelta time, base::TimeDelta max_time); | 261 void OnAudioTimeUpdate(base::TimeDelta time, base::TimeDelta max_time); |
256 | 262 |
(...skipping 19 matching lines...) Expand all Loading... |
276 | 282 |
277 // Carries out notifying filters that the playback rate has changed. | 283 // Carries out notifying filters that the playback rate has changed. |
278 void PlaybackRateChangedTask(float playback_rate); | 284 void PlaybackRateChangedTask(float playback_rate); |
279 | 285 |
280 // Carries out notifying filters that the volume has changed. | 286 // Carries out notifying filters that the volume has changed. |
281 void VolumeChangedTask(float volume); | 287 void VolumeChangedTask(float volume); |
282 | 288 |
283 // Carries out notifying filters that we are seeking to a new timestamp. | 289 // Carries out notifying filters that we are seeking to a new timestamp. |
284 void SeekTask(base::TimeDelta time, const PipelineStatusCB& seek_cb); | 290 void SeekTask(base::TimeDelta time, const PipelineStatusCB& seek_cb); |
285 | 291 |
286 // Handles audio/video ended logic and running |ended_cb_|. | 292 // Handles audio/video/text ended logic and running |ended_cb_|. |
287 void DoAudioRendererEnded(); | 293 void DoAudioRendererEnded(); |
288 void DoVideoRendererEnded(); | 294 void DoVideoRendererEnded(); |
| 295 void DoTextRendererEnded(); |
289 void RunEndedCallbackIfNeeded(); | 296 void RunEndedCallbackIfNeeded(); |
290 | 297 |
291 // Carries out disabling the audio renderer. | 298 // Carries out disabling the audio renderer. |
292 void AudioDisabledTask(); | 299 void AudioDisabledTask(); |
293 | 300 |
294 // Kicks off initialization for each media object, executing |done_cb| with | 301 // Kicks off initialization for each media object, executing |done_cb| with |
295 // the result when completed. | 302 // the result when completed. |
296 void InitializeDemuxer(const PipelineStatusCB& done_cb); | 303 void InitializeDemuxer(const PipelineStatusCB& done_cb); |
297 void InitializeAudioRenderer(const PipelineStatusCB& done_cb); | 304 void InitializeAudioRenderer(const PipelineStatusCB& done_cb); |
298 void InitializeVideoRenderer(const PipelineStatusCB& done_cb); | 305 void InitializeVideoRenderer(const PipelineStatusCB& done_cb); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 // for an update of the clock greater than or equal to the elapsed time to | 392 // for an update of the clock greater than or equal to the elapsed time to |
386 // start the clock. | 393 // start the clock. |
387 bool waiting_for_clock_update_; | 394 bool waiting_for_clock_update_; |
388 | 395 |
389 // Status of the pipeline. Initialized to PIPELINE_OK which indicates that | 396 // Status of the pipeline. Initialized to PIPELINE_OK which indicates that |
390 // the pipeline is operating correctly. Any other value indicates that the | 397 // the pipeline is operating correctly. Any other value indicates that the |
391 // pipeline is stopped or is stopping. Clients can call the Stop() method to | 398 // pipeline is stopped or is stopping. Clients can call the Stop() method to |
392 // reset the pipeline state, and restore this to PIPELINE_OK. | 399 // reset the pipeline state, and restore this to PIPELINE_OK. |
393 PipelineStatus status_; | 400 PipelineStatus status_; |
394 | 401 |
395 // Whether the media contains rendered audio and video streams. | 402 // Whether the media contains rendered audio or video streams. |
396 // TODO(fischman,scherkus): replace these with checks for | 403 // TODO(fischman,scherkus): replace these with checks for |
397 // {audio,video}_decoder_ once extraction of {Audio,Video}Decoder from the | 404 // {audio,video}_decoder_ once extraction of {Audio,Video}Decoder from the |
398 // Filter heirarchy is done. | 405 // Filter heirarchy is done. |
399 bool has_audio_; | 406 bool has_audio_; |
400 bool has_video_; | 407 bool has_video_; |
401 | 408 |
402 // The following data members are only accessed by tasks posted to | 409 // The following data members are only accessed by tasks posted to |
403 // |message_loop_|. | 410 // |message_loop_|. |
404 | 411 |
405 // Member that tracks the current state. | 412 // Member that tracks the current state. |
406 State state_; | 413 State state_; |
407 | 414 |
408 // Whether we've received the audio/video ended events. | 415 // Whether we've received the audio/video/text ended events. |
409 bool audio_ended_; | 416 bool audio_ended_; |
410 bool video_ended_; | 417 bool video_ended_; |
| 418 bool text_ended_; |
411 | 419 |
412 // Set to true in DisableAudioRendererTask(). | 420 // Set to true in DisableAudioRendererTask(). |
413 bool audio_disabled_; | 421 bool audio_disabled_; |
414 | 422 |
415 // Temporary callback used for Start() and Seek(). | 423 // Temporary callback used for Start() and Seek(). |
416 PipelineStatusCB seek_cb_; | 424 PipelineStatusCB seek_cb_; |
417 | 425 |
418 // Temporary callback used for Stop(). | 426 // Temporary callback used for Stop(). |
419 base::Closure stop_cb_; | 427 base::Closure stop_cb_; |
420 | 428 |
421 // Permanent callbacks passed in via Start(). | 429 // Permanent callbacks passed in via Start(). |
422 base::Closure ended_cb_; | 430 base::Closure ended_cb_; |
423 PipelineStatusCB error_cb_; | 431 PipelineStatusCB error_cb_; |
424 BufferingStateCB buffering_state_cb_; | 432 BufferingStateCB buffering_state_cb_; |
425 base::Closure duration_change_cb_; | 433 base::Closure duration_change_cb_; |
426 | 434 |
427 // Contains the demuxer and renderers to use when initializing. | 435 // Contains the demuxer and renderers to use when initializing. |
428 scoped_ptr<FilterCollection> filter_collection_; | 436 scoped_ptr<FilterCollection> filter_collection_; |
429 | 437 |
430 // Holds the initialized demuxer. Used for seeking. Owned by client. | 438 // Holds the initialized demuxer. Used for seeking. Owned by client. |
431 Demuxer* demuxer_; | 439 Demuxer* demuxer_; |
432 | 440 |
433 // Holds the initialized renderers. Used for setting the volume, | 441 // Holds the initialized renderers. Used for setting the volume, |
434 // playback rate, and determining when playback has finished. | 442 // playback rate, and determining when playback has finished. |
435 scoped_ptr<AudioRenderer> audio_renderer_; | 443 scoped_ptr<AudioRenderer> audio_renderer_; |
436 scoped_ptr<VideoRenderer> video_renderer_; | 444 scoped_ptr<VideoRenderer> video_renderer_; |
| 445 scoped_ptr<TextRenderer> text_renderer_; |
437 | 446 |
438 PipelineStatistics statistics_; | 447 PipelineStatistics statistics_; |
439 | 448 |
440 // Time of pipeline creation; is non-zero only until the pipeline first | 449 // Time of pipeline creation; is non-zero only until the pipeline first |
441 // reaches "kStarted", at which point it is used & zeroed out. | 450 // reaches "kStarted", at which point it is used & zeroed out. |
442 base::TimeTicks creation_time_; | 451 base::TimeTicks creation_time_; |
443 | 452 |
444 scoped_ptr<SerialRunner> pending_callbacks_; | 453 scoped_ptr<SerialRunner> pending_callbacks_; |
445 | 454 |
446 base::ThreadChecker thread_checker_; | 455 base::ThreadChecker thread_checker_; |
447 | 456 |
448 DISALLOW_COPY_AND_ASSIGN(Pipeline); | 457 DISALLOW_COPY_AND_ASSIGN(Pipeline); |
449 }; | 458 }; |
450 | 459 |
451 } // namespace media | 460 } // namespace media |
452 | 461 |
453 #endif // MEDIA_BASE_PIPELINE_H_ | 462 #endif // MEDIA_BASE_PIPELINE_H_ |
OLD | NEW |