1 // Copyright 2016 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 #ifndef REMOTING_PROTOCOL_WEBRTC_AUDIO_SINK_ADAPTER_H_ 6 #define REMOTING_PROTOCOL_WEBRTC_AUDIO_SINK_ADAPTER_H_ 7 8 #include "base/memory/ref_counted.h" 9 #include "base/memory/weak_ptr.h" 10 #include "base/threading/thread_task_runner_handle.h" 11 #include "third_party/webrtc/api/media_stream_interface.h" 12 13 namespace base { 14 class SingleThreadTaskRunner; 15 } // namespace base 16 17 namespace remoting { 18 namespace protocol { 19 20 class AudioStub; 21 22 class WebrtcAudioSinkAdapter : public webrtc::AudioTrackSinkInterface { 23 public: 24 WebrtcAudioSinkAdapter(scoped_refptr<webrtc::MediaStreamInterface> stream, 25 base::WeakPtr<AudioStub> audio_stub); 26 ~WebrtcAudioSinkAdapter() override; 27 28 void OnData(const void* audio_data, 29 int bits_per_sample, 30 int sample_rate, 31 size_t number_of_channels, 32 size_t number_of_frames) override; 33 34 private: 35 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 36 base::WeakPtr<AudioStub> audio_stub_; 37 scoped_refptr<webrtc::MediaStreamInterface> media_stream_; 38 scoped_refptr<webrtc::AudioTrackInterface> audio_track_; 39 }; 40 41 } // namespace protocol 42 } // namespace remoting 43 44 #endif // REMOTING_PROTOCOL_WEBRTC_AUDIO_SINK_ADAPTER_H_ 45