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..17256addab27b3f7181b4f90dd4a4a6fa4ed2660 |
--- /dev/null |
+++ b/ppapi/cpp/video_encoder.cc |
@@ -0,0 +1,78 @@ |
+// Copyright (c) 2014 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. |
+ |
+#include "ppapi/cpp/video_encoder.h" |
+ |
+#include "ppapi/c/pp_errors.h" |
+#include "ppapi/c/ppb_console.h" |
+#include "ppapi/c/ppb_video_encoder.h" |
+#include "ppapi/cpp/completion_callback.h" |
+#include "ppapi/cpp/instance_handle.h" |
+#include "ppapi/cpp/logging.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(PP_Resource resource) |
+ : Resource(resource) { |
+} |
+ |
+VideoEncoder::VideoEncoder(const VideoEncoder& other) |
+ : Resource(other) { |
+} |
+ |
+int32_t VideoEncoder::Initialize( |
+ const Graphics3D& context, |
+ const PP_VideoEncoderParams& params, |
+ void* user_data, |
+ PPB_VideoEncoder_Ready_Func callback) { |
+ if (has_interface<PPB_VideoEncoder_0_1>()) { |
+ return get_interface<PPB_VideoEncoder_0_1>()->Initialize( |
+ pp_resource(), context.pp_resource(), ¶ms, user_data, callback); |
+ } |
+ return PP_ERROR_NOINTERFACE; |
+} |
+ |
+int32_t VideoEncoder::Encode(uint32_t encode_id, |
+ const PP_VideoEncoderPicture& picture, |
+ const PP_Bool force_keyframe, |
+ const CompletionCallback& callback) { |
+ if (has_interface<PPB_VideoEncoder_0_1>()) { |
+ return get_interface<PPB_VideoEncoder_0_1>()->Encode( |
+ pp_resource(), encode_id, &picture, force_keyframe, |
+ callback.pp_completion_callback()); |
+ } |
+ return callback.MayForce(PP_ERROR_NOINTERFACE); |
+} |
+ |
+int32_t VideoEncoder::Reset(const CompletionCallback& callback) { |
+ if (has_interface<PPB_VideoEncoder_0_1>()) { |
+ return get_interface<PPB_VideoEncoder_0_1>()->Reset( |
+ pp_resource(), callback.pp_completion_callback()); |
+ } |
+ return callback.MayForce(PP_ERROR_NOINTERFACE); |
+} |
+ |
+} // namespace pp |