Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: media/capture/video/android/tango_client_api_glue.cc

Issue 2983473002: Android Tango depth camera capture support.
Patch Set: rename tango_api files to tango_client_api_glue Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 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 "tango_client_api_glue.h"
6
7 #include <dlfcn.h>
8
9 #include "base/logging.h"
10
11 namespace media {
12
13 void* TangoClientApiGlue::handle() {
14 static void* lib = dlopen(
15 "/data/data/com.google.tango/libfiles/armeabi-v7a/"
16 "libtango_client_api.so",
17 RTLD_NOW);
18 DLOG_IF(ERROR, !lib) << "Could not dlopen(\"libtango_client_api\")";
19 return lib;
20 }
21
22 // An example of expanded code for TANGO_METHOD:
23 // TANGO_METHOD(TangoErrorType, TangoService_setBinder, TANGO_ERROR,
24 // void* jni_env, void* iBinder)
25 // expands to:
26 // TangoErrorType TangoService_setBinder(void* jni_env, void* iBinder) {
27 // using TangoService_setBinderPtr = TangoErrorType(*)(void* jni_env,
28 // void* iBinder);
29 // static TangoService_setBinderPtr func =
30 // reinterpret_cast<TangoService_setBinderPtr>(dlsym(lib_, __func__));
31 // if (!func) {
32 // DLOG(ERROR) << "dlsym failed on"<< __func__;
33 // return TANGO_ERROR;
34 // }
35 #define TANGO_METHOD(ret, name, return_on_error, params, ...) \
36 ret TangoClientApiGlue::name(__VA_ARGS__) { \
37 using name##Ptr = ret (*)(__VA_ARGS__); \
38 static name##Ptr func = \
39 reinterpret_cast<name##Ptr>(dlsym(handle(), __func__)); \
40 if (!func) { \
41 DLOG(ERROR) << "dlsym failed on" << __func__; \
42 return return_on_error; \
43 } \
44 return params; \
45 }
46
47 TANGO_METHOD(TangoClientApiGlue::TangoErrorType,
48 TangoService_setBinder,
49 TANGO_METHOD_NOT_FOUND,
50 func(jni_env, iBinder),
51 void* jni_env,
52 void* iBinder)
53
54 TANGO_METHOD(TangoClientApiGlue::TangoConfig,
55 TangoService_getConfig,
56 nullptr,
57 func(config_type),
58 TangoConfigType config_type)
59
60 TANGO_METHOD(TangoClientApiGlue::TangoErrorType,
61 TangoConfig_setBool,
62 TANGO_METHOD_NOT_FOUND,
63 func(config, key, value),
64 TangoConfig config,
65 const char* key,
66 bool value)
67
68 TANGO_METHOD(TangoClientApiGlue::TangoErrorType,
69 TangoConfig_setInt32,
70 TANGO_METHOD_NOT_FOUND,
71 func(config, key, value),
72 TangoConfig config,
73 const char* key,
74 int32_t value)
75
76 TANGO_METHOD(TangoClientApiGlue::TangoErrorType,
77 TangoService_connect,
78 TANGO_METHOD_NOT_FOUND,
79 func(context, config),
80 void* context,
81 TangoConfig config)
82
83 TANGO_METHOD(TangoClientApiGlue::TangoErrorType,
84 TangoService_getCameraIntrinsics,
85 TANGO_METHOD_NOT_FOUND,
86 func(camera_id, intrinsics),
87 TangoCameraId camera_id,
88 TangoCameraIntrinsics* intrinsics)
89
90 TANGO_METHOD(void, TangoService_disconnect, void(), func())
91
92 TangoClientApiGlue::TangoErrorType
93 TangoClientApiGlue::TangoService_connectOnPointCloudAvailable(
94 void (*TangoService_onPointCloudAvailable)(void* context,
95 const TangoPointCloud* cloud),
96 ...) {
97 using TangoService_connectOnPointCloudAvailablePtr =
98 TangoClientApiGlue::TangoErrorType (*)(
99 void (*TangoService_onPointCloudAvailable)(
100 void* context, const TangoPointCloud* cloud),
101 ...);
102 static TangoService_connectOnPointCloudAvailablePtr func =
103 reinterpret_cast<TangoService_connectOnPointCloudAvailablePtr>(
104 dlsym(handle(), __func__));
105 if (!func) {
106 DLOG(ERROR) << "dlsym failed on" << __func__;
107 return TANGO_METHOD_NOT_FOUND;
108 }
109 va_list args;
110 va_start(args, TangoService_onPointCloudAvailable);
111 TangoClientApiGlue::TangoErrorType result =
112 func(TangoService_onPointCloudAvailable, args);
113 va_end(args);
114 return result;
115 }
116
117 } // namespace media
OLDNEW
« no previous file with comments | « media/capture/video/android/tango_client_api_glue.h ('k') | media/capture/video/android/video_capture_device_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698