Merge pull request #3345 from Carbenium/ci-freebsd-13

Fix FreeBSD build and improve CI
This commit is contained in:
Isaac Connor 2021-09-07 18:57:25 -04:00 committed by GitHub
commit f576613c7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 147 additions and 45 deletions

View File

@ -1,17 +1,19 @@
task:
name: freebsd-build
freebsd_instance:
image_family: freebsd-12-2
matrix:
- image_family: freebsd-12-2
- image_family: freebsd-13-0
prepare_script:
- pkg install -yq git cmake pkgconf jpeg-turbo mysql80-client ffmpeg libvncserver libjwt catch p5-DBI p5-DBD-mysql p5-Date-Manip p5-Test-LWP-UserAgent p5-Sys-Mmap
- pkg install -yq git cmake pkgconf jpeg-turbo mysql80-client ffmpeg libvncserver libjwt catch p5-DBI p5-DBD-mysql p5-Date-Manip p5-Test-LWP-UserAgent p5-Sys-Mmap v4l_compat
configure_script:
- git submodule update --init --recursive
- mkdir build
- cd build
- cmake --version
- cmake ../ -DBUILD_MAN=0 -DBUILD_TEST_SUITE=1 -DENABLE_WERROR=1
- cmake ../ -DBUILD_MAN=0 -DBUILD_TEST_SUITE=1 -DENABLE_WERROR=1 -DCMAKE_C_FLAGS="-Wno-deprecated-declarations" -DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations"
build_script:
- cd build

View File

@ -268,7 +268,6 @@ if(ZM_SYSTEMD OR (IS_DIRECTORY /usr/lib/systemd/system) OR (IS_DIRECTORY /lib/sy
endif()
# System checks
check_include_file("linux/videodev2.h" HAVE_LINUX_VIDEODEV2_H)
check_include_file("execinfo.h" HAVE_EXECINFO_H)
if(HAVE_EXECINFO_H)
check_function_exists("backtrace" HAVE_DECL_BACKTRACE)
@ -528,17 +527,14 @@ if((NOT HAVE_LIBJWT) AND (NOT HAVE_LIBOPENSSL))
message(FATAL_ERROR "Using the jwt-cpp backend requires OpenSSL as crypto backend.")
endif()
# Check for V4L header files and enable ZM_HAS_V4L, ZM_HAS_V4L2 accordingly
# Setting to zeros first is required because ZM uses #define for these
set(ZM_HAS_V4L 0)
set(ZM_HAS_V4L2 0)
if(HAVE_LINUX_VIDEODEV2_H)
set(ZM_HAS_V4L 1)
find_package(V4L2)
if(TARGET V4L2::videodev2)
set(ZM_HAS_V4L2 1)
endif()
if(NOT HAVE_LINUX_VIDEODEV2_H)
else()
set(ZM_HAS_V4L2 0)
message(AUTHOR_WARNING "Video 4 Linux headers weren't found - Analog and USB camera support will not be available")
endif()
# Check for PCRE and enable ZM_PCRE accordingly
set(ZM_PCRE 0)
if(HAVE_LIBPCRE AND HAVE_PCRE_H)

View File

@ -0,0 +1,99 @@
#[=======================================================================[.rst:
FindV4L2
----------
Find V4L2 headers and libv4l2
This module accepts optional COMPONENTS:
videodev2 (default)
libv4l2
IMPORTED Targets
^^^^^^^^^^^^^^^^
This module defines the following :prop_tgt:`IMPORTED` targets::
``V4L2::videodev2``
The Video for Linux Two header file, if found.
``V4L2::libv4l2``
A thin abstraction layer on top of video4linux2 devices, if found.
Result Variables
^^^^^^^^^^^^^^^^
``V4L2_FOUND``
System has v4l2 support. If no components are specified only the videodev2.h header has to be found.
``V4L2_INCLUDE_DIRS``
The v4l2 include directories.
``V4L2_LIBRARIES``
The libraries needed to have v4l2 support according to the specified components.
#]=======================================================================]
find_path(V4L2_VIDEODEV2_INCLUDE_DIR
NAMES linux/videodev2.h)
mark_as_advanced(V4L2_VIDEODEV2_INCLUDE_DIR)
if(EXISTS "${V4L2_VIDEODEV2_INCLUDE_DIR}")
set(V4L2_videodev2_FOUND TRUE)
else()
set(V4L2_videodev2_FOUND FALSE)
endif()
pkg_check_modules(PC_V4L2_LIBV4L2 QUIET libv4l2)
find_path(V4L2_LIBV4L2_INCLUDE_DIR
NAMES libv4l2.h
HINTS
${PC_V4L2_LIBV4L2_INCLUDEDIR}
${PC_V4L2_LIBV4L2_INCLUDE_DIRS})
mark_as_advanced(V4L2_LIBV4L2_INCLUDE_DIR)
find_library(V4L2_LIBV4L2_LIBRARY
NAMES ${PC_V4L2_LIBV4L2_LIBRARIES}
HINTS
${PC_V4L2_LIBV4L2_LIBDIR}
${PC_V4L2_LIBV4L2_LIBRARY_DIR})
mark_as_advanced(V4L2_LIBV4L2_LIBRARY)
if(EXISTS "${V4L2_LIBV4L2_INCLUDE_DIR}" AND
EXISTS "${V4L2_LIBV4L2_LIBRARY}")
set(V4L2_libv4l2_FOUND TRUE)
else()
set(V4L2_libv4l2_FOUND FALSE)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(V4L2
REQUIRED_VARS
V4L2_VIDEODEV2_INCLUDE_DIR
HANDLE_COMPONENTS)
set(V4L2_INCLUDE_DIRS)
set(V4L2_LIBRARIES)
if(V4L2_videodev2_FOUND)
set(V4L2_VIDEODEV2_INCLUDE_DIRS ${V4L2_VIDEODEV2_INCLUDE_DIR})
list(APPEND V4L2_INCLUDE2_DIRS
"${V4L2_VIDEODEV2_INCLUDE_DIRS}")
add_library(V4L2::videodev2 INTERFACE IMPORTED)
set_target_properties(V4L2::videodev2 PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${V4L2_VIDEODEV2_INCLUDE_DIRS}")
endif()
if(V4L2_libv4l2_FOUND)
set(V4L2_LIBV4L2_INCLUDE_DIRS ${V4L2_LIBV4L2_INCLUDE_DIR})
set(V4L2_LIBV4L2_LIBRARIES ${V4L2_LIBV4L2_LIBRARY})
list(APPEND V4L2_INCLUDE_DIRS
"${V4L2_LIBV4L2_INCLUDE_DIRS}")
list(APPEND V4L2_LIBRARIES
"${V4L2_LIBV4L2_LIBRARIES}")
add_library(V4L2::libv4l2 UNKNOWN IMPORTED)
set_target_properties(V4L2::libv4l2 PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${V4L2_LIBV4L2_INCLUDE_DIRS}"
IMPORTED_LOCATION "${V4L2_LIBV4L2_LIBRARY}")
endif()

View File

@ -98,6 +98,12 @@ elseif(${ZM_JWT_BACKEND} STREQUAL "libjwt")
JWT::libjwt)
endif()
if(TARGET V4L2::videodev2)
target_link_libraries(zm
PRIVATE
V4L2::videodev2)
endif()
add_executable(zmc zmc.cpp)
add_executable(zms zms.cpp)
add_executable(zmu zmu.cpp)

View File

@ -24,8 +24,9 @@
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#if ZM_HAS_V4L
#if ZM_HAS_V4L2
/* Workaround for GNU/kFreeBSD and FreeBSD */
#if defined(__FreeBSD_kernel__) || defined(__FreeBSD__)
@ -1130,17 +1131,17 @@ bool LocalCamera::GetCurrentSettings(
" Name: %s\n"
" Type: %s\n"
" Audioset: %08x\n"
" Standards: 0x%llx\n"
" Standards: 0x%" PRIx64"\n"
, input.index
, input.name
, input.type==V4L2_INPUT_TYPE_TUNER?"Tuner":(input.type==V4L2_INPUT_TYPE_CAMERA?"Camera":"Unknown")
, input.audioset
, input.std );
, static_cast<uint64>(input.std));
} else {
output_ptr += sprintf( output_ptr, "i%d:%s|i%dT:%s|i%dS:%llx|"
output_ptr += sprintf( output_ptr, "i%d:%s|i%dT:%s|i%dS:%" PRIx64 "|"
, input.index, input.name
, input.index, input.type==V4L2_INPUT_TYPE_TUNER?"Tuner":(input.type==V4L2_INPUT_TYPE_CAMERA?"Camera":"Unknown")
, input.index, input.std);
, input.index, static_cast<uint64>(input.std));
}
if ( verbose ) {
@ -1482,4 +1483,4 @@ int LocalCamera::Capture(std::shared_ptr<ZMPacket> &zm_packet) {
int LocalCamera::PostCapture() {
return 1;
}
#endif // ZM_HAS_V4L
#endif // ZM_HAS_V4L2

View File

@ -22,7 +22,7 @@
#include "zm_camera.h"
#if ZM_HAS_V4L
#if ZM_HAS_V4L2
#include <linux/videodev2.h>
@ -126,6 +126,6 @@ public:
static bool GetCurrentSettings(const std::string &device, char *output, int version, bool verbose);
};
#endif // ZM_HAS_V4L
#endif // ZM_HAS_V4L2
#endif // ZM_LOCAL_CAMERA_H

View File

@ -33,9 +33,9 @@
#include "zm_utils.h"
#include "zm_zone.h"
#if ZM_HAS_V4L
#if ZM_HAS_V4L2
#include "zm_local_camera.h"
#endif // ZM_HAS_V4L
#endif // ZM_HAS_V4L2
#if HAVE_LIBVLC
#include "zm_libvlc_camera.h"
@ -684,7 +684,7 @@ void Monitor::LoadCamera() {
switch (type) {
case LOCAL: {
#if ZM_HAS_V4L
#if ZM_HAS_V4L2
int extras = (deinterlacing >> 24) & 0xff;
camera = zm::make_unique<LocalCamera>(this,
@ -2416,7 +2416,7 @@ std::vector<std::shared_ptr<Monitor>> Monitor::LoadMonitors(const std::string &w
return monitors;
}
#if ZM_HAS_V4L
#if ZM_HAS_V4L2
std::vector<std::shared_ptr<Monitor>> Monitor::LoadLocalMonitors
(const char *device, Purpose purpose) {
@ -2428,7 +2428,7 @@ std::vector<std::shared_ptr<Monitor>> Monitor::LoadLocalMonitors
where += stringtf(" AND `ServerId`=%d", staticConfig.SERVER_ID);
return LoadMonitors(where, purpose);
}
#endif // ZM_HAS_V4L
#endif // ZM_HAS_V4L2
std::vector<std::shared_ptr<Monitor>> Monitor::LoadRemoteMonitors
(const char *protocol, const char *host, const char *port, const char *path, Purpose purpose) {
@ -2947,14 +2947,14 @@ bool Monitor::DumpSettings(char *output, bool verbose) {
sprintf( output+strlen(output), "Id : %u\n", id );
sprintf( output+strlen(output), "Name : %s\n", name.c_str() );
sprintf( output+strlen(output), "Type : %s\n", camera->IsLocal()?"Local":(camera->IsRemote()?"Remote":"File") );
#if ZM_HAS_V4L
#if ZM_HAS_V4L2
if ( camera->IsLocal() ) {
LocalCamera* cam = static_cast<LocalCamera*>(camera.get());
sprintf( output+strlen(output), "Device : %s\n", cam->Device().c_str() );
sprintf( output+strlen(output), "Channel : %d\n", cam->Channel() );
sprintf( output+strlen(output), "Standard : %d\n", cam->Standard() );
} else
#endif // ZM_HAS_V4L
#endif // ZM_HAS_V4L2
if ( camera->IsRemote() ) {
RemoteCamera* cam = static_cast<RemoteCamera*>(camera.get());
sprintf( output+strlen(output), "Protocol : %s\n", cam->Protocol().c_str() );
@ -2971,12 +2971,12 @@ bool Monitor::DumpSettings(char *output, bool verbose) {
}
sprintf( output+strlen(output), "Width : %u\n", camera->Width() );
sprintf( output+strlen(output), "Height : %u\n", camera->Height() );
#if ZM_HAS_V4L
#if ZM_HAS_V4L2
if ( camera->IsLocal() ) {
LocalCamera* cam = static_cast<LocalCamera*>(camera.get());
sprintf( output+strlen(output), "Palette : %d\n", cam->Palette() );
}
#endif // ZM_HAS_V4L
#endif // ZM_HAS_V4L2
sprintf(output+strlen(output), "Colours : %u\n", camera->Colours() );
sprintf(output+strlen(output), "Subpixel Order : %u\n", camera->SubpixelOrder() );
sprintf(output+strlen(output), "Event Prefix : %s\n", event_prefix.c_str() );

View File

@ -600,9 +600,9 @@ public:
StringVector GroupNames();
static std::vector<std::shared_ptr<Monitor>> LoadMonitors(const std::string &sql, Purpose purpose); // Returns # of Monitors loaded, 0 on failure.
#if ZM_HAS_V4L
#if ZM_HAS_V4L2
static std::vector<std::shared_ptr<Monitor>> LoadLocalMonitors(const char *device, Purpose purpose);
#endif // ZM_HAS_V4L
#endif // ZM_HAS_V4L2
static std::vector<std::shared_ptr<Monitor>> LoadRemoteMonitors(const char *protocol, const char *host, const char*port, const char*path, Purpose purpose);
static std::vector<std::shared_ptr<Monitor>> LoadFileMonitors(const char *file, Purpose purpose);
static std::vector<std::shared_ptr<Monitor>> LoadFfmpegMonitors(const char *file, Purpose purpose);

View File

@ -190,11 +190,11 @@ int main(int argc, char *argv[]) {
HwCapsDetect();
std::vector<std::shared_ptr<Monitor>> monitors;
#if ZM_HAS_V4L
#if ZM_HAS_V4L2
if ( device[0] ) {
monitors = Monitor::LoadLocalMonitors(device, Monitor::CAPTURE);
} else
#endif // ZM_HAS_V4L
#endif // ZM_HAS_V4L2
if ( host[0] ) {
if ( !port )
port = "80";

View File

@ -265,9 +265,9 @@ int main(int argc, char *argv[]) {
char *password = nullptr;
char *auth = nullptr;
std::string jwt_token_str = "";
#if ZM_HAS_V4L
#if ZM_HAS_V4L2
int v4lVersion = 2;
#endif // ZM_HAS_V4L
#endif // ZM_HAS_V4L2
while (1) {
int option_index = 0;
@ -379,11 +379,11 @@ int main(int argc, char *argv[]) {
case 'T':
jwt_token_str = std::string(optarg);
break;
#if ZM_HAS_V4L
#if ZM_HAS_V4L2
case 'V':
v4lVersion = (atoi(optarg)==1)?1:2;
break;
#endif // ZM_HAS_V4L
#endif // ZM_HAS_V4L2
case 'h':
case '?':
Usage(0);
@ -719,15 +719,15 @@ int main(int argc, char *argv[]) {
}
} else { // non monitor functions
if ( function & ZMU_QUERY ) {
#if ZM_HAS_V4L
#if ZM_HAS_V4L2
char vidString[0x10000] = "";
bool ok = LocalCamera::GetCurrentSettings(device, vidString, v4lVersion, verbose);
printf("%s", vidString);
exit_zmu(ok ? 0 : -1);
#else // ZM_HAS_V4L
#else // ZM_HAS_V4L2
Error("Video4linux is required for device querying");
exit_zmu(-1);
#endif // ZM_HAS_V4L
#endif // ZM_HAS_V4L2
}
if ( function & ZMU_LIST ) {

View File

@ -73,7 +73,6 @@ define('ZMU_PATH', ZM_PATH_BIN.'/zmu'); // Local path to the ZoneM
// If setup supports Video 4 Linux v2
//
define('ZM_HAS_V4L2', '@ZM_HAS_V4L2@'); // V4L2 support enabled
define('ZM_HAS_V4L', '@ZM_HAS_V4L@'); // V4L support enabled
//
// If ONVIF support has been built in

View File

@ -107,7 +107,7 @@ if ( !empty($_REQUEST['probe']) ) {
$monitor->$name = urldecode($value);
}
}
if ( ZM_HAS_V4L && $monitor->Type() == 'Local' ) {
if ( ZM_HAS_V4L2 && $monitor->Type() == 'Local' ) {
$monitor->Palette( fourCC( substr($monitor->Palette,0,1), substr($monitor->Palette,1,1), substr($monitor->Palette,2,1), substr($monitor->Palette,3,1) ) );
if ( $monitor->Format() == 'PAL' )
$monitor->Format( 0x000000ff );
@ -127,7 +127,7 @@ $sourceTypes = array(
'NVSocket' => translate('NVSocket'),
'VNC' => translate('VNC'),
);
if ( !ZM_HAS_V4L )
if ( !ZM_HAS_V4L2 )
unset($sourceTypes['Local']);
$localMethods = array(
@ -641,7 +641,7 @@ switch ( $name ) {
}
case 'source' :
{
if ( ZM_HAS_V4L && $monitor->Type() == 'Local' ) {
if ( ZM_HAS_V4L2 && $monitor->Type() == 'Local' ) {
?>
<tr>
<td class="text-right pr-3"><?php echo translate('DevicePath') ?></td>

View File

@ -44,7 +44,6 @@
/* Few ZM options that are needed by the source code */
#cmakedefine ZM_MEM_MAPPED 1
#cmakedefine ZM_HAS_V4L 1
#cmakedefine ZM_HAS_V4L2 1
/* Its safe to assume that signal return type is void. This is a fix for zm_signal.h */