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