| 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" | |
| 9 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 11 | 10 |
| 12 namespace base { | 11 namespace base { |
| 13 class SingleThreadTaskRunner; | 12 class SingleThreadTaskRunner; |
| 14 } // namespace base | 13 } // namespace base |
| 15 | 14 |
| 16 namespace remoting { | 15 namespace remoting { |
| 17 | 16 |
| 18 namespace protocol { | 17 namespace protocol { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 29 // AudioStub on the network thread. | 28 // AudioStub on the network thread. |
| 30 class AudioScheduler : public base::RefCountedThreadSafe<AudioScheduler> { | 29 class AudioScheduler : public base::RefCountedThreadSafe<AudioScheduler> { |
| 31 public: | 30 public: |
| 32 // Audio capture and encoding tasks are dispatched via the | 31 // Audio capture and encoding tasks are dispatched via the |
| 33 // |audio_task_runner|. |audio_stub| tasks are dispatched via the | 32 // |audio_task_runner|. |audio_stub| tasks are dispatched via the |
| 34 // |network_task_runner|. The caller must ensure that the |audio_capturer| and | 33 // |network_task_runner|. The caller must ensure that the |audio_capturer| and |
| 35 // |audio_stub| exist until the scheduler is stopped using Stop() method. | 34 // |audio_stub| exist until the scheduler is stopped using Stop() method. |
| 36 static scoped_refptr<AudioScheduler> Create( | 35 static scoped_refptr<AudioScheduler> Create( |
| 37 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, | 36 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, |
| 38 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 37 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
| 39 AudioCapturer* audio_capturer, | 38 scoped_ptr<AudioCapturer> audio_capturer, |
| 40 scoped_ptr<AudioEncoder> audio_encoder, | 39 scoped_ptr<AudioEncoder> audio_encoder, |
| 41 protocol::AudioStub* audio_stub); | 40 protocol::AudioStub* audio_stub); |
| 42 | 41 |
| 43 // Stop the recording session. | 42 // Stops the recording session. |
| 44 void Stop(const base::Closure& done_task); | 43 void Stop(); |
| 45 | 44 |
| 46 // Enable or disable audio on a running session. | 45 // Pauses or resumes audio on a running session. This leaves the audio |
| 47 // This leaves the audio capturer running, and only affects whether or not the | 46 // capturer running, and only affects whether or not the captured audio is |
| 48 // captured audio is encoded and sent on the wire. | 47 // encoded and sent on the wire. |
| 49 void SetEnabled(bool enabled); | 48 void Pause(bool pause); |
| 50 | 49 |
| 51 private: | 50 private: |
| 52 friend class base::RefCountedThreadSafe<AudioScheduler>; | 51 friend class base::RefCountedThreadSafe<AudioScheduler>; |
| 53 | 52 |
| 54 AudioScheduler( | 53 AudioScheduler( |
| 55 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, | 54 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, |
| 56 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 55 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
| 57 AudioCapturer* audio_capturer, | 56 scoped_ptr<AudioCapturer> audio_capturer, |
| 58 scoped_ptr<AudioEncoder> audio_encoder, | 57 scoped_ptr<AudioEncoder> audio_encoder, |
| 59 protocol::AudioStub* audio_stub); | 58 protocol::AudioStub* audio_stub); |
| 60 virtual ~AudioScheduler(); | 59 virtual ~AudioScheduler(); |
| 61 | 60 |
| 62 // Called on the audio thread to start capturing. | 61 // Called on the audio thread to start capturing. |
| 63 void StartOnAudioThread(); | 62 void StartOnAudioThread(); |
| 64 | 63 |
| 65 // Called on the audio thread to stop capturing. | 64 // Called on the audio thread to stop capturing. |
| 66 void StopOnAudioThread(const base::Closure& done_task); | 65 void StopOnAudioThread(); |
| 67 | 66 |
| 68 // Called on the audio thread when a new audio packet is available. | 67 // Called on the audio thread when a new audio packet is available. |
| 69 void EncodeAudioPacket(scoped_ptr<AudioPacket> packet); | 68 void EncodeAudioPacket(scoped_ptr<AudioPacket> packet); |
| 70 | 69 |
| 71 // Called on the network thread to send a captured packet to the audio stub. | 70 // Called on the network thread to send a captured packet to the audio stub. |
| 72 void SendAudioPacket(scoped_ptr<AudioPacket> packet); | 71 void SendAudioPacket(scoped_ptr<AudioPacket> packet); |
| 73 | 72 |
| 74 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_; | 73 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_; |
| 75 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | 74 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
| 76 | 75 |
| 77 AudioCapturer* audio_capturer_; | 76 scoped_ptr<AudioCapturer> audio_capturer_; |
| 78 | 77 |
| 79 scoped_ptr<AudioEncoder> audio_encoder_; | 78 scoped_ptr<AudioEncoder> audio_encoder_; |
| 80 | 79 |
| 81 protocol::AudioStub* audio_stub_; | 80 protocol::AudioStub* audio_stub_; |
| 82 | 81 |
| 83 bool network_stopped_; | 82 bool network_stopped_; |
| 84 | 83 |
| 85 bool enabled_; | 84 bool enabled_; |
| 86 | 85 |
| 87 DISALLOW_COPY_AND_ASSIGN(AudioScheduler); | 86 DISALLOW_COPY_AND_ASSIGN(AudioScheduler); |
| 88 }; | 87 }; |
| 89 | 88 |
| 90 } // namespace remoting | 89 } // namespace remoting |
| 91 | 90 |
| 92 #endif // REMOTING_HOST_AUDIO_SCHEDULER_H_ | 91 #endif // REMOTING_HOST_AUDIO_SCHEDULER_H_ |
| OLD | NEW |