Chromium Code Reviews| Index: ppapi/cpp/video_writer.cc |
| diff --git a/ppapi/cpp/video_writer.cc b/ppapi/cpp/video_writer.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..08677f965d85e172a6b2b17113974bd36dd1eb2e |
| --- /dev/null |
| +++ b/ppapi/cpp/video_writer.cc |
| @@ -0,0 +1,73 @@ |
| +// Copyright (c) 2013 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_writer.h" |
| + |
| +#include "ppapi/c/pp_errors.h" |
| +#include "ppapi/c/ppb_video_writer.h" |
| +#include "ppapi/cpp/instance_handle.h" |
| +#include "ppapi/cpp/module.h" |
| +#include "ppapi/cpp/module_impl.h" |
| +#include "ppapi/cpp/var.h" |
| +#include "ppapi/cpp/video_frame.h" |
| + |
| +namespace pp { |
| + |
| +namespace { |
| + |
| +template <> const char* interface_name<PPB_VideoWriter_1_0>() { |
|
yzshen1
2013/04/04 23:48:12
Please update the version number.
bbudge
2013/04/04 23:53:36
Done.
|
| + return PPB_VIDEOWRITER_INTERFACE_1_0; |
| +} |
| + |
| +} // namespace |
| + |
| +// VideoWriter ----------------------------------------------------------------- |
| + |
| +VideoWriter::VideoWriter() { |
| +} |
| + |
| +VideoWriter::VideoWriter(const InstanceHandle& instance) { |
| + if (!has_interface<PPB_VideoWriter_1_0>()) |
| + return; |
| + PassRefFromConstructor(get_interface<PPB_VideoWriter_1_0>()->Create( |
| + instance.pp_instance())); |
| +} |
| + |
| +VideoWriter::VideoWriter(const VideoWriter& other) |
| + : Resource(other) { |
| +} |
| + |
| +VideoWriter::VideoWriter(PassRef, PP_Resource resource) |
| + : Resource(PASS_REF, resource) { |
| +} |
| + |
| +int32_t VideoWriter::Open(const std::string& stream_id, |
| + const CompletionCallback& cc) { |
| + if (has_interface<PPB_VideoWriter_1_0>()) { |
| + Var id(stream_id); |
| + int32_t result = |
| + get_interface<PPB_VideoWriter_1_0>()->Open( |
| + pp_resource(), |
| + id.pp_var(), cc.pp_completion_callback()); |
| + return result; |
| + } |
| + return cc.MayForce(PP_ERROR_NOINTERFACE); |
| +} |
| + |
| +int32_t VideoWriter::PutFrame(const VideoFrame& frame) { |
| + if (has_interface<PPB_VideoWriter_1_0>()) { |
| + return get_interface<PPB_VideoWriter_1_0>()->PutFrame( |
| + pp_resource(), |
| + &frame.pp_video_frame()); |
| + } |
| + return PP_ERROR_NOINTERFACE; |
| +} |
| + |
| +void VideoWriter::Close() { |
| + if (has_interface<PPB_VideoWriter_1_0>()) { |
| + get_interface<PPB_VideoWriter_1_0>()->Close(pp_resource()); |
| + } |
| +} |
| + |
| +} // namespace pp |