Revert of Sandbox html_viewer on Linux. (patchset #6 id:100001 of https://codereview...
[chromium-blink-merge.git] / remoting / host / audio_pump.h
blobbd3cdb5d3214ecf6ec4b54aa8778f0605acf284a
1 // Copyright 2015 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_PUMP_H_
6 #define REMOTING_HOST_AUDIO_PUMP_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/threading/thread_checker.h"
13 namespace base {
14 class SingleThreadTaskRunner;
15 } // namespace base
17 namespace remoting {
19 namespace protocol {
20 class AudioStub;
21 } // namespace protocol
23 class AudioCapturer;
24 class AudioEncoder;
25 class AudioPacket;
27 // AudioPump is responsible for fetching audio data from the AudioCapturer
28 // and encoding it before passing it to the AudioStub for delivery to the
29 // client. Audio is captured and encoded on the audio thread and then passed to
30 // AudioStub on the network thread.
31 class AudioPump {
32 public:
33 // The caller must ensure that the |audio_stub| is not destroyed until the
34 // pump is destroyed.
35 AudioPump(scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner,
36 scoped_ptr<AudioCapturer> audio_capturer,
37 scoped_ptr<AudioEncoder> audio_encoder,
38 protocol::AudioStub* audio_stub);
39 virtual ~AudioPump();
41 // Pauses or resumes audio on a running session. This leaves the audio
42 // capturer running, and only affects whether or not the captured audio is
43 // encoded and sent on the wire.
44 void Pause(bool pause);
46 private:
47 class Core;
49 // Called on the network thread to send a captured packet to the audio stub.
50 void SendAudioPacket(scoped_ptr<AudioPacket> packet, int size);
52 // Callback for BufferedSocketWriter.
53 void OnPacketSent(int size);
55 base::ThreadChecker thread_checker_;
57 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_;
58 protocol::AudioStub* audio_stub_;
60 scoped_ptr<Core> core_;
62 base::WeakPtrFactory<AudioPump> weak_factory_;
64 DISALLOW_COPY_AND_ASSIGN(AudioPump);
67 } // namespace remoting
69 #endif // REMOTING_HOST_AUDIO_PUMP_H_