-
Notifications
You must be signed in to change notification settings - Fork 0
/
audio_renderer_host.h
94 lines (76 loc) · 3.07 KB
/
audio_renderer_host.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
//
#ifndef CHROMIUM_MEDIA_LIB_AUDIO_RENDERER_HOST_H_
#define CHROMIUM_MEDIA_LIB_AUDIO_RENDERER_HOST_H_
#include "media/base/media_export.h"
#include <map>
#include <memory>
#include <string>
#include <vector>
#include "base/callback.h"
#include "base/memory/shared_memory_handle.h"
#include "base/sync_socket.h"
#include "media/audio/audio_output_delegate.h"
#include "media/base/output_device_info.h"
#include "url/origin.h"
namespace media {
class AudioManager;
class AudioParameters;
class AudioSystem;
class MEDIA_EXPORT AudioRendererHost
: public AudioOutputDelegate::EventHandler {
public:
class AudioRendererHostClient {
public:
virtual void OnStreamCreated(
int stream_id,
base::SharedMemoryHandle handle,
base::SyncSocket::TransitDescriptor socket_descriptor,
uint32_t length) = 0;
virtual void OnStreamError(int stream_id) = 0;
};
void SetClient(AudioRendererHostClient* client);
AudioRendererHost(AudioManager* audio_manager,
AudioSystem* audio_system,
AudioRendererHostClient* client);
using AuthorizationCompletedCallback =
base::Callback<void(int stream_id,
OutputDeviceStatus status,
const AudioParameters& output_params,
const std::string& matched_device_id)>;
void RequestDeviceAuthorization(int stream_id,
int render_frame_id,
int session_id,
const std::string& device_id,
const url::Origin& security_origin,
AuthorizationCompletedCallback cb);
void CreateStream(int stream_id,
int render_frame_id,
const AudioParameters& params);
void PlayStream(int stream_id);
// AudioOutputDelegate::EventHandler implementation
void OnStreamCreated(
int stream_id,
const base::SharedMemory* shared_memory,
std::unique_ptr<base::CancelableSyncSocket> foreign_socket) override;
void OnStreamError(int stream_id) override;
~AudioRendererHost() override;
private:
void DeviceParametersReceived(int stream_id,
AuthorizationCompletedCallback cb,
const std::string& raw_device_id,
const AudioParameters& output_params) const;
using AudioOutputDelegateVector =
std::vector<std::unique_ptr<AudioOutputDelegate>>;
AudioOutputDelegateVector::iterator LookupIteratorById(int stream_id);
void OnCloseStream(int stream_id);
AudioOutputDelegate* LookupById(int stream_id);
AudioManager* const audio_manager_;
AudioSystem* const audio_system_;
std::map<int, std::pair<bool, std::string>> authorizations_;
AudioRendererHostClient* client_;
AudioOutputDelegateVector delegates_;
};
} // namespace media
#endif // CHROMIUM_MEDIA_LIB_AUDIO_RENDERER_HOST_H_