android/jni/advanced_mode.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 #include "../../../include/librealsense2/rs.h"
7 #include "../../../include/librealsense2/rs_advanced_mode.h"
8 #include "../../api.h"
9 
10 extern "C" JNIEXPORT void JNICALL
12  jlong handle, jboolean enable) {
13  rs2_error* e = NULL;
14  rs2_toggle_advanced_mode(reinterpret_cast<rs2_device *>(handle), enable, &e);
15  handle_error(env, e);
16 }
17 
18 extern "C" JNIEXPORT jboolean JNICALL
20  jlong handle) {
21  rs2_error* e = NULL;
22  int rv = -1;
23  rs2_is_enabled(reinterpret_cast<rs2_device *>(handle), &rv, &e);
24  handle_error(env, e);
25  return rv > 0;
26 }
27 
28 extern "C" JNIEXPORT void JNICALL
30  jlong handle, jbyteArray data_) {
31  jbyte *data = env->GetByteArrayElements(data_, NULL);
32  jsize length = env->GetArrayLength(data_);
33  rs2_error* e = NULL;
34  rs2_load_json(reinterpret_cast<rs2_device *>(handle), data, length, &e);
35  handle_error(env, e);
36  env->ReleaseByteArrayElements(data_, data, 0);
37 }
38 
39 extern "C" JNIEXPORT jbyteArray JNICALL
41  jlong handle) {
42  rs2_error* e = NULL;
43  std::shared_ptr<rs2_raw_data_buffer> raw_data_buffer(
44  rs2_serialize_json(reinterpret_cast<rs2_device *>(handle), &e),
45  [](rs2_raw_data_buffer* buff){ if(buff) delete buff;});
46  handle_error(env, e);
47  jbyteArray rv = env->NewByteArray(raw_data_buffer->buffer.size());
48  env->SetByteArrayRegion(rv, 0, raw_data_buffer->buffer.size(),
49  reinterpret_cast<const jbyte *>(raw_data_buffer->buffer.data()));
50  return rv;
51 }
JNIEXPORT jbyteArray JNICALL Java_com_intel_realsense_librealsense_Device_nSerializePresetToJson(JNIEnv *env, jclass type, jlong handle)
JNIEXPORT void JNICALL Java_com_intel_realsense_librealsense_Device_nToggleAdvancedMode(JNIEnv *env, jclass type, jlong handle, jboolean enable)
void rs2_toggle_advanced_mode(rs2_device *dev, int enable, rs2_error **error)
JNIEXPORT void JNICALL Java_com_intel_realsense_librealsense_Device_nLoadPresetFromJson(JNIEnv *env, jclass type, jlong handle, jbyteArray data_)
void handle_error(JNIEnv *env, rs2_error *error)
Definition: error.cpp:6
void rs2_load_json(rs2_device *dev, const void *json_content, unsigned content_size, rs2_error **error)
Definition: rs.cpp:3331
void rs2_is_enabled(rs2_device *dev, int *enabled, rs2_error **error)
e
Definition: rmse.py:177
rs2_raw_data_buffer * rs2_serialize_json(rs2_device *dev, rs2_error **error)
Definition: rs.cpp:3323
JNIEXPORT jboolean JNICALL Java_com_intel_realsense_librealsense_Device_nIsInAdvancedMode(JNIEnv *env, jclass type, jlong handle)
GLenum type
#define NULL
Definition: tinycthread.c:47
GLenum GLuint GLenum GLsizei length
Definition: parser.hpp:153


librealsense2
Author(s): LibRealSense ROS Team
autogenerated on Thu Dec 22 2022 03:41:41