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/private/video_source_private.h" 6 7 #include "ppapi/c/pp_errors.h" 8 #include "ppapi/c/private/ppb_video_source_private.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/private/video_frame_private.h" 13 #include "ppapi/cpp/var.h" 14 15 namespace pp { 16 17 namespace { 18 interface_name()19template <> const char* interface_name<PPB_VideoSource_Private_0_1>() { 20 return PPB_VIDEOSOURCE_PRIVATE_INTERFACE_0_1; 21 } 22 23 } // namespace 24 VideoSource_Private()25VideoSource_Private::VideoSource_Private() { 26 } 27 VideoSource_Private(const InstanceHandle & instance)28VideoSource_Private::VideoSource_Private(const InstanceHandle& instance) { 29 if (!has_interface<PPB_VideoSource_Private_0_1>()) 30 return; 31 PassRefFromConstructor(get_interface<PPB_VideoSource_Private_0_1>()->Create( 32 instance.pp_instance())); 33 } 34 VideoSource_Private(const VideoSource_Private & other)35VideoSource_Private::VideoSource_Private(const VideoSource_Private& other) 36 : Resource(other) { 37 } 38 VideoSource_Private(PassRef,PP_Resource resource)39VideoSource_Private::VideoSource_Private(PassRef, PP_Resource resource) 40 : Resource(PASS_REF, resource) { 41 } 42 Open(const Var & stream_url,const CompletionCallback & cc)43int32_t VideoSource_Private::Open(const Var& stream_url, 44 const CompletionCallback& cc) { 45 if (has_interface<PPB_VideoSource_Private_0_1>()) { 46 int32_t result = 47 get_interface<PPB_VideoSource_Private_0_1>()->Open( 48 pp_resource(), 49 stream_url.pp_var(), cc.pp_completion_callback()); 50 return result; 51 } 52 return cc.MayForce(PP_ERROR_NOINTERFACE); 53 } 54 GetFrame(const CompletionCallbackWithOutput<VideoFrame_Private> & cc)55int32_t VideoSource_Private::GetFrame( 56 const CompletionCallbackWithOutput<VideoFrame_Private>& cc) { 57 if (has_interface<PPB_VideoSource_Private_0_1>()) { 58 return get_interface<PPB_VideoSource_Private_0_1>()->GetFrame( 59 pp_resource(), 60 cc.output(), cc.pp_completion_callback()); 61 } 62 return cc.MayForce(PP_ERROR_NOINTERFACE); 63 } 64 Close()65void VideoSource_Private::Close() { 66 if (has_interface<PPB_VideoSource_Private_0_1>()) { 67 get_interface<PPB_VideoSource_Private_0_1>()->Close(pp_resource()); 68 } 69 } 70 71 } // namespace pp 72