- add sources.
[platform/framework/web/crosswalk.git] / src / content / renderer / media / webrtc_audio_capturer_sink_owner.cc
1 // 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
7 namespace content {
8
9 WebRtcAudioCapturerSinkOwner::WebRtcAudioCapturerSinkOwner(
10     WebRtcAudioCapturerSink* sink)
11     : delegate_(sink) {
12 }
13
14 int 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,
22                                               bool key_pressed) {
23   base::AutoLock lock(lock_);
24   if (delegate_) {
25     return delegate_->CaptureData(channels,
26                                   audio_data,
27                                   sample_rate,
28                                   number_of_channels,
29                                   number_of_frames,
30                                   audio_delay_milliseconds,
31                                   current_volume,
32                                   need_audio_processing,
33                                   key_pressed);
34   }
35
36   return 0;
37 }
38
39 void WebRtcAudioCapturerSinkOwner::SetCaptureFormat(
40     const media::AudioParameters& params) {
41   base::AutoLock lock(lock_);
42   if (delegate_)
43     delegate_->SetCaptureFormat(params);
44 }
45
46 bool WebRtcAudioCapturerSinkOwner::IsEqual(
47     const WebRtcAudioCapturerSink* other) const {
48   base::AutoLock lock(lock_);
49   return (other == delegate_);
50 }
51
52 void WebRtcAudioCapturerSinkOwner::Reset() {
53   base::AutoLock lock(lock_);
54   delegate_ = NULL;
55 }
56
57 }  // namespace content