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" | 9 #include "base/time/time.h" |
11 #include "media/base/buffering_state.h" | 10 #include "media/base/buffering_state.h" |
12 #include "media/base/media_export.h" | 11 #include "media/base/media_export.h" |
13 #include "media/base/pipeline_status.h" | 12 #include "media/base/pipeline_status.h" |
14 | 13 |
15 namespace media { | 14 namespace media { |
16 | 15 |
17 class DemuxerStream; | 16 class DemuxerStream; |
| 17 class TimeSource; |
18 | 18 |
19 class MEDIA_EXPORT AudioRenderer { | 19 class MEDIA_EXPORT AudioRenderer { |
20 public: | 20 public: |
21 // First parameter is the current time that has been rendered. | 21 // First parameter is the current time that has been rendered. |
22 // Second parameter is the maximum time value that the clock cannot exceed. | 22 // Second parameter is the maximum time value that the clock cannot exceed. |
23 typedef base::Callback<void(base::TimeDelta, base::TimeDelta)> TimeCB; | 23 typedef base::Callback<void(base::TimeDelta, base::TimeDelta)> TimeCB; |
24 | 24 |
25 AudioRenderer(); | 25 AudioRenderer(); |
26 virtual ~AudioRenderer(); | 26 virtual ~AudioRenderer(); |
27 | 27 |
(...skipping 11 matching lines...) Expand all Loading... |
39 // | 39 // |
40 // |error_cb| is executed if an error was encountered. | 40 // |error_cb| is executed if an error was encountered. |
41 virtual void Initialize(DemuxerStream* stream, | 41 virtual void Initialize(DemuxerStream* stream, |
42 const PipelineStatusCB& init_cb, | 42 const PipelineStatusCB& init_cb, |
43 const StatisticsCB& statistics_cb, | 43 const StatisticsCB& statistics_cb, |
44 const TimeCB& time_cb, | 44 const TimeCB& time_cb, |
45 const BufferingStateCB& buffering_state_cb, | 45 const BufferingStateCB& buffering_state_cb, |
46 const base::Closure& ended_cb, | 46 const base::Closure& ended_cb, |
47 const PipelineStatusCB& error_cb) = 0; | 47 const PipelineStatusCB& error_cb) = 0; |
48 | 48 |
49 // Signal audio playback to start at the current rate. It is expected that | 49 // Returns the TimeSource associated with audio rendering. |
50 // |time_cb| will eventually start being run with time updates. | 50 virtual TimeSource* GetTimeSource() = 0; |
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 | 51 |
67 // Discard any audio data, executing |callback| when completed. | 52 // Discard any audio data, executing |callback| when completed. |
68 // | 53 // |
69 // Clients should expect |buffering_state_cb| to be called with | 54 // Clients should expect |buffering_state_cb| to be called with |
70 // BUFFERING_HAVE_NOTHING while flushing is in progress. | 55 // BUFFERING_HAVE_NOTHING while flushing is in progress. |
71 virtual void Flush(const base::Closure& callback) = 0; | 56 virtual void Flush(const base::Closure& callback) = 0; |
72 | 57 |
73 // Starts playback by reading from |stream| and decoding and rendering audio. | 58 // Starts playback by reading from |stream| and decoding and rendering audio. |
74 // | 59 // |
75 // Only valid to call after a successful Initialize() or Flush(). | 60 // Only valid to call after a successful Initialize() or Flush(). |
76 virtual void StartPlaying() = 0; | 61 virtual void StartPlaying() = 0; |
77 | 62 |
78 // Stop all operations in preparation for being deleted, executing |callback| | 63 // Stop all operations in preparation for being deleted, executing |callback| |
79 // when complete. | 64 // when complete. |
80 virtual void Stop(const base::Closure& callback) = 0; | 65 virtual void Stop(const base::Closure& callback) = 0; |
81 | 66 |
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. | 67 // Sets the output volume. |
88 virtual void SetVolume(float volume) = 0; | 68 virtual void SetVolume(float volume) = 0; |
89 | 69 |
90 private: | 70 private: |
91 DISALLOW_COPY_AND_ASSIGN(AudioRenderer); | 71 DISALLOW_COPY_AND_ASSIGN(AudioRenderer); |
92 }; | 72 }; |
93 | 73 |
94 } // namespace media | 74 } // namespace media |
95 | 75 |
96 #endif // MEDIA_BASE_AUDIO_RENDERER_H_ | 76 #endif // MEDIA_BASE_AUDIO_RENDERER_H_ |
OLD | NEW |