| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 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_PUMP_H_ | |
| 6 #define REMOTING_HOST_AUDIO_PUMP_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "base/threading/thread_checker.h" | |
| 14 | |
| 15 namespace base { | |
| 16 class SingleThreadTaskRunner; | |
| 17 } // namespace base | |
| 18 | |
| 19 namespace remoting { | |
| 20 | |
| 21 namespace protocol { | |
| 22 class AudioStub; | |
| 23 } // namespace protocol | |
| 24 | |
| 25 class AudioCapturer; | |
| 26 class AudioEncoder; | |
| 27 class AudioPacket; | |
| 28 | |
| 29 // AudioPump is responsible for fetching audio data from the AudioCapturer | |
| 30 // and encoding it before passing it to the AudioStub for delivery to the | |
| 31 // client. Audio is captured and encoded on the audio thread and then passed to | |
| 32 // AudioStub on the network thread. | |
| 33 class AudioPump { | |
| 34 public: | |
| 35 // The caller must ensure that the |audio_stub| is not destroyed until the | |
| 36 // pump is destroyed. | |
| 37 AudioPump(scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, | |
| 38 std::unique_ptr<AudioCapturer> audio_capturer, | |
| 39 std::unique_ptr<AudioEncoder> audio_encoder, | |
| 40 protocol::AudioStub* audio_stub); | |
| 41 virtual ~AudioPump(); | |
| 42 | |
| 43 // Pauses or resumes audio on a running session. This leaves the audio | |
| 44 // capturer running, and only affects whether or not the captured audio is | |
| 45 // encoded and sent on the wire. | |
| 46 void Pause(bool pause); | |
| 47 | |
| 48 private: | |
| 49 class Core; | |
| 50 | |
| 51 // Called on the network thread to send a captured packet to the audio stub. | |
| 52 void SendAudioPacket(std::unique_ptr<AudioPacket> packet, int size); | |
| 53 | |
| 54 // Callback for BufferedSocketWriter. | |
| 55 void OnPacketSent(int size); | |
| 56 | |
| 57 base::ThreadChecker thread_checker_; | |
| 58 | |
| 59 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_; | |
| 60 protocol::AudioStub* audio_stub_; | |
| 61 | |
| 62 std::unique_ptr<Core> core_; | |
| 63 | |
| 64 base::WeakPtrFactory<AudioPump> weak_factory_; | |
| 65 | |
| 66 DISALLOW_COPY_AND_ASSIGN(AudioPump); | |
| 67 }; | |
| 68 | |
| 69 } // namespace remoting | |
| 70 | |
| 71 #endif // REMOTING_HOST_AUDIO_PUMP_H_ | |
| OLD | NEW |