Standardize usage of virtual/override/final specifiers in crypto/.
[chromium-blink-merge.git] / remoting / host / audio_scheduler.h
blobd0224f3cc24af1d2632d6a5d2b9364645ae3c97a
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
3 // found in the LICENSE file.
5 #ifndef REMOTING_HOST_AUDIO_SCHEDULER_H_
6 #define REMOTING_HOST_AUDIO_SCHEDULER_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
11 namespace base {
12 class SingleThreadTaskRunner;
13 } // namespace base
15 namespace remoting {
17 namespace protocol {
18 class AudioStub;
19 } // namespace protocol
21 class AudioCapturer;
22 class AudioEncoder;
23 class AudioPacket;
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
27 // client. Audio is captured and encoded on the audio thread and then passed to
28 // AudioStub on the network thread.
29 class AudioScheduler : public base::RefCountedThreadSafe<AudioScheduler> {
30 public:
31 // Audio capture and encoding 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
34 // |audio_stub| exist until the scheduler is stopped using Stop() method.
35 AudioScheduler(
36 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner,
37 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
38 scoped_ptr<AudioCapturer> audio_capturer,
39 scoped_ptr<AudioEncoder> audio_encoder,
40 protocol::AudioStub* audio_stub);
42 // Starts the recording session.
43 void Start();
45 // Stops the recording session.
46 void Stop();
48 // Pauses or resumes audio on a running session. This leaves the audio
49 // capturer running, and only affects whether or not the captured audio is
50 // encoded and sent on the wire.
51 void Pause(bool pause);
53 private:
54 friend class base::RefCountedThreadSafe<AudioScheduler>;
55 virtual ~AudioScheduler();
57 // Called on the audio thread to start capturing.
58 void StartOnAudioThread();
60 // Called on the audio thread to stop capturing.
61 void StopOnAudioThread();
63 // Called on the audio thread when a new audio packet is available.
64 void EncodeAudioPacket(scoped_ptr<AudioPacket> packet);
66 // Called on the network thread to send a captured packet to the audio stub.
67 void SendAudioPacket(scoped_ptr<AudioPacket> packet);
69 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_;
70 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
72 scoped_ptr<AudioCapturer> audio_capturer_;
74 scoped_ptr<AudioEncoder> audio_encoder_;
76 protocol::AudioStub* audio_stub_;
78 bool network_stopped_;
80 bool enabled_;
82 DISALLOW_COPY_AND_ASSIGN(AudioScheduler);
85 } // namespace remoting
87 #endif // REMOTING_HOST_AUDIO_SCHEDULER_H_