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_SCHEDULER_H_ | 5 #ifndef REMOTING_HOST_AUDIO_SCHEDULER_H_ |
6 #define REMOTING_HOST_AUDIO_SCHEDULER_H_ | 6 #define REMOTING_HOST_AUDIO_SCHEDULER_H_ |
7 | 7 |
8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/time.h" | 11 #include "base/time.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 class SingleThreadTaskRunner; | 14 class SingleThreadTaskRunner; |
15 } // namespace base | 15 } // namespace base |
16 | 16 |
17 namespace remoting { | 17 namespace remoting { |
18 | 18 |
19 namespace protocol { | 19 namespace protocol { |
20 class AudioStub; | 20 class AudioStub; |
21 } // namespace protocol | 21 } // namespace protocol |
22 | 22 |
23 class AudioCapturer; | 23 class AudioCapturer; |
| 24 class AudioEncoder; |
24 class AudioPacket; | 25 class AudioPacket; |
25 | 26 |
26 // A class for controlling AudioCapturer and forwarding audio packets to the | 27 // A class for controlling AudioCapturer and forwarding audio packets to the |
27 // client. | 28 // client. |
28 // | 29 // |
29 // THREADING | 30 // THREADING |
30 // | 31 // |
31 // This class works on two threads: the capture and network threads. | 32 // This class works on two threads: the capture and network threads. |
32 // Any encoding that is done on the audio samples will be done on the capture | 33 // Any encoding that is done on the audio samples will be done on the capture |
33 // thread. | 34 // thread. |
34 // | 35 // |
35 // AudioScheduler is responsible for: | 36 // AudioScheduler is responsible for: |
36 // 1. managing the AudioCapturer. | 37 // 1. managing the AudioCapturer. |
37 // 2. sending packets of audio samples over the network to the client. | 38 // 2. sending packets of audio samples over the network to the client. |
38 class AudioScheduler : public base::RefCountedThreadSafe<AudioScheduler> { | 39 class AudioScheduler : public base::RefCountedThreadSafe<AudioScheduler> { |
39 public: | 40 public: |
40 // Construct an AudioScheduler. TaskRunners are used for message passing | 41 // Construct an AudioScheduler. TaskRunners are used for message passing |
41 // among the capturer and network threads. The caller is responsible for | 42 // among the capturer and network threads. The caller is responsible for |
42 // ensuring that the |audio_capturer| and |audio_stub| outlive the | 43 // ensuring that the |audio_capturer| and |audio_stub| outlive the |
43 // AudioScheduler. | 44 // AudioScheduler. |
44 AudioScheduler( | 45 AudioScheduler( |
45 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, | 46 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, |
46 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 47 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
47 AudioCapturer* audio_capturer, | 48 AudioCapturer* audio_capturer, |
| 49 scoped_ptr<AudioEncoder> audio_encoder, |
48 protocol::AudioStub* audio_stub); | 50 protocol::AudioStub* audio_stub); |
49 | 51 |
50 // Stop the recording session. | 52 // Stop the recording session. |
51 void Stop(const base::Closure& done_task); | 53 void Stop(const base::Closure& done_task); |
52 | 54 |
53 // Called when a client disconnects. | 55 // Called when a client disconnects. |
54 void OnClientDisconnected(); | 56 void OnClientDisconnected(); |
55 | 57 |
56 private: | 58 private: |
57 friend class base::RefCountedThreadSafe<AudioScheduler>; | 59 friend class base::RefCountedThreadSafe<AudioScheduler>; |
(...skipping 10 matching lines...) Expand all Loading... |
68 void DoStopOnNetworkThread(const base::Closure& done_task); | 70 void DoStopOnNetworkThread(const base::Closure& done_task); |
69 | 71 |
70 // Called when an AudioPacket has been delivered to the client. | 72 // Called when an AudioPacket has been delivered to the client. |
71 void OnCaptureCallbackNotified(); | 73 void OnCaptureCallbackNotified(); |
72 | 74 |
73 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; | 75 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; |
74 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | 76 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
75 | 77 |
76 AudioCapturer* audio_capturer_; | 78 AudioCapturer* audio_capturer_; |
77 | 79 |
| 80 scoped_ptr<AudioEncoder> audio_encoder_; |
| 81 |
78 protocol::AudioStub* audio_stub_; | 82 protocol::AudioStub* audio_stub_; |
79 | 83 |
80 bool network_stopped_; | 84 bool network_stopped_; |
81 | 85 |
82 DISALLOW_COPY_AND_ASSIGN(AudioScheduler); | 86 DISALLOW_COPY_AND_ASSIGN(AudioScheduler); |
83 }; | 87 }; |
84 | 88 |
85 } // namespace remoting | 89 } // namespace remoting |
86 | 90 |
87 #endif // REMOTING_HOST_AUDIO_SCHEDULER_H_ | 91 #endif // REMOTING_HOST_AUDIO_SCHEDULER_H_ |
OLD | NEW |