forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
audio_stream_consumer_proxy.h
57 lines (42 loc) · 1.7 KB
/
audio_stream_consumer_proxy.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef REMOTING_IOS_AUDIO_AUDIO_STREAM_CONSUMER_PROXY_H_
#define REMOTING_IOS_AUDIO_AUDIO_STREAM_CONSUMER_PROXY_H_
#include <cstdint>
#include <list>
#include <memory>
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.h"
#include "remoting/client/audio/audio_stream_consumer.h"
#include "remoting/proto/audio.pb.h"
namespace base {
class SingleThreadTaskRunner;
}
namespace remoting {
class AudioStreamConsumer;
// Takes an instance of |AudioConsumer| and runs it on the |audio_task_runner|
// thread.
class AudioStreamConsumerProxy : public AudioStreamConsumer {
public:
static std::unique_ptr<AudioStreamConsumerProxy> Create(
scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner,
base::WeakPtr<AudioStreamConsumer> audio_stream_consumer);
~AudioStreamConsumerProxy() override;
// AudioStreamConsumer overrides.
void AddAudioPacket(std::unique_ptr<AudioPacket> packet) override;
base::WeakPtr<AudioStreamConsumer> AudioStreamConsumerAsWeakPtr() override;
private:
class Core;
AudioStreamConsumerProxy(
scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner,
std::unique_ptr<Core> core);
// Task runner on which |core_| is called.
scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_;
// All thread switching logic is implemented in the |Core| class.
std::unique_ptr<Core> core_;
base::WeakPtrFactory<AudioStreamConsumerProxy> weak_factory_;
};
} // namespace remoting
#endif // REMOTING_IOS_AUDIO_AUDIO_STREAM_CONSUMER_PROXY_H_