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 CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ |
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // is "playing", Pause() won't be called when the state already is "paused" | 45 // is "playing", Pause() won't be called when the state already is "paused" |
46 // etc and similarly maintains the same state for Stop(). | 46 // etc and similarly maintains the same state for Stop(). |
47 // When Stop() is called or when the proxy goes out of scope, the proxy | 47 // When Stop() is called or when the proxy goes out of scope, the proxy |
48 // will ensure that Pause() is called followed by a call to Stop(), which | 48 // will ensure that Pause() is called followed by a call to Stop(), which |
49 // is the usage pattern that WebRtcAudioRenderer requires. | 49 // is the usage pattern that WebRtcAudioRenderer requires. |
50 scoped_refptr<MediaStreamAudioRenderer> CreateSharedAudioRendererProxy(); | 50 scoped_refptr<MediaStreamAudioRenderer> CreateSharedAudioRendererProxy(); |
51 | 51 |
52 // Used to DCHECK on the expected state. | 52 // Used to DCHECK on the expected state. |
53 bool IsStarted() const; | 53 bool IsStarted() const; |
54 | 54 |
| 55 // Accessors to the sink audio parameters. |
| 56 int channels() const { return number_of_channels_; } |
| 57 int sample_rate() const { return sample_rate_; } |
| 58 |
55 private: | 59 private: |
56 // MediaStreamAudioRenderer implementation. This is private since we want | 60 // MediaStreamAudioRenderer implementation. This is private since we want |
57 // callers to use proxy objects. | 61 // callers to use proxy objects. |
58 // TODO(tommi): Make the MediaStreamAudioRenderer implementation a pimpl? | 62 // TODO(tommi): Make the MediaStreamAudioRenderer implementation a pimpl? |
59 virtual void Start() OVERRIDE; | 63 virtual void Start() OVERRIDE; |
60 virtual void Play() OVERRIDE; | 64 virtual void Play() OVERRIDE; |
61 virtual void Pause() OVERRIDE; | 65 virtual void Pause() OVERRIDE; |
62 virtual void Stop() OVERRIDE; | 66 virtual void Stop() OVERRIDE; |
63 virtual void SetVolume(float volume) OVERRIDE; | 67 virtual void SetVolume(float volume) OVERRIDE; |
64 virtual base::TimeDelta GetCurrentRenderTime() const OVERRIDE; | 68 virtual base::TimeDelta GetCurrentRenderTime() const OVERRIDE; |
(...skipping 28 matching lines...) Expand all Loading... |
93 // The render view in which the audio is rendered into |sink_|. | 97 // The render view in which the audio is rendered into |sink_|. |
94 const int source_render_view_id_; | 98 const int source_render_view_id_; |
95 const int session_id_; | 99 const int session_id_; |
96 | 100 |
97 // The sink (destination) for rendered audio. | 101 // The sink (destination) for rendered audio. |
98 scoped_refptr<media::AudioOutputDevice> sink_; | 102 scoped_refptr<media::AudioOutputDevice> sink_; |
99 | 103 |
100 // Audio data source from the browser process. | 104 // Audio data source from the browser process. |
101 WebRtcAudioRendererSource* source_; | 105 WebRtcAudioRendererSource* source_; |
102 | 106 |
103 // Buffers used for temporary storage during render callbacks. | |
104 // Allocated during initialization. | |
105 scoped_ptr<int16[]> buffer_; | |
106 | |
107 // Protects access to |state_|, |source_| and |sink_|. | 107 // Protects access to |state_|, |source_| and |sink_|. |
108 base::Lock lock_; | 108 base::Lock lock_; |
109 | 109 |
110 // Ref count for the MediaPlayers which are playing audio. | 110 // Ref count for the MediaPlayers which are playing audio. |
111 int play_ref_count_; | 111 int play_ref_count_; |
112 | 112 |
113 // Ref count for the MediaPlayers which have called Start() but not Stop(). | 113 // Ref count for the MediaPlayers which have called Start() but not Stop(). |
114 int start_ref_count_; | 114 int start_ref_count_; |
115 | 115 |
116 // Used to buffer data between the client and the output device in cases where | 116 // Used to buffer data between the client and the output device in cases where |
117 // the client buffer size is not the same as the output device buffer size. | 117 // the client buffer size is not the same as the output device buffer size. |
118 scoped_ptr<media::AudioPullFifo> audio_fifo_; | 118 scoped_ptr<media::AudioPullFifo> audio_fifo_; |
119 | 119 |
120 // Contains the accumulated delay estimate which is provided to the WebRTC | 120 // Contains the accumulated delay estimate which is provided to the WebRTC |
121 // AEC. | 121 // AEC. |
122 int audio_delay_milliseconds_; | 122 int audio_delay_milliseconds_; |
123 | 123 |
124 // Delay due to the FIFO in milliseconds. | 124 // Delay due to the FIFO in milliseconds. |
125 int fifo_delay_milliseconds_; | 125 int fifo_delay_milliseconds_; |
126 | 126 |
127 // The preferred sample rate and buffer sizes provided via the ctor. | 127 // The sample rate, number of channels and buffer sizes used by the sink of |
128 const int sample_rate_; | 128 // the renderer. |
129 const int frames_per_buffer_; | 129 int sample_rate_; |
| 130 int number_of_channels_; |
| 131 int frames_per_buffer_; |
130 | 132 |
131 DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioRenderer); | 133 DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioRenderer); |
132 }; | 134 }; |
133 | 135 |
134 } // namespace content | 136 } // namespace content |
135 | 137 |
136 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ | 138 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ |
OLD | NEW |