From a134b2094d6b74e5e8ba5a0f1436cb86b72277b8 Mon Sep 17 00:00:00 2001 From: JeroMiya Date: Mon, 28 Sep 2015 18:19:30 -0400 Subject: [PATCH 1/8] Fix to IPCRingBuffer.cpp and temporary JNI bridge code in ImagingInterfaceC.cpp. --- src/osvr/Common/CMakeLists.txt | 1 + src/osvr/Common/IPCRingBuffer.cpp | 1 + src/osvr/PluginKit/CMakeLists.txt | 2 +- src/osvr/PluginKit/ImagingInterfaceC.cpp | 30 ++++++++++++++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/osvr/Common/CMakeLists.txt b/src/osvr/Common/CMakeLists.txt index e5621df77..0690bf97f 100644 --- a/src/osvr/Common/CMakeLists.txt +++ b/src/osvr/Common/CMakeLists.txt @@ -184,6 +184,7 @@ target_link_libraries(${LIBNAME_FULL} PRIVATE jsoncpp_lib opencv_core + log vendored-vrpn eigen-headers osvr_cxx11_flags diff --git a/src/osvr/Common/IPCRingBuffer.cpp b/src/osvr/Common/IPCRingBuffer.cpp index dc5cc08cf..fd8ec5412 100644 --- a/src/osvr/Common/IPCRingBuffer.cpp +++ b/src/osvr/Common/IPCRingBuffer.cpp @@ -23,6 +23,7 @@ // limitations under the License. // Internal Includes +#define BOOST_INTERPROCESS_SHARED_DIR_PATH "/sdcard" #include #include "IPCRingBufferResults.h" #include "IPCRingBufferSharedObjects.h" diff --git a/src/osvr/PluginKit/CMakeLists.txt b/src/osvr/PluginKit/CMakeLists.txt index 85e2c1e96..4de2473a8 100644 --- a/src/osvr/PluginKit/CMakeLists.txt +++ b/src/osvr/PluginKit/CMakeLists.txt @@ -51,6 +51,7 @@ target_link_libraries(${LIBNAME_FULL} osvrConnection osvrUtilCpp osvrCommon + log vendored-vrpn boost_thread) @@ -83,7 +84,6 @@ add_library(osvr::${LIBNAME_INTERFACE} ALIAS ${LIBNAME_INTERFACE}) ### osvr_add_interface_library(Imaging) - # In an installed version, we search and add the dependency in the # osvrConfigInstalledOpenCV.cmake script since we don't need the same version in # the same place. Thus, here we only add it to the interface if using a build tree. diff --git a/src/osvr/PluginKit/ImagingInterfaceC.cpp b/src/osvr/PluginKit/ImagingInterfaceC.cpp index eca03ad43..5cddd0374 100644 --- a/src/osvr/PluginKit/ImagingInterfaceC.cpp +++ b/src/osvr/PluginKit/ImagingInterfaceC.cpp @@ -38,6 +38,36 @@ // Standard includes // - none +#include +OSVR_ImageBufferElement *gLastFrame = NULL; +OSVR_ImagingMetadata gLastFrameMetadata; + +extern "C" { + JNIEXPORT void JNICALL Java_com_osvr_android_gles2sample_MainActivityJNILib_reportFrame(JNIEnv * env, jclass clazz, + jbyteArray data, jlong width, jlong height, jshort channels, jshort depth); +} + +JNIEXPORT void JNICALL Java_com_osvr_android_gles2sample_MainActivityJNILib_reportFrame(JNIEnv * env, jclass clazz, + jbyteArray data, jlong width, jlong height, jshort channels, jshort depth) { + + gLastFrameMetadata.height = (OSVR_ImageDimension)height; + gLastFrameMetadata.width = (OSVR_ImageDimension)width; + gLastFrameMetadata.channels = (OSVR_ImageChannels)channels; + gLastFrameMetadata.depth = (OSVR_ImageDepth)depth; + + // @todo determine whether the current metadata matches the last metadata, + // and if so, reuse the last frame buffer instead of deleting and recreating. + // better yet, use a ring buffer so that image reports aren't lost if update + // isn't called frequently enough. + if(gLastFrame) { + // this image will be lost. the plugin's update method wasn't called + // fast enough. + delete[] gLastFrame; + } + int size = env->GetArrayLength(data); + gLastFrame = new OSVR_ImageBufferElement[size]; + env->GetByteArrayRegion(data, 0, size, reinterpret_cast(gLastFrame)); +} struct OSVR_ImagingDeviceInterfaceObject : public osvr::connection::DeviceInterfaceBase { From 03edc71c9467057a86a487977625cb1b6696f7e8 Mon Sep 17 00:00:00 2001 From: JeroMiya Date: Tue, 6 Oct 2015 12:09:25 -0400 Subject: [PATCH 2/8] Added new imaging message type for in-process-memory images. This must be enabled in CMake (default off). --- inc/osvr/Common/ImagingComponent.h | 28 +++++ src/osvr/Common/CMakeLists.txt | 4 + src/osvr/Common/ImagingComponent.cpp | 100 ++++++++++++++++++ .../Common/ImagingComponentConfig.h.cmake_in | 30 ++++++ 4 files changed, 162 insertions(+) create mode 100644 src/osvr/Common/ImagingComponentConfig.h.cmake_in diff --git a/inc/osvr/Common/ImagingComponent.h b/inc/osvr/Common/ImagingComponent.h index caa2cb2ac..393a5600c 100644 --- a/inc/osvr/Common/ImagingComponent.h +++ b/inc/osvr/Common/ImagingComponent.h @@ -32,6 +32,7 @@ #include #include #include +#include // Library/third-party includes #include @@ -54,6 +55,14 @@ namespace common { static const char *identifier(); }; +#ifdef OSVR_COMMON_IN_PROCESS_IMAGING + class ImagePlacedInProcessMemory + : public MessageRegistration { + public: + class MessageSerialization; + static const char *identifier(); + }; +#endif class ImagePlacedInSharedMemory : public MessageRegistration { public: @@ -79,6 +88,12 @@ namespace common { /// shared memory ring buffer. messages::ImagePlacedInSharedMemory imagePlacedInSharedMemory; +#ifdef OSVR_COMMON_IN_PROCESS_IMAGING + /// @brief Message from server to client, notifying of image data in process + /// memory (assumes joint client kit) + messages::ImagePlacedInProcessMemory imagePlacedInProcessMemory; +#endif + OSVR_COMMON_EXPORT void sendImageData( OSVR_ImagingMetadata metadata, OSVR_ImageBufferElement *imageData, OSVR_ChannelCount sensor, OSVR_TimeValue const ×tamp); @@ -103,12 +118,25 @@ namespace common { OSVR_ChannelCount sensor, OSVR_TimeValue const ×tamp); +#ifdef OSVR_COMMON_IN_PROCESS_IMAGING + /// @return true if we could send it. + bool m_sendImageDataViaInProcessMemory(OSVR_ImagingMetadata metadata, + OSVR_ImageBufferElement *imageData, + OSVR_ChannelCount sensor, + OSVR_TimeValue const ×tamp); +#endif + static int VRPN_CALLBACK m_handleImageRegion(void *userdata, vrpn_HANDLERPARAM p); static int VRPN_CALLBACK m_handleImagePlacedInSharedMemory(void *userdata, vrpn_HANDLERPARAM p); +#ifdef OSVR_COMMON_IN_PROCESS_IMAGING + static int VRPN_CALLBACK + m_handleImagePlacedInProcessMemory(void *userdata, vrpn_HANDLERPARAM p); +#endif + void m_checkFirst(OSVR_ImagingMetadata const &metadata); void m_growShmVecIfRequired(OSVR_ChannelCount sensor); diff --git a/src/osvr/Common/CMakeLists.txt b/src/osvr/Common/CMakeLists.txt index a003d26de..16db3457d 100644 --- a/src/osvr/Common/CMakeLists.txt +++ b/src/osvr/Common/CMakeLists.txt @@ -23,8 +23,11 @@ if(BUILD_WITH_TRACING) endif() endif() +option(OSVR_COMMON_IN_PROCESS_IMAGING OFF) + configure_file(TracingConfig.h.cmake_in "${CMAKE_CURRENT_BINARY_DIR}/TracingConfig.h") +configure_file(ImagingComponentConfig.h.cmake_in "${CMAKE_CURRENT_BINARY_DIR}/ImagingComponentConfig.h") set(API "${HEADER_LOCATION}/AddDevice.h" @@ -58,6 +61,7 @@ set(API "${HEADER_LOCATION}/GeneralizedTransform.h" "${HEADER_LOCATION}/GetEnvironmentVariable.h" "${HEADER_LOCATION}/ImagingComponent.h" + "${CMAKE_CURRENT_BINARY_DIR}/ImagingComponentConfig.h" "${HEADER_LOCATION}/IntegerByteSwap.h" "${HEADER_LOCATION}/InterfaceCallbacks.h" "${HEADER_LOCATION}/InterfaceList.h" diff --git a/src/osvr/Common/ImagingComponent.cpp b/src/osvr/Common/ImagingComponent.cpp index 36e3cf069..8d6207c9d 100644 --- a/src/osvr/Common/ImagingComponent.cpp +++ b/src/osvr/Common/ImagingComponent.cpp @@ -108,6 +108,47 @@ namespace common { return "com.osvr.imaging.imageregion"; } +#ifdef OSVR_COMMON_IN_PROCESS_IMAGING + namespace { + struct InProcessMemoryMessage { + OSVR_ImagingMetadata metadata; + OSVR_ChannelCount sensor; + int buffer; + }; + template + void process(InProcessMemoryMessage &ipmmMsg, T &p) { + process(ipmmMsg.metadata, p); + p(ipmmMsg.sensor); + p(ipmmMsg.buffer); + } + } + + const char *ImagePlacedInProcessMemory::identifier() { + return "com.osvr.imaging.imageplacedinprocessmemory"; + } + + class ImagePlacedInProcessMemory::MessageSerialization { + public: + MessageSerialization() {} + explicit MessageSerialization(InProcessMemoryMessage &&msg) + : m_msgData(std::move(msg)) {} + +#if defined(_MSC_VER) && defined(_PREFAST_) + // @todo workaround for apparent bug in VS2013 /analyze + explicit MessageSerialization(InProcessMemoryMessage const &msg) + : m_msgData(msg) { } +#endif + template void processMessage(T &p) { + process(m_msgData, p); + } + + InProcessMemoryMessage const &getMessage() { return m_msgData; } + + private: + InProcessMemoryMessage m_msgData; + }; +#endif + namespace { struct SharedMemoryMessage { OSVR_ImagingMetadata metadata; @@ -169,8 +210,14 @@ namespace common { OSVR_TimeValue const ×tamp) { util::Flag dataSent; + +#ifdef OSVR_COMMON_IN_PROCESS_IMAGING + dataSent += + m_sendImageDataViaInProcessMemory(metadata, imageData, sensor, timestamp); +#else dataSent += m_sendImageDataViaSharedMemory(metadata, imageData, sensor, timestamp); +#endif dataSent += m_sendImageDataOnTheWire(metadata, imageData, sensor, timestamp); if (dataSent) { @@ -178,6 +225,26 @@ namespace common { } } +#ifdef OSVR_COMMON_IN_PROCESS_IMAGING + bool ImagingComponent::m_sendImageDataViaInProcessMemory( + OSVR_ImagingMetadata metadata, OSVR_ImageBufferElement *imageData, + OSVR_ChannelCount sensor, OSVR_TimeValue const ×tamp) { + + auto imgBufferSize = getBufferSize(metadata); + auto dataCopy = new OSVR_ImageBufferElement[imgBufferSize]; + memcpy(dataCopy, imageData, imgBufferSize); + Buffer<> buf; + messages::ImagePlacedInProcessMemory::MessageSerialization serialization( + messages::InProcessMemoryMessage{ metadata, sensor, reinterpret_cast(dataCopy) }); + + serialize(buf, serialization); + m_getParent().packMessage( + buf, imagePlacedInProcessMemory.getMessageType(), timestamp); + + return true; + } +#endif + bool ImagingComponent::m_sendImageDataViaSharedMemory( OSVR_ImagingMetadata metadata, OSVR_ImageBufferElement *imageData, OSVR_ChannelCount sensor, OSVR_TimeValue const ×tamp) { @@ -259,6 +326,30 @@ namespace common { return 0; } +#ifdef OSVR_COMMON_IN_PROCESS_IMAGING + int VRPN_CALLBACK + ImagingComponent::m_handleImagePlacedInProcessMemory(void *userdata, + vrpn_HANDLERPARAM p) { + auto self = static_cast(userdata); + auto bufReader = readExternalBuffer(p.buffer, p.payload_len); + + messages::ImagePlacedInProcessMemory::MessageSerialization msgSerialize; + deserialize(bufReader, msgSerialize); + auto msg = msgSerialize.getMessage(); + ImageData data; + data.sensor = msg.sensor; + data.metadata = msg.metadata; + data.buffer.reset(reinterpret_cast(msg.buffer)); + auto timestamp = util::time::fromStructTimeval(p.msg_time); + + self->m_checkFirst(msg.metadata); + for (auto const &cb : self->m_cb) { + cb(data, timestamp); + } + return 0; + } +#endif + int VRPN_CALLBACK ImagingComponent::m_handleImagePlacedInSharedMemory(void *userdata, vrpn_HANDLERPARAM p) { @@ -317,12 +408,21 @@ namespace common { m_registerHandler( &ImagingComponent::m_handleImagePlacedInSharedMemory, this, imagePlacedInSharedMemory.getMessageType()); + +#ifdef OSVR_COMMON_IN_PROCESS_IMAGING + m_registerHandler( + &ImagingComponent::m_handleImagePlacedInProcessMemory, this, + imagePlacedInProcessMemory.getMessageType()); +#endif } m_cb.push_back(handler); } void ImagingComponent::m_parentSet() { m_getParent().registerMessageType(imageRegion); m_getParent().registerMessageType(imagePlacedInSharedMemory); +#ifdef OSVR_COMMON_IN_PROCESS_IMAGING + m_getParent().registerMessageType(imagePlacedInProcessMemory); +#endif } void ImagingComponent::m_checkFirst(OSVR_ImagingMetadata const &metadata) { diff --git a/src/osvr/Common/ImagingComponentConfig.h.cmake_in b/src/osvr/Common/ImagingComponentConfig.h.cmake_in new file mode 100644 index 000000000..185a957bd --- /dev/null +++ b/src/osvr/Common/ImagingComponentConfig.h.cmake_in @@ -0,0 +1,30 @@ +/** @file + @brief Generated header describing imaging component config + + @date 2015 + + @author + Sensics, Inc. + +*/ + +// Copyright 2015 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef INCLUDED_ImagingComponentConfig_h_GUID_093B7AF1_DCAB_4307_ACBB_F9DA4282E3BB +#define INCLUDED_ImagingComponentConfig_h_GUID_093B7AF1_DCAB_4307_ACBB_F9DA4282E3BB + +#cmakedefine OSVR_COMMON_IN_PROCESS_IMAGING 1 + +#endif // INCLUDED_ImagingComponentConfig_h_GUID_093B7AF1_DCAB_4307_ACBB_F9DA4282E3BB From 306bafecae984162cda76e502e73774195f82be7 Mon Sep 17 00:00:00 2001 From: JeroMiya Date: Wed, 7 Oct 2015 11:43:37 -0400 Subject: [PATCH 3/8] in-process image message now uses OpenCV allocation and free functions to create the image copy. --- src/osvr/Common/ImagingComponent.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/osvr/Common/ImagingComponent.cpp b/src/osvr/Common/ImagingComponent.cpp index 8d6207c9d..9a5465466 100644 --- a/src/osvr/Common/ImagingComponent.cpp +++ b/src/osvr/Common/ImagingComponent.cpp @@ -230,12 +230,13 @@ namespace common { OSVR_ImagingMetadata metadata, OSVR_ImageBufferElement *imageData, OSVR_ChannelCount sensor, OSVR_TimeValue const ×tamp) { - auto imgBufferSize = getBufferSize(metadata); - auto dataCopy = new OSVR_ImageBufferElement[imgBufferSize]; - memcpy(dataCopy, imageData, imgBufferSize); + auto imageBufferSize = getBufferSize(metadata); + auto imageBufferCopy = reinterpret_cast(cv::fastMalloc(imageBufferSize)); + memcpy(imageBufferCopy, imageData, imageBufferSize); + Buffer<> buf; messages::ImagePlacedInProcessMemory::MessageSerialization serialization( - messages::InProcessMemoryMessage{ metadata, sensor, reinterpret_cast(dataCopy) }); + messages::InProcessMemoryMessage{ metadata, sensor, reinterpret_cast(imageBufferCopy) }); serialize(buf, serialization); m_getParent().packMessage( @@ -339,7 +340,7 @@ namespace common { ImageData data; data.sensor = msg.sensor; data.metadata = msg.metadata; - data.buffer.reset(reinterpret_cast(msg.buffer)); + data.buffer.reset(reinterpret_cast(msg.buffer), &cv::fastFree); auto timestamp = util::time::fromStructTimeval(p.msg_time); self->m_checkFirst(msg.metadata); From 38b6c8fbc7a16e95f7602b84fde1e9efc19b5967 Mon Sep 17 00:00:00 2001 From: JeroMiya Date: Wed, 7 Oct 2015 12:02:22 -0400 Subject: [PATCH 4/8] Reverting a commit from a work in progress branch. --- src/osvr/Common/CMakeLists.txt | 1 - src/osvr/Common/IPCRingBuffer.cpp | 1 - src/osvr/PluginKit/CMakeLists.txt | 1 - 3 files changed, 3 deletions(-) diff --git a/src/osvr/Common/CMakeLists.txt b/src/osvr/Common/CMakeLists.txt index 3b978c966..16db3457d 100644 --- a/src/osvr/Common/CMakeLists.txt +++ b/src/osvr/Common/CMakeLists.txt @@ -197,7 +197,6 @@ target_link_libraries(${LIBNAME_FULL} PRIVATE jsoncpp_lib opencv_core - log vendored-vrpn eigen-headers osvr_cxx11_flags diff --git a/src/osvr/Common/IPCRingBuffer.cpp b/src/osvr/Common/IPCRingBuffer.cpp index 65c2c08bf..5ac9394b2 100644 --- a/src/osvr/Common/IPCRingBuffer.cpp +++ b/src/osvr/Common/IPCRingBuffer.cpp @@ -23,7 +23,6 @@ // limitations under the License. // Internal Includes -#define BOOST_INTERPROCESS_SHARED_DIR_PATH "/sdcard" #include #include "IPCRingBufferResults.h" #include "IPCRingBufferSharedObjects.h" diff --git a/src/osvr/PluginKit/CMakeLists.txt b/src/osvr/PluginKit/CMakeLists.txt index faa551053..5f5aa8d9a 100644 --- a/src/osvr/PluginKit/CMakeLists.txt +++ b/src/osvr/PluginKit/CMakeLists.txt @@ -53,7 +53,6 @@ target_link_libraries(${LIBNAME_FULL} osvrConnection osvrUtilCpp osvrCommon - log vendored-vrpn boost_thread) From 871ce0c6f8140507d53536ae4939204d8769cc2c Mon Sep 17 00:00:00 2001 From: JeroMiya Date: Wed, 7 Oct 2015 17:40:46 -0400 Subject: [PATCH 5/8] added todo comment. --- src/osvr/PluginKit/ImagingInterfaceC.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/osvr/PluginKit/ImagingInterfaceC.cpp b/src/osvr/PluginKit/ImagingInterfaceC.cpp index 5cddd0374..476a6c0d0 100644 --- a/src/osvr/PluginKit/ImagingInterfaceC.cpp +++ b/src/osvr/PluginKit/ImagingInterfaceC.cpp @@ -38,6 +38,11 @@ // Standard includes // - none + +// @todo This is a hack. expect this to be moved to a separate osvrJniBridge +// library and encapsulated behind a proper API. + +#if defined(__ANDROID__) #include OSVR_ImageBufferElement *gLastFrame = NULL; OSVR_ImagingMetadata gLastFrameMetadata; @@ -68,6 +73,7 @@ JNIEXPORT void JNICALL Java_com_osvr_android_gles2sample_MainActivityJNILib_repo gLastFrame = new OSVR_ImageBufferElement[size]; env->GetByteArrayRegion(data, 0, size, reinterpret_cast(gLastFrame)); } +#endif struct OSVR_ImagingDeviceInterfaceObject : public osvr::connection::DeviceInterfaceBase { From 82db7689c7c1a14534ca0e232d30f14d8705dfa7 Mon Sep 17 00:00:00 2001 From: "bell.jeremy@gmail.com" Date: Thu, 8 Oct 2015 01:31:07 -0400 Subject: [PATCH 6/8] Reusing the gLastFrame instead of allocating it every time. --- src/osvr/PluginKit/ImagingInterfaceC.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/osvr/PluginKit/ImagingInterfaceC.cpp b/src/osvr/PluginKit/ImagingInterfaceC.cpp index 5cddd0374..4722713ae 100644 --- a/src/osvr/PluginKit/ImagingInterfaceC.cpp +++ b/src/osvr/PluginKit/ImagingInterfaceC.cpp @@ -38,16 +38,18 @@ // Standard includes // - none +#if defined(__ANDROID__) #include OSVR_ImageBufferElement *gLastFrame = NULL; +OSVR_ImageBufferElement *gLastFrameBuffer = NULL; OSVR_ImagingMetadata gLastFrameMetadata; extern "C" { - JNIEXPORT void JNICALL Java_com_osvr_android_gles2sample_MainActivityJNILib_reportFrame(JNIEnv * env, jclass clazz, + JNIEXPORT void JNICALL Java_com_osvr_android_jni_JNIBridge_reportFrame(JNIEnv * env, jclass clazz, jbyteArray data, jlong width, jlong height, jshort channels, jshort depth); } -JNIEXPORT void JNICALL Java_com_osvr_android_gles2sample_MainActivityJNILib_reportFrame(JNIEnv * env, jclass clazz, +JNIEXPORT void JNICALL Java_com_osvr_android_jni_JNIBridge_reportFrame(JNIEnv * env, jclass clazz, jbyteArray data, jlong width, jlong height, jshort channels, jshort depth) { gLastFrameMetadata.height = (OSVR_ImageDimension)height; @@ -59,15 +61,15 @@ JNIEXPORT void JNICALL Java_com_osvr_android_gles2sample_MainActivityJNILib_repo // and if so, reuse the last frame buffer instead of deleting and recreating. // better yet, use a ring buffer so that image reports aren't lost if update // isn't called frequently enough. - if(gLastFrame) { - // this image will be lost. the plugin's update method wasn't called - // fast enough. - delete[] gLastFrame; - } int size = env->GetArrayLength(data); - gLastFrame = new OSVR_ImageBufferElement[size]; - env->GetByteArrayRegion(data, 0, size, reinterpret_cast(gLastFrame)); + + if(gLastFrameBuffer == NULL) { + gLastFrameBuffer = new OSVR_ImageBufferElement[size]; + } + gLastFrame = gLastFrameBuffer; + env->GetByteArrayRegion(data, 0, size, reinterpret_cast(gLastFrameBuffer)); } +#endif struct OSVR_ImagingDeviceInterfaceObject : public osvr::connection::DeviceInterfaceBase { From b1ce65fdab986238ff1cd61def2a88961c6ead37 Mon Sep 17 00:00:00 2001 From: JeroMiya Date: Fri, 9 Oct 2015 18:07:44 -0400 Subject: [PATCH 7/8] Removed some arguments of the reportFrame jni method. The jni plugin will determine the depth/channels. --- src/osvr/PluginKit/ImagingInterfaceC.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/osvr/PluginKit/ImagingInterfaceC.cpp b/src/osvr/PluginKit/ImagingInterfaceC.cpp index 92684ede9..8cfac9615 100644 --- a/src/osvr/PluginKit/ImagingInterfaceC.cpp +++ b/src/osvr/PluginKit/ImagingInterfaceC.cpp @@ -50,16 +50,16 @@ OSVR_ImagingMetadata gLastFrameMetadata; extern "C" { JNIEXPORT void JNICALL Java_com_osvr_android_jni_JNIBridge_reportFrame(JNIEnv * env, jclass clazz, - jbyteArray data, jlong width, jlong height, jshort channels, jshort depth); + jbyteArray data, jlong width, jlong height); } JNIEXPORT void JNICALL Java_com_osvr_android_jni_JNIBridge_reportFrame(JNIEnv * env, jclass clazz, - jbyteArray data, jlong width, jlong height, jshort channels, jshort depth) { + jbyteArray data, jlong width, jlong height) { gLastFrameMetadata.height = (OSVR_ImageDimension)height; gLastFrameMetadata.width = (OSVR_ImageDimension)width; - gLastFrameMetadata.channels = (OSVR_ImageChannels)channels; - gLastFrameMetadata.depth = (OSVR_ImageDepth)depth; + gLastFrameMetadata.channels = (OSVR_ImageChannels)4; + gLastFrameMetadata.depth = (OSVR_ImageDepth)1; // @todo determine whether the current metadata matches the last metadata, // and if so, reuse the last frame buffer instead of deleting and recreating. From ca2171960685882dc92bcffe1be017c7e2961d78 Mon Sep 17 00:00:00 2001 From: JeroMiya Date: Tue, 13 Oct 2015 16:47:15 -0400 Subject: [PATCH 8/8] Updates per code review. --- src/osvr/Common/CMakeLists.txt | 4 +++- src/osvr/Common/ImagingComponent.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/osvr/Common/CMakeLists.txt b/src/osvr/Common/CMakeLists.txt index 16db3457d..eec94bc24 100644 --- a/src/osvr/Common/CMakeLists.txt +++ b/src/osvr/Common/CMakeLists.txt @@ -23,7 +23,9 @@ if(BUILD_WITH_TRACING) endif() endif() -option(OSVR_COMMON_IN_PROCESS_IMAGING OFF) +option(OSVR_COMMON_IN_PROCESS_IMAGING "Option to switch from shared-memory imaging messages to use only in-process memory messages. Requires single-process client/server." OFF) + +mark_as_advanced(OSVR_COMMON_IN_PROCESS_IMAGING) configure_file(TracingConfig.h.cmake_in "${CMAKE_CURRENT_BINARY_DIR}/TracingConfig.h") diff --git a/src/osvr/Common/ImagingComponent.cpp b/src/osvr/Common/ImagingComponent.cpp index 9a5465466..0aeaee9a1 100644 --- a/src/osvr/Common/ImagingComponent.cpp +++ b/src/osvr/Common/ImagingComponent.cpp @@ -121,7 +121,7 @@ namespace common { p(ipmmMsg.sensor); p(ipmmMsg.buffer); } - } + } // namespace const char *ImagePlacedInProcessMemory::identifier() { return "com.osvr.imaging.imageplacedinprocessmemory";