Roll src/third_party/WebKit f36d5e0:68b67cd (svn 193299:193303)
[chromium-blink-merge.git] / remoting / host / audio_capturer_linux.h
blobdf68022fdffaac1f7de5504473cc9b4060d0ee9d
1 // Copyright (c) 2012 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.
5 #ifndef REMOTING_HOST_AUDIO_CAPTURER_LINUX_H_
6 #define REMOTING_HOST_AUDIO_CAPTURER_LINUX_H_
8 #include "base/memory/ref_counted.h"
9 #include "remoting/host/audio_capturer.h"
10 #include "remoting/host/audio_silence_detector.h"
11 #include "remoting/host/linux/audio_pipe_reader.h"
13 namespace base {
14 class FilePath;
17 namespace remoting {
19 // Linux implementation of AudioCapturer interface which captures audio by
20 // reading samples from a Pulseaudio "pipe" sink.
21 class AudioCapturerLinux : public AudioCapturer,
22 public AudioPipeReader::StreamObserver {
23 public:
24 // Must be called to configure the capturer before the first capturer instance
25 // is created. |task_runner| is an IO thread that is passed to AudioPipeReader
26 // to read from the pipe.
27 static void InitializePipeReader(
28 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
29 const base::FilePath& pipe_name);
31 explicit AudioCapturerLinux(
32 scoped_refptr<AudioPipeReader> pipe_reader);
33 ~AudioCapturerLinux() override;
35 // AudioCapturer interface.
36 bool Start(const PacketCapturedCallback& callback) override;
38 // AudioPipeReader::StreamObserver interface.
39 void OnDataRead(scoped_refptr<base::RefCountedString> data) override;
41 private:
42 scoped_refptr<AudioPipeReader> pipe_reader_;
43 PacketCapturedCallback callback_;
45 AudioSilenceDetector silence_detector_;
47 DISALLOW_COPY_AND_ASSIGN(AudioCapturerLinux);
50 } // namespace remoting
52 #endif // REMOTING_HOST_AUDIO_CAPTURER_LINUX_H_