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/peer_connection_audio_sink_owner.h"
6
7#include "content/renderer/media/webrtc_audio_device_impl.h"
8
9namespace content {
10
11PeerConnectionAudioSinkOwner::PeerConnectionAudioSinkOwner(
12    PeerConnectionAudioSink* sink)
13    : delegate_(sink) {
14}
15
16int PeerConnectionAudioSinkOwner::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  if (delegate_) {
27    return delegate_->OnData(audio_data,
28                             sample_rate,
29                             number_of_channels,
30                             number_of_frames,
31                             channels,
32                             audio_delay_milliseconds,
33                             current_volume,
34                             need_audio_processing,
35                             key_pressed);
36  }
37
38  return 0;
39}
40
41void PeerConnectionAudioSinkOwner::OnSetFormat(
42    const media::AudioParameters& params) {
43  base::AutoLock lock(lock_);
44  if (delegate_)
45    delegate_->OnSetFormat(params);
46}
47
48void PeerConnectionAudioSinkOwner::OnReadyStateChanged(
49    blink::WebMediaStreamSource::ReadyState state) {
50  // Not forwarded at the moment.
51}
52
53void PeerConnectionAudioSinkOwner::Reset() {
54  base::AutoLock lock(lock_);
55  delegate_ = NULL;
56}
57
58bool PeerConnectionAudioSinkOwner::IsEqual(
59    const MediaStreamAudioSink* other) const {
60  DCHECK(other);
61  return false;
62}
63
64bool PeerConnectionAudioSinkOwner::IsEqual(
65    const PeerConnectionAudioSink* other) const {
66  DCHECK(other);
67  base::AutoLock lock(lock_);
68  return (other == delegate_);
69}
70
71}  // namespace content
72