Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef REMOTING_HOST_AUDIO_CAPTURER_LINUX_H_ | 5 #ifndef REMOTING_HOST_AUDIO_CAPTURER_LINUX_H_ |
| 6 #define REMOTING_HOST_AUDIO_CAPTURER_LINUX_H_ | 6 #define REMOTING_HOST_AUDIO_CAPTURER_LINUX_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | |
| 8 #include "remoting/host/audio_capturer.h" | 9 #include "remoting/host/audio_capturer.h" |
| 9 | 10 #include "remoting/host/linux/pulseaudio_pipe_sink_reader.h" |
| 10 #include "base/message_loop.h" | |
| 11 #include "base/time.h" | |
| 12 #include "base/timer.h" | |
| 13 | 11 |
| 14 class FilePath; | 12 class FilePath; |
| 15 | 13 |
| 16 namespace remoting { | 14 namespace remoting { |
| 17 | 15 |
| 16 // Linux implementation of AudioCapturer interface. | |
|
Wez
2012/10/31 00:56:28
nit: Suggest elaborating a little e.g. adding "...
Sergey Ulanov
2012/10/31 18:41:24
Done.
| |
| 18 class AudioCapturerLinux : public AudioCapturer, | 17 class AudioCapturerLinux : public AudioCapturer, |
| 19 public MessageLoopForIO::Watcher { | 18 public PulseaudioPipeSinkReader::StreamObserver { |
| 20 public: | 19 public: |
| 21 // Must be called to configure the capturer before the first instance is | 20 // Must be called to configure the capturer before the first capturer instance |
| 22 // created. | 21 // is created. |task_runner| is an IO thread that is passed |
|
Wez
2012/10/31 00:56:28
nit: "... passed to PulseaudioPipeSinkReader ..."
Sergey Ulanov
2012/10/31 18:41:24
Done.
| |
| 23 static void SetPipeName(const FilePath& pipe_name); | 22 // PulseaudioPipeSinkReader to read from the pipe. |
| 23 static void InitializePipeReader( | |
| 24 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | |
| 25 const FilePath& pipe_name); | |
| 24 | 26 |
| 25 explicit AudioCapturerLinux(const FilePath& pipe_name); | 27 explicit AudioCapturerLinux( |
| 28 scoped_refptr<PulseaudioPipeSinkReader> reader); | |
| 26 virtual ~AudioCapturerLinux(); | 29 virtual ~AudioCapturerLinux(); |
| 27 | 30 |
| 28 // AudioCapturer interface. | 31 // AudioCapturer interface. |
| 29 virtual bool Start(const PacketCapturedCallback& callback) OVERRIDE; | 32 virtual bool Start(const PacketCapturedCallback& callback) OVERRIDE; |
| 30 virtual void Stop() OVERRIDE; | 33 virtual void Stop() OVERRIDE; |
| 31 virtual bool IsStarted() OVERRIDE; | 34 virtual bool IsStarted() OVERRIDE; |
| 32 | 35 |
| 33 // MessageLoopForIO::Watcher interface. | 36 // PulseaudioPipeSinkReader::StreamObserver interface. |
| 34 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; | 37 virtual void OnDataRead(scoped_refptr<base::RefCountedString> data) OVERRIDE; |
| 35 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; | |
| 36 | 38 |
| 37 private: | 39 private: |
| 38 void StartTimer(); | 40 scoped_refptr<PulseaudioPipeSinkReader> reader_; |
|
Wez
2012/10/31 00:56:28
nit: pipe_reader_
Sergey Ulanov
2012/10/31 18:41:24
Done.
| |
| 39 void DoCapture(); | |
| 40 void WaitForPipeReadable(); | |
| 41 | |
| 42 int pipe_fd_; | |
| 43 base::RepeatingTimer<AudioCapturerLinux> timer_; | |
| 44 PacketCapturedCallback callback_; | 41 PacketCapturedCallback callback_; |
| 45 | 42 |
| 46 // Time when capturing was started. | |
| 47 base::TimeTicks started_time_; | |
| 48 | |
| 49 // Stream position of the last capture. | |
| 50 int64 last_capture_samples_; | |
| 51 | |
| 52 // Bytes left from the previous read. | |
| 53 std::string left_over_bytes_; | |
| 54 | |
| 55 MessageLoopForIO::FileDescriptorWatcher file_descriptor_watcher_; | |
| 56 | |
| 57 DISALLOW_COPY_AND_ASSIGN(AudioCapturerLinux); | 43 DISALLOW_COPY_AND_ASSIGN(AudioCapturerLinux); |
| 58 }; | 44 }; |
| 59 | 45 |
| 60 } // namespace remoting | 46 } // namespace remoting |
| 61 | 47 |
| 62 #endif // REMOTING_HOST_AUDIO_CAPTURER_LINUX_H_ | 48 #endif // REMOTING_HOST_AUDIO_CAPTURER_LINUX_H_ |
| OLD | NEW |