OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef REMOTING_HOST_AUDIO_CAPTURER_LINUX_H_ |
| 6 #define REMOTING_HOST_AUDIO_CAPTURER_LINUX_H_ |
| 7 |
| 8 #include "remoting/host/audio_capturer.h" |
| 9 |
| 10 #include "base/message_loop.h" |
| 11 #include "base/time.h" |
| 12 #include "base/timer.h" |
| 13 |
| 14 class FilePath; |
| 15 |
| 16 namespace remoting { |
| 17 |
| 18 class AudioCapturerLinux : public AudioCapturer, |
| 19 public MessageLoopForIO::Watcher { |
| 20 public: |
| 21 explicit AudioCapturerLinux(const FilePath& pipe_name); |
| 22 virtual ~AudioCapturerLinux(); |
| 23 |
| 24 // AudioCapturer interface. |
| 25 virtual bool Start(const PacketCapturedCallback& callback) OVERRIDE; |
| 26 virtual void Stop() OVERRIDE; |
| 27 virtual bool IsStarted() OVERRIDE; |
| 28 |
| 29 // MessageLoopForIO::Watcher interface. |
| 30 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; |
| 31 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; |
| 32 |
| 33 private: |
| 34 void StartTimer(); |
| 35 void DoCapture(); |
| 36 void WaitForPipeReadable(); |
| 37 |
| 38 int pipe_fd_; |
| 39 base::RepeatingTimer<AudioCapturerLinux> timer_; |
| 40 PacketCapturedCallback callback_; |
| 41 |
| 42 // Time when capturing was started. |
| 43 base::TimeTicks started_time_; |
| 44 |
| 45 // Stream position of the last capture. |
| 46 int64 last_capture_samples_; |
| 47 |
| 48 // Bytes left from the previous read. |
| 49 std::string left_over_bytes_; |
| 50 |
| 51 MessageLoopForIO::FileDescriptorWatcher file_descriptor_watcher_; |
| 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(AudioCapturerLinux); |
| 54 }; |
| 55 |
| 56 } // namespace remoting |
| 57 |
| 58 #endif // REMOTING_HOST_AUDIO_CAPTURER_LINUX_H_ |
OLD | NEW |