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_SINK_H_ | 5 #ifndef MEDIA_BASE_AUDIO_RENDERER_SINK_H_ |
6 #define MEDIA_BASE_AUDIO_RENDERER_SINK_H_ | 6 #define MEDIA_BASE_AUDIO_RENDERER_SINK_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "media/base/audio_bus.h" | 14 #include "media/base/audio_bus.h" |
15 #include "media/base/audio_parameters.h" | 15 #include "media/base/audio_parameters.h" |
16 #include "media/base/output_device_info.h" | 16 #include "media/base/output_device_info.h" |
17 #include "url/origin.h" | 17 #include "url/origin.h" |
18 | 18 |
19 namespace media { | 19 namespace media { |
20 | 20 |
| 21 struct AudioTimestamp; |
| 22 |
21 // AudioRendererSink is an interface representing the end-point for | 23 // AudioRendererSink is an interface representing the end-point for |
22 // rendered audio. An implementation is expected to | 24 // rendered audio. An implementation is expected to |
23 // periodically call Render() on a callback object. | 25 // periodically call Render() on a callback object. |
24 | 26 |
25 class AudioRendererSink | 27 class AudioRendererSink |
26 : public base::RefCountedThreadSafe<media::AudioRendererSink> { | 28 : public base::RefCountedThreadSafe<media::AudioRendererSink> { |
27 public: | 29 public: |
28 class RenderCallback { | 30 class MEDIA_EXPORT RenderCallback { |
29 public: | 31 public: |
30 // Attempts to completely fill all channels of |dest|, returns actual | 32 // Attempts to completely fill all channels of |dest|, returns actual |
31 // number of frames filled. |frames_skipped| contains the number of frames | 33 // number of frames filled. |frames_skipped| contains the number of frames |
32 // the consumer has skipped, if any. | 34 // the consumer has skipped, if any. |
33 virtual int Render(AudioBus* dest, | 35 virtual int Render(AudioBus* dest, |
34 uint32_t frames_delayed, | 36 uint32_t frames_delayed, |
35 uint32_t frames_skipped) = 0; | 37 uint32_t frames_skipped); |
| 38 // An alternate version which provides also device stream position, |
| 39 // if not overriden it just invokes the method above. |
| 40 virtual int Render(AudioBus* dest, |
| 41 uint32_t audio_delay_milliseconds, |
| 42 uint32_t frames_skipped, |
| 43 const AudioTimestamp& output_timestamp); |
36 | 44 |
37 // Signals an error has occurred. | 45 // Signals an error has occurred. |
38 virtual void OnRenderError() = 0; | 46 virtual void OnRenderError() = 0; |
39 | 47 |
40 protected: | 48 protected: |
41 virtual ~RenderCallback() {} | 49 virtual ~RenderCallback() {} |
42 }; | 50 }; |
43 | 51 |
44 // Sets important information about the audio stream format. | 52 // Sets important information about the audio stream format. |
45 // It must be called before any of the other methods. | 53 // It must be called before any of the other methods. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 const url::Origin& security_origin, | 109 const url::Origin& security_origin, |
102 const OutputDeviceStatusCB& callback) = 0; | 110 const OutputDeviceStatusCB& callback) = 0; |
103 | 111 |
104 protected: | 112 protected: |
105 ~SwitchableAudioRendererSink() override {} | 113 ~SwitchableAudioRendererSink() override {} |
106 }; | 114 }; |
107 | 115 |
108 } // namespace media | 116 } // namespace media |
109 | 117 |
110 #endif // MEDIA_BASE_AUDIO_RENDERER_SINK_H_ | 118 #endif // MEDIA_BASE_AUDIO_RENDERER_SINK_H_ |
OLD | NEW |