| 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/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // AudioScheduler is responsible for fetching audio data from the AudioCapturer | 25 // AudioScheduler is responsible for fetching audio data from the AudioCapturer |
| 26 // and encoding it before passing it to the AudioStub for delivery to the | 26 // and encoding it before passing it to the AudioStub for delivery to the |
| 27 // client. Audio is captured and encoded on the audio thread and then passed to | 27 // client. Audio is captured and encoded on the audio thread and then passed to |
| 28 // AudioStub on the network thread. | 28 // AudioStub on the network thread. |
| 29 class AudioScheduler : public base::RefCountedThreadSafe<AudioScheduler> { | 29 class AudioScheduler : public base::RefCountedThreadSafe<AudioScheduler> { |
| 30 public: | 30 public: |
| 31 // Audio capture and encoding tasks are dispatched via the | 31 // Audio capture and encoding tasks are dispatched via the |
| 32 // |audio_task_runner|. |audio_stub| tasks are dispatched via the | 32 // |audio_task_runner|. |audio_stub| tasks are dispatched via the |
| 33 // |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 |
| 34 // |audio_stub| exist until the scheduler is stopped using Stop() method. | 34 // |audio_stub| exist until the scheduler is stopped using Stop() method. |
| 35 static scoped_refptr<AudioScheduler> Create( | 35 AudioScheduler( |
| 36 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, | 36 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, |
| 37 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 37 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
| 38 scoped_ptr<AudioCapturer> audio_capturer, | 38 scoped_ptr<AudioCapturer> audio_capturer, |
| 39 scoped_ptr<AudioEncoder> audio_encoder, | 39 scoped_ptr<AudioEncoder> audio_encoder, |
| 40 protocol::AudioStub* audio_stub); | 40 protocol::AudioStub* audio_stub); |
| 41 | 41 |
| 42 // Starts the recording session. |
| 43 void Start(); |
| 44 |
| 42 // Stops the recording session. | 45 // Stops the recording session. |
| 43 void Stop(); | 46 void Stop(); |
| 44 | 47 |
| 45 // Pauses or resumes audio on a running session. This leaves the audio | 48 // Pauses or resumes audio on a running session. This leaves the audio |
| 46 // capturer running, and only affects whether or not the captured audio is | 49 // capturer running, and only affects whether or not the captured audio is |
| 47 // encoded and sent on the wire. | 50 // encoded and sent on the wire. |
| 48 void Pause(bool pause); | 51 void Pause(bool pause); |
| 49 | 52 |
| 50 private: | 53 private: |
| 51 friend class base::RefCountedThreadSafe<AudioScheduler>; | 54 friend class base::RefCountedThreadSafe<AudioScheduler>; |
| 52 | |
| 53 AudioScheduler( | |
| 54 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, | |
| 55 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | |
| 56 scoped_ptr<AudioCapturer> audio_capturer, | |
| 57 scoped_ptr<AudioEncoder> audio_encoder, | |
| 58 protocol::AudioStub* audio_stub); | |
| 59 virtual ~AudioScheduler(); | 55 virtual ~AudioScheduler(); |
| 60 | 56 |
| 61 // Called on the audio thread to start capturing. | 57 // Called on the audio thread to start capturing. |
| 62 void StartOnAudioThread(); | 58 void StartOnAudioThread(); |
| 63 | 59 |
| 64 // Called on the audio thread to stop capturing. | 60 // Called on the audio thread to stop capturing. |
| 65 void StopOnAudioThread(); | 61 void StopOnAudioThread(); |
| 66 | 62 |
| 67 // Called on the audio thread when a new audio packet is available. | 63 // Called on the audio thread when a new audio packet is available. |
| 68 void EncodeAudioPacket(scoped_ptr<AudioPacket> packet); | 64 void EncodeAudioPacket(scoped_ptr<AudioPacket> packet); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 82 bool network_stopped_; | 78 bool network_stopped_; |
| 83 | 79 |
| 84 bool enabled_; | 80 bool enabled_; |
| 85 | 81 |
| 86 DISALLOW_COPY_AND_ASSIGN(AudioScheduler); | 82 DISALLOW_COPY_AND_ASSIGN(AudioScheduler); |
| 87 }; | 83 }; |
| 88 | 84 |
| 89 } // namespace remoting | 85 } // namespace remoting |
| 90 | 86 |
| 91 #endif // REMOTING_HOST_AUDIO_SCHEDULER_H_ | 87 #endif // REMOTING_HOST_AUDIO_SCHEDULER_H_ |
| OLD | NEW |