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)#ifndef CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_AUDIO_SINK_ADAPTER_H_ 6a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#define CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_AUDIO_SINK_ADAPTER_H_ 7a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 8a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "base/memory/scoped_ptr.h" 9a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/public/renderer/media_stream_audio_sink.h" 10a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 11a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace webrtc { 12a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class AudioTrackSinkInterface; 13a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} // namespace webrtc 14a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 15a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace content { 16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 17a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Adapter to the webrtc::AudioTrackSinkInterface of the audio track. 18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// This class is used in between the MediaStreamAudioSink and 19a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// webrtc::AudioTrackSinkInterface. It gets data callback via the 20a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// MediaStreamAudioSink::OnData() interface and pass the data to 21a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// webrtc::AudioTrackSinkInterface. 22a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class WebRtcAudioSinkAdapter : public MediaStreamAudioSink { 23a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) public: 24a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) explicit WebRtcAudioSinkAdapter( 25a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) webrtc::AudioTrackSinkInterface* sink); 26a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual ~WebRtcAudioSinkAdapter(); 27a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 28a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool IsEqual(const webrtc::AudioTrackSinkInterface* other) const; 29a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 30a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) private: 31a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // MediaStreamAudioSink implementation. 32a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual void OnData(const int16* audio_data, 33a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) int sample_rate, 34a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) int number_of_channels, 35a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) int number_of_frames) OVERRIDE; 36a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual void OnSetFormat(const media::AudioParameters& params) OVERRIDE; 37a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 38a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) webrtc::AudioTrackSinkInterface* const sink_; 39a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 40a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(WebRtcAudioSinkAdapter); 41a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}; 42a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 43a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} // namespace content 44a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 45a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#endif // CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_AUDIO_SINK_ADAPTER_H_ 46