Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: content/renderer/pepper/pepper_audio_output_host.h

Issue 2755613002: Support audio output device enumeration and selection in PPAPI (Closed)
Patch Set: Fix format, Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2017 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 CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_OUTPUT_HOST_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_OUTPUT_HOST_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include <memory>
12 #include <string>
13
14 #include "base/compiler_specific.h"
15 #include "base/macros.h"
16 #include "base/memory/shared_memory.h"
17 #include "base/sync_socket.h"
18 #include "content/public/renderer/plugin_instance_throttler.h"
19 #include "content/renderer/pepper/pepper_device_enumeration_host_helper.h"
20 #include "ipc/ipc_platform_file.h"
21 #include "ppapi/c/ppb_audio_config.h"
22 #include "ppapi/host/host_message_context.h"
23 #include "ppapi/host/resource_host.h"
24
25 namespace content {
26 class PepperPlatformAudioOutputDev;
27 class RendererPpapiHostImpl;
28
29 class PepperAudioOutputHost : public ppapi::host::ResourceHost,
30 public PluginInstanceThrottler::Observer {
31 public:
32 PepperAudioOutputHost(RendererPpapiHostImpl* host,
33 PP_Instance instance,
34 PP_Resource resource);
35 ~PepperAudioOutputHost() override;
36
37 int32_t OnResourceMessageReceived(
38 const IPC::Message& msg,
39 ppapi::host::HostMessageContext* context) override;
40
41 // Called when the stream is created.
42 void StreamCreated(base::SharedMemoryHandle shared_memory_handle,
43 size_t shared_memory_size,
44 base::SyncSocket::Handle socket);
45 void StreamCreationFailed();
46 void SetVolume(double volume);
47
48 private:
49 int32_t OnOpen(ppapi::host::HostMessageContext* context,
50 const std::string& device_id,
51 PP_AudioSampleRate sample_rate,
52 uint32_t sample_frame_count);
53 int32_t OnStartOrStop(ppapi::host::HostMessageContext* context,
54 bool playback);
55 int32_t OnClose(ppapi::host::HostMessageContext* context);
56
57 void OnOpenComplete(int32_t result,
58 base::SharedMemoryHandle shared_memory_handle,
59 size_t shared_memory_size,
60 base::SyncSocket::Handle socket_handle);
61
62 int32_t GetRemoteHandles(
63 const base::SyncSocket& socket,
64 const base::SharedMemory& shared_memory,
65 IPC::PlatformFileForTransit* remote_socket_handle,
66 base::SharedMemoryHandle* remote_shared_memory_handle);
67
68 void Close();
69
70 void SendOpenReply(int32_t result);
71
72 // PluginInstanceThrottler::Observer implementation.
73 void OnThrottleStateChange() override;
74
75 // Starts the deferred playback and unsubscribes from the throttler.
76 void StartDeferredPlayback();
77
78 // Non-owning pointer.
79 RendererPpapiHostImpl* renderer_ppapi_host_;
80
81 ppapi::host::ReplyMessageContext open_context_;
82
83 // Audio output object that we delegate audio IPC through.
84 // We don't own this pointer but are responsible for calling Shutdown on it.
85 PepperPlatformAudioOutputDev* audio_output_;
86
87 // Stream is playing, but throttled due to Plugin Power Saver.
88 bool playback_throttled_;
89
90 PepperDeviceEnumerationHostHelper enumeration_helper_;
91
92 DISALLOW_COPY_AND_ASSIGN(PepperAudioOutputHost);
93 };
94
95 } // namespace content
96
97 #endif // CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_OUTPUT_HOST_H_
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_audio_controller.cc ('k') | content/renderer/pepper/pepper_audio_output_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698