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

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: Should not include local change to ppapi/generators/idl_outfile.py Created 3 years, 9 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 PepperPlatformAudioOutput;
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 private:
48 int32_t OnOpen(ppapi::host::HostMessageContext* context,
49 const std::string& device_id,
50 PP_AudioSampleRate sample_rate,
51 uint32_t sample_frame_count);
52 int32_t OnStartOrStop(ppapi::host::HostMessageContext* context,
53 bool playback);
54 int32_t OnClose(ppapi::host::HostMessageContext* context);
55
56 void OnOpenComplete(int32_t result,
57 base::SharedMemoryHandle shared_memory_handle,
58 size_t shared_memory_size,
59 base::SyncSocket::Handle socket_handle);
60
61 int32_t GetRemoteHandles(
62 const base::SyncSocket& socket,
63 const base::SharedMemory& shared_memory,
64 IPC::PlatformFileForTransit* remote_socket_handle,
65 base::SharedMemoryHandle* remote_shared_memory_handle);
66
67 void Close();
68
69 void SendOpenReply(int32_t result);
70
71 // PluginInstanceThrottler::Observer implementation.
72 void OnThrottleStateChange() override;
73
74 // Starts the deferred playback and unsubscribes from the throttler.
75 void StartDeferredPlayback();
76
77 // Non-owning pointer.
78 RendererPpapiHostImpl* renderer_ppapi_host_;
79
80 ppapi::host::ReplyMessageContext open_context_;
81
82 // Audio output object that we delegate audio IPC through.
83 // We don't own this pointer but are responsible for calling Shutdown on it.
84 PepperPlatformAudioOutput* audio_output_;
85
86 // Stream is playing, but throttled due to Plugin Power Saver.
87 bool playback_throttled_;
88
89 PepperDeviceEnumerationHostHelper enumeration_helper_;
90
91 DISALLOW_COPY_AND_ASSIGN(PepperAudioOutputHost);
92 };
93
94 } // namespace content
95
96 #endif // CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_OUTPUT_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698