OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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/image_capture_private.h" |
| 6 |
| 7 #include "ppapi/c/pp_bool.h" |
| 8 #include "ppapi/c/pp_errors.h" |
| 9 #include "ppapi/cpp/completion_callback.h" |
| 10 #include "ppapi/cpp/instance_handle.h" |
| 11 #include "ppapi/cpp/module_impl.h" |
| 12 #include "ppapi/cpp/private/camera_capabilities_private.h" |
| 13 #include "ppapi/cpp/private/image_capture_config_private.h" |
| 14 |
| 15 namespace pp { |
| 16 |
| 17 namespace { |
| 18 |
| 19 template <> |
| 20 const char* interface_name<PPB_ImageCapture_Private_0_1>() { |
| 21 return PPB_IMAGECAPTURE_PRIVATE_INTERFACE_0_1; |
| 22 } |
| 23 |
| 24 } // namespace |
| 25 |
| 26 ImageCapture_Private::ImageCapture_Private() { |
| 27 } |
| 28 |
| 29 ImageCapture_Private::ImageCapture_Private(const ImageCapture_Private& other) |
| 30 : Resource(other) { |
| 31 } |
| 32 |
| 33 ImageCapture_Private::ImageCapture_Private(const Resource& resource) |
| 34 : Resource(resource) { |
| 35 PP_DCHECK(IsImageCapture(resource)); |
| 36 } |
| 37 |
| 38 ImageCapture_Private::ImageCapture_Private(const InstanceHandle& instance) { |
| 39 if (has_interface<PPB_ImageCapture_Private_0_1>()) { |
| 40 PassRefFromConstructor( |
| 41 get_interface<PPB_ImageCapture_Private_0_1>()->Create( |
| 42 instance.pp_instance())); |
| 43 return; |
| 44 } |
| 45 PP_DCHECK(false); |
| 46 } |
| 47 |
| 48 ImageCapture_Private::ImageCapture_Private(PassRef, PP_Resource resource) |
| 49 : Resource(PASS_REF, resource) { |
| 50 } |
| 51 |
| 52 ImageCapture_Private::~ImageCapture_Private() { |
| 53 } |
| 54 |
| 55 int32_t ImageCapture_Private::Open(const Var& camera_source_id, |
| 56 const CompletionCallback& callback) { |
| 57 if (!has_interface<PPB_ImageCapture_Private_0_1>()) |
| 58 return PP_ERROR_NOINTERFACE; |
| 59 |
| 60 return get_interface<PPB_ImageCapture_Private_0_1>()->Open( |
| 61 pp_resource(), |
| 62 camera_source_id.pp_var(), |
| 63 callback.pp_completion_callback()); |
| 64 } |
| 65 |
| 66 void ImageCapture_Private::Close() { |
| 67 if (has_interface<PPB_ImageCapture_Private_0_1>()) { |
| 68 get_interface<PPB_ImageCapture_Private_0_1>()->Close(pp_resource()); |
| 69 } |
| 70 } |
| 71 |
| 72 int32_t ImageCapture_Private::SetConfig( |
| 73 const ImageCaptureConfig_Private& config, |
| 74 const CompletionCallback& callback) { |
| 75 if (!has_interface<PPB_ImageCapture_Private_0_1>()) |
| 76 return PP_ERROR_NOINTERFACE; |
| 77 |
| 78 return get_interface<PPB_ImageCapture_Private_0_1>()->SetConfig( |
| 79 pp_resource(), config.pp_resource(), callback.pp_completion_callback()); |
| 80 } |
| 81 |
| 82 int32_t ImageCapture_Private::GetConfig( |
| 83 const CompletionCallbackWithOutput<ImageCaptureConfig_Private>& callback) { |
| 84 if (!has_interface<PPB_ImageCapture_Private_0_1>()) |
| 85 return PP_ERROR_NOINTERFACE; |
| 86 |
| 87 return get_interface<PPB_ImageCapture_Private_0_1>()->GetConfig( |
| 88 pp_resource(), callback.output(), callback.pp_completion_callback()); |
| 89 } |
| 90 |
| 91 int32_t ImageCapture_Private::GetCameraCapabilities( |
| 92 const CompletionCallbackWithOutput<CameraCapabilities_Private>& callback) { |
| 93 if (!has_interface<PPB_ImageCapture_Private_0_1>()) |
| 94 return PP_ERROR_NOINTERFACE; |
| 95 |
| 96 return get_interface<PPB_ImageCapture_Private_0_1>()->GetCameraCapabilities( |
| 97 pp_resource(), callback.output(), callback.pp_completion_callback()); |
| 98 } |
| 99 |
| 100 int32_t ImageCapture_Private::ReuseBuffers() { |
| 101 if (!has_interface<PPB_ImageCapture_Private_0_1>()) |
| 102 return PP_ERROR_NOINTERFACE; |
| 103 |
| 104 return get_interface<PPB_ImageCapture_Private_0_1>()->ReuseBuffers( |
| 105 pp_resource()); |
| 106 } |
| 107 |
| 108 int32_t ImageCapture_Private::CaptureStillImage( |
| 109 PPB_ImageCapture_Private_ShutterCallback shutter_callback, |
| 110 PPB_ImageCapture_Private_PreviewCallback preview_callback, |
| 111 PPB_ImageCapture_Private_JpegCallback jpeg_callback, |
| 112 PPB_ImageCapture_Private_ErrorCallback error_callback, |
| 113 uint64_t* sequence_id) { |
| 114 if (!has_interface<PPB_ImageCapture_Private_0_1>()) |
| 115 return PP_ERROR_NOINTERFACE; |
| 116 |
| 117 return get_interface<PPB_ImageCapture_Private_0_1>()->CaptureStillImage( |
| 118 pp_resource(), |
| 119 shutter_callback, |
| 120 preview_callback, |
| 121 jpeg_callback, |
| 122 error_callback, |
| 123 sequence_id); |
| 124 } |
| 125 |
| 126 // static |
| 127 bool ImageCapture_Private::IsImageCapture(const Resource& resource) { |
| 128 if (!has_interface<PPB_ImageCapture_Private_0_1>()) |
| 129 return false; |
| 130 |
| 131 return PP_ToBool( |
| 132 get_interface<PPB_ImageCapture_Private_0_1>()->IsImageCapture( |
| 133 resource.pp_resource())); |
| 134 } |
| 135 |
| 136 } // namespace pp |
OLD | NEW |