feat(*): update to androidx and add mynteye jni
This commit is contained in:
parent
d41f4cbcbc
commit
a8796478e6
|
@ -8,7 +8,7 @@ android {
|
||||||
targetSdkVersion xversions.targetSdk
|
targetSdkVersion xversions.targetSdk
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
ndk {
|
ndk {
|
||||||
abiFilters xabis
|
abiFilters xabis
|
||||||
}
|
}
|
||||||
|
@ -19,17 +19,26 @@ android {
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
|
||||||
implementation xdeps.support.appcompat
|
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
|
||||||
implementation xdeps.support.constraint
|
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
|
||||||
|
|
||||||
|
implementation 'com.jakewharton.timber:timber:4.7.1'
|
||||||
|
|
||||||
|
implementation 'com.jakewharton:butterknife:10.0.0'
|
||||||
|
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
|
||||||
|
|
||||||
implementation project(':libmynteye')
|
implementation project(':libmynteye')
|
||||||
|
|
||||||
testImplementation xdeps.junit
|
testImplementation 'junit:junit:4.12'
|
||||||
androidTestImplementation xdeps.support.test.runner
|
androidTestImplementation 'androidx.test:runner:1.1.1'
|
||||||
androidTestImplementation xdeps.support.test.espresso
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.slightech.mynteye.demo;
|
package com.slightech.mynteye.demo;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.test.InstrumentationRegistry;
|
import androidx.test.InstrumentationRegistry;
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<application
|
<application
|
||||||
android:allowBackup="false"
|
android:allowBackup="false"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
android:name=".MyApplication"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
tools:ignore="GoogleAppIndexingWarning">
|
tools:ignore="GoogleAppIndexingWarning">
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package com.slightech.mynteye.demo;
|
package com.slightech.mynteye.demo;
|
||||||
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import com.slightech.mynteye.Device;
|
||||||
|
import com.slightech.mynteye.DeviceUsbInfo;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
@ -9,5 +12,9 @@ public class MainActivity extends AppCompatActivity {
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
for (DeviceUsbInfo info : Device.query()) {
|
||||||
|
Timber.i(info.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.slightech.mynteye.demo;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
|
public class MyApplication extends Application {
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("mynteye_jni");
|
||||||
|
} catch (UnsatisfiedLinkError e) {
|
||||||
|
System.err.println("mynteye_jni library failed to load.\n" + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void onCreate() {
|
||||||
|
super.onCreate();
|
||||||
|
Timber.plant(new Timber.DebugTree());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void onLowMemory() {
|
||||||
|
super.onLowMemory();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void onTrimMemory(int level) {
|
||||||
|
super.onTrimMemory(level);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void onTerminate() {
|
||||||
|
super.onTerminate();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<android.support.constraint.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
@ -18,4 +18,4 @@
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</android.support.constraint.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -8,7 +8,7 @@ buildscript {
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath xplugins.android.buildGradle
|
classpath 'com.android.tools.build:gradle:3.3.0'
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||||
# Specifies the JVM arguments used for the daemon process.
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
# The setting is particularly useful for tweaking memory settings.
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
|
android.enableJetifier=true
|
||||||
|
android.useAndroidX=true
|
||||||
org.gradle.jvmargs=-Xmx1536m
|
org.gradle.jvmargs=-Xmx1536m
|
||||||
# When configured, Gradle will run in incubating parallel mode.
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
# This option should only be used with decoupled projects. More details, visit
|
# This option should only be used with decoupled projects. More details, visit
|
||||||
|
|
|
@ -1,45 +1,8 @@
|
||||||
ext {
|
ext {
|
||||||
xplugins = [
|
|
||||||
'android': [
|
|
||||||
// Gradle: https://mvnrepository.com/artifact/com.android.tools.build/gradle?repo=google
|
|
||||||
buildGradle: 'com.android.tools.build:gradle:3.2.1',
|
|
||||||
],
|
|
||||||
]
|
|
||||||
|
|
||||||
xversions = [
|
xversions = [
|
||||||
'compileSdk': 28,
|
'compileSdk': 28,
|
||||||
'minSdk': 21,
|
'minSdk': 24,
|
||||||
'targetSdk': 28,
|
'targetSdk': 28,
|
||||||
|
|
||||||
'androidSupport': '28.0.0',
|
|
||||||
]
|
|
||||||
|
|
||||||
xdeps = [
|
|
||||||
// Support Library
|
|
||||||
// https://developer.android.com/topic/libraries/support-library/
|
|
||||||
'support': [
|
|
||||||
// Android AppCompat Library V7
|
|
||||||
// https://mvnrepository.com/artifact/com.android.support/appcompat-v7?repo=google
|
|
||||||
'appcompat': "com.android.support:appcompat-v7:${xversions.androidSupport}",
|
|
||||||
|
|
||||||
// Android ConstraintLayout Solver
|
|
||||||
// https://mvnrepository.com/artifact/com.android.support.constraint/constraint-layout-solver
|
|
||||||
'constraint': 'com.android.support.constraint:constraint-layout:1.1.3',
|
|
||||||
// Android Multi Dex Library
|
|
||||||
// https://mvnrepository.com/artifact/com.android.support/multidex
|
|
||||||
'multidex': 'com.android.support:multidex:1.0.3',
|
|
||||||
|
|
||||||
// Test apps on Android
|
|
||||||
// https://developer.android.com/training/testing/
|
|
||||||
'test': [
|
|
||||||
'espresso': 'com.android.support.test.espresso:espresso-core:3.0.2',
|
|
||||||
'rules': 'com.android.support.test:rules:1.0.2',
|
|
||||||
'runner': 'com.android.support.test:runner:1.0.2',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
|
|
||||||
// JUnit4: https://github.com/junit-team/junit4
|
|
||||||
'junit': 'junit:junit:4.12',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
xabis = ['arm64-v8a', 'armeabi-v7a'] as String[]
|
xabis = ['arm64-v8a', 'armeabi-v7a'] as String[]
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
#Tue Jan 15 14:54:17 CST 2019
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
|
||||||
|
|
|
@ -5,29 +5,46 @@
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.4.1)
|
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}")
|
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}")
|
# libs
|
||||||
message(STATUS "Namespace: ${MYNTEYE_NAMESPACE}")
|
|
||||||
|
## 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(
|
configure_file(
|
||||||
${MYNTETE_ROOT}/include/mynteye/mynteye.h.in
|
${MYNTETE_ROOT}/include/mynteye/mynteye.h.in
|
||||||
include/mynteye/mynteye.h @ONLY
|
include/mynteye/mynteye.h @ONLY
|
||||||
)
|
)
|
||||||
|
|
||||||
## libs
|
|
||||||
|
|
||||||
find_library(log-lib log)
|
|
||||||
|
|
||||||
## targets
|
|
||||||
|
|
||||||
# libmynteye
|
|
||||||
|
|
||||||
add_definitions(-DMYNTEYE_EXPORTS)
|
|
||||||
|
|
||||||
set(MYNTEYE_SRCS
|
set(MYNTEYE_SRCS
|
||||||
${MYNTETE_ROOT}/src/mynteye/uvc/linux/uvc-v4l2.cc
|
${MYNTETE_ROOT}/src/mynteye/uvc/linux/uvc-v4l2.cc
|
||||||
${MYNTETE_ROOT}/src/mynteye/types.cc
|
${MYNTETE_ROOT}/src/mynteye/types.cc
|
||||||
|
@ -56,12 +73,35 @@ set(MYNTEYE_SRCS
|
||||||
|
|
||||||
list(APPEND MYNTEYE_SRCS ${MYNTETE_ROOT}/src/mynteye/miniglog.cc)
|
list(APPEND MYNTEYE_SRCS ${MYNTETE_ROOT}/src/mynteye/miniglog.cc)
|
||||||
|
|
||||||
add_library(${MYNTEYE_NAME} SHARED ${MYNTEYE_SRCS})
|
add_library(mynteye STATIC ${MYNTEYE_SRCS})
|
||||||
target_link_libraries(${MYNTEYE_NAME} ${log-lib})
|
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}/include>"
|
||||||
"$<BUILD_INTERFACE:${MYNTETE_ROOT}/src>"
|
"$<BUILD_INTERFACE:${MYNTETE_ROOT}/src>"
|
||||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>"
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>"
|
||||||
"$<INSTALL_INTERFACE: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)
|
|
@ -9,7 +9,7 @@ android {
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
|
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
// https://developer.android.com/ndk/guides/cmake
|
// https://developer.android.com/ndk/guides/cmake
|
||||||
|
@ -32,15 +32,22 @@ android {
|
||||||
|
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
cmake {
|
cmake {
|
||||||
path "src/main/cpp/CMakeLists.txt"
|
path "CMakeLists.txt"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
|
||||||
testImplementation xdeps.junit
|
implementation 'androidx.annotation:annotation:1.0.1'
|
||||||
androidTestImplementation xdeps.support.test.runner
|
|
||||||
androidTestImplementation xdeps.support.test.espresso
|
testImplementation 'junit:junit:4.12'
|
||||||
|
androidTestImplementation 'androidx.test:runner:1.1.1'
|
||||||
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.slightech.mynteye;
|
package com.slightech.mynteye;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.test.InstrumentationRegistry;
|
import androidx.test.InstrumentationRegistry;
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 +
|
||||||
|
"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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,
|
||||||
|
;
|
||||||
|
}
|
|
@ -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 +
|
||||||
|
"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
1
wrappers/android/mynteye/scripts/.gitignore
vendored
Normal file
1
wrappers/android/mynteye/scripts/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/djinni-output-temp/
|
33
wrappers/android/mynteye/scripts/mynteye.djinni
Normal file
33
wrappers/android/mynteye/scripts/mynteye.djinni
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
|
||||||
|
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 = interface +c {
|
||||||
|
static query(): list<device_usb_info>;
|
||||||
|
|
||||||
|
static create(info: device_usb_info): device;
|
||||||
|
|
||||||
|
get_stream_requests(): list<stream_request>;
|
||||||
|
config_stream_request(request: stream_request);
|
||||||
|
|
||||||
|
start();
|
||||||
|
stop();
|
||||||
|
}
|
83
wrappers/android/mynteye/scripts/run_djinni.sh
Executable file
83
wrappers/android/mynteye/scripts/run_djinni.sh
Executable file
|
@ -0,0 +1,83 @@
|
||||||
|
#! /usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
shopt -s nullglob
|
||||||
|
|
||||||
|
base_dir=$(cd "$(dirname "$0")" && pwd)
|
||||||
|
|
||||||
|
# options
|
||||||
|
|
||||||
|
while getopts "d:i:" opt; do
|
||||||
|
case "$opt" in
|
||||||
|
d) djinni_dir="$OPTARG" ;;
|
||||||
|
i) in_idl="$OPTARG" ;;
|
||||||
|
?) echo "Usage: $0 <-d DJINNI_DIR> [-i IN_IDL]"
|
||||||
|
exit 2 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$djinni_dir" ]; then
|
||||||
|
echo "<-d DJINNI_DIR> option is required" 1>&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ -n "$in_idl" ] || in_idl="$base_dir/mynteye.djinni"
|
||||||
|
|
||||||
|
# generate
|
||||||
|
|
||||||
|
djinni_run="$djinni_dir/src/run-assume-built"
|
||||||
|
if [ ! -x "$djinni_run" ]; then
|
||||||
|
echo "djinni run file not found: $djinni_run" 1>&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
temp_out="$base_dir/djinni-output-temp"
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
# copy
|
||||||
|
|
||||||
|
mirror() {
|
||||||
|
local prefix="$1" ; shift
|
||||||
|
local src="$1" ; shift
|
||||||
|
local dest="$1" ; shift
|
||||||
|
mkdir -p "$dest"
|
||||||
|
rsync -r --delete --checksum --itemize-changes "$src"/ "$dest" | sed "s/^/[$prefix]/"
|
||||||
|
}
|
||||||
|
|
||||||
|
dst_dir="$base_dir/../libmynteye/src/main"
|
||||||
|
cpp_out="$dst_dir/cpp/mynteye/cpp"
|
||||||
|
jni_out="$dst_dir/cpp/mynteye/jni"
|
||||||
|
java_out="$dst_dir/java/com/slightech/mynteye"
|
||||||
|
|
||||||
|
gen_stamp="$temp_out/gen.stamp"
|
||||||
|
|
||||||
|
echo "Copying generated code to final directories..."
|
||||||
|
mirror "cpp" "$temp_out/cpp" "$cpp_out"
|
||||||
|
mirror "jni" "$temp_out/jni" "$jni_out"
|
||||||
|
mirror "java" "$temp_out/java" "$java_out"
|
||||||
|
|
||||||
|
date > "$gen_stamp"
|
||||||
|
|
||||||
|
echo "djinni completed."
|
Loading…
Reference in New Issue
Block a user