| 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_reader.h" | |
| 6 | |
| 7 #include "ppapi/c/pp_errors.h" | |
| 8 #include "ppapi/c/ppb_video_reader.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_VideoReader_0_1>() { | |
| 20 return PPB_VIDEOREADER_INTERFACE_0_1; | |
| 21 } | |
| 22 | |
| 23 } // namespace | |
| 24 | |
| 25 // VideoReader ----------------------------------------------------------------- | |
| 26 | |
| 27 VideoReader::VideoReader() { | |
| 28 } | |
| 29 | |
| 30 VideoReader::VideoReader(const InstanceHandle& instance) { | |
| 31 if (!has_interface<PPB_VideoReader_0_1>()) | |
| 32 return; | |
| 33 PassRefFromConstructor(get_interface<PPB_VideoReader_0_1>()->Create( | |
| 34 instance.pp_instance())); | |
| 35 } | |
| 36 | |
| 37 VideoReader::VideoReader(const VideoReader& other) | |
| 38 : Resource(other) { | |
| 39 } | |
| 40 | |
| 41 VideoReader::VideoReader(PassRef, PP_Resource resource) | |
| 42 : Resource(PASS_REF, resource) { | |
| 43 } | |
| 44 | |
| 45 int32_t VideoReader::Open(const Var& stream_id, | |
| 46 const CompletionCallback& cc) { | |
| 47 if (has_interface<PPB_VideoReader_0_1>()) { | |
| 48 int32_t result = | |
| 49 get_interface<PPB_VideoReader_0_1>()->Open( | |
| 50 pp_resource(), | |
| 51 stream_id.pp_var(), cc.pp_completion_callback()); | |
| 52 return result; | |
| 53 } | |
| 54 return cc.MayForce(PP_ERROR_NOINTERFACE); | |
| 55 } | |
| 56 | |
| 57 int32_t VideoReader::GetFrame( | |
| 58 const CompletionCallbackWithOutput<VideoFrame>& cc) { | |
| 59 if (has_interface<PPB_VideoReader_0_1>()) { | |
| 60 return get_interface<PPB_VideoReader_0_1>()->GetFrame( | |
| 61 pp_resource(), | |
| 62 cc.output(), cc.pp_completion_callback()); | |
| 63 } | |
| 64 return cc.MayForce(PP_ERROR_NOINTERFACE); | |
| 65 } | |
| 66 | |
| 67 void VideoReader::Close() { | |
| 68 if (has_interface<PPB_VideoReader_0_1>()) { | |
| 69 get_interface<PPB_VideoReader_0_1>()->Close(pp_resource()); | |
| 70 } | |
| 71 } | |
| 72 | |
| 73 } // namespace pp | |
| OLD | NEW |