blob: cb6a813b0702443d34545ca9afa9935d0f3d4702 [file] [log] [blame]
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +01001// Copyright 2013 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.
4
5#include "content/renderer/media/webrtc_audio_capturer_sink_owner.h"
6
7namespace content {
8
9WebRtcAudioCapturerSinkOwner::WebRtcAudioCapturerSinkOwner(
10 WebRtcAudioCapturerSink* sink)
11 : delegate_(sink) {
12}
13
Ben Murdochbb1529c2013-08-08 10:24:53 +010014int WebRtcAudioCapturerSinkOwner::CaptureData(const std::vector<int>& channels,
15 const int16* audio_data,
16 int sample_rate,
17 int number_of_channels,
18 int number_of_frames,
19 int audio_delay_milliseconds,
20 int current_volume,
21 bool need_audio_processing) {
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010022 base::AutoLock lock(lock_);
23 if (delegate_) {
Ben Murdochbb1529c2013-08-08 10:24:53 +010024 return delegate_->CaptureData(channels, audio_data, sample_rate,
25 number_of_channels, number_of_frames,
26 audio_delay_milliseconds, current_volume,
27 need_audio_processing);
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010028 }
Ben Murdochbb1529c2013-08-08 10:24:53 +010029
30 return 0;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010031}
32
33void WebRtcAudioCapturerSinkOwner::SetCaptureFormat(
34 const media::AudioParameters& params) {
35 base::AutoLock lock(lock_);
36 if (delegate_)
37 delegate_->SetCaptureFormat(params);
38}
39
40bool WebRtcAudioCapturerSinkOwner::IsEqual(
41 const WebRtcAudioCapturerSink* other) const {
42 base::AutoLock lock(lock_);
43 return (other == delegate_);
44}
45
46void WebRtcAudioCapturerSinkOwner::Reset() {
47 base::AutoLock lock(lock_);
48 delegate_ = NULL;
49}
50
51} // namespace content