| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 // Return true if loading progress has been made since the last time this | 169 // Return true if loading progress has been made since the last time this |
| 170 // method was called. | 170 // method was called. |
| 171 bool DidLoadingProgress(); | 171 bool DidLoadingProgress(); |
| 172 | 172 |
| 173 // Gets the current pipeline statistics. | 173 // Gets the current pipeline statistics. |
| 174 PipelineStatistics GetStatistics() const; | 174 PipelineStatistics GetStatistics() const; |
| 175 | 175 |
| 176 void set_underflow_disabled_for_testing(bool disabled) { | 176 void set_underflow_disabled_for_testing(bool disabled) { |
| 177 underflow_disabled_for_testing_ = disabled; | 177 underflow_disabled_for_testing_ = disabled; |
| 178 } | 178 } |
| 179 void SetClockForTesting(Clock* clock); | 179 void SetTimeDeltaInterpolatorForTesting(TimeDeltaInterpolator* interpolator); |
| 180 void SetErrorForTesting(PipelineStatus status); | 180 void SetErrorForTesting(PipelineStatus status); |
| 181 | 181 |
| 182 private: | 182 private: |
| 183 FRIEND_TEST_ALL_PREFIXES(PipelineTest, GetBufferedTimeRanges); | 183 FRIEND_TEST_ALL_PREFIXES(PipelineTest, GetBufferedTimeRanges); |
| 184 FRIEND_TEST_ALL_PREFIXES(PipelineTest, EndedCallback); | 184 FRIEND_TEST_ALL_PREFIXES(PipelineTest, EndedCallback); |
| 185 FRIEND_TEST_ALL_PREFIXES(PipelineTest, AudioStreamShorterThanVideo); | 185 FRIEND_TEST_ALL_PREFIXES(PipelineTest, AudioStreamShorterThanVideo); |
| 186 friend class MediaLog; | 186 friend class MediaLog; |
| 187 | 187 |
| 188 // Pipeline states, as described above. | 188 // Pipeline states, as described above. |
| 189 enum State { | 189 enum State { |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 float volume_; | 342 float volume_; |
| 343 | 343 |
| 344 // Current playback rate (>= 0.0f). This value is set immediately via | 344 // Current playback rate (>= 0.0f). This value is set immediately via |
| 345 // SetPlaybackRate() and a task is dispatched on the task runner to notify | 345 // SetPlaybackRate() and a task is dispatched on the task runner to notify |
| 346 // the filters. | 346 // the filters. |
| 347 float playback_rate_; | 347 float playback_rate_; |
| 348 | 348 |
| 349 // Current duration as reported by |demuxer_|. | 349 // Current duration as reported by |demuxer_|. |
| 350 base::TimeDelta duration_; | 350 base::TimeDelta duration_; |
| 351 | 351 |
| 352 // base::TickClock used by |clock_|. | 352 // base::TickClock used by |interpolator_|. |
| 353 base::DefaultTickClock default_tick_clock_; | 353 base::DefaultTickClock default_tick_clock_; |
| 354 | 354 |
| 355 // Reference clock. Keeps track of current playback time. Uses system | 355 // Tracks the most recent media time update and provides interpolated values |
| 356 // clock and linear interpolation, but can have its time manually set | 356 // as playback progresses. |
| 357 // by filters. | 357 scoped_ptr<TimeDeltaInterpolator> interpolator_; |
| 358 scoped_ptr<Clock> clock_; | |
| 359 | 358 |
| 360 enum ClockState { | 359 enum InterpolationState { |
| 361 // Audio (if present) is not rendering. Clock isn't playing. | 360 // Audio (if present) is not rendering. Time isn't being interpolated. |
| 362 CLOCK_PAUSED, | 361 INTERPOLATION_STOPPED, |
| 363 | 362 |
| 364 // Audio (if present) is rendering. Clock isn't playing. | 363 // Audio (if present) is rendering. Time isn't being interpolated. |
| 365 CLOCK_WAITING_FOR_AUDIO_TIME_UPDATE, | 364 INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE, |
| 366 | 365 |
| 367 // Audio (if present) is rendering. Clock is playing. | 366 // Audio (if present) is rendering. Time is being interpolated. |
| 368 CLOCK_PLAYING, | 367 INTERPOLATION_STARTED, |
| 369 }; | 368 }; |
| 370 | 369 |
| 371 ClockState clock_state_; | 370 InterpolationState interpolation_state_; |
| 372 | 371 |
| 373 // Status of the pipeline. Initialized to PIPELINE_OK which indicates that | 372 // Status of the pipeline. Initialized to PIPELINE_OK which indicates that |
| 374 // the pipeline is operating correctly. Any other value indicates that the | 373 // the pipeline is operating correctly. Any other value indicates that the |
| 375 // pipeline is stopped or is stopping. Clients can call the Stop() method to | 374 // pipeline is stopped or is stopping. Clients can call the Stop() method to |
| 376 // reset the pipeline state, and restore this to PIPELINE_OK. | 375 // reset the pipeline state, and restore this to PIPELINE_OK. |
| 377 PipelineStatus status_; | 376 PipelineStatus status_; |
| 378 | 377 |
| 379 // The following data members are only accessed by tasks posted to | 378 // The following data members are only accessed by tasks posted to |
| 380 // |task_runner_|. | 379 // |task_runner_|. |
| 381 | 380 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 bool underflow_disabled_for_testing_; | 424 bool underflow_disabled_for_testing_; |
| 426 | 425 |
| 427 base::ThreadChecker thread_checker_; | 426 base::ThreadChecker thread_checker_; |
| 428 | 427 |
| 429 DISALLOW_COPY_AND_ASSIGN(Pipeline); | 428 DISALLOW_COPY_AND_ASSIGN(Pipeline); |
| 430 }; | 429 }; |
| 431 | 430 |
| 432 } // namespace media | 431 } // namespace media |
| 433 | 432 |
| 434 #endif // MEDIA_BASE_PIPELINE_H_ | 433 #endif // MEDIA_BASE_PIPELINE_H_ |
| OLD | NEW |