OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ppapi/cpp/video_writer.h" |
| 6 |
| 7 #include "ppapi/c/pp_errors.h" |
| 8 #include "ppapi/c/ppb_video_writer.h" |
| 9 #include "ppapi/cpp/instance_handle.h" |
| 10 #include "ppapi/cpp/module.h" |
| 11 #include "ppapi/cpp/module_impl.h" |
| 12 #include "ppapi/cpp/var.h" |
| 13 #include "ppapi/cpp/video_frame.h" |
| 14 |
| 15 namespace pp { |
| 16 |
| 17 namespace { |
| 18 |
| 19 template <> const char* interface_name<PPB_VideoWriter_0_1>() { |
| 20 return PPB_VIDEOWRITER_INTERFACE_0_1; |
| 21 } |
| 22 |
| 23 } // namespace |
| 24 |
| 25 // VideoWriter ----------------------------------------------------------------- |
| 26 |
| 27 VideoWriter::VideoWriter() { |
| 28 } |
| 29 |
| 30 VideoWriter::VideoWriter(const InstanceHandle& instance) { |
| 31 if (!has_interface<PPB_VideoWriter_0_1>()) |
| 32 return; |
| 33 PassRefFromConstructor(get_interface<PPB_VideoWriter_0_1>()->Create( |
| 34 instance.pp_instance())); |
| 35 } |
| 36 |
| 37 VideoWriter::VideoWriter(const VideoWriter& other) |
| 38 : Resource(other) { |
| 39 } |
| 40 |
| 41 VideoWriter::VideoWriter(PassRef, PP_Resource resource) |
| 42 : Resource(PASS_REF, resource) { |
| 43 } |
| 44 |
| 45 int32_t VideoWriter::Open(const std::string& stream_id, |
| 46 const CompletionCallback& cc) { |
| 47 if (has_interface<PPB_VideoWriter_0_1>()) { |
| 48 Var id(stream_id); |
| 49 int32_t result = |
| 50 get_interface<PPB_VideoWriter_0_1>()->Open( |
| 51 pp_resource(), |
| 52 id.pp_var(), cc.pp_completion_callback()); |
| 53 return result; |
| 54 } |
| 55 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 56 } |
| 57 |
| 58 int32_t VideoWriter::PutFrame(const VideoFrame& frame) { |
| 59 if (has_interface<PPB_VideoWriter_0_1>()) { |
| 60 return get_interface<PPB_VideoWriter_0_1>()->PutFrame( |
| 61 pp_resource(), |
| 62 &frame.pp_video_frame()); |
| 63 } |
| 64 return PP_ERROR_NOINTERFACE; |
| 65 } |
| 66 |
| 67 void VideoWriter::Close() { |
| 68 if (has_interface<PPB_VideoWriter_0_1>()) { |
| 69 get_interface<PPB_VideoWriter_0_1>()->Close(pp_resource()); |
| 70 } |
| 71 } |
| 72 |
| 73 } // namespace pp |
OLD | NEW |