summaryrefslogtreecommitdiffstats
path: root/content/renderer/media/peer_connection_audio_sink_owner.cc
blob: 4073ac614258baf3afb0b509b7ddd4e1855b6a37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/renderer/media/peer_connection_audio_sink_owner.h"

#include "content/renderer/media/webrtc_audio_device_impl.h"

namespace content {

PeerConnectionAudioSinkOwner::PeerConnectionAudioSinkOwner(
    PeerConnectionAudioSink* sink)
    : delegate_(sink) {
}

int PeerConnectionAudioSinkOwner::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) {
  base::AutoLock lock(lock_);
  if (delegate_) {
    return delegate_->OnData(audio_data,
                             sample_rate,
                             number_of_channels,
                             number_of_frames,
                             channels,
                             audio_delay_milliseconds,
                             current_volume,
                             need_audio_processing,
                             key_pressed);
  }

  return 0;
}

void PeerConnectionAudioSinkOwner::OnSetFormat(
    const media::AudioParameters& params) {
  base::AutoLock lock(lock_);
  if (delegate_)
    delegate_->OnSetFormat(params);
}

void PeerConnectionAudioSinkOwner::OnReadyStateChanged(
    blink::WebMediaStreamSource::ReadyState state) {
  // Not forwarded at the moment.
}

void PeerConnectionAudioSinkOwner::Reset() {
  base::AutoLock lock(lock_);
  delegate_ = NULL;
}

bool PeerConnectionAudioSinkOwner::IsEqual(
    const MediaStreamAudioSink* other) const {
  DCHECK(other);
  return false;
}

bool PeerConnectionAudioSinkOwner::IsEqual(
    const PeerConnectionAudioSink* other) const {
  DCHECK(other);
  base::AutoLock lock(lock_);
  return (other == delegate_);
}

}  // namespace content