Chromium Code Reviews| Index: ppapi/proxy/audio_encoder_resource.h |
| diff --git a/ppapi/proxy/audio_encoder_resource.h b/ppapi/proxy/audio_encoder_resource.h |
| index 23fcee2cdc297351024b86ce47717252fed3c14f..2ff917ee173c47d31e7ba1c37cf7b2ae18a2fc58 100644 |
| --- a/ppapi/proxy/audio_encoder_resource.h |
| +++ b/ppapi/proxy/audio_encoder_resource.h |
| @@ -11,6 +11,7 @@ |
| #include "base/memory/scoped_vector.h" |
| #include "ppapi/proxy/connection.h" |
| #include "ppapi/proxy/plugin_resource.h" |
| +#include "ppapi/shared_impl/media_stream_buffer_manager.h" |
| #include "ppapi/shared_impl/resource.h" |
| #include "ppapi/thunk/ppb_audio_encoder_api.h" |
| @@ -20,12 +21,12 @@ class TrackedCallback; |
| namespace proxy { |
| -class SerializedHandle; |
| -class VideoFrameResource; |
| +class AudioBufferResource; |
| class PPAPI_PROXY_EXPORT AudioEncoderResource |
| : public PluginResource, |
| - public thunk::PPB_AudioEncoder_API { |
| + public thunk::PPB_AudioEncoder_API, |
| + public ppapi::MediaStreamBufferManager::Delegate { |
| public: |
| AudioEncoderResource(Connection connection, PP_Instance instance); |
| ~AudioEncoderResource() override; |
| @@ -33,7 +34,12 @@ class PPAPI_PROXY_EXPORT AudioEncoderResource |
| thunk::PPB_AudioEncoder_API* AsPPB_AudioEncoder_API() override; |
| private: |
| - // PPB_AduioEncoder_API implementation. |
| + class BitstreamBufferManager; |
| + |
| + // MediaStreamBufferManager::Delegate implementation. |
| + void OnNewBufferEnqueued() override {} |
| + |
| + // PPB_AudioEncoder_API implementation. |
| int32_t GetSupportedProfiles( |
| const PP_ArrayOutput& output, |
| const scoped_refptr<TrackedCallback>& callback) override; |
| @@ -57,6 +63,63 @@ class PPAPI_PROXY_EXPORT AudioEncoderResource |
| void RequestBitrateChange(uint32_t bitrate) override; |
| void Close() override; |
| + // PluginResource implementation. |
| + void OnReplyReceived(const ResourceMessageReplyParams& params, |
| + const IPC::Message& msg) override; |
| + |
| + // Message handlers for the host's messages. |
| + void OnPluginMsgGetSupportedProfilesReply( |
| + const PP_ArrayOutput& output, |
| + const ResourceMessageReplyParams& params, |
| + const std::vector<PP_AudioProfileDescription>& profiles); |
| + void OnPluginMsgInitializeReply(const ResourceMessageReplyParams& params, |
| + int32_t number_of_samples, |
| + int32_t audio_buffer_count, |
| + int32_t audio_buffer_size, |
| + int32_t bistream_buffer_count, |
| + int32_t bistream_buffer_size); |
| + void OnPluginMsgEncodeReply(const ResourceMessageReplyParams& params, |
| + int32_t buffer_id); |
| + void OnPluginMsgBitstreamBufferReady(const ResourceMessageReplyParams& params, |
| + int32_t buffer_id, |
| + int32_t buffer_size); |
| + void OnPluginMsgNotifyError(const ResourceMessageReplyParams& params, |
| + int32_t error); |
| + |
| + // Internal utility functions. |
| + void NotifyError(int32_t error); |
| + void TryWriteAudioBuffer(); |
| + void TryWriteBitstreamBuffer(); |
| + void ReleaseBuffers(); |
| + |
| + int32_t encoder_last_error_; |
| + |
| + bool initialized_; |
| + bool closed_; |
| + |
| + uint32_t number_of_samples_; |
| + |
| + typedef std::map<PP_Resource, scoped_refptr<AudioBufferResource>> |
|
bbudge
2015/11/13 20:37:56
Should these be 'using' as well?
llandwerlin-old
2015/11/16 11:23:57
Done.
|
| + AudioBufferMap; |
| + AudioBufferMap audio_buffers_; |
| + |
| + scoped_refptr<TrackedCallback> get_supported_profiles_callback_; |
| + scoped_refptr<TrackedCallback> initialize_callback_; |
| + scoped_refptr<TrackedCallback> get_buffer_callback_; |
| + PP_Resource* get_buffer_data_; |
| + |
| + typedef std::map<int32_t, scoped_refptr<TrackedCallback>> EncodeMap; |
| + EncodeMap encode_callbacks_; |
| + |
| + scoped_refptr<TrackedCallback> get_bitstream_buffer_callback_; |
| + PP_AudioBitstreamBuffer* get_bitstream_buffer_data_; |
| + |
| + // Buffer manager for audio frames. |
| + MediaStreamBufferManager audio_buffer_manager_; |
| + |
| + // Buffer manager for bitstream buffers. |
| + scoped_ptr<BitstreamBufferManager> bitstream_buffer_manager_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(AudioEncoderResource); |
| }; |