Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / renderer / media / webrtc / webrtc_audio_sink_adapter.h
blob3b837a31735824a384d9891ab2d90d6d7436c365
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_AUDIO_SINK_ADAPTER_H_
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_AUDIO_SINK_ADAPTER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "content/public/renderer/media_stream_audio_sink.h"
10 #include "media/audio/audio_parameters.h"
12 namespace webrtc {
13 class AudioTrackSinkInterface;
14 } // namespace webrtc
16 namespace content {
18 // Adapter to the webrtc::AudioTrackSinkInterface of the audio track.
19 // This class is used in between the MediaStreamAudioSink and
20 // webrtc::AudioTrackSinkInterface. It gets data callback via the
21 // MediaStreamAudioSink::OnData() interface and pass the data to
22 // webrtc::AudioTrackSinkInterface.
23 class WebRtcAudioSinkAdapter : public MediaStreamAudioSink {
24 public:
25 explicit WebRtcAudioSinkAdapter(
26 webrtc::AudioTrackSinkInterface* sink);
27 ~WebRtcAudioSinkAdapter() override;
29 bool IsEqual(const webrtc::AudioTrackSinkInterface* other) const;
31 private:
32 // MediaStreamAudioSink implementation.
33 void OnData(const media::AudioBus& audio_bus,
34 base::TimeTicks estimated_capture_time) override;
35 void OnSetFormat(const media::AudioParameters& params) override;
37 webrtc::AudioTrackSinkInterface* const sink_;
39 media::AudioParameters params_;
40 scoped_ptr<int16[]> interleaved_data_;
42 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioSinkAdapter);
45 } // namespace content
47 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_AUDIO_SINK_ADAPTER_H_