Index: content/renderer/pepper/pepper_video_encoder_host.h |
diff --git a/content/renderer/pepper/pepper_video_encoder_host.h b/content/renderer/pepper/pepper_video_encoder_host.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7d401a2be9b0265ded17fa1457ec1e7711c34c03 |
--- /dev/null |
+++ b/content/renderer/pepper/pepper_video_encoder_host.h |
@@ -0,0 +1,134 @@ |
+// Copyright (c) 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_VIDEO_ENCODER_HOST_H_ |
+#define CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_ENCODER_HOST_H_ |
+ |
+#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 "gpu/command_buffer/common/mailbox_holder.h" |
+#include "media/video/video_encode_accelerator.h" |
+#include "ppapi/c/pp_codecs.h" |
+#include "ppapi/c/ppb_video_frame.h" |
+#include "ppapi/host/host_message_context.h" |
+#include "ppapi/host/resource_host.h" |
+#include "ppapi/proxy/resource_message_params.h" |
+#include "ppapi/shared_impl/media_stream_buffer_manager.h" |
+ |
+namespace media { |
+class GpuVideoAcceleratorFactories; |
+} |
+ |
+namespace content { |
+ |
+class CommandBufferProxyImpl; |
+class GpuChannelHost; |
+class RendererPpapiHost; |
+class RenderViewImpl; |
+ |
+class CONTENT_EXPORT PepperVideoEncoderHost |
+ : public ppapi::host::ResourceHost, |
+ public media::VideoEncodeAccelerator::Client { |
+ public: |
+ PepperVideoEncoderHost(RendererPpapiHost* host, |
+ PP_Instance instance, |
+ PP_Resource resource); |
+ ~PepperVideoEncoderHost() override; |
+ |
+ private: |
+ // media::VideoEncodeAccelerator implementation. |
+ virtual void RequireBitstreamBuffers(unsigned int input_count, |
+ const gfx::Size& input_coded_size, |
+ size_t output_buffer_size) override; |
+ virtual void BitstreamBufferReady(int32 bitstream_buffer_id, |
+ size_t payload_size, |
+ bool key_frame) override; |
+ virtual void NotifyError(media::VideoEncodeAccelerator::Error error) override; |
+ |
+ // ResourceHost implementation. |
+ virtual int32_t OnResourceMessageReceived( |
+ const IPC::Message& msg, |
+ ppapi::host::HostMessageContext* context) override; |
+ |
+ // Plugin's IPC calls. |
+ int32_t OnHostMsgGetSupportedProfiles( |
+ ppapi::host::HostMessageContext* context); |
+ int32_t OnHostMsgInitialize(ppapi::host::HostMessageContext* context, |
+ PP_VideoFrame_Format input_format, |
+ const PP_Size& input_visible_size, |
+ PP_VideoProfile output_profile, |
+ uint32_t initial_bitrate, |
+ PP_HardwareAcceleration acceleration); |
+ int32_t OnHostMsgGetVideoFrames(ppapi::host::HostMessageContext* context); |
+ int32_t OnHostMsgEncode(ppapi::host::HostMessageContext* context, |
+ uint32_t frame_id, |
+ bool force_keyframe); |
+ int32_t OnHostMsgRecycleBitstreamBuffer( |
+ ppapi::host::HostMessageContext* context, |
+ uint32_t buffer_id); |
+ int32_t OnHostMsgRequestEncodingParametersChange( |
+ ppapi::host::HostMessageContext* context, |
+ uint32_t bitrate, |
+ uint32_t framerate); |
+ int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context); |
+ |
+ // Internal methods. |
+ // void* BufferIdToAddress(int32_t buffer_id); |
+ scoped_refptr<media::VideoFrame> CreateVideoFrame( |
+ uint32_t frame_id, |
+ const ppapi::host::ReplyMessageContext& reply_context); |
+ void EncodeVideoFrameDone( |
+ const ppapi::host::ReplyMessageContext& reply_context, |
+ uint32_t frame_id); |
+ void NotifyPepperError(int32_t error); |
+ |
+ // Non-owning pointer. |
+ RendererPpapiHost* renderer_ppapi_host_; |
+ |
+ ppapi::host::ReplyMessageContext initialize_reply_context_; |
+ |
+ // Shared memory buffers. |
+ class ShmBuffer { |
+ public: |
+ ShmBuffer(int32_t id, scoped_ptr<base::SharedMemory> memory, size_t size); |
+ ~ShmBuffer(); |
+ |
+ media::BitstreamBuffer toBitstreamBuffer(); |
+ |
+ int32_t id; |
+ scoped_ptr<base::SharedMemory> shm; |
+ bool in_use; |
+ }; |
+ |
+ // Bitstream buffers. |
+ ScopedVector<ShmBuffer> buffers_; |
+ size_t buffer_count_hint_; |
+ |
+ // Video frames. |
+ scoped_ptr<ppapi::MediaStreamBufferManager::Delegate> |
+ buffer_manager_delegate_; |
bbudge
2015/02/10 01:31:07
Why not make the host implement the Delegate inter
llandwerlin-old
2015/02/10 14:28:12
Done.
|
+ scoped_ptr<ppapi::MediaStreamBufferManager> buffer_manager_; |
bbudge
2015/02/10 01:31:07
Since this is owned by the host and not shared, yo
llandwerlin-old
2015/02/10 14:28:12
Done.
|
+ |
+ scoped_ptr<media::VideoEncodeAccelerator> encoder_; |
+ |
+ // Global state |
+ bool initialized_; |
+ int32_t encoder_last_error_; |
+ gfx::Size input_coded_size_; |
+ int32_t frame_count_; |
+ media::VideoFrame::Format media_format_; |
+ |
+ scoped_refptr<GpuChannelHost> channel_; |
+ CommandBufferProxyImpl* command_buffer_; |
+ |
+ base::WeakPtrFactory<PepperVideoEncoderHost> weak_ptr_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PepperVideoEncoderHost); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_ENCODER_HOST_H_ |