Index: content/renderer/pepper/pepper_audio_encoder_host.h |
diff --git a/content/renderer/pepper/pepper_audio_encoder_host.h b/content/renderer/pepper/pepper_audio_encoder_host.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..dd039d5c590e5622c81969abf2a7fcb3a673ba0a |
--- /dev/null |
+++ b/content/renderer/pepper/pepper_audio_encoder_host.h |
@@ -0,0 +1,111 @@ |
+// Copyright 2015 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 CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_ENCODER_HOST_H_ |
+#define CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_ENCODER_HOST_H_ |
+ |
+#include <deque> |
+ |
+#include "base/memory/ref_counted.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/memory/scoped_vector.h" |
+#include "content/common/content_export.h" |
+#include "content/renderer/pepper/audio_encoder_shim.h" |
+#include "ppapi/c/pp_codecs.h" |
+#include "ppapi/host/host_message_context.h" |
+#include "ppapi/host/resource_host.h" |
+#include "ppapi/proxy/resource_message_params.h" |
+#include "ppapi/proxy/serialized_structs.h" |
+#include "ppapi/shared_impl/media_stream_buffer_manager.h" |
+ |
+namespace content { |
+ |
+class RendererPpapiHost; |
+ |
+class CONTENT_EXPORT PepperAudioEncoderHost : public ppapi::host::ResourceHost { |
+ public: |
+ PepperAudioEncoderHost(RendererPpapiHost* host, |
+ PP_Instance instance, |
+ PP_Resource resource); |
+ ~PepperAudioEncoderHost() override; |
+ |
+ private: |
+ class AudioData; |
+ class BufferManager; |
+ class BitstreamBufferManager; |
+ class PcmBufferManager; |
+ |
+ // ResourceHost implementation. |
+ int32_t OnResourceMessageReceived( |
+ const IPC::Message& msg, |
+ ppapi::host::HostMessageContext* context) override; |
+ |
+ int32_t OnHostMsgGetSupportedProfiles( |
+ ppapi::host::HostMessageContext* context); |
+ int32_t OnHostMsgInitialize( |
+ ppapi::host::HostMessageContext* context, |
+ const ppapi::proxy::PPB_AudioEncodeParameters& parameters); |
+ int32_t OnHostMsgGetAudioFrames(ppapi::host::HostMessageContext* context); |
+ int32_t OnHostMsgEncode(ppapi::host::HostMessageContext* context, |
+ uint32_t buffer_id); |
+ int32_t OnHostMsgRecycleBitstreamBuffer( |
+ ppapi::host::HostMessageContext* context, |
+ uint32_t buffer_id); |
+ int32_t OnHostMsgRequestBitrateChange( |
+ ppapi::host::HostMessageContext* context, |
+ uint32_t bitrate); |
+ int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context); |
+ |
+ void GetSupportedProfiles(std::vector<PP_AudioProfileDescription>* profiles); |
+ bool IsInitializationValid( |
+ const ppapi::proxy::PPB_AudioEncodeParameters& parameters); |
+ bool AllocateAudioFrames(uint32_t number_of_samples); |
+ bool AllocateBitstreamBuffers(size_t buffer_size); |
+ scoped_refptr<AudioEncoderShim::AudioData> GetAudioData( |
+ const scoped_refptr<BufferManager>& buffer_manager); |
+ void DoEncode(); |
+ void BitstreamBufferReady( |
+ int32_t audio_buffer_id, |
+ const scoped_refptr<AudioEncoderShim::AudioData>& output, |
+ int32_t size); |
+ void NotifyPepperError(int32_t error); |
+ void Close(); |
+ |
+ // Non-owning pointer. |
+ RendererPpapiHost* renderer_ppapi_host_; |
+ |
+ scoped_ptr<AudioEncoderShim> encoder_; |
+ |
+ // Whether the encoder has been successfully initialized. |
+ bool initialized_; |
+ |
+ // Last error reported by the encoder. |
+ int32_t encoder_last_error_; |
+ |
+ // Encoder's parameters, only valid if |initialized_| is true. |
+ ppapi::proxy::PPB_AudioEncodeParameters encode_parameters_; |
+ |
+ // Queue of pending audio buffer ids to be encoded. |
+ std::deque<int32_t> pending_encode_buffers_; |
+ |
+ // Buffer manager for the audio buffers handed by the plugin. |
+ scoped_refptr<BufferManager> audio_buffer_manager_; |
+ |
+ // Buffer manager for bitstream buffers handed to the plugin. |
+ scoped_refptr<BufferManager> bitstream_buffer_manager_; |
+ |
+ // Saved context to answer an Initialize message from the plugin. |
+ ppapi::host::ReplyMessageContext initialize_reply_context_; |
+ |
+ // Saved context to answer a GetAudioFrames message from the plugin. |
+ ppapi::host::ReplyMessageContext get_audio_frames_reply_context_; |
+ |
+ base::WeakPtrFactory<PepperAudioEncoderHost> weak_ptr_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PepperAudioEncoderHost); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_ENCODER_HOST_H_ |