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/media_stream_audio_sink_owner.h"
6
7 #include "content/public/renderer/media_stream_audio_sink.h"
8 #include "media/audio/audio_parameters.h"
9
10 namespace content {
11
MediaStreamAudioSinkOwner(MediaStreamAudioSink * sink)12 MediaStreamAudioSinkOwner::MediaStreamAudioSinkOwner(MediaStreamAudioSink* sink)
13 : delegate_(sink) {
14 }
15
OnData(const int16 * audio_data,int sample_rate,int number_of_channels,int number_of_frames,const std::vector<int> & channels,int audio_delay_milliseconds,int current_volume,bool need_audio_processing,bool key_pressed)16 int MediaStreamAudioSinkOwner::OnData(const int16* audio_data,
17 int sample_rate,
18 int number_of_channels,
19 int number_of_frames,
20 const std::vector<int>& channels,
21 int audio_delay_milliseconds,
22 int current_volume,
23 bool need_audio_processing,
24 bool key_pressed) {
25 base::AutoLock lock(lock_);
26 // TODO(xians): Investigate on the possibility of not calling out with the
27 // lock.
28 if (delegate_) {
29 delegate_->OnData(audio_data,
30 sample_rate,
31 number_of_channels,
32 number_of_frames);
33 }
34
35 return 0;
36 }
37
OnSetFormat(const media::AudioParameters & params)38 void MediaStreamAudioSinkOwner::OnSetFormat(
39 const media::AudioParameters& params) {
40 base::AutoLock lock(lock_);
41 if (delegate_)
42 delegate_->OnSetFormat(params);
43 }
44
OnReadyStateChanged(blink::WebMediaStreamSource::ReadyState state)45 void MediaStreamAudioSinkOwner::OnReadyStateChanged(
46 blink::WebMediaStreamSource::ReadyState state) {
47 base::AutoLock lock(lock_);
48 if (delegate_)
49 delegate_->OnReadyStateChanged(state);
50 }
51
Reset()52 void MediaStreamAudioSinkOwner::Reset() {
53 base::AutoLock lock(lock_);
54 delegate_ = NULL;
55 }
56
IsEqual(const MediaStreamAudioSink * other) const57 bool MediaStreamAudioSinkOwner::IsEqual(
58 const MediaStreamAudioSink* other) const {
59 DCHECK(other);
60 base::AutoLock lock(lock_);
61 return (other == delegate_);
62 }
63
IsEqual(const PeerConnectionAudioSink * other) const64 bool MediaStreamAudioSinkOwner::IsEqual(
65 const PeerConnectionAudioSink* other) const {
66 DCHECK(other);
67 return false;
68 }
69
70 } // namespace content
71