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

Unified Diff: ppapi/cpp/video_encoder.cc

Issue 842293003: Pepper: Define PPB_VideoEncoder API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add |acceleration| field to PP_SupportedVideoProfile. 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
Index: ppapi/cpp/video_encoder.cc
diff --git a/ppapi/cpp/video_encoder.cc b/ppapi/cpp/video_encoder.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0792e12f215547177660a200dbe41a05da35367c
--- /dev/null
+++ b/ppapi/cpp/video_encoder.cc
@@ -0,0 +1,122 @@
+// Copyright (c) 2015 The Chromium Authors. All rights reserved.
dmichael (off chromium) 2015/02/03 23:26:08 super nitty nit: prefer no (c) (here and other new
bbudge 2015/02/05 18:19:04 Whoops, I'll get this in a follow-on CL.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/cpp/video_encoder.h"
+
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/ppb_video_encoder.h"
+#include "ppapi/cpp/completion_callback.h"
+#include "ppapi/cpp/instance_handle.h"
+#include "ppapi/cpp/module.h"
+#include "ppapi/cpp/module_impl.h"
+
+namespace pp {
+
+namespace {
+
+template <>
+const char* interface_name<PPB_VideoEncoder_0_1>() {
+ return PPB_VIDEOENCODER_INTERFACE_0_1;
+}
+
+} // namespace
+
+VideoEncoder::VideoEncoder() {
+}
+
+VideoEncoder::VideoEncoder(const InstanceHandle& instance) {
+ if (has_interface<PPB_VideoEncoder_0_1>()) {
+ PassRefFromConstructor(
+ get_interface<PPB_VideoEncoder_0_1>()->Create(instance.pp_instance()));
+ }
+}
+
+VideoEncoder::VideoEncoder(const VideoEncoder& other) : Resource(other) {
+}
+
+int32_t VideoEncoder::GetSupportedProfiles(const CompletionCallbackWithOutput<
+ std::vector<PP_SupportedVideoProfile>>& cc) {
+ if (has_interface<PPB_VideoEncoder_0_1>()) {
+ return get_interface<PPB_VideoEncoder_0_1>()->GetSupportedProfiles(
+ pp_resource(), cc.output(), cc.pp_completion_callback());
+ }
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
+}
+
+int32_t VideoEncoder::Initialize(const PP_VideoFrame_Format& input_format,
+ const PP_Size& input_visible_size,
+ const PP_VideoProfile& output_profile,
+ const uint32_t initial_bitrate,
+ PP_HardwareAcceleration acceleration,
+ const CompletionCallback& cc) {
+ if (has_interface<PPB_VideoEncoder_0_1>()) {
+ return get_interface<PPB_VideoEncoder_0_1>()->Initialize(
+ pp_resource(), input_format, &input_visible_size, output_profile,
+ initial_bitrate, acceleration, cc.pp_completion_callback());
+ }
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
+}
+
+int32_t VideoEncoder::GetFramesRequired() {
+ if (has_interface<PPB_VideoEncoder_0_1>()) {
+ return get_interface<PPB_VideoEncoder_0_1>()->GetFramesRequired(
+ pp_resource());
+ }
+ return PP_ERROR_NOINTERFACE;
+}
+
+int32_t VideoEncoder::GetFrameCodedSize(PP_Size* coded_size) {
+ if (has_interface<PPB_VideoEncoder_0_1>()) {
+ return get_interface<PPB_VideoEncoder_0_1>()->GetFrameCodedSize(
+ pp_resource(), coded_size);
+ }
+ return PP_ERROR_NOINTERFACE;
+}
+
+int32_t VideoEncoder::GetVideoFrame(
+ const CompletionCallbackWithOutput<VideoFrame>& cc) {
+ if (has_interface<PPB_VideoEncoder_0_1>()) {
+ return get_interface<PPB_VideoEncoder_0_1>()->GetVideoFrame(
+ pp_resource(), cc.output(), cc.pp_completion_callback());
+ }
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
+}
+
+int32_t VideoEncoder::Encode(const VideoFrame& video_frame,
+ bool force_keyframe,
+ const CompletionCallback& cc) {
+ if (has_interface<PPB_VideoEncoder_0_1>()) {
+ return get_interface<PPB_VideoEncoder_0_1>()->Encode(
+ pp_resource(), video_frame.pp_resource(), PP_FromBool(force_keyframe),
+ cc.pp_completion_callback());
+ }
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
+}
+
+int32_t VideoEncoder::GetBitstreamBuffer(
+ const CompletionCallbackWithOutput<PP_BitstreamBuffer>& cc) {
+ if (has_interface<PPB_VideoEncoder_0_1>()) {
+ return get_interface<PPB_VideoEncoder_0_1>()->GetBitstreamBuffer(
+ pp_resource(), cc.output(), cc.pp_completion_callback());
+ }
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
+}
+
+void VideoEncoder::RecycleBitstreamBuffer(
+ const PP_BitstreamBuffer& bitstream_buffer) {
+ if (has_interface<PPB_VideoEncoder_0_1>()) {
+ get_interface<PPB_VideoEncoder_0_1>()->RecycleBitstreamBuffer(
+ pp_resource(), &bitstream_buffer);
+ }
+}
+
+void VideoEncoder::RequestEncodingParametersChange(uint32_t bitrate,
+ uint32_t framerate) {
+ if (has_interface<PPB_VideoEncoder_0_1>()) {
+ get_interface<PPB_VideoEncoder_0_1>()->RequestEncodingParametersChange(
+ pp_resource(), bitrate, framerate);
+ }
+}
+
+} // namespace pp

Powered by Google App Engine
This is Rietveld 408576698