| 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..ae9197eaf42bef001743ceb4180ac346bb0635a9
|
| --- /dev/null
|
| +++ b/content/renderer/pepper/pepper_video_encoder_host.h
|
| @@ -0,0 +1,135 @@
|
| +// 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 <map>
|
| +// #include <queue>
|
| +
|
| +// #include "base/basictypes.h"
|
| +// #include "base/containers/hash_tables.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/c/ppb_video_encoder.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 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,
|
| + PP_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);
|
| +
|
| + // 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);
|
| +
|
| + // Non-owning pointer.
|
| + RendererPpapiHost* renderer_ppapi_host_;
|
| +
|
| + // The message loop on which to post callbacks to |weak_encoder_|.
|
| + const scoped_refptr<base::MessageLoopProxy> encoder_message_loop_proxy_;
|
| + base::ThreadChecker thread_checker_;
|
| +
|
| + 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_;
|
| + scoped_ptr<ppapi::MediaStreamBufferManager> buffer_manager_;
|
| +
|
| + 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_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(PepperVideoEncoderHost);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_ENCODER_HOST_H_
|
|
|