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 10 matching lines...) Expand all Loading... | |
21 #include "media/base/serial_runner.h" | 21 #include "media/base/serial_runner.h" |
22 #include "ui/gfx/size.h" | 22 #include "ui/gfx/size.h" |
23 | 23 |
24 namespace base { | 24 namespace base { |
25 class SingleThreadTaskRunner; | 25 class SingleThreadTaskRunner; |
26 class TimeDelta; | 26 class TimeDelta; |
27 } | 27 } |
28 | 28 |
29 namespace media { | 29 namespace media { |
30 | 30 |
31 class Clock; | |
32 class FilterCollection; | 31 class FilterCollection; |
33 class MediaLog; | 32 class MediaLog; |
34 class TextRenderer; | 33 class TextRenderer; |
35 class TextTrackConfig; | 34 class TextTrackConfig; |
35 class TimeDeltaInterpolator; | |
36 class VideoRenderer; | 36 class VideoRenderer; |
37 | 37 |
38 // Metadata describing a pipeline once it has been initialized. | 38 // Metadata describing a pipeline once it has been initialized. |
39 struct PipelineMetadata { | 39 struct PipelineMetadata { |
40 PipelineMetadata() : has_audio(false), has_video(false) {} | 40 PipelineMetadata() : has_audio(false), has_video(false) {} |
41 | 41 |
42 bool has_audio; | 42 bool has_audio; |
43 bool has_video; | 43 bool has_video; |
44 gfx::Size natural_size; | 44 gfx::Size natural_size; |
45 base::Time timeline_offset; | 45 base::Time timeline_offset; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 // Return true if loading progress has been made since the last time this | 172 // Return true if loading progress has been made since the last time this |
173 // method was called. | 173 // method was called. |
174 bool DidLoadingProgress(); | 174 bool DidLoadingProgress(); |
175 | 175 |
176 // Gets the current pipeline statistics. | 176 // Gets the current pipeline statistics. |
177 PipelineStatistics GetStatistics() const; | 177 PipelineStatistics GetStatistics() const; |
178 | 178 |
179 void set_underflow_disabled_for_testing(bool disabled) { | 179 void set_underflow_disabled_for_testing(bool disabled) { |
180 underflow_disabled_for_testing_ = disabled; | 180 underflow_disabled_for_testing_ = disabled; |
181 } | 181 } |
182 void SetClockForTesting(Clock* clock); | 182 void SetTimeDeltaInterpolatorForTesting(TimeDeltaInterpolator* interpolator); |
183 void SetErrorForTesting(PipelineStatus status); | 183 void SetErrorForTesting(PipelineStatus status); |
184 | 184 |
185 private: | 185 private: |
186 FRIEND_TEST_ALL_PREFIXES(PipelineTest, GetBufferedTimeRanges); | 186 FRIEND_TEST_ALL_PREFIXES(PipelineTest, GetBufferedTimeRanges); |
187 FRIEND_TEST_ALL_PREFIXES(PipelineTest, EndedCallback); | 187 FRIEND_TEST_ALL_PREFIXES(PipelineTest, EndedCallback); |
188 FRIEND_TEST_ALL_PREFIXES(PipelineTest, AudioStreamShorterThanVideo); | 188 FRIEND_TEST_ALL_PREFIXES(PipelineTest, AudioStreamShorterThanVideo); |
189 friend class MediaLog; | 189 friend class MediaLog; |
190 | 190 |
191 // Pipeline states, as described above. | 191 // Pipeline states, as described above. |
192 enum State { | 192 enum State { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 // - A waiting to non-waiting transition indicates preroll has completed | 315 // - A waiting to non-waiting transition indicates preroll has completed |
316 // and StartPlayback() should be called | 316 // and StartPlayback() should be called |
317 // - A non-waiting to waiting transition indicates underflow has occurred | 317 // - A non-waiting to waiting transition indicates underflow has occurred |
318 // and PausePlayback() should be called | 318 // and PausePlayback() should be called |
319 void BufferingStateChanged(BufferingState* buffering_state, | 319 void BufferingStateChanged(BufferingState* buffering_state, |
320 BufferingState new_buffering_state); | 320 BufferingState new_buffering_state); |
321 bool WaitingForEnoughData() const; | 321 bool WaitingForEnoughData() const; |
322 void PausePlayback(); | 322 void PausePlayback(); |
323 void StartPlayback(); | 323 void StartPlayback(); |
324 | 324 |
325 void PauseClockAndStopRendering_Locked(); | 325 void PauseClockAndStopRendering_Locked(); |
scherkus (not reviewing)
2014/07/08 22:36:49
note to self: I need to update these method names
| |
326 void StartClockIfWaitingForTimeUpdate_Locked(); | 326 void StartClockIfWaitingForTimeUpdate_Locked(); |
327 | 327 |
328 // Task runner used to execute pipeline tasks. | 328 // Task runner used to execute pipeline tasks. |
329 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 329 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
330 | 330 |
331 // MediaLog to which to log events. | 331 // MediaLog to which to log events. |
332 scoped_refptr<MediaLog> media_log_; | 332 scoped_refptr<MediaLog> media_log_; |
333 | 333 |
334 // Lock used to serialize access for the following data members. | 334 // Lock used to serialize access for the following data members. |
335 mutable base::Lock lock_; | 335 mutable base::Lock lock_; |
(...skipping 14 matching lines...) Expand all Loading... | |
350 float volume_; | 350 float volume_; |
351 | 351 |
352 // Current playback rate (>= 0.0f). This value is set immediately via | 352 // Current playback rate (>= 0.0f). This value is set immediately via |
353 // SetPlaybackRate() and a task is dispatched on the task runner to notify | 353 // SetPlaybackRate() and a task is dispatched on the task runner to notify |
354 // the filters. | 354 // the filters. |
355 float playback_rate_; | 355 float playback_rate_; |
356 | 356 |
357 // Current duration as reported by |demuxer_|. | 357 // Current duration as reported by |demuxer_|. |
358 base::TimeDelta duration_; | 358 base::TimeDelta duration_; |
359 | 359 |
360 // base::TickClock used by |clock_|. | 360 // base::TickClock used by |interpolator_|. |
361 base::DefaultTickClock default_tick_clock_; | 361 base::DefaultTickClock default_tick_clock_; |
362 | 362 |
363 // Reference clock. Keeps track of current playback time. Uses system | 363 // Tracks the most recent media time update and provides interpolated values |
364 // clock and linear interpolation, but can have its time manually set | 364 // as playback progresses. |
365 // by filters. | 365 scoped_ptr<TimeDeltaInterpolator> interpolator_; |
366 scoped_ptr<Clock> clock_; | |
367 | 366 |
368 enum ClockState { | 367 enum InterpolationState { |
acolwell GONE FROM CHROMIUM
2014/07/09 00:42:46
It seems weird that we are keeping track of this s
scherkus (not reviewing)
2014/07/09 01:54:32
Yeah I have some future CLs in mind to help clean
| |
369 // Audio (if present) is not rendering. Clock isn't playing. | 368 // Audio (if present) is not rendering. Time isn't being interpolated. |
370 CLOCK_PAUSED, | 369 INTERPOLATION_STOPPED, |
371 | 370 |
372 // Audio (if present) is rendering. Clock isn't playing. | 371 // Audio (if present) is rendering. Time isn't being interpolated. |
373 CLOCK_WAITING_FOR_AUDIO_TIME_UPDATE, | 372 INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE, |
374 | 373 |
375 // Audio (if present) is rendering. Clock is playing. | 374 // Audio (if present) is rendering. Time is being interpolated. |
376 CLOCK_PLAYING, | 375 INTERPOLATION_STARTED, |
377 }; | 376 }; |
378 | 377 |
379 ClockState clock_state_; | 378 InterpolationState interpolation_state_; |
380 | 379 |
381 // Status of the pipeline. Initialized to PIPELINE_OK which indicates that | 380 // Status of the pipeline. Initialized to PIPELINE_OK which indicates that |
382 // the pipeline is operating correctly. Any other value indicates that the | 381 // the pipeline is operating correctly. Any other value indicates that the |
383 // pipeline is stopped or is stopping. Clients can call the Stop() method to | 382 // pipeline is stopped or is stopping. Clients can call the Stop() method to |
384 // reset the pipeline state, and restore this to PIPELINE_OK. | 383 // reset the pipeline state, and restore this to PIPELINE_OK. |
385 PipelineStatus status_; | 384 PipelineStatus status_; |
386 | 385 |
387 // The following data members are only accessed by tasks posted to | 386 // The following data members are only accessed by tasks posted to |
388 // |task_runner_|. | 387 // |task_runner_|. |
389 | 388 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
433 bool underflow_disabled_for_testing_; | 432 bool underflow_disabled_for_testing_; |
434 | 433 |
435 base::ThreadChecker thread_checker_; | 434 base::ThreadChecker thread_checker_; |
436 | 435 |
437 DISALLOW_COPY_AND_ASSIGN(Pipeline); | 436 DISALLOW_COPY_AND_ASSIGN(Pipeline); |
438 }; | 437 }; |
439 | 438 |
440 } // namespace media | 439 } // namespace media |
441 | 440 |
442 #endif // MEDIA_BASE_PIPELINE_H_ | 441 #endif // MEDIA_BASE_PIPELINE_H_ |
OLD | NEW |