1a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
2a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// found in the LICENSE file.
4a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
5a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "base/logging.h"
6a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/renderer/media/webrtc/webrtc_audio_sink_adapter.h"
7a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h"
8a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
9a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace content {
10a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
11a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)WebRtcAudioSinkAdapter::WebRtcAudioSinkAdapter(
12a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    webrtc::AudioTrackSinkInterface* sink)
13a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    : sink_(sink) {
14a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  DCHECK(sink);
15a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
17a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)WebRtcAudioSinkAdapter::~WebRtcAudioSinkAdapter() {
18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
19a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
20a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)bool WebRtcAudioSinkAdapter::IsEqual(
21a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    const webrtc::AudioTrackSinkInterface* other) const {
22a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  return (other == sink_);
23a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
24a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
25a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void WebRtcAudioSinkAdapter::OnData(const int16* audio_data,
26a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                    int sample_rate,
27a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                    int number_of_channels,
28a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                    int number_of_frames) {
29a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  sink_->OnData(audio_data, 16, sample_rate, number_of_channels,
30a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                number_of_frames);
31a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
32a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
33a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void WebRtcAudioSinkAdapter::OnSetFormat(
34a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    const media::AudioParameters& params) {
35a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // No need to forward the OnSetFormat() callback to
36a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // webrtc::AudioTrackSinkInterface sink since the sink will handle the
37a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // format change in OnData().
38a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
39a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
40a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}  // namespace content
41