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

Side by Side Diff: media/base/pipeline.h

Issue 23702007: Render inband text tracks in the media pipeline (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: incorporate aaron's comments (10/22) Created 7 years, 2 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
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 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
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
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 const TextTrackConfig& config) OVERRIDE;
238 virtual void RemoveTextStream(DemuxerStream* text_stream) OVERRIDE;
235 239
236 // Initiates teardown sequence in response to a runtime error. 240 // Initiates teardown sequence in response to a runtime error.
237 // 241 //
238 // Safe to call from any thread. 242 // Safe to call from any thread.
239 void SetError(PipelineStatus error); 243 void SetError(PipelineStatus error);
240 244
241 // Callback executed when the natural size of the video has changed. 245 // Callback executed when the natural size of the video has changed.
242 void OnNaturalVideoSizeChanged(const gfx::Size& size); 246 void OnNaturalVideoSizeChanged(const gfx::Size& size);
243 247
244 // Callbacks executed when a renderer has ended. 248 // Callbacks executed when a renderer has ended.
245 void OnAudioRendererEnded(); 249 void OnAudioRendererEnded();
246 void OnVideoRendererEnded(); 250 void OnVideoRendererEnded();
251 void OnTextRendererEnded();
247 252
248 // Callback executed by filters to update statistics. 253 // Callback executed by filters to update statistics.
249 void OnUpdateStatistics(const PipelineStatistics& stats); 254 void OnUpdateStatistics(const PipelineStatistics& stats);
250 255
251 // Callback executed by audio renderer when it has been disabled. 256 // Callback executed by audio renderer when it has been disabled.
252 void OnAudioDisabled(); 257 void OnAudioDisabled();
253 258
254 // Callback executed by audio renderer to update clock time. 259 // Callback executed by audio renderer to update clock time.
255 void OnAudioTimeUpdate(base::TimeDelta time, base::TimeDelta max_time); 260 void OnAudioTimeUpdate(base::TimeDelta time, base::TimeDelta max_time);
256 261
(...skipping 19 matching lines...) Expand all
276 281
277 // Carries out notifying filters that the playback rate has changed. 282 // Carries out notifying filters that the playback rate has changed.
278 void PlaybackRateChangedTask(float playback_rate); 283 void PlaybackRateChangedTask(float playback_rate);
279 284
280 // Carries out notifying filters that the volume has changed. 285 // Carries out notifying filters that the volume has changed.
281 void VolumeChangedTask(float volume); 286 void VolumeChangedTask(float volume);
282 287
283 // Carries out notifying filters that we are seeking to a new timestamp. 288 // Carries out notifying filters that we are seeking to a new timestamp.
284 void SeekTask(base::TimeDelta time, const PipelineStatusCB& seek_cb); 289 void SeekTask(base::TimeDelta time, const PipelineStatusCB& seek_cb);
285 290
286 // Handles audio/video ended logic and running |ended_cb_|. 291 // Handles audio/video/text ended logic and running |ended_cb_|.
287 void DoAudioRendererEnded(); 292 void DoAudioRendererEnded();
288 void DoVideoRendererEnded(); 293 void DoVideoRendererEnded();
294 void DoTextRendererEnded();
289 void RunEndedCallbackIfNeeded(); 295 void RunEndedCallbackIfNeeded();
290 296
291 // Carries out disabling the audio renderer. 297 // Carries out disabling the audio renderer.
292 void AudioDisabledTask(); 298 void AudioDisabledTask();
293 299
300 // Carries out adding a new text stream to the text renderer.
301 void AddTextStreamTask(DemuxerStream* text_stream,
302 const TextTrackConfig& config);
303
304 // Carries out removing a text stream from the text renderer.
305 void RemoveTextStreamTask(DemuxerStream* text_stream);
306
294 // Kicks off initialization for each media object, executing |done_cb| with 307 // Kicks off initialization for each media object, executing |done_cb| with
295 // the result when completed. 308 // the result when completed.
296 void InitializeDemuxer(const PipelineStatusCB& done_cb); 309 void InitializeDemuxer(const PipelineStatusCB& done_cb);
297 void InitializeAudioRenderer(const PipelineStatusCB& done_cb); 310 void InitializeAudioRenderer(const PipelineStatusCB& done_cb);
298 void InitializeVideoRenderer(const PipelineStatusCB& done_cb); 311 void InitializeVideoRenderer(const PipelineStatusCB& done_cb);
299 312
300 // Kicks off destroying filters. Called by StopTask() and ErrorChangedTask(). 313 // Kicks off destroying filters. Called by StopTask() and ErrorChangedTask().
301 // When we start to tear down the pipeline, we will consider two cases: 314 // When we start to tear down the pipeline, we will consider two cases:
302 // 1. when pipeline has not been initialized, we will transit to stopping 315 // 1. when pipeline has not been initialized, we will transit to stopping
303 // state first. 316 // state first.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 // for an update of the clock greater than or equal to the elapsed time to 398 // for an update of the clock greater than or equal to the elapsed time to
386 // start the clock. 399 // start the clock.
387 bool waiting_for_clock_update_; 400 bool waiting_for_clock_update_;
388 401
389 // Status of the pipeline. Initialized to PIPELINE_OK which indicates that 402 // Status of the pipeline. Initialized to PIPELINE_OK which indicates that
390 // the pipeline is operating correctly. Any other value indicates that the 403 // 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 404 // pipeline is stopped or is stopping. Clients can call the Stop() method to
392 // reset the pipeline state, and restore this to PIPELINE_OK. 405 // reset the pipeline state, and restore this to PIPELINE_OK.
393 PipelineStatus status_; 406 PipelineStatus status_;
394 407
395 // Whether the media contains rendered audio and video streams. 408 // Whether the media contains rendered audio or video streams.
396 // TODO(fischman,scherkus): replace these with checks for 409 // TODO(fischman,scherkus): replace these with checks for
397 // {audio,video}_decoder_ once extraction of {Audio,Video}Decoder from the 410 // {audio,video}_decoder_ once extraction of {Audio,Video}Decoder from the
398 // Filter heirarchy is done. 411 // Filter heirarchy is done.
399 bool has_audio_; 412 bool has_audio_;
400 bool has_video_; 413 bool has_video_;
401 414
402 // The following data members are only accessed by tasks posted to 415 // The following data members are only accessed by tasks posted to
403 // |message_loop_|. 416 // |message_loop_|.
404 417
405 // Member that tracks the current state. 418 // Member that tracks the current state.
406 State state_; 419 State state_;
407 420
408 // Whether we've received the audio/video ended events. 421 // Whether we've received the audio/video/text ended events.
409 bool audio_ended_; 422 bool audio_ended_;
410 bool video_ended_; 423 bool video_ended_;
424 bool text_ended_;
411 425
412 // Set to true in DisableAudioRendererTask(). 426 // Set to true in DisableAudioRendererTask().
413 bool audio_disabled_; 427 bool audio_disabled_;
414 428
415 // Temporary callback used for Start() and Seek(). 429 // Temporary callback used for Start() and Seek().
416 PipelineStatusCB seek_cb_; 430 PipelineStatusCB seek_cb_;
417 431
418 // Temporary callback used for Stop(). 432 // Temporary callback used for Stop().
419 base::Closure stop_cb_; 433 base::Closure stop_cb_;
420 434
421 // Permanent callbacks passed in via Start(). 435 // Permanent callbacks passed in via Start().
422 base::Closure ended_cb_; 436 base::Closure ended_cb_;
423 PipelineStatusCB error_cb_; 437 PipelineStatusCB error_cb_;
424 BufferingStateCB buffering_state_cb_; 438 BufferingStateCB buffering_state_cb_;
425 base::Closure duration_change_cb_; 439 base::Closure duration_change_cb_;
426 440
427 // Contains the demuxer and renderers to use when initializing. 441 // Contains the demuxer and renderers to use when initializing.
428 scoped_ptr<FilterCollection> filter_collection_; 442 scoped_ptr<FilterCollection> filter_collection_;
429 443
430 // Holds the initialized demuxer. Used for seeking. Owned by client. 444 // Holds the initialized demuxer. Used for seeking. Owned by client.
431 Demuxer* demuxer_; 445 Demuxer* demuxer_;
432 446
433 // Holds the initialized renderers. Used for setting the volume, 447 // Holds the initialized renderers. Used for setting the volume,
434 // playback rate, and determining when playback has finished. 448 // playback rate, and determining when playback has finished.
435 scoped_ptr<AudioRenderer> audio_renderer_; 449 scoped_ptr<AudioRenderer> audio_renderer_;
436 scoped_ptr<VideoRenderer> video_renderer_; 450 scoped_ptr<VideoRenderer> video_renderer_;
451 scoped_ptr<TextRenderer> text_renderer_;
437 452
438 PipelineStatistics statistics_; 453 PipelineStatistics statistics_;
439 454
440 // Time of pipeline creation; is non-zero only until the pipeline first 455 // Time of pipeline creation; is non-zero only until the pipeline first
441 // reaches "kStarted", at which point it is used & zeroed out. 456 // reaches "kStarted", at which point it is used & zeroed out.
442 base::TimeTicks creation_time_; 457 base::TimeTicks creation_time_;
443 458
444 scoped_ptr<SerialRunner> pending_callbacks_; 459 scoped_ptr<SerialRunner> pending_callbacks_;
445 460
446 base::ThreadChecker thread_checker_; 461 base::ThreadChecker thread_checker_;
447 462
448 DISALLOW_COPY_AND_ASSIGN(Pipeline); 463 DISALLOW_COPY_AND_ASSIGN(Pipeline);
449 }; 464 };
450 465
451 } // namespace media 466 } // namespace media
452 467
453 #endif // MEDIA_BASE_PIPELINE_H_ 468 #endif // MEDIA_BASE_PIPELINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698