diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/device.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/device.hpp index 6e0214f..bc620a6 100644 --- a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/device.hpp +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/device.hpp @@ -3,29 +3,55 @@ #pragma once +#include "device_usb_info.hpp" +#include "motion_data.hpp" +#include "source.hpp" +#include "stream.hpp" +#include "stream_data.hpp" +#include "stream_request.hpp" +#include #include #include namespace mynteye_jni { -struct DeviceUsbInfo; -struct StreamRequest; - +/** Device class to communicate with MYNT® EYE device */ class Device { public: virtual ~Device() {} - static std::vector Query(); + /** Query devices */ + static std::vector<::mynteye_jni::DeviceUsbInfo> Query(); - static std::shared_ptr Create(const DeviceUsbInfo & info); + /** Create the device instance */ + static std::shared_ptr Create(const ::mynteye_jni::DeviceUsbInfo & info); - virtual std::vector GetStreamRequests() = 0; + /** Get all stream requests */ + virtual std::vector<::mynteye_jni::StreamRequest> GetStreamRequests() = 0; - virtual void ConfigStreamRequest(const StreamRequest & request) = 0; + /** Config the stream request */ + virtual void ConfigStreamRequest(const ::mynteye_jni::StreamRequest & request) = 0; - virtual void Start() = 0; + /** Start capturing the source */ + virtual void Start(::mynteye_jni::Source source) = 0; - virtual void Stop() = 0; + /** Stop capturing the source */ + virtual void Stop(::mynteye_jni::Source source) = 0; + + /** Wait the streams are ready */ + virtual void WaitForStreams() = 0; + + /** Get the latest data of stream */ + virtual std::shared_ptr<::mynteye_jni::StreamData> GetStreamData(::mynteye_jni::Stream stream) = 0; + + /** Get the datas of stream */ + virtual std::vector> GetStreamDatas(::mynteye_jni::Stream stream) = 0; + + /** Enable cache motion datas */ + virtual void EnableCacheMotionDatas(int32_t max_size) = 0; + + /** Get the motion datas */ + virtual std::vector> GetMotionDatas() = 0; }; } // namespace mynteye_jni diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/device_usb_info.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/device_usb_info.hpp index 5f93d25..3ba215d 100644 --- a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/device_usb_info.hpp +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/device_usb_info.hpp @@ -1,5 +1,5 @@ // AUTOGENERATED FILE - DO NOT MODIFY! -// This file generated by Djinni from mynteye.djinni +// This file generated by Djinni from mynteye_types.djinni #pragma once @@ -9,9 +9,13 @@ namespace mynteye_jni { +/** Device USB information */ struct DeviceUsbInfo final { + /** Device index */ int32_t index; + /** Device name */ std::string name; + /** Device serial number */ std::string sn; DeviceUsbInfo(int32_t index_, diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/format.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/format.hpp index 55febf5..69c9ee0 100644 --- a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/format.hpp +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/format.hpp @@ -1,5 +1,5 @@ // AUTOGENERATED FILE - DO NOT MODIFY! -// This file generated by Djinni from mynteye.djinni +// This file generated by Djinni from mynteye_types.djinni #pragma once @@ -8,9 +8,13 @@ namespace mynteye_jni { enum class Format : int { + /** Greyscale, 8 bits per pixel */ GREY, + /** YUV 4:2:2, 16 bits per pixel */ YUYV, + /** BGR 8:8:8, 24 bits per pixel */ BGR888, + /** RGB 8:8:8, 24 bits per pixel */ RGB888, }; diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/frame.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/frame.hpp new file mode 100644 index 0000000..ad8dd43 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/frame.hpp @@ -0,0 +1,34 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +#pragma once + +#include +#include + +namespace mynteye_jni { + +enum class Format; + +/** Frame with raw data */ +class Frame { +public: + virtual ~Frame() {} + + /** Get the width */ + virtual int32_t Width() = 0; + + /** Get the height */ + virtual int32_t Height() = 0; + + /** Get the pixel format */ + virtual ::mynteye_jni::Format Format() = 0; + + /** Get the size */ + virtual int32_t Size() = 0; + + /** Get the data */ + virtual std::vector Data() = 0; +}; + +} // namespace mynteye_jni diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/img_data.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/img_data.hpp new file mode 100644 index 0000000..160b314 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/img_data.hpp @@ -0,0 +1,29 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +#pragma once + +#include +#include + +namespace mynteye_jni { + +/** Image data */ +struct ImgData final { + /** Image frame id */ + int64_t frame_id; + /** Image timestamp in 1us */ + int64_t timestamp; + /** Image exposure time, virtual value in [1, 480] */ + int64_t exposure_time; + + ImgData(int64_t frame_id_, + int64_t timestamp_, + int64_t exposure_time_) + : frame_id(std::move(frame_id_)) + , timestamp(std::move(timestamp_)) + , exposure_time(std::move(exposure_time_)) + {} +}; + +} // namespace mynteye_jni diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/imu_data.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/imu_data.hpp new file mode 100644 index 0000000..05f2a65 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/imu_data.hpp @@ -0,0 +1,47 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +#pragma once + +#include +#include +#include + +namespace mynteye_jni { + +/** IMU data */ +struct ImuData final { + /** IMU frame id */ + int64_t frame_id; + /** + * IMU accel or gyro flag + * 0: accel and gyro are both valid + * 1: accel is valid + * 2: gyro is valid + */ + int32_t flag; + /** IMU timestamp in 1us */ + int64_t timestamp; + /** IMU accelerometer data for 3-axis: X, Y, Z. */ + std::vector accel; + /** IMU gyroscope data for 3-axis: X, Y, Z. */ + std::vector gyro; + /** IMU temperature */ + double temperature; + + ImuData(int64_t frame_id_, + int32_t flag_, + int64_t timestamp_, + std::vector accel_, + std::vector gyro_, + double temperature_) + : frame_id(std::move(frame_id_)) + , flag(std::move(flag_)) + , timestamp(std::move(timestamp_)) + , accel(std::move(accel_)) + , gyro(std::move(gyro_)) + , temperature(std::move(temperature_)) + {} +}; + +} // namespace mynteye_jni diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/model.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/model.hpp new file mode 100644 index 0000000..6404632 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/model.hpp @@ -0,0 +1,30 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +#pragma once + +#include + +namespace mynteye_jni { + +enum class Model : int { + /** Standard */ + STANDARD, + /** Standard 2 */ + STANDARD2, + /** Standard 210a */ + STANDARD210A, +}; + +} // namespace mynteye_jni + +namespace std { + +template <> +struct hash<::mynteye_jni::Model> { + size_t operator()(::mynteye_jni::Model type) const { + return std::hash()(static_cast(type)); + } +}; + +} // namespace std diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/motion_data.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/motion_data.hpp new file mode 100644 index 0000000..21b66ad --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/motion_data.hpp @@ -0,0 +1,18 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +#pragma once + +namespace mynteye_jni { + +struct ImuData; + +/** Device motion data */ +class MotionData { +public: + virtual ~MotionData() {} + + virtual ImuData Imu() = 0; +}; + +} // namespace mynteye_jni diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/source.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/source.hpp new file mode 100644 index 0000000..d2bbb38 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/source.hpp @@ -0,0 +1,30 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +#pragma once + +#include + +namespace mynteye_jni { + +enum class Source : int { + /** Video streaming of stereo, color, depth, etc. */ + VIDEO_STREAMING, + /** Motion tracking of IMU (accelerometer, gyroscope) */ + MOTION_TRACKING, + /** Enable everything together */ + ALL, +}; + +} // namespace mynteye_jni + +namespace std { + +template <> +struct hash<::mynteye_jni::Source> { + size_t operator()(::mynteye_jni::Source type) const { + return std::hash()(static_cast(type)); + } +}; + +} // namespace std diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/stream.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/stream.hpp new file mode 100644 index 0000000..e21a691 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/stream.hpp @@ -0,0 +1,28 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +#pragma once + +#include + +namespace mynteye_jni { + +enum class Stream : int { + /** Left stream */ + LEFT, + /** Right stream */ + RIGHT, +}; + +} // namespace mynteye_jni + +namespace std { + +template <> +struct hash<::mynteye_jni::Stream> { + size_t operator()(::mynteye_jni::Stream type) const { + return std::hash()(static_cast(type)); + } +}; + +} // namespace std diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/stream_data.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/stream_data.hpp new file mode 100644 index 0000000..3f3899b --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/stream_data.hpp @@ -0,0 +1,26 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +#pragma once + +#include +#include + +namespace mynteye_jni { + +class Frame; +struct ImgData; + +/** Device stream data */ +class StreamData { +public: + virtual ~StreamData() {} + + virtual ImgData Img() = 0; + + virtual std::shared_ptr<::mynteye_jni::Frame> Frame() = 0; + + virtual int64_t FrameId() = 0; +}; + +} // namespace mynteye_jni diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/stream_request.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/stream_request.hpp index 0238c74..a708025 100644 --- a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/stream_request.hpp +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/stream_request.hpp @@ -1,5 +1,5 @@ // AUTOGENERATED FILE - DO NOT MODIFY! -// This file generated by Djinni from mynteye.djinni +// This file generated by Djinni from mynteye_types.djinni #pragma once @@ -9,11 +9,17 @@ namespace mynteye_jni { +/** Stream request */ struct StreamRequest final { + /** Stream index */ int32_t index; + /** Stream width in pixels */ int32_t width; + /** Stream height in pixels */ int32_t height; + /** Stream pixel format */ Format format; + /** Stream frames per second */ int32_t fps; StreamRequest(int32_t index_, diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/device_impl.cpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/device_impl.cpp index 8677b10..a35561b 100644 --- a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/device_impl.cpp +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/device_impl.cpp @@ -8,11 +8,15 @@ #include "stream_request.hpp" #include "type_conversion.hpp" +#include "frame_impl.hpp" +#include "motion_data_impl.hpp" +#include "stream_data_impl.hpp" + MYNTEYE_USE_NAMESPACE namespace mynteye_jni { -std::vector Device::Query() { +std::vector<::mynteye_jni::DeviceUsbInfo> Device::Query() { VLOG(2) << __func__; std::vector infos; @@ -28,7 +32,7 @@ std::vector Device::Query() { return infos; } -std::shared_ptr Device::Create(const DeviceUsbInfo & info) { +std::shared_ptr Device::Create(const ::mynteye_jni::DeviceUsbInfo & info) { VLOG(2) << __func__; Context context; int32_t i = 0; @@ -49,9 +53,9 @@ DeviceImpl::~DeviceImpl() { VLOG(2) << __func__; } -std::vector DeviceImpl::GetStreamRequests() { +std::vector<::mynteye_jni::StreamRequest> DeviceImpl::GetStreamRequests() { VLOG(2) << __func__; - std::vector requests; + std::vector<::mynteye_jni::StreamRequest> requests; int32_t i = 0; for (auto&& req : device_->GetStreamRequests()) { @@ -63,7 +67,8 @@ std::vector DeviceImpl::GetStreamRequests() { return requests; } -void DeviceImpl::ConfigStreamRequest(const StreamRequest & request) { +void DeviceImpl::ConfigStreamRequest( + const ::mynteye_jni::StreamRequest & request) { VLOG(2) << __func__; int32_t i = 0; for (auto&& req : device_->GetStreamRequests()) { @@ -75,12 +80,31 @@ void DeviceImpl::ConfigStreamRequest(const StreamRequest & request) { } } -void DeviceImpl::Start() { - VLOG(2) << __func__; +void DeviceImpl::Start(::mynteye_jni::Source source) { } -void DeviceImpl::Stop() { - VLOG(2) << __func__; +void DeviceImpl::Stop(::mynteye_jni::Source source) { +} + +void DeviceImpl::WaitForStreams() { +} + +std::shared_ptr<::mynteye_jni::StreamData> DeviceImpl::GetStreamData( + ::mynteye_jni::Stream stream) { + return nullptr; +} + +std::vector> +DeviceImpl::GetStreamDatas(::mynteye_jni::Stream stream) { + return {}; +} + +void DeviceImpl::EnableCacheMotionDatas(int32_t max_size) { +} + +std::vector> +DeviceImpl::GetMotionDatas() { + return {}; } } // namespace mynteye_jni diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/device_impl.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/device_impl.hpp index 9462704..1a555bb 100644 --- a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/device_impl.hpp +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/device_impl.hpp @@ -16,13 +16,32 @@ class DeviceImpl : public Device { explicit DeviceImpl(const device_t & device); ~DeviceImpl(); - std::vector GetStreamRequests() override; + /** Get all stream requests */ + std::vector<::mynteye_jni::StreamRequest> GetStreamRequests() override; - void ConfigStreamRequest(const StreamRequest & request) override; + /** Config the stream request */ + void ConfigStreamRequest(const ::mynteye_jni::StreamRequest & request) override; - void Start() override; + /** Start capturing the source */ + void Start(::mynteye_jni::Source source) override; - void Stop() override; + /** Stop capturing the source */ + void Stop(::mynteye_jni::Source source) override; + + /** Wait the streams are ready */ + void WaitForStreams() override; + + /** Get the latest data of stream */ + std::shared_ptr<::mynteye_jni::StreamData> GetStreamData(::mynteye_jni::Stream stream) override; + + /** Get the datas of stream */ + std::vector> GetStreamDatas(::mynteye_jni::Stream stream) override; + + /** Enable cache motion datas */ + void EnableCacheMotionDatas(int32_t max_size) override; + + /** Get the motion datas */ + std::vector> GetMotionDatas() override; private: device_t device_; diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/frame_impl.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/frame_impl.hpp new file mode 100644 index 0000000..01225b6 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/frame_impl.hpp @@ -0,0 +1,46 @@ +#pragma once + +#include "mynteye/device/callbacks.h" + +#include "frame.hpp" +#include "type_conversion.hpp" + +namespace mynteye_jni { + +class FrameImpl : public Frame { + public: + using frame_t = std::shared_ptr; + + explicit FrameImpl(const frame_t& frame) : frame_(frame) {} + ~FrameImpl() {} + + /** Get the width */ + int32_t Width() override { + return frame_->width(); + } + + /** Get the height */ + int32_t Height() override { + return frame_->height(); + } + + /** Get the pixel format */ + ::mynteye_jni::Format Format() override { + return to_jni(frame_->format()); + } + + /** Get the size */ + int32_t Size() override { + return frame_->size(); + } + + /** Get the data */ + std::vector Data() override { + return std::vector(frame_->data(), frame_->data() + frame_->size()); + } + + private: + frame_t frame_; +}; + +} // namespace mynteye_jni diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/motion_data_impl.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/motion_data_impl.hpp new file mode 100644 index 0000000..45db7aa --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/motion_data_impl.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include "mynteye/device/callbacks.h" + +#include "imu_data.hpp" +#include "motion_data.hpp" + +namespace mynteye_jni { + +class MotionDataImpl : public MotionData { + public: + using motion_data_t = std::shared_ptr; + + explicit MotionDataImpl(const motion_data_t& data) : data_(data) {} + ~MotionDataImpl() {} + + ImuData Imu() override { + auto&& imu = data_->imu; + return { + imu->frame_id, + imu->flag, + static_cast(imu->timestamp), + std::vector(imu->accel, imu->accel + 3), + std::vector(imu->gyro, imu->gyro + 3), + imu->temperature, + }; + } + + private: + motion_data_t data_; +}; + +} // namespace mynteye_jni diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/stream_data_impl.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/stream_data_impl.hpp new file mode 100644 index 0000000..8e3d5db --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/stream_data_impl.hpp @@ -0,0 +1,39 @@ +#pragma once + +#include "mynteye/device/callbacks.h" + +#include "frame_impl.hpp" +#include "img_data.hpp" +#include "stream_data.hpp" + +namespace mynteye_jni { + +class StreamDataImpl : public StreamData { + public: + using stream_data_t = std::shared_ptr; + + explicit StreamDataImpl(const stream_data_t& data) : data_(data) {} + ~StreamDataImpl() {} + + ImgData Img() override { + auto&& img = data_->img; + return { + img->frame_id, + static_cast(img->timestamp), + img->exposure_time, + }; + } + + std::shared_ptr<::mynteye_jni::Frame> Frame() override { + return std::make_shared<::mynteye_jni::FrameImpl>(data_->frame); + } + + int64_t FrameId() override { + return data_->frame_id; + } + + private: + stream_data_t data_; +}; + +} // namespace mynteye_jni diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/type_conversion.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/type_conversion.hpp index b705f26..f4b600b 100644 --- a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/type_conversion.hpp +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/type_conversion.hpp @@ -1,12 +1,42 @@ +#pragma once + #include #include "mynteye/logger.h" #include "mynteye/types.h" #include "format.hpp" +#include "model.hpp" +#include "source.hpp" +#include "stream.hpp" namespace mynteye_jni { +using RawModel = MYNTEYE_NAMESPACE::Model; +using JniModel = mynteye_jni::Model; + +inline +RawModel from_jni(const JniModel& model) { + switch (model) { + case JniModel::STANDARD: return RawModel::STANDARD; + case JniModel::STANDARD2: return RawModel::STANDARD2; + case JniModel::STANDARD210A: return RawModel::STANDARD210A; + default: + LOG(FATAL) << "Model is unknown"; + } +} + +inline +JniModel to_jni(const RawModel& model) { + switch (model) { + case RawModel::STANDARD: return JniModel::STANDARD; + case RawModel::STANDARD2: return JniModel::STANDARD2; + case RawModel::STANDARD210A: return JniModel::STANDARD210A; + default: + LOG(FATAL) << "Model is unknown"; + } +} + using RawFormat = MYNTEYE_NAMESPACE::Format; using JniFormat = mynteye_jni::Format; @@ -34,4 +64,52 @@ JniFormat to_jni(const RawFormat& format) { } } +using RawSource = MYNTEYE_NAMESPACE::Source; +using JniSource = mynteye_jni::Source; + +inline +RawSource from_jni(const JniSource& source) { + switch (source) { + case JniSource::VIDEO_STREAMING: return RawSource::VIDEO_STREAMING; + case JniSource::MOTION_TRACKING: return RawSource::MOTION_TRACKING; + case JniSource::ALL: return RawSource::ALL; + default: + LOG(FATAL) << "Source is unknown"; + } +} + +inline +JniSource to_jni(const RawSource& source) { + switch (source) { + case RawSource::VIDEO_STREAMING: return JniSource::VIDEO_STREAMING; + case RawSource::MOTION_TRACKING: return JniSource::MOTION_TRACKING; + case RawSource::ALL: return JniSource::ALL; + default: + LOG(FATAL) << "Source is unknown"; + } +} + +using RawStream = MYNTEYE_NAMESPACE::Stream; +using JniStream = mynteye_jni::Stream; + +inline +RawStream from_jni(const JniStream& stream) { + switch (stream) { + case JniStream::LEFT: return RawStream::LEFT; + case JniStream::RIGHT: return RawStream::RIGHT; + default: + LOG(FATAL) << "Stream is unknown"; + } +} + +inline +JniStream to_jni(const RawStream& stream) { + switch (stream) { + case RawStream::LEFT: return JniStream::LEFT; + case RawStream::RIGHT: return JniStream::RIGHT; + default: + LOG(FATAL) << "Stream is unknown"; + } +} + } // namespace mynteye_jni diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeDevice.cpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeDevice.cpp index a551ac0..1673a2a 100644 --- a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeDevice.cpp +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeDevice.cpp @@ -4,6 +4,10 @@ #include "NativeDevice.hpp" // my header #include "Marshal.hpp" #include "NativeDeviceUsbInfo.hpp" +#include "NativeMotionData.hpp" +#include "NativeSource.hpp" +#include "NativeStream.hpp" +#include "NativeStreamData.hpp" #include "NativeStreamRequest.hpp" namespace djinni_generated { @@ -30,7 +34,7 @@ CJNIEXPORT jobject JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_query } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) } -CJNIEXPORT jobject JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_create(JNIEnv* jniEnv, jobject /*this*/, jobject j_info) +CJNIEXPORT jobject JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_create(JNIEnv* jniEnv, jobject /*this*/, ::djinni_generated::NativeDeviceUsbInfo::JniType j_info) { try { DJINNI_FUNCTION_PROLOGUE0(jniEnv); @@ -49,7 +53,7 @@ CJNIEXPORT jobject JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_nativ } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) } -CJNIEXPORT void JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_native_1configStreamRequest(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, jobject j_request) +CJNIEXPORT void JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_native_1configStreamRequest(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, ::djinni_generated::NativeStreamRequest::JniType j_request) { try { DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); @@ -58,22 +62,70 @@ CJNIEXPORT void JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_native_1 } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) } -CJNIEXPORT void JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_native_1start(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +CJNIEXPORT void JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_native_1start(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, ::djinni_generated::NativeSource::JniType j_source) { try { DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); const auto& ref = ::djinni::objectFromHandleAddress<::mynteye_jni::Device>(nativeRef); - ref->Start(); + ref->Start(::djinni_generated::NativeSource::toCpp(jniEnv, j_source)); } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) } -CJNIEXPORT void JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_native_1stop(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +CJNIEXPORT void JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_native_1stop(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, ::djinni_generated::NativeSource::JniType j_source) { try { DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); const auto& ref = ::djinni::objectFromHandleAddress<::mynteye_jni::Device>(nativeRef); - ref->Stop(); + ref->Stop(::djinni_generated::NativeSource::toCpp(jniEnv, j_source)); } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) } +CJNIEXPORT void JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_native_1waitForStreams(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::mynteye_jni::Device>(nativeRef); + ref->WaitForStreams(); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) +} + +CJNIEXPORT ::djinni_generated::NativeStreamData::JniType JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_native_1getStreamData(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, ::djinni_generated::NativeStream::JniType j_stream) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::mynteye_jni::Device>(nativeRef); + auto r = ref->GetStreamData(::djinni_generated::NativeStream::toCpp(jniEnv, j_stream)); + return ::djinni::release(::djinni_generated::NativeStreamData::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +CJNIEXPORT jobject JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_native_1getStreamDatas(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, ::djinni_generated::NativeStream::JniType j_stream) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::mynteye_jni::Device>(nativeRef); + auto r = ref->GetStreamDatas(::djinni_generated::NativeStream::toCpp(jniEnv, j_stream)); + return ::djinni::release(::djinni::List<::djinni_generated::NativeStreamData>::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +CJNIEXPORT void JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_native_1enableCacheMotionDatas(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, jint j_maxSize) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::mynteye_jni::Device>(nativeRef); + ref->EnableCacheMotionDatas(::djinni::I32::toCpp(jniEnv, j_maxSize)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) +} + +CJNIEXPORT jobject JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_native_1getMotionDatas(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::mynteye_jni::Device>(nativeRef); + auto r = ref->GetMotionDatas(); + return ::djinni::release(::djinni::List<::djinni_generated::NativeMotionData>::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + } // namespace djinni_generated diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeDeviceUsbInfo.cpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeDeviceUsbInfo.cpp index 755af55..b26ee82 100644 --- a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeDeviceUsbInfo.cpp +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeDeviceUsbInfo.cpp @@ -1,5 +1,5 @@ // AUTOGENERATED FILE - DO NOT MODIFY! -// This file generated by Djinni from mynteye.djinni +// This file generated by Djinni from mynteye_types.djinni #include "NativeDeviceUsbInfo.hpp" // my header #include "Marshal.hpp" diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeDeviceUsbInfo.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeDeviceUsbInfo.hpp index 0d8b5f3..f29492b 100644 --- a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeDeviceUsbInfo.hpp +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeDeviceUsbInfo.hpp @@ -1,5 +1,5 @@ // AUTOGENERATED FILE - DO NOT MODIFY! -// This file generated by Djinni from mynteye.djinni +// This file generated by Djinni from mynteye_types.djinni #pragma once diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeFormat.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeFormat.hpp index 36cf938..437505e 100644 --- a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeFormat.hpp +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeFormat.hpp @@ -1,5 +1,5 @@ // AUTOGENERATED FILE - DO NOT MODIFY! -// This file generated by Djinni from mynteye.djinni +// This file generated by Djinni from mynteye_types.djinni #pragma once diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeFrame.cpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeFrame.cpp new file mode 100644 index 0000000..c5cb443 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeFrame.cpp @@ -0,0 +1,73 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +#include "NativeFrame.hpp" // my header +#include "Marshal.hpp" +#include "NativeFormat.hpp" + +namespace djinni_generated { + +NativeFrame::NativeFrame() : ::djinni::JniInterface<::mynteye_jni::Frame, NativeFrame>("com/slightech/mynteye/Frame$CppProxy") {} + +NativeFrame::~NativeFrame() = default; + + +CJNIEXPORT void JNICALL Java_com_slightech_mynteye_Frame_00024CppProxy_nativeDestroy(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + delete reinterpret_cast<::djinni::CppProxyHandle<::mynteye_jni::Frame>*>(nativeRef); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) +} + +CJNIEXPORT jint JNICALL Java_com_slightech_mynteye_Frame_00024CppProxy_native_1width(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::mynteye_jni::Frame>(nativeRef); + auto r = ref->Width(); + return ::djinni::release(::djinni::I32::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +CJNIEXPORT jint JNICALL Java_com_slightech_mynteye_Frame_00024CppProxy_native_1height(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::mynteye_jni::Frame>(nativeRef); + auto r = ref->Height(); + return ::djinni::release(::djinni::I32::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +CJNIEXPORT jobject JNICALL Java_com_slightech_mynteye_Frame_00024CppProxy_native_1format(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::mynteye_jni::Frame>(nativeRef); + auto r = ref->Format(); + return ::djinni::release(::djinni_generated::NativeFormat::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +CJNIEXPORT jint JNICALL Java_com_slightech_mynteye_Frame_00024CppProxy_native_1size(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::mynteye_jni::Frame>(nativeRef); + auto r = ref->Size(); + return ::djinni::release(::djinni::I32::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +CJNIEXPORT jbyteArray JNICALL Java_com_slightech_mynteye_Frame_00024CppProxy_native_1data(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::mynteye_jni::Frame>(nativeRef); + auto r = ref->Data(); + return ::djinni::release(::djinni::Binary::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +} // namespace djinni_generated diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeFrame.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeFrame.hpp new file mode 100644 index 0000000..44c7216 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeFrame.hpp @@ -0,0 +1,32 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +#pragma once + +#include "djinni_support.hpp" +#include "frame.hpp" + +namespace djinni_generated { + +class NativeFrame final : ::djinni::JniInterface<::mynteye_jni::Frame, NativeFrame> { +public: + using CppType = std::shared_ptr<::mynteye_jni::Frame>; + using CppOptType = std::shared_ptr<::mynteye_jni::Frame>; + using JniType = jobject; + + using Boxed = NativeFrame; + + ~NativeFrame(); + + static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass::get()._fromJava(jniEnv, j); } + static ::djinni::LocalRef fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass::get()._toJava(jniEnv, c)}; } + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); } + +private: + NativeFrame(); + friend ::djinni::JniClass; + friend ::djinni::JniInterface<::mynteye_jni::Frame, NativeFrame>; + +}; + +} // namespace djinni_generated diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeImgData.cpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeImgData.cpp new file mode 100644 index 0000000..cd97986 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeImgData.cpp @@ -0,0 +1,32 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +#include "NativeImgData.hpp" // my header +#include "Marshal.hpp" + +namespace djinni_generated { + +NativeImgData::NativeImgData() = default; + +NativeImgData::~NativeImgData() = default; + +auto NativeImgData::fromCpp(JNIEnv* jniEnv, const CppType& c) -> ::djinni::LocalRef { + const auto& data = ::djinni::JniClass::get(); + auto r = ::djinni::LocalRef{jniEnv->NewObject(data.clazz.get(), data.jconstructor, + ::djinni::get(::djinni::I64::fromCpp(jniEnv, c.frame_id)), + ::djinni::get(::djinni::I64::fromCpp(jniEnv, c.timestamp)), + ::djinni::get(::djinni::I64::fromCpp(jniEnv, c.exposure_time)))}; + ::djinni::jniExceptionCheck(jniEnv); + return r; +} + +auto NativeImgData::toCpp(JNIEnv* jniEnv, JniType j) -> CppType { + ::djinni::JniLocalScope jscope(jniEnv, 4); + assert(j != nullptr); + const auto& data = ::djinni::JniClass::get(); + return {::djinni::I64::toCpp(jniEnv, jniEnv->GetLongField(j, data.field_mFrameId)), + ::djinni::I64::toCpp(jniEnv, jniEnv->GetLongField(j, data.field_mTimestamp)), + ::djinni::I64::toCpp(jniEnv, jniEnv->GetLongField(j, data.field_mExposureTime))}; +} + +} // namespace djinni_generated diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeImgData.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeImgData.hpp new file mode 100644 index 0000000..a254254 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeImgData.hpp @@ -0,0 +1,34 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +#pragma once + +#include "djinni_support.hpp" +#include "img_data.hpp" + +namespace djinni_generated { + +class NativeImgData final { +public: + using CppType = ::mynteye_jni::ImgData; + using JniType = jobject; + + using Boxed = NativeImgData; + + ~NativeImgData(); + + static CppType toCpp(JNIEnv* jniEnv, JniType j); + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, const CppType& c); + +private: + NativeImgData(); + friend ::djinni::JniClass; + + const ::djinni::GlobalRef clazz { ::djinni::jniFindClass("com/slightech/mynteye/ImgData") }; + const jmethodID jconstructor { ::djinni::jniGetMethodID(clazz.get(), "", "(JJJ)V") }; + const jfieldID field_mFrameId { ::djinni::jniGetFieldID(clazz.get(), "mFrameId", "J") }; + const jfieldID field_mTimestamp { ::djinni::jniGetFieldID(clazz.get(), "mTimestamp", "J") }; + const jfieldID field_mExposureTime { ::djinni::jniGetFieldID(clazz.get(), "mExposureTime", "J") }; +}; + +} // namespace djinni_generated diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeImuData.cpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeImuData.cpp new file mode 100644 index 0000000..46dce8c --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeImuData.cpp @@ -0,0 +1,38 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +#include "NativeImuData.hpp" // my header +#include "Marshal.hpp" + +namespace djinni_generated { + +NativeImuData::NativeImuData() = default; + +NativeImuData::~NativeImuData() = default; + +auto NativeImuData::fromCpp(JNIEnv* jniEnv, const CppType& c) -> ::djinni::LocalRef { + const auto& data = ::djinni::JniClass::get(); + auto r = ::djinni::LocalRef{jniEnv->NewObject(data.clazz.get(), data.jconstructor, + ::djinni::get(::djinni::I64::fromCpp(jniEnv, c.frame_id)), + ::djinni::get(::djinni::I32::fromCpp(jniEnv, c.flag)), + ::djinni::get(::djinni::I64::fromCpp(jniEnv, c.timestamp)), + ::djinni::get(::djinni::List<::djinni::F64>::fromCpp(jniEnv, c.accel)), + ::djinni::get(::djinni::List<::djinni::F64>::fromCpp(jniEnv, c.gyro)), + ::djinni::get(::djinni::F64::fromCpp(jniEnv, c.temperature)))}; + ::djinni::jniExceptionCheck(jniEnv); + return r; +} + +auto NativeImuData::toCpp(JNIEnv* jniEnv, JniType j) -> CppType { + ::djinni::JniLocalScope jscope(jniEnv, 7); + assert(j != nullptr); + const auto& data = ::djinni::JniClass::get(); + return {::djinni::I64::toCpp(jniEnv, jniEnv->GetLongField(j, data.field_mFrameId)), + ::djinni::I32::toCpp(jniEnv, jniEnv->GetIntField(j, data.field_mFlag)), + ::djinni::I64::toCpp(jniEnv, jniEnv->GetLongField(j, data.field_mTimestamp)), + ::djinni::List<::djinni::F64>::toCpp(jniEnv, jniEnv->GetObjectField(j, data.field_mAccel)), + ::djinni::List<::djinni::F64>::toCpp(jniEnv, jniEnv->GetObjectField(j, data.field_mGyro)), + ::djinni::F64::toCpp(jniEnv, jniEnv->GetDoubleField(j, data.field_mTemperature))}; +} + +} // namespace djinni_generated diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeImuData.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeImuData.hpp new file mode 100644 index 0000000..0345ff0 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeImuData.hpp @@ -0,0 +1,37 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +#pragma once + +#include "djinni_support.hpp" +#include "imu_data.hpp" + +namespace djinni_generated { + +class NativeImuData final { +public: + using CppType = ::mynteye_jni::ImuData; + using JniType = jobject; + + using Boxed = NativeImuData; + + ~NativeImuData(); + + static CppType toCpp(JNIEnv* jniEnv, JniType j); + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, const CppType& c); + +private: + NativeImuData(); + friend ::djinni::JniClass; + + const ::djinni::GlobalRef clazz { ::djinni::jniFindClass("com/slightech/mynteye/ImuData") }; + const jmethodID jconstructor { ::djinni::jniGetMethodID(clazz.get(), "", "(JIJLjava/util/ArrayList;Ljava/util/ArrayList;D)V") }; + const jfieldID field_mFrameId { ::djinni::jniGetFieldID(clazz.get(), "mFrameId", "J") }; + const jfieldID field_mFlag { ::djinni::jniGetFieldID(clazz.get(), "mFlag", "I") }; + const jfieldID field_mTimestamp { ::djinni::jniGetFieldID(clazz.get(), "mTimestamp", "J") }; + const jfieldID field_mAccel { ::djinni::jniGetFieldID(clazz.get(), "mAccel", "Ljava/util/ArrayList;") }; + const jfieldID field_mGyro { ::djinni::jniGetFieldID(clazz.get(), "mGyro", "Ljava/util/ArrayList;") }; + const jfieldID field_mTemperature { ::djinni::jniGetFieldID(clazz.get(), "mTemperature", "D") }; +}; + +} // namespace djinni_generated diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeModel.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeModel.hpp new file mode 100644 index 0000000..ebbbb88 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeModel.hpp @@ -0,0 +1,26 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +#pragma once + +#include "djinni_support.hpp" +#include "model.hpp" + +namespace djinni_generated { + +class NativeModel final : ::djinni::JniEnum { +public: + using CppType = ::mynteye_jni::Model; + using JniType = jobject; + + using Boxed = NativeModel; + + static CppType toCpp(JNIEnv* jniEnv, JniType j) { return static_cast(::djinni::JniClass::get().ordinal(jniEnv, j)); } + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, CppType c) { return ::djinni::JniClass::get().create(jniEnv, static_cast(c)); } + +private: + NativeModel() : JniEnum("com/slightech/mynteye/Model") {} + friend ::djinni::JniClass; +}; + +} // namespace djinni_generated diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeMotionData.cpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeMotionData.cpp new file mode 100644 index 0000000..3b634e1 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeMotionData.cpp @@ -0,0 +1,32 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +#include "NativeMotionData.hpp" // my header +#include "NativeImuData.hpp" + +namespace djinni_generated { + +NativeMotionData::NativeMotionData() : ::djinni::JniInterface<::mynteye_jni::MotionData, NativeMotionData>("com/slightech/mynteye/MotionData$CppProxy") {} + +NativeMotionData::~NativeMotionData() = default; + + +CJNIEXPORT void JNICALL Java_com_slightech_mynteye_MotionData_00024CppProxy_nativeDestroy(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + delete reinterpret_cast<::djinni::CppProxyHandle<::mynteye_jni::MotionData>*>(nativeRef); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) +} + +CJNIEXPORT jobject JNICALL Java_com_slightech_mynteye_MotionData_00024CppProxy_native_1imu(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::mynteye_jni::MotionData>(nativeRef); + auto r = ref->Imu(); + return ::djinni::release(::djinni_generated::NativeImuData::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +} // namespace djinni_generated diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeMotionData.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeMotionData.hpp new file mode 100644 index 0000000..8884a6c --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeMotionData.hpp @@ -0,0 +1,32 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +#pragma once + +#include "djinni_support.hpp" +#include "motion_data.hpp" + +namespace djinni_generated { + +class NativeMotionData final : ::djinni::JniInterface<::mynteye_jni::MotionData, NativeMotionData> { +public: + using CppType = std::shared_ptr<::mynteye_jni::MotionData>; + using CppOptType = std::shared_ptr<::mynteye_jni::MotionData>; + using JniType = jobject; + + using Boxed = NativeMotionData; + + ~NativeMotionData(); + + static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass::get()._fromJava(jniEnv, j); } + static ::djinni::LocalRef fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass::get()._toJava(jniEnv, c)}; } + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); } + +private: + NativeMotionData(); + friend ::djinni::JniClass; + friend ::djinni::JniInterface<::mynteye_jni::MotionData, NativeMotionData>; + +}; + +} // namespace djinni_generated diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeSource.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeSource.hpp new file mode 100644 index 0000000..ce6ad69 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeSource.hpp @@ -0,0 +1,26 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +#pragma once + +#include "djinni_support.hpp" +#include "source.hpp" + +namespace djinni_generated { + +class NativeSource final : ::djinni::JniEnum { +public: + using CppType = ::mynteye_jni::Source; + using JniType = jobject; + + using Boxed = NativeSource; + + static CppType toCpp(JNIEnv* jniEnv, JniType j) { return static_cast(::djinni::JniClass::get().ordinal(jniEnv, j)); } + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, CppType c) { return ::djinni::JniClass::get().create(jniEnv, static_cast(c)); } + +private: + NativeSource() : JniEnum("com/slightech/mynteye/Source") {} + friend ::djinni::JniClass; +}; + +} // namespace djinni_generated diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeStream.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeStream.hpp new file mode 100644 index 0000000..e899132 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeStream.hpp @@ -0,0 +1,26 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +#pragma once + +#include "djinni_support.hpp" +#include "stream.hpp" + +namespace djinni_generated { + +class NativeStream final : ::djinni::JniEnum { +public: + using CppType = ::mynteye_jni::Stream; + using JniType = jobject; + + using Boxed = NativeStream; + + static CppType toCpp(JNIEnv* jniEnv, JniType j) { return static_cast(::djinni::JniClass::get().ordinal(jniEnv, j)); } + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, CppType c) { return ::djinni::JniClass::get().create(jniEnv, static_cast(c)); } + +private: + NativeStream() : JniEnum("com/slightech/mynteye/Stream") {} + friend ::djinni::JniClass; +}; + +} // namespace djinni_generated diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeStreamData.cpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeStreamData.cpp new file mode 100644 index 0000000..7476d72 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeStreamData.cpp @@ -0,0 +1,54 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +#include "NativeStreamData.hpp" // my header +#include "Marshal.hpp" +#include "NativeFrame.hpp" +#include "NativeImgData.hpp" + +namespace djinni_generated { + +NativeStreamData::NativeStreamData() : ::djinni::JniInterface<::mynteye_jni::StreamData, NativeStreamData>("com/slightech/mynteye/StreamData$CppProxy") {} + +NativeStreamData::~NativeStreamData() = default; + + +CJNIEXPORT void JNICALL Java_com_slightech_mynteye_StreamData_00024CppProxy_nativeDestroy(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + delete reinterpret_cast<::djinni::CppProxyHandle<::mynteye_jni::StreamData>*>(nativeRef); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) +} + +CJNIEXPORT jobject JNICALL Java_com_slightech_mynteye_StreamData_00024CppProxy_native_1img(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::mynteye_jni::StreamData>(nativeRef); + auto r = ref->Img(); + return ::djinni::release(::djinni_generated::NativeImgData::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +CJNIEXPORT jobject JNICALL Java_com_slightech_mynteye_StreamData_00024CppProxy_native_1frame(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::mynteye_jni::StreamData>(nativeRef); + auto r = ref->Frame(); + return ::djinni::release(::djinni_generated::NativeFrame::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +CJNIEXPORT jlong JNICALL Java_com_slightech_mynteye_StreamData_00024CppProxy_native_1frameId(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::mynteye_jni::StreamData>(nativeRef); + auto r = ref->FrameId(); + return ::djinni::release(::djinni::I64::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +} // namespace djinni_generated diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeStreamData.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeStreamData.hpp new file mode 100644 index 0000000..380ab19 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeStreamData.hpp @@ -0,0 +1,32 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +#pragma once + +#include "djinni_support.hpp" +#include "stream_data.hpp" + +namespace djinni_generated { + +class NativeStreamData final : ::djinni::JniInterface<::mynteye_jni::StreamData, NativeStreamData> { +public: + using CppType = std::shared_ptr<::mynteye_jni::StreamData>; + using CppOptType = std::shared_ptr<::mynteye_jni::StreamData>; + using JniType = jobject; + + using Boxed = NativeStreamData; + + ~NativeStreamData(); + + static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass::get()._fromJava(jniEnv, j); } + static ::djinni::LocalRef fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass::get()._toJava(jniEnv, c)}; } + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); } + +private: + NativeStreamData(); + friend ::djinni::JniClass; + friend ::djinni::JniInterface<::mynteye_jni::StreamData, NativeStreamData>; + +}; + +} // namespace djinni_generated diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeStreamRequest.cpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeStreamRequest.cpp index b20eb93..7747789 100644 --- a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeStreamRequest.cpp +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeStreamRequest.cpp @@ -1,5 +1,5 @@ // AUTOGENERATED FILE - DO NOT MODIFY! -// This file generated by Djinni from mynteye.djinni +// This file generated by Djinni from mynteye_types.djinni #include "NativeStreamRequest.hpp" // my header #include "Marshal.hpp" diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeStreamRequest.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeStreamRequest.hpp index bdc80b1..35d9133 100644 --- a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeStreamRequest.hpp +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeStreamRequest.hpp @@ -1,5 +1,5 @@ // AUTOGENERATED FILE - DO NOT MODIFY! -// This file generated by Djinni from mynteye.djinni +// This file generated by Djinni from mynteye_types.djinni #pragma once diff --git a/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Device.java b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Device.java index 725cd1b..7b90aef 100644 --- a/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Device.java +++ b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Device.java @@ -8,24 +8,49 @@ import androidx.annotation.Nullable; import java.util.ArrayList; import java.util.concurrent.atomic.AtomicBoolean; +/** Device class to communicate with MYNT® EYE device */ public interface Device { + /** Get all stream requests */ @NonNull - public ArrayList getStreamRequests(); + public ArrayList getStreamRequests(); - public void configStreamRequest(@NonNull StreamRequest request); + /** Config the stream request */ + public void configStreamRequest(@NonNull com.slightech.mynteye.StreamRequest request); - public void start(); + /** Start capturing the source */ + public void start(@NonNull com.slightech.mynteye.Source source); - public void stop(); + /** Stop capturing the source */ + public void stop(@NonNull com.slightech.mynteye.Source source); + /** Wait the streams are ready */ + public void waitForStreams(); + + /** Get the latest data of stream */ + @Nullable + public com.slightech.mynteye.StreamData getStreamData(@NonNull com.slightech.mynteye.Stream stream); + + /** Get the datas of stream */ @NonNull - public static ArrayList query() + public ArrayList getStreamDatas(@NonNull com.slightech.mynteye.Stream stream); + + /** Enable cache motion datas */ + public void enableCacheMotionDatas(int maxSize); + + /** Get the motion datas */ + @NonNull + public ArrayList getMotionDatas(); + + /** Query devices */ + @NonNull + public static ArrayList query() { return CppProxy.query(); } + /** Create the device instance */ @Nullable - public static Device create(@NonNull DeviceUsbInfo info) + public static Device create(@NonNull com.slightech.mynteye.DeviceUsbInfo info) { return CppProxy.create(info); } @@ -54,41 +79,81 @@ public interface Device { } @Override - public ArrayList getStreamRequests() + public ArrayList getStreamRequests() { assert !this.destroyed.get() : "trying to use a destroyed object"; return native_getStreamRequests(this.nativeRef); } - private native ArrayList native_getStreamRequests(long _nativeRef); + private native ArrayList native_getStreamRequests(long _nativeRef); @Override - public void configStreamRequest(StreamRequest request) + public void configStreamRequest(com.slightech.mynteye.StreamRequest request) { assert !this.destroyed.get() : "trying to use a destroyed object"; native_configStreamRequest(this.nativeRef, request); } - private native void native_configStreamRequest(long _nativeRef, StreamRequest request); + private native void native_configStreamRequest(long _nativeRef, com.slightech.mynteye.StreamRequest request); @Override - public void start() + public void start(com.slightech.mynteye.Source source) { assert !this.destroyed.get() : "trying to use a destroyed object"; - native_start(this.nativeRef); + native_start(this.nativeRef, source); } - private native void native_start(long _nativeRef); + private native void native_start(long _nativeRef, com.slightech.mynteye.Source source); @Override - public void stop() + public void stop(com.slightech.mynteye.Source source) { assert !this.destroyed.get() : "trying to use a destroyed object"; - native_stop(this.nativeRef); + native_stop(this.nativeRef, source); } - private native void native_stop(long _nativeRef); + private native void native_stop(long _nativeRef, com.slightech.mynteye.Source source); + + @Override + public void waitForStreams() + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + native_waitForStreams(this.nativeRef); + } + private native void native_waitForStreams(long _nativeRef); + + @Override + public com.slightech.mynteye.StreamData getStreamData(com.slightech.mynteye.Stream stream) + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_getStreamData(this.nativeRef, stream); + } + private native com.slightech.mynteye.StreamData native_getStreamData(long _nativeRef, com.slightech.mynteye.Stream stream); + + @Override + public ArrayList getStreamDatas(com.slightech.mynteye.Stream stream) + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_getStreamDatas(this.nativeRef, stream); + } + private native ArrayList native_getStreamDatas(long _nativeRef, com.slightech.mynteye.Stream stream); + + @Override + public void enableCacheMotionDatas(int maxSize) + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + native_enableCacheMotionDatas(this.nativeRef, maxSize); + } + private native void native_enableCacheMotionDatas(long _nativeRef, int maxSize); + + @Override + public ArrayList getMotionDatas() + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_getMotionDatas(this.nativeRef); + } + private native ArrayList native_getMotionDatas(long _nativeRef); @NonNull - public static native ArrayList query(); + public static native ArrayList query(); @Nullable - public static native Device create(@NonNull DeviceUsbInfo info); + public static native Device create(@NonNull com.slightech.mynteye.DeviceUsbInfo info); } } diff --git a/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/DeviceUsbInfo.java b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/DeviceUsbInfo.java index d190c89..7e4ec6e 100644 --- a/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/DeviceUsbInfo.java +++ b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/DeviceUsbInfo.java @@ -1,11 +1,12 @@ // AUTOGENERATED FILE - DO NOT MODIFY! -// This file generated by Djinni from mynteye.djinni +// This file generated by Djinni from mynteye_types.djinni package com.slightech.mynteye; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +/** Device USB information */ public final class DeviceUsbInfo { @@ -24,15 +25,18 @@ public final class DeviceUsbInfo { this.mSn = sn; } + /** Device index */ public int getIndex() { return mIndex; } + /** Device name */ @NonNull public String getName() { return mName; } + /** Device serial number */ @NonNull public String getSn() { return mSn; diff --git a/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Format.java b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Format.java index 860daf6..7f7b7c9 100644 --- a/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Format.java +++ b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Format.java @@ -1,15 +1,20 @@ // AUTOGENERATED FILE - DO NOT MODIFY! -// This file generated by Djinni from mynteye.djinni +// This file generated by Djinni from mynteye_types.djinni package com.slightech.mynteye; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +/** Formats define how each stream can be encoded */ public enum Format { + /** Greyscale, 8 bits per pixel */ GREY, + /** YUV 4:2:2, 16 bits per pixel */ YUYV, + /** BGR 8:8:8, 24 bits per pixel */ BGR888, + /** RGB 8:8:8, 24 bits per pixel */ RGB888, ; } diff --git a/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Frame.java b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Frame.java new file mode 100644 index 0000000..f7aae46 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Frame.java @@ -0,0 +1,92 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +package com.slightech.mynteye; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +/** Frame with raw data */ +public interface Frame { + /** Get the width */ + public int width(); + + /** Get the height */ + public int height(); + + /** Get the pixel format */ + @NonNull + public Format format(); + + /** Get the size */ + public int size(); + + /** Get the data */ + @NonNull + public byte[] data(); + + static final class CppProxy implements Frame + { + private final long nativeRef; + private final AtomicBoolean destroyed = new AtomicBoolean(false); + + private CppProxy(long nativeRef) + { + if (nativeRef == 0) throw new RuntimeException("nativeRef is zero"); + this.nativeRef = nativeRef; + } + + private native void nativeDestroy(long nativeRef); + public void _djinni_private_destroy() + { + boolean destroyed = this.destroyed.getAndSet(true); + if (!destroyed) nativeDestroy(this.nativeRef); + } + protected void finalize() throws java.lang.Throwable + { + _djinni_private_destroy(); + super.finalize(); + } + + @Override + public int width() + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_width(this.nativeRef); + } + private native int native_width(long _nativeRef); + + @Override + public int height() + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_height(this.nativeRef); + } + private native int native_height(long _nativeRef); + + @Override + public Format format() + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_format(this.nativeRef); + } + private native Format native_format(long _nativeRef); + + @Override + public int size() + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_size(this.nativeRef); + } + private native int native_size(long _nativeRef); + + @Override + public byte[] data() + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_data(this.nativeRef); + } + private native byte[] native_data(long _nativeRef); + } +} diff --git a/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/ImgData.java b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/ImgData.java new file mode 100644 index 0000000..cddfd00 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/ImgData.java @@ -0,0 +1,52 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +package com.slightech.mynteye; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +/** Image data */ +public final class ImgData { + + + /*package*/ final long mFrameId; + + /*package*/ final long mTimestamp; + + /*package*/ final long mExposureTime; + + public ImgData( + long frameId, + long timestamp, + long exposureTime) { + this.mFrameId = frameId; + this.mTimestamp = timestamp; + this.mExposureTime = exposureTime; + } + + /** Image frame id */ + public long getFrameId() { + return mFrameId; + } + + /** Image timestamp in 1us */ + public long getTimestamp() { + return mTimestamp; + } + + /** Image exposure time, virtual value in [1, 480] */ + public long getExposureTime() { + return mExposureTime; + } + + @Override + public String toString() { + return "ImgData{" + + "mFrameId=" + mFrameId + + "," + "mTimestamp=" + mTimestamp + + "," + "mExposureTime=" + mExposureTime + + "}"; + } + +} diff --git a/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/ImuData.java b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/ImuData.java new file mode 100644 index 0000000..b850829 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/ImuData.java @@ -0,0 +1,90 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +package com.slightech.mynteye; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import java.util.ArrayList; + +/** IMU data */ +public final class ImuData { + + + /*package*/ final long mFrameId; + + /*package*/ final int mFlag; + + /*package*/ final long mTimestamp; + + /*package*/ final ArrayList mAccel; + + /*package*/ final ArrayList mGyro; + + /*package*/ final double mTemperature; + + public ImuData( + long frameId, + int flag, + long timestamp, + @NonNull ArrayList accel, + @NonNull ArrayList gyro, + double temperature) { + this.mFrameId = frameId; + this.mFlag = flag; + this.mTimestamp = timestamp; + this.mAccel = accel; + this.mGyro = gyro; + this.mTemperature = temperature; + } + + /** IMU frame id */ + public long getFrameId() { + return mFrameId; + } + + /** + * IMU accel or gyro flag + * 0: accel and gyro are both valid + * 1: accel is valid + * 2: gyro is valid + */ + public int getFlag() { + return mFlag; + } + + /** IMU timestamp in 1us */ + public long getTimestamp() { + return mTimestamp; + } + + /** IMU accelerometer data for 3-axis: X, Y, Z. */ + @NonNull + public ArrayList getAccel() { + return mAccel; + } + + /** IMU gyroscope data for 3-axis: X, Y, Z. */ + @NonNull + public ArrayList getGyro() { + return mGyro; + } + + /** IMU temperature */ + public double getTemperature() { + return mTemperature; + } + + @Override + public String toString() { + return "ImuData{" + + "mFrameId=" + mFrameId + + "," + "mFlag=" + mFlag + + "," + "mTimestamp=" + mTimestamp + + "," + "mAccel=" + mAccel + + "," + "mGyro=" + mGyro + + "," + "mTemperature=" + mTemperature + + "}"; + } + +} diff --git a/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Model.java b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Model.java new file mode 100644 index 0000000..2124342 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Model.java @@ -0,0 +1,18 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +package com.slightech.mynteye; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +/** Device model */ +public enum Model { + /** Standard */ + STANDARD, + /** Standard 2 */ + STANDARD2, + /** Standard 210a */ + STANDARD210A, + ; +} diff --git a/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/MotionData.java b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/MotionData.java new file mode 100644 index 0000000..37c247c --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/MotionData.java @@ -0,0 +1,46 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +package com.slightech.mynteye; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +/** Device motion data */ +public interface MotionData { + @NonNull + public ImuData imu(); + + static final class CppProxy implements MotionData + { + private final long nativeRef; + private final AtomicBoolean destroyed = new AtomicBoolean(false); + + private CppProxy(long nativeRef) + { + if (nativeRef == 0) throw new RuntimeException("nativeRef is zero"); + this.nativeRef = nativeRef; + } + + private native void nativeDestroy(long nativeRef); + public void _djinni_private_destroy() + { + boolean destroyed = this.destroyed.getAndSet(true); + if (!destroyed) nativeDestroy(this.nativeRef); + } + protected void finalize() throws java.lang.Throwable + { + _djinni_private_destroy(); + super.finalize(); + } + + @Override + public ImuData imu() + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_imu(this.nativeRef); + } + private native ImuData native_imu(long _nativeRef); + } +} diff --git a/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Source.java b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Source.java new file mode 100644 index 0000000..da4bb00 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Source.java @@ -0,0 +1,18 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +package com.slightech.mynteye; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +/** Source allows the user to choose which data to be captured */ +public enum Source { + /** Video streaming of stereo, color, depth, etc. */ + VIDEO_STREAMING, + /** Motion tracking of IMU (accelerometer, gyroscope) */ + MOTION_TRACKING, + /** Enable everything together */ + ALL, + ; +} diff --git a/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Stream.java b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Stream.java new file mode 100644 index 0000000..89f6083 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Stream.java @@ -0,0 +1,16 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +package com.slightech.mynteye; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +/** Streams define different type of data */ +public enum Stream { + /** Left stream */ + LEFT, + /** Right stream */ + RIGHT, + ; +} diff --git a/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/StreamData.java b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/StreamData.java new file mode 100644 index 0000000..ebc6203 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/StreamData.java @@ -0,0 +1,67 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye_types.djinni + +package com.slightech.mynteye; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +/** Device stream data */ +public interface StreamData { + @NonNull + public ImgData img(); + + @Nullable + public Frame frame(); + + public long frameId(); + + static final class CppProxy implements StreamData + { + private final long nativeRef; + private final AtomicBoolean destroyed = new AtomicBoolean(false); + + private CppProxy(long nativeRef) + { + if (nativeRef == 0) throw new RuntimeException("nativeRef is zero"); + this.nativeRef = nativeRef; + } + + private native void nativeDestroy(long nativeRef); + public void _djinni_private_destroy() + { + boolean destroyed = this.destroyed.getAndSet(true); + if (!destroyed) nativeDestroy(this.nativeRef); + } + protected void finalize() throws java.lang.Throwable + { + _djinni_private_destroy(); + super.finalize(); + } + + @Override + public ImgData img() + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_img(this.nativeRef); + } + private native ImgData native_img(long _nativeRef); + + @Override + public Frame frame() + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_frame(this.nativeRef); + } + private native Frame native_frame(long _nativeRef); + + @Override + public long frameId() + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_frameId(this.nativeRef); + } + private native long native_frameId(long _nativeRef); + } +} diff --git a/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/StreamRequest.java b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/StreamRequest.java index a653e54..be2c89d 100644 --- a/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/StreamRequest.java +++ b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/StreamRequest.java @@ -1,11 +1,12 @@ // AUTOGENERATED FILE - DO NOT MODIFY! -// This file generated by Djinni from mynteye.djinni +// This file generated by Djinni from mynteye_types.djinni package com.slightech.mynteye; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +/** Stream request */ public final class StreamRequest { @@ -32,23 +33,28 @@ public final class StreamRequest { this.mFps = fps; } + /** Stream index */ public int getIndex() { return mIndex; } + /** Stream width in pixels */ public int getWidth() { return mWidth; } + /** Stream height in pixels */ public int getHeight() { return mHeight; } + /** Stream pixel format */ @NonNull public Format getFormat() { return mFormat; } + /** Stream frames per second */ public int getFps() { return mFps; } diff --git a/wrappers/android/mynteye/scripts/.gitignore b/wrappers/android/mynteye/scripts/.gitignore index 0c9146c..2340a45 100644 --- a/wrappers/android/mynteye/scripts/.gitignore +++ b/wrappers/android/mynteye/scripts/.gitignore @@ -1 +1,2 @@ /djinni-output-temp/ +/*.yaml \ No newline at end of file diff --git a/wrappers/android/mynteye/scripts/mynteye.djinni b/wrappers/android/mynteye/scripts/mynteye.djinni index 236cfc5..e77db0c 100644 --- a/wrappers/android/mynteye/scripts/mynteye.djinni +++ b/wrappers/android/mynteye/scripts/mynteye.djinni @@ -1,33 +1,33 @@ +@extern "mynteye_types.yaml" -format = enum { - grey; - yuyv; - bgr888; - rgb888; -} - -stream_request = record { - index: i32; - width: i32; - height: i32; - format: format; - fps: i32; -} - -device_usb_info = record { - index: i32; - name: string; - sn: string; -} - +# Device class to communicate with MYNT® EYE device device = interface +c { + # Query devices static query(): list; + # Create the device instance static create(info: device_usb_info): device; + # Get all stream requests get_stream_requests(): list; + # Config the stream request config_stream_request(request: stream_request); - start(); - stop(); + # Start capturing the source + start(source: source); + # Stop capturing the source + stop(source: source); + + # Wait the streams are ready + wait_for_streams(); + + # Get the latest data of stream + get_stream_data(stream: stream): stream_data; + # Get the datas of stream + get_stream_datas(stream: stream): list; + + # Enable cache motion datas + enable_cache_motion_datas(max_size: i32); + # Get the motion datas + get_motion_datas(): list; } diff --git a/wrappers/android/mynteye/scripts/mynteye_types.djinni b/wrappers/android/mynteye/scripts/mynteye_types.djinni new file mode 100644 index 0000000..a2cec16 --- /dev/null +++ b/wrappers/android/mynteye/scripts/mynteye_types.djinni @@ -0,0 +1,119 @@ + +# Device USB information +device_usb_info = record { + # Device index + index: i32; + # Device name + name: string; + # Device serial number + sn: string; +} + +# Device model +model = enum { + # Standard + standard; + # Standard 2 + standard2; + # Standard 210a + standard210a; +} + +# Formats define how each stream can be encoded +format = enum { + # Greyscale, 8 bits per pixel + grey; + # YUV 4:2:2, 16 bits per pixel + yuyv; + # BGR 8:8:8, 24 bits per pixel + bgr888; + # RGB 8:8:8, 24 bits per pixel + rgb888; +} + +# Stream request +stream_request = record { + # Stream index + index: i32; + # Stream width in pixels + width: i32; + # Stream height in pixels + height: i32; + # Stream pixel format + format: format; + # Stream frames per second + fps: i32; +} + +# Source allows the user to choose which data to be captured +source = enum { + # Video streaming of stereo, color, depth, etc. + video_streaming; + # Motion tracking of IMU (accelerometer, gyroscope) + motion_tracking; + # Enable everything together + all; +} + +# Streams define different type of data +stream = enum { + # Left stream + left; + # Right stream + right; +} + +# Frame with raw data +frame = interface +c { + # Get the width + width(): i32; + # Get the height + height(): i32; + # Get the pixel format + format(): format; + # Get the size + size(): i32; + # Get the data + data(): binary; +} + +# Image data +img_data = record { + # Image frame id + frame_id: i64; + # Image timestamp in 1us + timestamp: i64; + # Image exposure time, virtual value in [1, 480] + exposure_time: i64; +} + +# IMU data +imu_data = record { + # IMU frame id + frame_id: i64; + # IMU accel or gyro flag + # 0: accel and gyro are both valid + # 1: accel is valid + # 2: gyro is valid + flag: i32; + # IMU timestamp in 1us + timestamp: i64; + # IMU accelerometer data for 3-axis: X, Y, Z. + accel: list; + # IMU gyroscope data for 3-axis: X, Y, Z. + gyro: list; + # IMU temperature + temperature: f64; +} + +# Device stream data +stream_data = interface +c { + img(): img_data; + frame(): frame; + frame_id(): i64; +} + +# Device motion data +motion_data = interface +c { + imu(): imu_data; +} diff --git a/wrappers/android/mynteye/scripts/run_djinni.sh b/wrappers/android/mynteye/scripts/run_djinni.sh index 675cb15..75d6dd0 100755 --- a/wrappers/android/mynteye/scripts/run_djinni.sh +++ b/wrappers/android/mynteye/scripts/run_djinni.sh @@ -6,11 +6,10 @@ base_dir=$(cd "$(dirname "$0")" && pwd) # options -while getopts "d:i:" opt; do +while getopts "d:" opt; do case "$opt" in d) djinni_dir="$OPTARG" ;; - i) in_idl="$OPTARG" ;; - ?) echo "Usage: $0 <-d DJINNI_DIR> [-i IN_IDL]" + ?) echo "Usage: $0 <-d DJINNI_DIR>" exit 2 ;; esac done @@ -20,8 +19,6 @@ if [ -z "$djinni_dir" ]; then exit 2 fi -[ -n "$in_idl" ] || in_idl="$base_dir/mynteye.djinni" - # generate djinni_run="$djinni_dir/src/run-assume-built" @@ -36,25 +33,35 @@ java_package="com.slightech.mynteye" cpp_namespace="mynteye_jni" [ ! -e "$temp_out" ] || rm -r "$temp_out" -"$djinni_run" \ ---java-out "$temp_out/java" \ ---java-package "$java_package" \ ---java-class-access-modifier "public" \ ---java-generate-interfaces true \ ---java-nullable-annotation "androidx.annotation.Nullable" \ ---java-nonnull-annotation "androidx.annotation.NonNull" \ ---ident-java-field mFooBar \ -\ ---cpp-out "$temp_out/cpp" \ ---cpp-namespace "$cpp_namespace" \ ---ident-cpp-enum-type FooBar \ ---ident-cpp-method FooBar \ -\ ---jni-out "$temp_out/jni" \ ---ident-jni-class NativeFooBar \ ---ident-jni-file NativeFooBar \ -\ ---idl "$in_idl" + +djinni_build() { + local in_idl="$1"; shift + "$djinni_run" \ + --java-out "$temp_out/java" \ + --java-package "$java_package" \ + --java-class-access-modifier "public" \ + --java-generate-interfaces true \ + --java-nullable-annotation "androidx.annotation.Nullable" \ + --java-nonnull-annotation "androidx.annotation.NonNull" \ + --ident-java-field mFooBar \ + \ + --cpp-out "$temp_out/cpp" \ + --cpp-namespace "$cpp_namespace" \ + --ident-cpp-enum-type FooBar \ + --ident-cpp-method FooBar \ + \ + --jni-out "$temp_out/jni" \ + --ident-jni-class NativeFooBar \ + --ident-jni-file NativeFooBar \ + \ + --yaml-out $(dirname "$in_idl") \ + --yaml-out-file "$(basename "$in_idl" .djinni).yaml" \ + \ + --idl "$in_idl" +} + +djinni_build "$base_dir/mynteye_types.djinni" +djinni_build "$base_dir/mynteye.djinni" # copy