options.cpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2019 Intel Corporation. All Rights Reserved.
3 
4 #include <jni.h>
5 #include "error.h"
6 
7 #include "../../../include/librealsense2/rs.h"
8 
9 extern "C" JNIEXPORT jboolean JNICALL
11  rs2_error* e = NULL;
12  auto rv = rs2_supports_option((const rs2_options *) handle, (rs2_option) option, &e);
13  handle_error(env, e);
14  return rv > 0;
15 }
16 
17 extern "C" JNIEXPORT void JNICALL
19  jint option, jfloat value) {
20  rs2_error* e = NULL;
21  rs2_set_option(reinterpret_cast<const rs2_options *>(handle), static_cast<rs2_option>(option), value, &e);
22  handle_error(env, e);
23 }
24 
25 extern "C" JNIEXPORT jfloat JNICALL
27  jint option) {
28  rs2_error* e = NULL;
29  float rv = rs2_get_option(reinterpret_cast<const rs2_options *>(handle),
30  static_cast<rs2_option>(option), &e);
31  handle_error(env, e);
32  return rv;
33 }
34 
35 extern "C" JNIEXPORT void JNICALL
37  jint option, jobject outParams) {
38  float min = -1;
39  float max = -1;
40  float step = -1;
41  float def = -1;
42  rs2_error *e = NULL;
43  jclass clazz = env->GetObjectClass(outParams);
44 
45  rs2_get_option_range(reinterpret_cast<const rs2_options *>(handle),
46  static_cast<rs2_option>(option), &min, &max, &step, &def, &e);
47  handle_error(env, e);
48 
49  if(e)
50  return;
51 
52  jfieldID minField = env->GetFieldID(clazz, "min", "F");
53  jfieldID maxField = env->GetFieldID(clazz, "max", "F");
54  jfieldID stepField = env->GetFieldID(clazz, "step", "F");
55  jfieldID defField = env->GetFieldID(clazz, "def", "F");
56 
57  env->SetFloatField(outParams, minField, min);
58  env->SetFloatField(outParams, maxField, max);
59  env->SetFloatField(outParams, stepField, step);
60  env->SetFloatField(outParams, defField, def);
61 }
62 
63 extern "C" JNIEXPORT jboolean JNICALL
65  jint option) {
66  rs2_error* e = NULL;
67  int rv = rs2_is_option_read_only(reinterpret_cast<const rs2_options *>(handle),
68  static_cast<rs2_option>(option), &e);
69  handle_error(env, e);
70  return rv > 0;
71 }
72 
73 extern "C" JNIEXPORT jstring JNICALL
75  jlong handle, jint option) {
76  rs2_error* e = NULL;
77  const char *rv = rs2_get_option_description(reinterpret_cast<const rs2_options *>(handle),
78  static_cast<rs2_option>(option), &e);
79  handle_error(env, e);
80  return env->NewStringUTF(rv);
81 }
82 
83 extern "C" JNIEXPORT jstring JNICALL
85  jlong handle, jint option,
86  jfloat value) {
87  rs2_error* e = NULL;
88  const char *rv = rs2_get_option_value_description(reinterpret_cast<const rs2_options *>(handle),
89  static_cast<rs2_option>(option), value, &e);
90  handle_error(env, e);
91  return env->NewStringUTF(rv);
92 }
float rs2_get_option(const rs2_options *options, rs2_option option, rs2_error **error)
Definition: rs.cpp:628
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls...
Definition: rs_option.h:22
GLuint64 GLenum void * handle
Definition: glext.h:7785
GLfloat value
void handle_error(JNIEnv *env, rs2_error *error)
Definition: error.cpp:6
e
Definition: rmse.py:177
JNIEXPORT jboolean JNICALL Java_com_intel_realsense_librealsense_Options_nIsReadOnly(JNIEnv *env, jclass type, jlong handle, jint option)
Definition: options.cpp:64
int rs2_supports_option(const rs2_options *options, rs2_option option, rs2_error **error)
Definition: rs.cpp:679
Definition: getopt.h:41
const char * rs2_get_option_value_description(const rs2_options *options, rs2_option option, float value, rs2_error **error)
Definition: rs.cpp:1022
void rs2_get_option_range(const rs2_options *sensor, rs2_option option, float *min, float *max, float *step, float *def, rs2_error **error)
Definition: rs.cpp:686
JNIEXPORT void JNICALL Java_com_intel_realsense_librealsense_Options_nGetRange(JNIEnv *env, jclass type, jlong handle, jint option, jobject outParams)
Definition: options.cpp:36
JNIEXPORT jboolean JNICALL Java_com_intel_realsense_librealsense_Options_nSupports(JNIEnv *env, jclass type, jlong handle, jint option)
Definition: options.cpp:10
GLenum type
int min(int a, int b)
Definition: lz4s.c:73
JNIEXPORT void JNICALL Java_com_intel_realsense_librealsense_Options_nSetValue(JNIEnv *env, jclass type, jlong handle, jint option, jfloat value)
Definition: options.cpp:18
const char * rs2_get_option_description(const rs2_options *options, rs2_option option, rs2_error **error)
Definition: rs.cpp:1007
int rs2_is_option_read_only(const rs2_options *options, rs2_option option, rs2_error **error)
Definition: rs.cpp:621
#define NULL
Definition: tinycthread.c:47
JNIEXPORT jstring JNICALL Java_com_intel_realsense_librealsense_Options_nGetDescription(JNIEnv *env, jclass type, jlong handle, jint option)
Definition: options.cpp:74
JNIEXPORT jstring JNICALL Java_com_intel_realsense_librealsense_Options_nGetValueDescription(JNIEnv *env, jclass type, jlong handle, jint option, jfloat value)
Definition: options.cpp:84
void rs2_set_option(const rs2_options *options, rs2_option option, float value, rs2_error **error)
Definition: rs.cpp:636
JNIEXPORT jfloat JNICALL Java_com_intel_realsense_librealsense_Options_nGetValue(JNIEnv *env, jclass type, jlong handle, jint option)
Definition: options.cpp:26


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:39