forked from webcamoid/webcamoid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restored Android JNI and NDK camera plugins, ow working fine.
- Loading branch information
1 parent
bbd4096
commit 0ef4a4b
Showing
18 changed files
with
4,712 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
libAvKys/Plugins/VideoCapture/src/capture/androidcamera/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Webcamoid, webcam capture application. | ||
# Copyright (C) 2021 Gonzalo Exequiel Pedone | ||
# | ||
# Webcamoid is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# Webcamoid is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with Webcamoid. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
# Web-Site: https://webcamoid.github.io/ | ||
|
||
cmake_minimum_required(VERSION 3.16) | ||
|
||
project(VideoCapture_androidcamera) | ||
|
||
add_subdirectory(jar) | ||
add_subdirectory(src) |
44 changes: 44 additions & 0 deletions
44
libAvKys/Plugins/VideoCapture/src/capture/androidcamera/jar/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Webcamoid, webcam capture application. | ||
# Copyright (C) 2021 Gonzalo Exequiel Pedone | ||
# | ||
# Webcamoid is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# Webcamoid is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with Webcamoid. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
# Web-Site: https://webcamoid.github.io/ | ||
|
||
cmake_minimum_required(VERSION 3.16) | ||
|
||
project(VideoCapture_androidcamerajar) | ||
|
||
include(../../../../../../cmake/ProjectCommons.cmake) | ||
|
||
set(SOURCES_PREFIX src/org/webcamoid/plugins/VideoCapture/submodules/androidcamera) | ||
set(SOURCES ${SOURCES_PREFIX}/AkAndroidCameraCallbacks.java) | ||
|
||
if (ANDROID) | ||
include(UseJava) | ||
find_package(Java ${ANDROID_JAVA_VERSION}) | ||
|
||
if (Java_FOUND) | ||
set(CMAKE_JAVA_COMPILE_FLAGS "-source" "${ANDROID_JAVA_VERSION}" "-target" "${ANDROID_JAVA_VERSION}") | ||
add_jar(VideoCapture_androidcamerajar | ||
SOURCES ${SOURCES} | ||
INCLUDE_JARS | ||
${ANDROID_JAR_DIRECTORY}/android.jar | ||
OUTPUT_NAME AkVideoCapture_androidcamera | ||
OUTPUT_DIR ${CMAKE_BINARY_DIR}/${BUILDDIR}/${JARDIR}) | ||
install_jar(VideoCapture_androidcamerajar DESTINATION ${JARDIR}) | ||
endif () | ||
endif () | ||
|
||
add_custom_target(VideoCapture_androidcamerajar_sources SOURCES ${SOURCES}) |
107 changes: 107 additions & 0 deletions
107
...org/webcamoid/plugins/VideoCapture/submodules/androidcamera/AkAndroidCameraCallbacks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* Webcamoid, webcam capture application. | ||
* Copyright (C) 2019 Gonzalo Exequiel Pedone | ||
* | ||
* Webcamoid is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Webcamoid is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Webcamoid. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
* Web-Site: https://webcamoid.github.io/ | ||
*/ | ||
|
||
package org.webcamoid.plugins.VideoCapture.submodules.androidcamera; | ||
|
||
import android.hardware.Camera; | ||
import android.view.SurfaceHolder; | ||
|
||
public class AkAndroidCameraCallbacks implements Camera.PreviewCallback, | ||
Camera.ShutterCallback, | ||
Camera.PictureCallback, | ||
SurfaceHolder.Callback | ||
{ | ||
private long m_userPtr = 0; | ||
private byte[] m_lastPreviewBuffer = null; | ||
private int m_index = 0; | ||
|
||
private AkAndroidCameraCallbacks(long userPtr) | ||
{ | ||
m_userPtr = userPtr; | ||
} | ||
|
||
public void resetPictureIndex() | ||
{ | ||
m_index = 0; | ||
} | ||
|
||
// Camera.PreviewCallback | ||
|
||
@Override | ||
public void onPreviewFrame(byte[] data, Camera camera) | ||
{ | ||
// Re-enqueue the last buffer | ||
if (m_lastPreviewBuffer != null) | ||
camera.addCallbackBuffer(m_lastPreviewBuffer); | ||
|
||
m_lastPreviewBuffer = data; | ||
|
||
if (data != null) | ||
previewFrameReady(m_userPtr, data); | ||
} | ||
|
||
// Camera.ShutterCallback | ||
|
||
@Override | ||
public void onShutter() | ||
{ | ||
shutterActivated(m_userPtr); | ||
} | ||
|
||
// Camera.PictureCallback | ||
|
||
@Override | ||
public void onPictureTaken(byte[] data, Camera camera) | ||
{ | ||
if (data != null) | ||
pictureTaken(m_userPtr, m_index, data); | ||
|
||
m_index++; | ||
} | ||
|
||
// SurfaceHolder.Callback | ||
|
||
@Override | ||
public void surfaceChanged(SurfaceHolder holder, | ||
int format, | ||
int width, | ||
int height) | ||
{ | ||
} | ||
|
||
@Override | ||
public void surfaceCreated(SurfaceHolder holder) | ||
{ | ||
notifySurfaceCreated(m_userPtr); | ||
} | ||
|
||
@Override | ||
public void surfaceDestroyed(SurfaceHolder holder) | ||
{ | ||
notifySurfaceDestroyed(m_userPtr); | ||
} | ||
|
||
private static native void previewFrameReady(long userPtr, byte[] data); | ||
private static native void notifySurfaceCreated(long userPtr); | ||
private static native void notifySurfaceDestroyed(long userPtr); | ||
private static native void shutterActivated(long userPtr); | ||
private static native void pictureTaken(long userPtr, | ||
int index, | ||
byte[] data); | ||
} |
86 changes: 86 additions & 0 deletions
86
libAvKys/Plugins/VideoCapture/src/capture/androidcamera/src/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Webcamoid, webcam capture application. | ||
# Copyright (C) 2021 Gonzalo Exequiel Pedone | ||
# | ||
# Webcamoid is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# Webcamoid is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with Webcamoid. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
# Web-Site: https://webcamoid.github.io/ | ||
|
||
cmake_minimum_required(VERSION 3.16) | ||
|
||
project(VideoCapture_androidcamerasrc LANGUAGES CXX) | ||
|
||
include(../../../../../../cmake/ProjectCommons.cmake) | ||
|
||
set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
set(CMAKE_AUTOUIC ON) | ||
set(CMAKE_AUTOMOC ON) | ||
set(CMAKE_AUTORCC ON) | ||
|
||
set(QT_COMPONENTS | ||
Concurrent | ||
Widgets) | ||
|
||
if (ANDROID) | ||
include(UseJava) | ||
find_package(Java ${ANDROID_JAVA_VERSION}) | ||
endif () | ||
|
||
find_package(QT NAMES Qt${QT_VERSION_MAJOR} COMPONENTS | ||
${QT_COMPONENTS} | ||
REQUIRED) | ||
find_package(Qt${QT_VERSION_MAJOR} ${QT_MINIMUM_VERSION} COMPONENTS | ||
${QT_COMPONENTS} | ||
REQUIRED) | ||
|
||
set(SOURCES | ||
../../../capture.cpp | ||
../../../capture.h | ||
captureandroidcamera.cpp | ||
captureandroidcamera.h | ||
plugin.cpp | ||
plugin.h | ||
pspec.json) | ||
|
||
if (ANDROID AND Java_FOUND) | ||
qt_add_plugin(VideoCapture_androidcamerasrc ${SOURCES}) | ||
else () | ||
add_library(VideoCapture_androidcamerasrc SHARED EXCLUDE_FROM_ALL ${SOURCES}) | ||
endif () | ||
|
||
set_target_properties(VideoCapture_androidcamerasrc PROPERTIES | ||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${BUILDDIR}/${AKPLUGINSDIR} | ||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${BUILDDIR}/${AKPLUGINSDIR}) | ||
set_target_properties(VideoCapture_androidcamerasrc PROPERTIES | ||
OUTPUT_NAME VideoCapture_androidcamera) | ||
add_dependencies(VideoCapture_androidcamerasrc avkys) | ||
target_include_directories(VideoCapture_androidcamerasrc | ||
PRIVATE | ||
../../.. | ||
../../../../../../Lib/src) | ||
target_compile_definitions(VideoCapture_androidcamerasrc PRIVATE AVKYS_PLUGIN_VIDEOCAPTURE_ANDROIDCAMERA) | ||
list(TRANSFORM QT_COMPONENTS PREPEND Qt${QT_VERSION_MAJOR}:: OUTPUT_VARIABLE QT_LIBS) | ||
target_link_libraries(VideoCapture_androidcamerasrc | ||
PUBLIC | ||
${QT_LIBS} | ||
avkys) | ||
|
||
if (ANDROID) | ||
target_link_libraries(VideoCapture_androidcamerasrc | ||
PRIVATE | ||
Qt${QT_VERSION_MAJOR}::CorePrivate) | ||
endif () | ||
|
||
install(TARGETS VideoCapture_androidcamerasrc | ||
LIBRARY DESTINATION ${AKPLUGINSDIR} | ||
RUNTIME DESTINATION ${AKPLUGINSDIR}) |
Oops, something went wrong.