blob: 520300672dc4b4966c48069b2570acbe73cc3af3 [file] [log] [blame]
sergeyu77b42df82016-10-04 02:08:381// Copyright 2016 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.
4
5#ifndef REMOTING_PROTOCOL_AUDIO_DECODE_SCHEDULER_H_
6#define REMOTING_PROTOCOL_AUDIO_DECODE_SCHEDULER_H_
7
8#include <memory>
9
10#include "base/macros.h"
11#include "base/memory/ref_counted.h"
12#include "base/memory/weak_ptr.h"
13#include "base/threading/thread_checker.h"
14#include "remoting/protocol/audio_stub.h"
15
16namespace base {
17class SingleThreadTaskRunner;
18} // namespace base
19
20namespace remoting {
21
22class AudioDecoder;
23class AudioPacket;
24
25namespace protocol {
26
27class SessionConfig;
28class AudioStub;
29
30class AudioDecodeScheduler : public AudioStub {
31 public:
32 AudioDecodeScheduler(
33 scoped_refptr<base::SingleThreadTaskRunner> audio_decode_task_runner,
34 base::WeakPtr<AudioStub> audio_consumer);
35 ~AudioDecodeScheduler() override;
36
37 // Initializes decoder with the information from the protocol config.
38 void Initialize(const protocol::SessionConfig& config);
39
40 // AudioStub implementation.
41 void ProcessAudioPacket(std::unique_ptr<AudioPacket> packet,
42 const base::Closure& done) override;
43
44 private:
45 void ProcessDecodedPacket(const base::Closure& done,
46 std::unique_ptr<AudioPacket> packet);
47
48 scoped_refptr<base::SingleThreadTaskRunner> audio_decode_task_runner_;
49 base::WeakPtr<AudioStub> audio_consumer_;
50
51 // Decoder used on the audio thread.
52 std::unique_ptr<AudioDecoder> decoder_;
53
54 base::ThreadChecker thread_checker_;
55
56 base::WeakPtrFactory<AudioDecodeScheduler> weak_factory_;
57
58 DISALLOW_COPY_AND_ASSIGN(AudioDecodeScheduler);
59};
60
61} // namespace protocol
62} // namespace remoting
63
64#endif // REMOTING_PROTOCOL_AUDIO_DECODE_SCHEDULER_H_