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 <list> |
| 9 |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
9 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
10 #include "base/time.h" | 12 #include "base/time.h" |
11 #include "media/base/media_export.h" | 13 #include "media/base/media_export.h" |
12 #include "media/base/pipeline_status.h" | 14 #include "media/base/pipeline_status.h" |
13 | 15 |
14 namespace media { | 16 namespace media { |
15 | 17 |
16 class AudioDecoder; | 18 class AudioDecoder; |
| 19 class DemuxerStream; |
17 | 20 |
18 class MEDIA_EXPORT AudioRenderer | 21 class MEDIA_EXPORT AudioRenderer |
19 : public base::RefCountedThreadSafe<AudioRenderer> { | 22 : public base::RefCountedThreadSafe<AudioRenderer> { |
20 public: | 23 public: |
| 24 typedef std::list<scoped_refptr<AudioDecoder> > AudioDecoderList; |
| 25 |
21 // First parameter is the current time that has been rendered. | 26 // First parameter is the current time that has been rendered. |
22 // Second parameter is the maximum time value that the clock cannot exceed. | 27 // Second parameter is the maximum time value that the clock cannot exceed. |
23 typedef base::Callback<void(base::TimeDelta, base::TimeDelta)> TimeCB; | 28 typedef base::Callback<void(base::TimeDelta, base::TimeDelta)> TimeCB; |
24 | 29 |
25 // Initialize a AudioRenderer with the given AudioDecoder, executing the | 30 // Initialize a AudioRenderer with the given DemuxerStream and |
26 // |init_cb| upon completion. | 31 // AudioDecoderList, executing |init_cb| callback upon completion. |
| 32 |
| 33 // |statistics_cb| is executed periodically with audio rendering stats, such |
| 34 // as the number of decoded audio samples. |
27 // | 35 // |
28 // |underflow_cb| is executed when the renderer runs out of data to pass to | 36 // |underflow_cb| is executed when the renderer runs out of data to pass to |
29 // the audio card during playback. ResumeAfterUnderflow() must be called | 37 // the audio card during playback. ResumeAfterUnderflow() must be called |
30 // to resume playback. Pause(), Preroll(), or Stop() cancels the underflow | 38 // to resume playback. Pause(), Preroll(), or Stop() cancels the underflow |
31 // condition. | 39 // condition. |
32 // | 40 // |
33 // |time_cb| is executed whenever time has advanced by way of audio rendering. | 41 // |time_cb| is executed whenever time has advanced by way of audio rendering. |
34 // | 42 // |
35 // |ended_cb| is executed when audio rendering has reached the end of stream. | 43 // |ended_cb| is executed when audio rendering has reached the end of stream. |
36 // | 44 // |
37 // |disabled_cb| is executed when audio rendering has been disabled due to | 45 // |disabled_cb| is executed when audio rendering has been disabled due to |
38 // external factors (i.e., device was removed). |time_cb| will no longer be | 46 // external factors (i.e., device was removed). |time_cb| will no longer be |
39 // executed. | 47 // executed. |
40 // | 48 // |
41 // |error_cb| is executed if an error was encountered. | 49 // |error_cb| is executed if an error was encountered. |
42 virtual void Initialize(const scoped_refptr<AudioDecoder>& decoder, | 50 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, |
| 51 const AudioDecoderList& decoders, |
43 const PipelineStatusCB& init_cb, | 52 const PipelineStatusCB& init_cb, |
| 53 const StatisticsCB& statistics_cb, |
44 const base::Closure& underflow_cb, | 54 const base::Closure& underflow_cb, |
45 const TimeCB& time_cb, | 55 const TimeCB& time_cb, |
46 const base::Closure& ended_cb, | 56 const base::Closure& ended_cb, |
47 const base::Closure& disabled_cb, | 57 const base::Closure& disabled_cb, |
48 const PipelineStatusCB& error_cb) = 0; | 58 const PipelineStatusCB& error_cb) = 0; |
49 | 59 |
50 // Start audio decoding and rendering at the current playback rate, executing | 60 // Start audio decoding and rendering at the current playback rate, executing |
51 // |callback| when playback is underway. | 61 // |callback| when playback is underway. |
52 virtual void Play(const base::Closure& callback) = 0; | 62 virtual void Play(const base::Closure& callback) = 0; |
53 | 63 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 AudioRenderer(); | 97 AudioRenderer(); |
88 virtual ~AudioRenderer(); | 98 virtual ~AudioRenderer(); |
89 | 99 |
90 private: | 100 private: |
91 DISALLOW_COPY_AND_ASSIGN(AudioRenderer); | 101 DISALLOW_COPY_AND_ASSIGN(AudioRenderer); |
92 }; | 102 }; |
93 | 103 |
94 } // namespace media | 104 } // namespace media |
95 | 105 |
96 #endif // MEDIA_BASE_AUDIO_RENDERER_H_ | 106 #endif // MEDIA_BASE_AUDIO_RENDERER_H_ |
OLD | NEW |