Chromium Code Reviews| 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..9099f2bb98cc27898a3dbffae553c171dc5620ae |
| --- /dev/null |
| +++ b/content/renderer/pepper/pepper_audio_encoder_host.h |
| @@ -0,0 +1,114 @@ |
| +// 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<AudioData> GetAudioData( |
| + const scoped_refptr<BufferManager>& buffer_manager); |
| + void DoEncode(); |
| + void BitstreamBufferReady( |
| + uint32_t audio_buffer_id, |
| + const scoped_refptr<AudioEncoderShim::AudioData>& output, |
| + size_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. |
| + // This represents the current error state of the encoder, i.e. PP_OK |
| + // normally, or a Pepper error code if the encoder is uninitialized, |
| + // has been notified of an encoder error, has encountered some |
| + // other unrecoverable error, or has been closed by the plugin. |
|
Tom Sepez
2015/10/05 16:54:16
nit: extra space between "by" and "the"
llandwerlin-old
2015/10/05 17:16:31
Done.
|
| + // This field is checked in most message handlers to decide whether |
| + // operations should proceed or fail. |
| + int32_t encoder_last_error_; |
| + |
| + // Encoder's parameters, only valid if |initialized_| is true. |
| + ppapi::proxy::PPB_AudioEncodeParameters encode_parameters_; |
| + |
| + // 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_ |