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

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: Created 7 years, 3 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // returns true, it is expected that Stop() will be called before destroying 132 // returns true, it is expected that Stop() will be called before destroying
132 // the pipeline. 133 // the pipeline.
133 bool IsRunning() const; 134 bool IsRunning() const;
134 135
135 // Returns true if the media has audio. 136 // Returns true if the media has audio.
136 bool HasAudio() const; 137 bool HasAudio() const;
137 138
138 // Returns true if the media has video. 139 // Returns true if the media has video.
139 bool HasVideo() const; 140 bool HasVideo() const;
140 141
142 // Returns true if the media has text.
143 bool HasText() const;
acolwell GONE FROM CHROMIUM 2013/09/12 00:15:15 nit: This only appears to be used by test code. Do
Matthew Heaney (Chromium) 2013/09/13 19:51:54 I don't think so. We can replace it with some alt
Matthew Heaney (Chromium) 2013/09/20 23:53:54 I finally removed it.
144
141 // Gets the current playback rate of the pipeline. When the pipeline is 145 // Gets the current playback rate of the pipeline. When the pipeline is
142 // started, the playback rate will be 0.0f. A rate of 1.0f indicates 146 // started, the playback rate will be 0.0f. A rate of 1.0f indicates
143 // that the pipeline is rendering the media at the standard rate. Valid 147 // that the pipeline is rendering the media at the standard rate. Valid
144 // values for playback rate are >= 0.0f. 148 // values for playback rate are >= 0.0f.
145 float GetPlaybackRate() const; 149 float GetPlaybackRate() const;
146 150
147 // Attempt to adjust the playback rate. Setting a playback rate of 0.0f pauses 151 // Attempt to adjust the playback rate. Setting a playback rate of 0.0f pauses
148 // all rendering of the media. A rate of 1.0f indicates a normal playback 152 // all rendering of the media. A rate of 1.0f indicates a normal playback
149 // rate. Values for the playback rate must be greater than or equal to 0.0f. 153 // rate. Values for the playback rate must be greater than or equal to 0.0f.
150 // 154 //
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 FRIEND_TEST_ALL_PREFIXES(PipelineTest, EndedCallback); 202 FRIEND_TEST_ALL_PREFIXES(PipelineTest, EndedCallback);
199 FRIEND_TEST_ALL_PREFIXES(PipelineTest, AudioStreamShorterThanVideo); 203 FRIEND_TEST_ALL_PREFIXES(PipelineTest, AudioStreamShorterThanVideo);
200 friend class MediaLog; 204 friend class MediaLog;
201 205
202 // Pipeline states, as described above. 206 // Pipeline states, as described above.
203 enum State { 207 enum State {
204 kCreated, 208 kCreated,
205 kInitDemuxer, 209 kInitDemuxer,
206 kInitAudioRenderer, 210 kInitAudioRenderer,
207 kInitVideoRenderer, 211 kInitVideoRenderer,
212 kInitTextRenderer,
208 kInitPrerolling, 213 kInitPrerolling,
209 kSeeking, 214 kSeeking,
210 kStarting, 215 kStarting,
211 kStarted, 216 kStarted,
212 kStopping, 217 kStopping,
213 kStopped, 218 kStopped,
214 }; 219 };
215 220
216 // Updates |state_|. All state transitions should use this call. 221 // Updates |state_|. All state transitions should use this call.
217 void SetState(State next_state); 222 void SetState(State next_state);
(...skipping 19 matching lines...) Expand all
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
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);
306 void InitializeTextRenderer(const PipelineStatusCB& done_cb);
299 307
300 // Kicks off destroying filters. Called by StopTask() and ErrorChangedTask(). 308 // Kicks off destroying filters. Called by StopTask() and ErrorChangedTask().
301 // When we start to tear down the pipeline, we will consider two cases: 309 // 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 310 // 1. when pipeline has not been initialized, we will transit to stopping
303 // state first. 311 // state first.
304 // 2. when pipeline has been initialized, we will first transit to pausing 312 // 2. when pipeline has been initialized, we will first transit to pausing
305 // => flushing => stopping => stopped state. 313 // => flushing => stopping => stopped state.
306 // This will remove the race condition during stop between filters. 314 // This will remove the race condition during stop between filters.
307 void TearDownPipeline(); 315 void TearDownPipeline();
308 316
(...skipping 76 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 393 // for an update of the clock greater than or equal to the elapsed time to
386 // start the clock. 394 // start the clock.
387 bool waiting_for_clock_update_; 395 bool waiting_for_clock_update_;
388 396
389 // Status of the pipeline. Initialized to PIPELINE_OK which indicates that 397 // Status of the pipeline. Initialized to PIPELINE_OK which indicates that
390 // the pipeline is operating correctly. Any other value indicates that the 398 // 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 399 // pipeline is stopped or is stopping. Clients can call the Stop() method to
392 // reset the pipeline state, and restore this to PIPELINE_OK. 400 // reset the pipeline state, and restore this to PIPELINE_OK.
393 PipelineStatus status_; 401 PipelineStatus status_;
394 402
395 // Whether the media contains rendered audio and video streams. 403 // Whether the media contains rendered audio, video, and text streams.
396 // TODO(fischman,scherkus): replace these with checks for 404 // TODO(fischman,scherkus): replace these with checks for
397 // {audio,video}_decoder_ once extraction of {Audio,Video}Decoder from the 405 // {audio,video}_decoder_ once extraction of {Audio,Video}Decoder from the
398 // Filter heirarchy is done. 406 // Filter heirarchy is done.
399 bool has_audio_; 407 bool has_audio_;
400 bool has_video_; 408 bool has_video_;
409 bool has_text_;
401 410
402 // The following data members are only accessed by tasks posted to 411 // The following data members are only accessed by tasks posted to
403 // |message_loop_|. 412 // |message_loop_|.
404 413
405 // Member that tracks the current state. 414 // Member that tracks the current state.
406 State state_; 415 State state_;
407 416
408 // Whether we've received the audio/video ended events. 417 // Whether we've received the audio/video/text ended events.
409 bool audio_ended_; 418 bool audio_ended_;
410 bool video_ended_; 419 bool video_ended_;
420 bool text_ended_;
411 421
412 // Set to true in DisableAudioRendererTask(). 422 // Set to true in DisableAudioRendererTask().
413 bool audio_disabled_; 423 bool audio_disabled_;
414 424
415 // Temporary callback used for Start() and Seek(). 425 // Temporary callback used for Start() and Seek().
416 PipelineStatusCB seek_cb_; 426 PipelineStatusCB seek_cb_;
417 427
418 // Temporary callback used for Stop(). 428 // Temporary callback used for Stop().
419 base::Closure stop_cb_; 429 base::Closure stop_cb_;
420 430
421 // Permanent callbacks passed in via Start(). 431 // Permanent callbacks passed in via Start().
422 base::Closure ended_cb_; 432 base::Closure ended_cb_;
423 PipelineStatusCB error_cb_; 433 PipelineStatusCB error_cb_;
424 BufferingStateCB buffering_state_cb_; 434 BufferingStateCB buffering_state_cb_;
425 base::Closure duration_change_cb_; 435 base::Closure duration_change_cb_;
426 436
427 // Contains the demuxer and renderers to use when initializing. 437 // Contains the demuxer and renderers to use when initializing.
428 scoped_ptr<FilterCollection> filter_collection_; 438 scoped_ptr<FilterCollection> filter_collection_;
429 439
430 // Holds the initialized demuxer. Used for seeking. Owned by client. 440 // Holds the initialized demuxer. Used for seeking. Owned by client.
431 Demuxer* demuxer_; 441 Demuxer* demuxer_;
432 442
433 // Holds the initialized renderers. Used for setting the volume, 443 // Holds the initialized renderers. Used for setting the volume,
434 // playback rate, and determining when playback has finished. 444 // playback rate, and determining when playback has finished.
435 scoped_ptr<AudioRenderer> audio_renderer_; 445 scoped_ptr<AudioRenderer> audio_renderer_;
436 scoped_ptr<VideoRenderer> video_renderer_; 446 scoped_ptr<VideoRenderer> video_renderer_;
447 scoped_ptr<TextRenderer> text_renderer_;
437 448
438 PipelineStatistics statistics_; 449 PipelineStatistics statistics_;
439 450
440 // Time of pipeline creation; is non-zero only until the pipeline first 451 // Time of pipeline creation; is non-zero only until the pipeline first
441 // reaches "kStarted", at which point it is used & zeroed out. 452 // reaches "kStarted", at which point it is used & zeroed out.
442 base::TimeTicks creation_time_; 453 base::TimeTicks creation_time_;
443 454
444 scoped_ptr<SerialRunner> pending_callbacks_; 455 scoped_ptr<SerialRunner> pending_callbacks_;
445 456
446 base::ThreadChecker thread_checker_; 457 base::ThreadChecker thread_checker_;
447 458
448 DISALLOW_COPY_AND_ASSIGN(Pipeline); 459 DISALLOW_COPY_AND_ASSIGN(Pipeline);
449 }; 460 };
450 461
451 } // namespace media 462 } // namespace media
452 463
453 #endif // MEDIA_BASE_PIPELINE_H_ 464 #endif // MEDIA_BASE_PIPELINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698