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