Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Unified Diff: ppapi/proxy/video_encoder_resource.h

Issue 859313002: Pepper: Define PPB_VideoEncoder API + Implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/proxy/resource_creation_proxy.cc ('k') | ppapi/proxy/video_encoder_resource.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/video_encoder_resource.h
diff --git a/ppapi/proxy/video_encoder_resource.h b/ppapi/proxy/video_encoder_resource.h
new file mode 100644
index 0000000000000000000000000000000000000000..9ef1ba775e28edf3e29df0a68e75c2d570031fec
--- /dev/null
+++ b/ppapi/proxy/video_encoder_resource.h
@@ -0,0 +1,156 @@
+// 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 PPAPI_PROXY_VIDEO_ENCODER_RESOURCE_API_H_
+#define PPAPI_PROXY_VIDEO_ENCODER_RESOURCE_API_H_
+
+#include <deque>
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#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_video_encoder_api.h"
+
+namespace base {
+class SharedMemory;
+}
+
+namespace ppapi {
+
+class TrackedCallback;
+
+namespace proxy {
+
+class SerializedHandle;
+class VideoFrameResource;
+
+class PPAPI_PROXY_EXPORT VideoEncoderResource
+ : public PluginResource,
+ public thunk::PPB_VideoEncoder_API {
+ public:
+ VideoEncoderResource(Connection connection, PP_Instance instance);
+ ~VideoEncoderResource() override;
+
+ thunk::PPB_VideoEncoder_API* AsPPB_VideoEncoder_API() override;
+
+ private:
+ struct ShmBuffer {
+ ShmBuffer(base::SharedMemoryHandle handle, uint32_t id, uint32_t size);
+ ~ShmBuffer();
+
+ scoped_ptr<base::SharedMemory> shm;
+ uint32_t id;
+ uint32_t size;
+ };
+
+ struct BitstreamBuffer {
+ BitstreamBuffer(uint32_t id, uint32_t size, bool key_frame);
+ BitstreamBuffer(const BitstreamBuffer& other);
+ ~BitstreamBuffer();
+
+ uint32_t id;
+ uint32_t size;
+ bool key_frame;
+ };
+
+ // PPB_VideoEncoder_API implementation.
+ int32_t GetSupportedProfiles(
+ const PP_ArrayOutput& output,
+ const scoped_refptr<TrackedCallback>& callback) override;
+ int32_t Initialize(PP_VideoFrame_Format input_format,
+ const PP_Size* input_visible_size,
+ PP_VideoProfile output_profile,
+ uint32_t initial_bitrate,
+ PP_HardwareAcceleration acceleration,
+ const scoped_refptr<TrackedCallback>& callback) override;
+ int32_t GetFramesRequired() override;
+ int32_t GetFrameCodedSize(PP_Size* size) override;
+ int32_t GetVideoFrame(
+ PP_Resource* video_frame,
+ const scoped_refptr<TrackedCallback>& callback) override;
+ int32_t Encode(PP_Resource video_frame,
+ PP_Bool force_keyframe,
+ const scoped_refptr<TrackedCallback>& callback) override;
+ int32_t GetBitstreamBuffer(
+ PP_BitstreamBuffer* picture,
+ const scoped_refptr<TrackedCallback>& callback) override;
+ void RecycleBitstreamBuffer(const PP_BitstreamBuffer* picture) override;
+ void RequestEncodingParametersChange(uint32_t bitrate,
+ uint32_t framerate) override;
+
+ // PluginResource implementation.
+ void OnReplyReceived(const ResourceMessageReplyParams& params,
+ const IPC::Message& msg) override;
+
+ // Reply message handlers for operations that are done in the host.
+ void OnPluginMsgGetSupportedProfilesReply(
+ const PP_ArrayOutput& output,
+ const scoped_refptr<TrackedCallback>& callback,
+ const ResourceMessageReplyParams& params,
+ const std::vector<PP_SupportedVideoProfile>& profiles);
+ void OnPluginMsgInitializeReply(const ResourceMessageReplyParams& params,
+ uint32_t buffer_count,
+ uint32_t buffer_length,
+ uint32_t input_frame_count,
+ const PP_Size& input_coded_size);
+ void OnPluginMsgGetVideoFramesReply(const ResourceMessageReplyParams& params,
+ uint32_t frame_count,
+ uint32_t frame_length,
+ const PP_Size& frame_size);
+ void OnPluginMsgEncodeReply(const scoped_refptr<TrackedCallback>& callback,
+ const ResourceMessageReplyParams& params,
+ uint32_t frame_id);
+
+ // Unsolicited reply message handlers.
+ void OnPluginMsgBitstreamBufferReady(const ResourceMessageReplyParams& params,
+ uint32_t buffer_id,
+ uint32_t buffer_size,
+ bool key_frame);
+ void OnPluginMsgNotifyError(const ResourceMessageReplyParams& params,
+ int32_t error);
+
+ // Internal utility functions.
+ void NotifyGetVideoFrameCallbacks();
+ void NotifyGetVideoFrameCallbacksError(int32_t error);
+ void WriteBitstreamerBuffer(PP_BitstreamBuffer* bitstream_buffer,
+ const BitstreamBuffer& buffer);
+
+ bool initialized_;
+ int32_t encoder_last_error_;
+
+ int32_t encoder_frame_count_;
+ PP_Size encoder_coded_size_;
+
+ bool waiting_for_video_frames_;
+
+ scoped_ptr<MediaStreamBufferManager::Delegate> buffer_manager_delegate_;
+ scoped_ptr<MediaStreamBufferManager> media_stream_buffer_manager_;
+
+ typedef std::map<uint32_t, scoped_refptr<VideoFrameResource>> VideoFrameMap;
+ VideoFrameMap video_frames_;
+
+ std::deque<std::pair<PP_Resource*, scoped_refptr<TrackedCallback>>>
+ get_video_frame_cbs_;
+
+ ScopedVector<ShmBuffer> bitstream_buffers_;
+
+ std::deque<BitstreamBuffer> available_bitstream_buffers_;
+ typedef std::map<void*, uint32_t> BitstreamBufferMap;
+ BitstreamBufferMap bitstream_buffers_map_;
+
+ scoped_refptr<TrackedCallback> initialize_callback_;
+ scoped_refptr<TrackedCallback> get_bitstreamer_buffer_callback_;
+ PP_BitstreamBuffer* get_bitstreamer_buffer_data_;
+
+ DISALLOW_COPY_AND_ASSIGN(VideoEncoderResource);
+};
+
+} // namespace proxy
+} // namespace ppapi
+
+#endif // PPAPI_PROXY_VIDEO_ENCODER_RESOURCE_API_H_
« no previous file with comments | « ppapi/proxy/resource_creation_proxy.cc ('k') | ppapi/proxy/video_encoder_resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698