Misc: Merge ZM_HAS_V4L with ZM_HAS_V4L2

This commit is contained in:
Peter Keresztes Schmidt 2021-09-08 00:15:59 +02:00
parent 0ac060fb78
commit 6e96cbe14a
10 changed files with 28 additions and 34 deletions

View File

@ -527,15 +527,11 @@ 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
find_package(V4L2)
set(ZM_HAS_V4L 0)
set(ZM_HAS_V4L2 0)
if(TARGET V4L2::videodev2)
set(ZM_HAS_V4L 1)
set(ZM_HAS_V4L2 1)
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()

View File

@ -26,7 +26,7 @@
#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__)
@ -1483,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 */