Chromium Code Reviews| 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_AUDIO_RENDERER_H_ | 5 #ifndef MEDIA_BASE_AUDIO_RENDERER_H_ |
| 6 #define MEDIA_BASE_AUDIO_RENDERER_H_ | 6 #define MEDIA_BASE_AUDIO_RENDERER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "base/time/time.h" | |
| 11 #include "media/base/buffering_state.h" | 9 #include "media/base/buffering_state.h" |
| 12 #include "media/base/media_export.h" | 10 #include "media/base/media_export.h" |
| 13 #include "media/base/pipeline_status.h" | 11 #include "media/base/pipeline_status.h" |
| 12 #include "media/base/time_source.h" | |
| 14 | 13 |
| 15 namespace media { | 14 namespace media { |
| 16 | 15 |
| 17 class DemuxerStream; | 16 class DemuxerStream; |
| 18 | 17 |
| 19 class MEDIA_EXPORT AudioRenderer { | 18 class MEDIA_EXPORT AudioRenderer : public TimeSource { |
|
scherkus (not reviewing)
2014/07/21 17:07:53
alternatively, we can have this interface have a g
xhwang
2014/07/21 22:10:06
The Renderer will do pretty much the same as the A
| |
| 20 public: | 19 public: |
| 21 // First parameter is the current time that has been rendered. | 20 // First parameter is the current time that has been rendered. |
| 22 // Second parameter is the maximum time value that the clock cannot exceed. | 21 // Second parameter is the maximum time value that the clock cannot exceed. |
| 23 typedef base::Callback<void(base::TimeDelta, base::TimeDelta)> TimeCB; | 22 typedef base::Callback<void(base::TimeDelta, base::TimeDelta)> TimeCB; |
| 24 | 23 |
| 25 AudioRenderer(); | 24 AudioRenderer(); |
| 26 virtual ~AudioRenderer(); | 25 virtual ~AudioRenderer(); |
| 27 | 26 |
| 28 // Initialize an AudioRenderer with |stream|, executing |init_cb| upon | 27 // Initialize an AudioRenderer with |stream|, executing |init_cb| upon |
| 29 // completion. | 28 // completion. |
| 30 // | 29 // |
| 31 // |statistics_cb| is executed periodically with audio rendering stats. | 30 // |statistics_cb| is executed periodically with audio rendering stats. |
| 32 // | 31 // |
| 33 // |time_cb| is executed whenever time has advanced by way of audio rendering. | 32 // |time_cb| is executed whenever time has advanced by way of audio rendering. |
| 34 // | 33 // |
| 35 // |buffering_state_cb| is executed when audio rendering has either run out of | 34 // |buffering_state_cb| is executed when audio rendering has either run out of |
| 36 // data or has enough data to continue playback. | 35 // data or has enough data to continue playback. |
| 37 // | 36 // |
| 38 // |ended_cb| is executed when audio rendering has reached the end of stream. | 37 // |ended_cb| is executed when audio rendering has reached the end of stream. |
| 39 // | 38 // |
| 40 // |error_cb| is executed if an error was encountered. | 39 // |error_cb| is executed if an error was encountered. |
| 41 virtual void Initialize(DemuxerStream* stream, | 40 virtual void Initialize(DemuxerStream* stream, |
| 42 const PipelineStatusCB& init_cb, | 41 const PipelineStatusCB& init_cb, |
| 43 const StatisticsCB& statistics_cb, | 42 const StatisticsCB& statistics_cb, |
| 44 const TimeCB& time_cb, | 43 const TimeCB& time_cb, |
| 45 const BufferingStateCB& buffering_state_cb, | 44 const BufferingStateCB& buffering_state_cb, |
| 46 const base::Closure& ended_cb, | 45 const base::Closure& ended_cb, |
| 47 const PipelineStatusCB& error_cb) = 0; | 46 const PipelineStatusCB& error_cb) = 0; |
| 48 | 47 |
| 49 // Signal audio playback to start at the current rate. It is expected that | |
| 50 // |time_cb| will eventually start being run with time updates. | |
| 51 // | |
| 52 // TODO(scherkus): Fold into TimeSource API. | |
| 53 virtual void StartRendering() = 0; | |
| 54 | |
| 55 // Signal audio playback to stop until further notice. It is expected that | |
| 56 // |time_cb| will no longer be run. | |
| 57 // | |
| 58 // TODO(scherkus): Fold into TimeSource API. | |
| 59 virtual void StopRendering() = 0; | |
| 60 | |
| 61 // Sets the media time to start rendering from. Only valid to call while not | |
| 62 // currently rendering. | |
| 63 // | |
| 64 // TODO(scherkus): Fold into TimeSource API. | |
| 65 virtual void SetMediaTime(base::TimeDelta time) = 0; | |
| 66 | |
| 67 // Discard any audio data, executing |callback| when completed. | 48 // Discard any audio data, executing |callback| when completed. |
| 68 // | 49 // |
| 69 // Clients should expect |buffering_state_cb| to be called with | 50 // Clients should expect |buffering_state_cb| to be called with |
| 70 // BUFFERING_HAVE_NOTHING while flushing is in progress. | 51 // BUFFERING_HAVE_NOTHING while flushing is in progress. |
| 71 virtual void Flush(const base::Closure& callback) = 0; | 52 virtual void Flush(const base::Closure& callback) = 0; |
| 72 | 53 |
| 73 // Starts playback by reading from |stream| and decoding and rendering audio. | 54 // Starts playback by reading from |stream| and decoding and rendering audio. |
| 74 // | 55 // |
| 75 // Only valid to call after a successful Initialize() or Flush(). | 56 // Only valid to call after a successful Initialize() or Flush(). |
| 76 virtual void StartPlaying() = 0; | 57 virtual void StartPlaying() = 0; |
| 77 | 58 |
| 78 // Stop all operations in preparation for being deleted, executing |callback| | 59 // Stop all operations in preparation for being deleted, executing |callback| |
| 79 // when complete. | 60 // when complete. |
| 80 virtual void Stop(const base::Closure& callback) = 0; | 61 virtual void Stop(const base::Closure& callback) = 0; |
| 81 | 62 |
| 82 // Updates the current playback rate. | |
| 83 // | |
| 84 // TODO(scherkus): Fold into TimeSource API. | |
| 85 virtual void SetPlaybackRate(float playback_rate) = 0; | |
| 86 | |
| 87 // Sets the output volume. | 63 // Sets the output volume. |
| 88 virtual void SetVolume(float volume) = 0; | 64 virtual void SetVolume(float volume) = 0; |
| 89 | 65 |
| 90 private: | 66 private: |
| 91 DISALLOW_COPY_AND_ASSIGN(AudioRenderer); | 67 DISALLOW_COPY_AND_ASSIGN(AudioRenderer); |
| 92 }; | 68 }; |
| 93 | 69 |
| 94 } // namespace media | 70 } // namespace media |
| 95 | 71 |
| 96 #endif // MEDIA_BASE_AUDIO_RENDERER_H_ | 72 #endif // MEDIA_BASE_AUDIO_RENDERER_H_ |
| OLD | NEW |