Make |track_| in MediaStreamTrack const. and a couple of other cosmetic changes.
[chromium-blink-merge.git] / ppapi / thunk / ppb_image_capture_private_thunk.cc
blob9f00c3ca8004587fe7e985b76bde9c4fc9ec0df3
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.
5 // From private/ppb_image_capture_private.idl,
6 // modified Wed Aug 13 17:26:13 2014.
8 #include "ppapi/c/pp_completion_callback.h"
9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/c/private/ppb_image_capture_private.h"
11 #include "ppapi/shared_impl/tracked_callback.h"
12 #include "ppapi/thunk/enter.h"
13 #include "ppapi/thunk/ppapi_thunk_export.h"
14 #include "ppapi/thunk/ppb_image_capture_api.h"
16 namespace ppapi {
17 namespace thunk {
19 namespace {
21 PP_Resource Create(PP_Instance instance,
22 struct PP_Var camera_source_id,
23 PPB_ImageCapture_Private_ErrorCallback error_callback,
24 void* user_data) {
25 VLOG(4) << "PPB_ImageCapture_Private::Create()";
26 EnterResourceCreation enter(instance);
27 if (enter.failed())
28 return 0;
29 return enter.functions()->CreateImageCapturePrivate(instance,
30 camera_source_id,
31 error_callback,
32 user_data);
35 PP_Bool IsImageCapture(PP_Resource resource) {
36 VLOG(4) << "PPB_ImageCapture_Private::IsImageCapture()";
37 EnterResource<PPB_ImageCapture_API> enter(resource, false);
38 return PP_FromBool(enter.succeeded());
41 int32_t Close(PP_Resource resource, struct PP_CompletionCallback callback) {
42 VLOG(4) << "PPB_ImageCapture_Private::Close()";
43 EnterResource<PPB_ImageCapture_API> enter(resource, callback, true);
44 if (enter.failed())
45 return enter.retval();
46 return enter.SetResult(enter.object()->Close(enter.callback()));
49 int32_t SetConfig(PP_Resource image_capture,
50 PP_Resource config,
51 struct PP_CompletionCallback callback) {
52 VLOG(4) << "PPB_ImageCapture_Private::SetConfig()";
53 EnterResource<PPB_ImageCapture_API> enter(image_capture, callback, true);
54 if (enter.failed())
55 return enter.retval();
56 return enter.SetResult(enter.object()->SetConfig(config, enter.callback()));
59 int32_t GetConfig(PP_Resource image_capture,
60 PP_Resource* config,
61 struct PP_CompletionCallback callback) {
62 VLOG(4) << "PPB_ImageCapture_Private::GetConfig()";
63 EnterResource<PPB_ImageCapture_API> enter(image_capture, callback, true);
64 if (enter.failed())
65 return enter.retval();
66 return enter.SetResult(enter.object()->GetConfig(config, enter.callback()));
69 int32_t GetCameraCapabilities(PP_Resource image_capture,
70 PP_Resource* capabilities,
71 struct PP_CompletionCallback callback) {
72 VLOG(4) << "PPB_ImageCapture_Private::GetCameraCapabilities()";
73 EnterResource<PPB_ImageCapture_API> enter(image_capture, callback, true);
74 if (enter.failed())
75 return enter.retval();
76 return enter.SetResult(enter.object()->GetCameraCapabilities(
77 capabilities,
78 enter.callback()));
81 int32_t CaptureStillImage(
82 PP_Resource image_capture,
83 PPB_ImageCapture_Private_ShutterCallback shutter_callback,
84 PPB_ImageCapture_Private_PreviewCallback preview_callback,
85 PPB_ImageCapture_Private_JpegCallback jpeg_callback,
86 int64_t* sequence_id) {
87 VLOG(4) << "PPB_ImageCapture_Private::CaptureStillImage()";
88 EnterResource<PPB_ImageCapture_API> enter(image_capture, true);
89 if (enter.failed())
90 return enter.retval();
91 return enter.object()->CaptureStillImage(shutter_callback,
92 preview_callback,
93 jpeg_callback,
94 sequence_id);
97 const PPB_ImageCapture_Private_0_1 g_ppb_imagecapture_private_thunk_0_1 = {
98 &Create,
99 &IsImageCapture,
100 &Close,
101 &SetConfig,
102 &GetConfig,
103 &GetCameraCapabilities,
104 &CaptureStillImage
107 } // namespace
109 PPAPI_THUNK_EXPORT const PPB_ImageCapture_Private_0_1*
110 GetPPB_ImageCapture_Private_0_1_Thunk() {
111 return &g_ppb_imagecapture_private_thunk_0_1;
114 } // namespace thunk
115 } // namespace ppapi