Chromium Code Reviews| Index: content/renderer/media/media_stream_audio_sink_owner.cc |
| diff --git a/content/renderer/media/media_stream_audio_sink_owner.cc b/content/renderer/media/media_stream_audio_sink_owner.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b2c436b454125a32bc72797caa60cf92ff86b116 |
| --- /dev/null |
| +++ b/content/renderer/media/media_stream_audio_sink_owner.cc |
| @@ -0,0 +1,86 @@ |
| +// 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/media_stream_audio_sink_owner.h" |
| + |
| +namespace content { |
| + |
| +MediaStreamAudioSinkOwner::MediaStreamAudioSinkOwner( |
| + MediaStreamAudioSink* sink) |
| + : media_stream_delegate_(sink), |
| + peer_connection_delegate_(NULL) { |
| +} |
| + |
| +MediaStreamAudioSinkOwner::MediaStreamAudioSinkOwner( |
| + PeerConnectionAudioSink* sink) |
| + : media_stream_delegate_(NULL), |
| + peer_connection_delegate_(sink) { |
| +} |
| + |
| +int MediaStreamAudioSinkOwner::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 (media_stream_delegate_) { |
| + DCHECK(!peer_connection_delegate_); |
| + media_stream_delegate_->OnData(audio_data, |
| + sample_rate, |
| + number_of_channels, |
| + number_of_frames); |
| + return 0; |
| + } |
| + |
| + if (peer_connection_delegate_) { |
| + return peer_connection_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 MediaStreamAudioSinkOwner::OnSetFormat( |
| + const media::AudioParameters& params) { |
| + base::AutoLock lock(lock_); |
| + if (media_stream_delegate_) { |
| + DCHECK(!peer_connection_delegate_); |
| + media_stream_delegate_->OnSetFormat(params); |
| + return; |
| + } |
| + |
| + if (peer_connection_delegate_) |
| + peer_connection_delegate_->OnSetFormat(params); |
| +} |
| + |
| +bool MediaStreamAudioSinkOwner::IsEqual( |
|
Jói
2013/11/27 17:35:02
This will return true if |other| is NULL and media
no longer working on chromium
2013/11/28 17:27:18
Added a DCHECK(other);
no longer working on chromium
2013/11/28 19:22:22
I just realized that I forgot to commit the local
|
| + const MediaStreamAudioSink* other) const { |
| + base::AutoLock lock(lock_); |
| + return (other == media_stream_delegate_); |
| +} |
| + |
| +bool MediaStreamAudioSinkOwner::IsEqual( |
| + const PeerConnectionAudioSink* other) const { |
| + base::AutoLock lock(lock_); |
| + return (other == peer_connection_delegate_); |
| +} |
| + |
| +void MediaStreamAudioSinkOwner::Reset() { |
| + base::AutoLock lock(lock_); |
| + media_stream_delegate_ = NULL; |
| + peer_connection_delegate_ = NULL; |
| +} |
| + |
| +} // namespace content |