| Index: content/renderer/media/webrtc_audio_device_impl.h
|
| diff --git a/content/renderer/media/webrtc_audio_device_impl.h b/content/renderer/media/webrtc_audio_device_impl.h
|
| index 15790d269c993469cf50f025851514270b372608..85ee39729df897406cd55c3ba26f6f6d48bc4b06 100644
|
| --- a/content/renderer/media/webrtc_audio_device_impl.h
|
| +++ b/content/renderer/media/webrtc_audio_device_impl.h
|
| @@ -185,16 +185,11 @@ class WebRtcAudioRenderer;
|
| // libjingle can own references to the renderer and capturer.
|
| class WebRtcAudioRendererSource {
|
| public:
|
| - // Callback to get the rendered interleaved data.
|
| - // TODO(xians): Change uint8* to int16*.
|
| - virtual void RenderData(uint8* audio_data,
|
| - int number_of_channels,
|
| - int number_of_frames,
|
| + // Callback to get the rendered data.
|
| + virtual void RenderData(media::AudioBus* audio_bus,
|
| + int sample_rate,
|
| int audio_delay_milliseconds) = 0;
|
|
|
| - // Set the format for the capture audio parameters.
|
| - virtual void SetRenderFormat(const media::AudioParameters& params) = 0;
|
| -
|
| // Callback to notify the client that the renderer is going away.
|
| virtual void RemoveAudioRenderer(WebRtcAudioRenderer* renderer) = 0;
|
|
|
| @@ -235,13 +230,40 @@ class PeerConnectionAudioSink {
|
| virtual ~PeerConnectionAudioSink() {}
|
| };
|
|
|
| +// TODO(xians): Merge this interface with WebRtcAudioRendererSource.
|
| +// The reason why we could not do it today is that WebRtcAudioRendererSource
|
| +// gets the data by pulling, while the data is pushed into
|
| +// WebRtcPlayoutDataSource::Sink.
|
| +class WebRtcPlayoutDataSource {
|
| + public:
|
| + class Sink {
|
| + public:
|
| + // Callback to get the playout data.
|
| + virtual void OnPlayoutData(media::AudioBus* audio_bus,
|
| + int sample_rate,
|
| + int audio_delay_milliseconds) = 0;
|
| + protected:
|
| + virtual ~Sink() {}
|
| + };
|
| +
|
| + // Adds/Removes the sink of WebRtcAudioRendererSource to the ADM.
|
| + // These methods are used by the MediaStreamAudioProcesssor to get the
|
| + // rendered data for AEC.
|
| + virtual void AddPlayoutSink(Sink* sink) = 0;
|
| + virtual void RemovePlayoutSink(Sink* sink) = 0;
|
| +
|
| + protected:
|
| + virtual ~WebRtcPlayoutDataSource() {}
|
| +};
|
| +
|
| // Note that this class inherits from webrtc::AudioDeviceModule but due to
|
| // the high number of non-implemented methods, we move the cruft over to the
|
| // WebRtcAudioDeviceNotImpl.
|
| class CONTENT_EXPORT WebRtcAudioDeviceImpl
|
| : NON_EXPORTED_BASE(public PeerConnectionAudioSink),
|
| NON_EXPORTED_BASE(public WebRtcAudioDeviceNotImpl),
|
| - NON_EXPORTED_BASE(public WebRtcAudioRendererSource) {
|
| + NON_EXPORTED_BASE(public WebRtcAudioRendererSource),
|
| + NON_EXPORTED_BASE(public WebRtcPlayoutDataSource) {
|
| public:
|
| // The maximum volume value WebRtc uses.
|
| static const int kMaxVolumeLevel = 255;
|
| @@ -321,18 +343,11 @@ class CONTENT_EXPORT WebRtcAudioDeviceImpl
|
| const scoped_refptr<WebRtcAudioRenderer>& renderer() const {
|
| return renderer_;
|
| }
|
| - int output_buffer_size() const {
|
| - return output_audio_parameters_.frames_per_buffer();
|
| - }
|
| - int output_channels() const {
|
| - return output_audio_parameters_.channels();
|
| - }
|
| - int output_sample_rate() const {
|
| - return output_audio_parameters_.sample_rate();
|
| - }
|
|
|
| private:
|
| typedef std::list<scoped_refptr<WebRtcAudioCapturer> > CapturerList;
|
| + typedef std::list<WebRtcPlayoutDataSource::Sink*> PlayoutDataSinkList;
|
| + class RenderBuffer;
|
|
|
| // Make destructor private to ensure that we can only be deleted by Release().
|
| virtual ~WebRtcAudioDeviceImpl();
|
| @@ -356,15 +371,17 @@ class CONTENT_EXPORT WebRtcAudioDeviceImpl
|
| // WebRtcAudioRendererSource implementation.
|
|
|
| // Called on the AudioInputDevice worker thread.
|
| - virtual void RenderData(uint8* audio_data,
|
| - int number_of_channels,
|
| - int number_of_frames,
|
| + virtual void RenderData(media::AudioBus* audio_bus,
|
| + int sample_rate,
|
| int audio_delay_milliseconds) OVERRIDE;
|
|
|
| // Called on the main render thread.
|
| - virtual void SetRenderFormat(const media::AudioParameters& params) OVERRIDE;
|
| virtual void RemoveAudioRenderer(WebRtcAudioRenderer* renderer) OVERRIDE;
|
|
|
| + // WebRtcPlayoutDataSource implementation.
|
| + virtual void AddPlayoutSink(WebRtcPlayoutDataSource::Sink* sink) OVERRIDE;
|
| + virtual void RemovePlayoutSink(WebRtcPlayoutDataSource::Sink* sink) OVERRIDE;
|
| +
|
| // Used to DCHECK that we are called on the correct thread.
|
| base::ThreadChecker thread_checker_;
|
|
|
| @@ -377,14 +394,16 @@ class CONTENT_EXPORT WebRtcAudioDeviceImpl
|
| // Provides access to the audio renderer in the browser process.
|
| scoped_refptr<WebRtcAudioRenderer> renderer_;
|
|
|
| + // A list of raw pointer of WebRtcPlayoutDataSource::Sink objects which want
|
| + // to get the playout data, the sink need to call RemovePlayoutSink()
|
| + // before it goes away.
|
| + PlayoutDataSinkList playout_sinks_;
|
| +
|
| // Weak reference to the audio callback.
|
| // The webrtc client defines |audio_transport_callback_| by calling
|
| // RegisterAudioCallback().
|
| webrtc::AudioTransport* audio_transport_callback_;
|
|
|
| - // Cached values of used output audio parameters. Platform dependent.
|
| - media::AudioParameters output_audio_parameters_;
|
| -
|
| // Cached value of the current audio delay on the input/capture side.
|
| int input_delay_ms_;
|
|
|
| @@ -411,6 +430,10 @@ class CONTENT_EXPORT WebRtcAudioDeviceImpl
|
| // Range is [0, 255].
|
| uint32_t microphone_volume_;
|
|
|
| + // Buffer used for temporary storage during render callback.
|
| + // It is only accessed by the audio render thread.
|
| + std::vector<int16> render_buffer_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(WebRtcAudioDeviceImpl);
|
| };
|
|
|
|
|