feat(*): update to androidx and add mynteye jni

This commit is contained in:
John Zhao
2019-01-15 15:10:59 +08:00
parent d41f4cbcbc
commit a8796478e6
34 changed files with 1018 additions and 75 deletions

View File

@@ -5,29 +5,46 @@
cmake_minimum_required(VERSION 3.4.1)
get_filename_component(MYNTETE_ROOT "${PROJECT_SOURCE_DIR}/../../../../../../.." ABSOLUTE)
get_filename_component(MYNTETE_ROOT "${PROJECT_SOURCE_DIR}/../../../.." ABSOLUTE)
message(STATUS "MYNTETE_ROOT: ${MYNTETE_ROOT}")
set(MYNTEYE_NAME "mynteye")
if(NOT DJINNI_DIR)
if(DEFINED ENV{DJINNI_DIR})
set(DJINNI_DIR $ENV{DJINNI_DIR})
else()
set(DJINNI_DIR "$ENV{HOME}/Workspace/Fever/Dropbox/djinni")
endif()
endif()
set(MYNTEYE_NAMESPACE "${MYNTEYE_NAME}")
message(STATUS "Namespace: ${MYNTEYE_NAMESPACE}")
# libs
## log
find_library(log-lib log)
## djinni_jni
include_directories(
${DJINNI_DIR}/support-lib/jni
)
add_library(djinni_jni STATIC
${DJINNI_DIR}/support-lib/jni/djinni_support.cpp
)
# targets
## libmynteye
add_definitions(-DMYNTEYE_EXPORTS)
set(MYNTEYE_NAMESPACE "mynteye")
#message(STATUS "Namespace: ${MYNTEYE_NAMESPACE}")
configure_file(
${MYNTETE_ROOT}/include/mynteye/mynteye.h.in
include/mynteye/mynteye.h @ONLY
)
## libs
find_library(log-lib log)
## targets
# libmynteye
add_definitions(-DMYNTEYE_EXPORTS)
set(MYNTEYE_SRCS
${MYNTETE_ROOT}/src/mynteye/uvc/linux/uvc-v4l2.cc
${MYNTETE_ROOT}/src/mynteye/types.cc
@@ -56,12 +73,35 @@ set(MYNTEYE_SRCS
list(APPEND MYNTEYE_SRCS ${MYNTETE_ROOT}/src/mynteye/miniglog.cc)
add_library(${MYNTEYE_NAME} SHARED ${MYNTEYE_SRCS})
target_link_libraries(${MYNTEYE_NAME} ${log-lib})
add_library(mynteye STATIC ${MYNTEYE_SRCS})
target_link_libraries(mynteye ${log-lib})
target_include_directories(${MYNTEYE_NAME} PUBLIC
target_include_directories(mynteye PUBLIC
"$<BUILD_INTERFACE:${MYNTETE_ROOT}/include>"
"$<BUILD_INTERFACE:${MYNTETE_ROOT}/src>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
)
## libmynteye_jni
set(CPP_DIR "${PROJECT_SOURCE_DIR}/src/main/cpp")
include_directories(
${CPP_DIR}/mynteye/cpp
${CPP_DIR}/mynteye/impl
${CPP_DIR}/mynteye/jni
)
set(MYNTEYE_JNI_SRCS "")
foreach(__dir cpp impl jni)
file(GLOB __srcs "${CPP_DIR}/mynteye/${__dir}/*.cpp")
list(APPEND MYNTEYE_JNI_SRCS ${__srcs})
endforeach()
#message(STATUS "MYNTEYE_JNI_SRCS: ${MYNTEYE_JNI_SRCS}")
add_library(mynteye_jni SHARED
${DJINNI_DIR}/support-lib/jni/djinni_main.cpp
${MYNTEYE_JNI_SRCS}
)
target_link_libraries(mynteye_jni ${log-lib} djinni_jni mynteye)

View File

@@ -9,7 +9,7 @@ android {
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
// https://developer.android.com/ndk/guides/cmake
@@ -32,15 +32,22 @@ android {
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
path "CMakeLists.txt"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation xdeps.junit
androidTestImplementation xdeps.support.test.runner
androidTestImplementation xdeps.support.test.espresso
implementation 'androidx.annotation:annotation:1.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

View File

@@ -1,8 +1,8 @@
package com.slightech.mynteye;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;

View File

@@ -0,0 +1,31 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from mynteye.djinni
#pragma once
#include <memory>
#include <vector>
namespace mynteye_jni {
struct DeviceUsbInfo;
struct StreamRequest;
class Device {
public:
virtual ~Device() {}
static std::vector<DeviceUsbInfo> Query();
static std::shared_ptr<Device> Create(const DeviceUsbInfo & info);
virtual std::vector<StreamRequest> GetStreamRequests() = 0;
virtual void ConfigStreamRequest(const StreamRequest & request) = 0;
virtual void Start() = 0;
virtual void Stop() = 0;
};
} // namespace mynteye_jni

View File

@@ -0,0 +1,26 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from mynteye.djinni
#pragma once
#include <cstdint>
#include <string>
#include <utility>
namespace mynteye_jni {
struct DeviceUsbInfo final {
int32_t index;
std::string name;
std::string sn;
DeviceUsbInfo(int32_t index_,
std::string name_,
std::string sn_)
: index(std::move(index_))
, name(std::move(name_))
, sn(std::move(sn_))
{}
};
} // namespace mynteye_jni

View File

@@ -0,0 +1,28 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from mynteye.djinni
#pragma once
#include <functional>
namespace mynteye_jni {
enum class Format : int {
GREY,
YUYV,
BGR888,
RGB888,
};
} // namespace mynteye_jni
namespace std {
template <>
struct hash<::mynteye_jni::Format> {
size_t operator()(::mynteye_jni::Format type) const {
return std::hash<int>()(static_cast<int>(type));
}
};
} // namespace std

View File

@@ -0,0 +1,32 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from mynteye.djinni
#pragma once
#include "format.hpp"
#include <cstdint>
#include <utility>
namespace mynteye_jni {
struct StreamRequest final {
int32_t index;
int32_t width;
int32_t height;
Format format;
int32_t fps;
StreamRequest(int32_t index_,
int32_t width_,
int32_t height_,
Format format_,
int32_t fps_)
: index(std::move(index_))
, width(std::move(width_))
, height(std::move(height_))
, format(std::move(format_))
, fps(std::move(fps_))
{}
};
} // namespace mynteye_jni

View File

@@ -0,0 +1,77 @@
#include "device_impl.hpp"
#include "mynteye/device/context.h"
#include "mynteye/device/device.h"
#include "device_usb_info.hpp"
#include "stream_request.hpp"
#include "type_conversion.hpp"
MYNTEYE_USE_NAMESPACE
namespace mynteye_jni {
std::vector<DeviceUsbInfo> Device::Query() {
std::vector<DeviceUsbInfo> infos;
Context context;
int32_t i = 0;
for (auto&& d : context.devices()) {
infos.emplace_back(i,
d->GetInfo(Info::DEVICE_NAME),
d->GetInfo(Info::SERIAL_NUMBER));
++i;
}
return infos;
}
std::shared_ptr<Device> Device::Create(const DeviceUsbInfo & info) {
Context context;
int32_t i = 0;
for (auto&& d : context.devices()) {
if (i == info.index) {
return std::make_shared<DeviceImpl>(d);
}
++i;
}
return nullptr;
}
DeviceImpl::DeviceImpl(const device_t & device) : Device(), device_(device) {
}
DeviceImpl::~DeviceImpl() {
}
std::vector<StreamRequest> DeviceImpl::GetStreamRequests() {
std::vector<StreamRequest> requests;
int32_t i = 0;
for (auto&& req : device_->GetStreamRequests()) {
requests.emplace_back(i,
req.width, req.height, to_jni(req.format), req.fps);
++i;
}
return requests;
}
void DeviceImpl::ConfigStreamRequest(const StreamRequest & request) {
int32_t i = 0;
for (auto&& req : device_->GetStreamRequests()) {
if (i == request.index) {
device_->ConfigStreamRequest(req);
return;
}
++i;
}
}
void DeviceImpl::Start() {
}
void DeviceImpl::Stop() {
}
} // namespace mynteye_jni

View File

@@ -0,0 +1,31 @@
#pragma once
#include <vector>
#include <memory>
#include "mynteye/device/device.h"
#include "device.hpp"
namespace mynteye_jni {
class DeviceImpl : public Device {
public:
using device_t = std::shared_ptr<MYNTEYE_NAMESPACE::Device>;
explicit DeviceImpl(const device_t & device);
~DeviceImpl();
std::vector<StreamRequest> GetStreamRequests() override;
void ConfigStreamRequest(const StreamRequest & request) override;
void Start() override;
void Stop() override;
private:
device_t device_;
};
} // namespace mynteye_jni

View File

@@ -0,0 +1,37 @@
#include <memory>
#include "mynteye/logger.h"
#include "mynteye/types.h"
#include "format.hpp"
namespace mynteye_jni {
using RawFormat = MYNTEYE_NAMESPACE::Format;
using JniFormat = mynteye_jni::Format;
inline
RawFormat from_jni(const JniFormat& format) {
switch (format) {
case JniFormat::GREY: return RawFormat::GREY;
case JniFormat::YUYV: return RawFormat::YUYV;
case JniFormat::BGR888: return RawFormat::BGR888;
case JniFormat::RGB888: return RawFormat::RGB888;
default:
LOG(FATAL) << "Format is unknown";
}
}
inline
JniFormat to_jni(const RawFormat& format) {
switch (format) {
case RawFormat::GREY: return JniFormat::GREY;
case RawFormat::YUYV: return JniFormat::YUYV;
case RawFormat::BGR888: return JniFormat::BGR888;
case RawFormat::RGB888: return JniFormat::RGB888;
default:
LOG(FATAL) << "Format is unknown";
}
}
} // namespace mynteye_jni

View File

@@ -0,0 +1,79 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from mynteye.djinni
#include "NativeDevice.hpp" // my header
#include "Marshal.hpp"
#include "NativeDeviceUsbInfo.hpp"
#include "NativeStreamRequest.hpp"
namespace djinni_generated {
NativeDevice::NativeDevice() : ::djinni::JniInterface<::mynteye_jni::Device, NativeDevice>("com/slightech/mynteye/Device$CppProxy") {}
NativeDevice::~NativeDevice() = default;
CJNIEXPORT void JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_nativeDestroy(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef)
{
try {
DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef);
delete reinterpret_cast<::djinni::CppProxyHandle<::mynteye_jni::Device>*>(nativeRef);
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, )
}
CJNIEXPORT jobject JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_query(JNIEnv* jniEnv, jobject /*this*/)
{
try {
DJINNI_FUNCTION_PROLOGUE0(jniEnv);
auto r = ::mynteye_jni::Device::Query();
return ::djinni::release(::djinni::List<::djinni_generated::NativeDeviceUsbInfo>::fromCpp(jniEnv, r));
} 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)
{
try {
DJINNI_FUNCTION_PROLOGUE0(jniEnv);
auto r = ::mynteye_jni::Device::Create(::djinni_generated::NativeDeviceUsbInfo::toCpp(jniEnv, j_info));
return ::djinni::release(::djinni_generated::NativeDevice::fromCpp(jniEnv, r));
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */)
}
CJNIEXPORT jobject JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_native_1getStreamRequests(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef)
{
try {
DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef);
const auto& ref = ::djinni::objectFromHandleAddress<::mynteye_jni::Device>(nativeRef);
auto r = ref->GetStreamRequests();
return ::djinni::release(::djinni::List<::djinni_generated::NativeStreamRequest>::fromCpp(jniEnv, r));
} 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)
{
try {
DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef);
const auto& ref = ::djinni::objectFromHandleAddress<::mynteye_jni::Device>(nativeRef);
ref->ConfigStreamRequest(::djinni_generated::NativeStreamRequest::toCpp(jniEnv, j_request));
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, )
}
CJNIEXPORT void JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_native_1start(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef)
{
try {
DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef);
const auto& ref = ::djinni::objectFromHandleAddress<::mynteye_jni::Device>(nativeRef);
ref->Start();
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, )
}
CJNIEXPORT void JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_native_1stop(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef)
{
try {
DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef);
const auto& ref = ::djinni::objectFromHandleAddress<::mynteye_jni::Device>(nativeRef);
ref->Stop();
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, )
}
} // namespace djinni_generated

View File

@@ -0,0 +1,32 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from mynteye.djinni
#pragma once
#include "device.hpp"
#include "djinni_support.hpp"
namespace djinni_generated {
class NativeDevice final : ::djinni::JniInterface<::mynteye_jni::Device, NativeDevice> {
public:
using CppType = std::shared_ptr<::mynteye_jni::Device>;
using CppOptType = std::shared_ptr<::mynteye_jni::Device>;
using JniType = jobject;
using Boxed = NativeDevice;
~NativeDevice();
static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeDevice>::get()._fromJava(jniEnv, j); }
static ::djinni::LocalRef<JniType> fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass<NativeDevice>::get()._toJava(jniEnv, c)}; }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); }
private:
NativeDevice();
friend ::djinni::JniClass<NativeDevice>;
friend ::djinni::JniInterface<::mynteye_jni::Device, NativeDevice>;
};
} // namespace djinni_generated

View File

@@ -0,0 +1,32 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from mynteye.djinni
#include "NativeDeviceUsbInfo.hpp" // my header
#include "Marshal.hpp"
namespace djinni_generated {
NativeDeviceUsbInfo::NativeDeviceUsbInfo() = default;
NativeDeviceUsbInfo::~NativeDeviceUsbInfo() = default;
auto NativeDeviceUsbInfo::fromCpp(JNIEnv* jniEnv, const CppType& c) -> ::djinni::LocalRef<JniType> {
const auto& data = ::djinni::JniClass<NativeDeviceUsbInfo>::get();
auto r = ::djinni::LocalRef<JniType>{jniEnv->NewObject(data.clazz.get(), data.jconstructor,
::djinni::get(::djinni::I32::fromCpp(jniEnv, c.index)),
::djinni::get(::djinni::String::fromCpp(jniEnv, c.name)),
::djinni::get(::djinni::String::fromCpp(jniEnv, c.sn)))};
::djinni::jniExceptionCheck(jniEnv);
return r;
}
auto NativeDeviceUsbInfo::toCpp(JNIEnv* jniEnv, JniType j) -> CppType {
::djinni::JniLocalScope jscope(jniEnv, 4);
assert(j != nullptr);
const auto& data = ::djinni::JniClass<NativeDeviceUsbInfo>::get();
return {::djinni::I32::toCpp(jniEnv, jniEnv->GetIntField(j, data.field_mIndex)),
::djinni::String::toCpp(jniEnv, (jstring)jniEnv->GetObjectField(j, data.field_mName)),
::djinni::String::toCpp(jniEnv, (jstring)jniEnv->GetObjectField(j, data.field_mSn))};
}
} // namespace djinni_generated

View File

@@ -0,0 +1,34 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from mynteye.djinni
#pragma once
#include "device_usb_info.hpp"
#include "djinni_support.hpp"
namespace djinni_generated {
class NativeDeviceUsbInfo final {
public:
using CppType = ::mynteye_jni::DeviceUsbInfo;
using JniType = jobject;
using Boxed = NativeDeviceUsbInfo;
~NativeDeviceUsbInfo();
static CppType toCpp(JNIEnv* jniEnv, JniType j);
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c);
private:
NativeDeviceUsbInfo();
friend ::djinni::JniClass<NativeDeviceUsbInfo>;
const ::djinni::GlobalRef<jclass> clazz { ::djinni::jniFindClass("com/slightech/mynteye/DeviceUsbInfo") };
const jmethodID jconstructor { ::djinni::jniGetMethodID(clazz.get(), "<init>", "(ILjava/lang/String;Ljava/lang/String;)V") };
const jfieldID field_mIndex { ::djinni::jniGetFieldID(clazz.get(), "mIndex", "I") };
const jfieldID field_mName { ::djinni::jniGetFieldID(clazz.get(), "mName", "Ljava/lang/String;") };
const jfieldID field_mSn { ::djinni::jniGetFieldID(clazz.get(), "mSn", "Ljava/lang/String;") };
};
} // namespace djinni_generated

View File

@@ -0,0 +1,26 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from mynteye.djinni
#pragma once
#include "djinni_support.hpp"
#include "format.hpp"
namespace djinni_generated {
class NativeFormat final : ::djinni::JniEnum {
public:
using CppType = ::mynteye_jni::Format;
using JniType = jobject;
using Boxed = NativeFormat;
static CppType toCpp(JNIEnv* jniEnv, JniType j) { return static_cast<CppType>(::djinni::JniClass<NativeFormat>::get().ordinal(jniEnv, j)); }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, CppType c) { return ::djinni::JniClass<NativeFormat>::get().create(jniEnv, static_cast<jint>(c)); }
private:
NativeFormat() : JniEnum("com/slightech/mynteye/Format") {}
friend ::djinni::JniClass<NativeFormat>;
};
} // namespace djinni_generated

View File

@@ -0,0 +1,37 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from mynteye.djinni
#include "NativeStreamRequest.hpp" // my header
#include "Marshal.hpp"
#include "NativeFormat.hpp"
namespace djinni_generated {
NativeStreamRequest::NativeStreamRequest() = default;
NativeStreamRequest::~NativeStreamRequest() = default;
auto NativeStreamRequest::fromCpp(JNIEnv* jniEnv, const CppType& c) -> ::djinni::LocalRef<JniType> {
const auto& data = ::djinni::JniClass<NativeStreamRequest>::get();
auto r = ::djinni::LocalRef<JniType>{jniEnv->NewObject(data.clazz.get(), data.jconstructor,
::djinni::get(::djinni::I32::fromCpp(jniEnv, c.index)),
::djinni::get(::djinni::I32::fromCpp(jniEnv, c.width)),
::djinni::get(::djinni::I32::fromCpp(jniEnv, c.height)),
::djinni::get(::djinni_generated::NativeFormat::fromCpp(jniEnv, c.format)),
::djinni::get(::djinni::I32::fromCpp(jniEnv, c.fps)))};
::djinni::jniExceptionCheck(jniEnv);
return r;
}
auto NativeStreamRequest::toCpp(JNIEnv* jniEnv, JniType j) -> CppType {
::djinni::JniLocalScope jscope(jniEnv, 6);
assert(j != nullptr);
const auto& data = ::djinni::JniClass<NativeStreamRequest>::get();
return {::djinni::I32::toCpp(jniEnv, jniEnv->GetIntField(j, data.field_mIndex)),
::djinni::I32::toCpp(jniEnv, jniEnv->GetIntField(j, data.field_mWidth)),
::djinni::I32::toCpp(jniEnv, jniEnv->GetIntField(j, data.field_mHeight)),
::djinni_generated::NativeFormat::toCpp(jniEnv, jniEnv->GetObjectField(j, data.field_mFormat)),
::djinni::I32::toCpp(jniEnv, jniEnv->GetIntField(j, data.field_mFps))};
}
} // namespace djinni_generated

View File

@@ -0,0 +1,36 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from mynteye.djinni
#pragma once
#include "djinni_support.hpp"
#include "stream_request.hpp"
namespace djinni_generated {
class NativeStreamRequest final {
public:
using CppType = ::mynteye_jni::StreamRequest;
using JniType = jobject;
using Boxed = NativeStreamRequest;
~NativeStreamRequest();
static CppType toCpp(JNIEnv* jniEnv, JniType j);
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c);
private:
NativeStreamRequest();
friend ::djinni::JniClass<NativeStreamRequest>;
const ::djinni::GlobalRef<jclass> clazz { ::djinni::jniFindClass("com/slightech/mynteye/StreamRequest") };
const jmethodID jconstructor { ::djinni::jniGetMethodID(clazz.get(), "<init>", "(IIILcom/slightech/mynteye/Format;I)V") };
const jfieldID field_mIndex { ::djinni::jniGetFieldID(clazz.get(), "mIndex", "I") };
const jfieldID field_mWidth { ::djinni::jniGetFieldID(clazz.get(), "mWidth", "I") };
const jfieldID field_mHeight { ::djinni::jniGetFieldID(clazz.get(), "mHeight", "I") };
const jfieldID field_mFormat { ::djinni::jniGetFieldID(clazz.get(), "mFormat", "Lcom/slightech/mynteye/Format;") };
const jfieldID field_mFps { ::djinni::jniGetFieldID(clazz.get(), "mFps", "I") };
};
} // namespace djinni_generated

View File

@@ -0,0 +1,94 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from mynteye.djinni
package com.slightech.mynteye;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
public interface Device {
@NonNull
public ArrayList<StreamRequest> getStreamRequests();
public void configStreamRequest(@NonNull StreamRequest request);
public void start();
public void stop();
@NonNull
public static ArrayList<DeviceUsbInfo> query()
{
return CppProxy.query();
}
@Nullable
public static Device create(@NonNull DeviceUsbInfo info)
{
return CppProxy.create(info);
}
static final class CppProxy implements Device
{
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 ArrayList<StreamRequest> getStreamRequests()
{
assert !this.destroyed.get() : "trying to use a destroyed object";
return native_getStreamRequests(this.nativeRef);
}
private native ArrayList<StreamRequest> native_getStreamRequests(long _nativeRef);
@Override
public void configStreamRequest(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);
@Override
public void start()
{
assert !this.destroyed.get() : "trying to use a destroyed object";
native_start(this.nativeRef);
}
private native void native_start(long _nativeRef);
@Override
public void stop()
{
assert !this.destroyed.get() : "trying to use a destroyed object";
native_stop(this.nativeRef);
}
private native void native_stop(long _nativeRef);
@NonNull
public static native ArrayList<DeviceUsbInfo> query();
@Nullable
public static native Device create(@NonNull DeviceUsbInfo info);
}
}

View File

@@ -0,0 +1,50 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from mynteye.djinni
package com.slightech.mynteye;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
public final class DeviceUsbInfo {
/*package*/ final int mIndex;
/*package*/ final String mName;
/*package*/ final String mSn;
public DeviceUsbInfo(
int index,
@NonNull String name,
@NonNull String sn) {
this.mIndex = index;
this.mName = name;
this.mSn = sn;
}
public int getIndex() {
return mIndex;
}
@NonNull
public String getName() {
return mName;
}
@NonNull
public String getSn() {
return mSn;
}
@Override
public String toString() {
return "DeviceUsbInfo{" +
"mIndex=" + mIndex +
"," + "mName=" + mName +
"," + "mSn=" + mSn +
"}";
}
}

View File

@@ -0,0 +1,15 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from mynteye.djinni
package com.slightech.mynteye;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
public enum Format {
GREY,
YUYV,
BGR888,
RGB888,
;
}

View File

@@ -0,0 +1,67 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from mynteye.djinni
package com.slightech.mynteye;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
public final class StreamRequest {
/*package*/ final int mIndex;
/*package*/ final int mWidth;
/*package*/ final int mHeight;
/*package*/ final Format mFormat;
/*package*/ final int mFps;
public StreamRequest(
int index,
int width,
int height,
@NonNull Format format,
int fps) {
this.mIndex = index;
this.mWidth = width;
this.mHeight = height;
this.mFormat = format;
this.mFps = fps;
}
public int getIndex() {
return mIndex;
}
public int getWidth() {
return mWidth;
}
public int getHeight() {
return mHeight;
}
@NonNull
public Format getFormat() {
return mFormat;
}
public int getFps() {
return mFps;
}
@Override
public String toString() {
return "StreamRequest{" +
"mIndex=" + mIndex +
"," + "mWidth=" + mWidth +
"," + "mHeight=" + mHeight +
"," + "mFormat=" + mFormat +
"," + "mFps=" + mFps +
"}";
}
}