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

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

Issue 1151973003: ppapi: implement PPB_AudioEncoder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More Windows fixes in proxy code Created 5 years, 6 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 2015 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_ENCODER_HOST_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_ENCODER_HOST_H_
7
8 #include <deque>
9
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h"
13 #include "content/common/content_export.h"
14 #include "content/renderer/pepper/audio_encoder_shim.h"
15 #include "ppapi/c/pp_codecs.h"
16 #include "ppapi/host/host_message_context.h"
17 #include "ppapi/host/resource_host.h"
18 #include "ppapi/proxy/resource_message_params.h"
19 #include "ppapi/proxy/serialized_structs.h"
20 #include "ppapi/shared_impl/media_stream_buffer_manager.h"
21
22 namespace content {
23
24 class RendererPpapiHost;
25
26 class CONTENT_EXPORT PepperAudioEncoderHost : public ppapi::host::ResourceHost {
27 public:
28 PepperAudioEncoderHost(RendererPpapiHost* host,
29 PP_Instance instance,
30 PP_Resource resource);
31 ~PepperAudioEncoderHost() override;
32
33 private:
34 class AudioData;
35 class BufferManager;
36 class BitstreamBufferManager;
37 class PcmBufferManager;
38
39 // ResourceHost implementation.
40 int32_t OnResourceMessageReceived(
41 const IPC::Message& msg,
42 ppapi::host::HostMessageContext* context) override;
43
44 int32_t OnHostMsgGetSupportedProfiles(
45 ppapi::host::HostMessageContext* context);
46 int32_t OnHostMsgInitialize(
47 ppapi::host::HostMessageContext* context,
48 const ppapi::proxy::PPB_AudioEncodeParameters& parameters);
49 int32_t OnHostMsgGetAudioFrames(ppapi::host::HostMessageContext* context);
50 int32_t OnHostMsgEncode(ppapi::host::HostMessageContext* context,
51 uint32_t buffer_id);
52 int32_t OnHostMsgRecycleBitstreamBuffer(
53 ppapi::host::HostMessageContext* context,
54 uint32_t buffer_id);
55 int32_t OnHostMsgRequestBitrateChange(
56 ppapi::host::HostMessageContext* context,
57 uint32_t bitrate);
58 int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context);
59
60 void GetSupportedProfiles(std::vector<PP_AudioProfileDescription>* profiles);
61 bool IsInitializationValid(
62 const ppapi::proxy::PPB_AudioEncodeParameters& parameters);
63 bool AllocateAudioFrames(uint32_t number_of_samples);
64 bool AllocateBitstreamBuffers(size_t buffer_size);
65 scoped_refptr<AudioEncoderShim::AudioData> GetAudioData(
66 const scoped_refptr<BufferManager>& buffer_manager);
67 void DoEncode();
68 void BitstreamBufferReady(
69 int32_t audio_buffer_id,
70 const scoped_refptr<AudioEncoderShim::AudioData>& output,
71 int32_t size);
72 void NotifyPepperError(int32_t error);
73 void Close();
74
75 // Non-owning pointer.
76 RendererPpapiHost* renderer_ppapi_host_;
77
78 scoped_ptr<AudioEncoderShim> encoder_;
79
80 // Whether the encoder has been successfully initialized.
81 bool initialized_;
82
83 // Last error reported by the encoder.
84 int32_t encoder_last_error_;
85
86 // Encoder's parameters, only valid if |initialized_| is true.
87 ppapi::proxy::PPB_AudioEncodeParameters encode_parameters_;
88
89 // Queue of pending audio buffer ids to be encoded.
90 std::deque<int32_t> pending_encode_buffers_;
91
92 // Buffer manager for the audio buffers handed by the plugin.
93 scoped_refptr<BufferManager> audio_buffer_manager_;
94
95 // Buffer manager for bitstream buffers handed to the plugin.
96 scoped_refptr<BufferManager> bitstream_buffer_manager_;
97
98 // Saved context to answer an Initialize message from the plugin.
99 ppapi::host::ReplyMessageContext initialize_reply_context_;
100
101 // Saved context to answer a GetAudioFrames message from the plugin.
102 ppapi::host::ReplyMessageContext get_audio_frames_reply_context_;
103
104 base::WeakPtrFactory<PepperAudioEncoderHost> weak_ptr_factory_;
105
106 DISALLOW_COPY_AND_ASSIGN(PepperAudioEncoderHost);
107 };
108
109 } // namespace content
110
111 #endif // CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_ENCODER_HOST_H_
OLDNEW
« no previous file with comments | « content/renderer/pepper/content_renderer_pepper_host_factory.cc ('k') | content/renderer/pepper/pepper_audio_encoder_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698