This commit is contained in:
2021-10-14 13:47:35 +02:00
commit 6625a8dfaa
4026 changed files with 844291 additions and 0 deletions
@@ -0,0 +1,47 @@
project(openvibe-module-labstreamlayer)
SET(PROJECT_VERSION_MAJOR ${OV_GLOBAL_VERSION_MAJOR})
SET(PROJECT_VERSION_MINOR ${OV_GLOBAL_VERSION_MINOR})
SET(PROJECT_VERSION_PATCH ${OV_GLOBAL_VERSION_PATCH})
SET(PROJECT_VERSION ${OV_GLOBAL_VERSION_STRING})
SET(SRC_FILES
src/Utils.cpp
include/labstreamlayer/Utils.hpp)
ADD_LIBRARY(${PROJECT_NAME} STATIC ${SRC_FILES})
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME}
PRIVATE include/labstreamlayer
PUBLIC include)
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
FOLDER ${MODULES_FOLDER})
if(UNIX)
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-fPIC")
ENDIF(UNIX)
INCLUDE("FindOpenViBE")
INCLUDE("FindOpenViBEModuleSystem")
# OpenViBE Third Party
INCLUDE("FindThirdPartyLSL")
# ---------------------------------
# Target macros
# Defines target operating system, architecture and compiler
# ---------------------------------
SET_BUILD_PLATFORM()
# -----------------------------
# Install files
# -----------------------------
INSTALL(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${DIST_BINDIR}
LIBRARY DESTINATION ${DIST_LIBDIR}
ARCHIVE DESTINATION ${DIST_LIBDIR})
INSTALL(DIRECTORY include/ DESTINATION ${DIST_INCLUDEDIR} FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h")
@@ -0,0 +1,38 @@
///-------------------------------------------------------------------------------------------------
///
/// \file Utils.hpp
/// \brief Utils for LSL within OpenViBE
/// \author Thomas Prampart (INRIA).
/// \version 0.0.1.
/// \date Thu Apr 1 2021.
///
/// \copyright (C) 2021 INRIA
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as published
/// by the Free Software Foundation, either version 3 of the License, or
/// (at your option) any later version.
///
/// This program 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 Affero General Public License for more details.
///
/// You should have received a copy of the GNU Affero General Public License
/// along with this program. If not, see <https://www.gnu.org/licenses/>.
///-------------------------------------------------------------------------------------------------
#pragma once
namespace OpenViBE {
namespace LabStreamLayer {
///
/// \brief Get LSL relative time for an OV time
/// \param time The time in OV time referential
/// \return The time (in seconds) in lsl clock referential
double getLSLRelativeTime(const CTime& time);
} // namespace LabStreamLayer
} // namespace OpenViBE
@@ -0,0 +1,54 @@
///-------------------------------------------------------------------------------------------------
///
/// \file Utils.cpp
/// \brief Implementation of utils for LSL within OpenViBE
/// \author Thomas Prampart (INRIA).
/// \version 0.0.1.
/// \date Thu Apr 1 2021.
///
/// \copyright (C) 2021 INRIA
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as published
/// by the Free Software Foundation, either version 3 of the License, or
/// (at your option) any later version.
///
/// This program 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 Affero General Public License for more details.
///
/// You should have received a copy of the GNU Affero General Public License
/// along with this program. If not, see <https://www.gnu.org/licenses/>.
///-------------------------------------------------------------------------------------------------
#include <lsl_cpp.h>
#include <system/ovCTime.h>
#include <openvibe/CTime.hpp>
#include "Utils.hpp"
namespace OpenViBE {
namespace LabStreamLayer {
double getLSLRelativeTime(const CTime& time)
{
const CTime ovTimeNow(System::Time::zgetTime());
const double lslRelativeTime = lsl::local_clock();
double diffToCurrent;
if (time > ovTimeNow)
{
diffToCurrent = (time - ovTimeNow).toSeconds();
}
else
{
diffToCurrent = -(ovTimeNow - time).toSeconds();
}
return (lslRelativeTime + diffToCurrent);
}
} // namespace LabStreamLayer
} // namespace OpenViBE