From 8a3067f36965db2fff0caddb53daaf74a34abd6f Mon Sep 17 00:00:00 2001 From: Pisike Sipelgas Date: Tue, 6 Dec 2016 14:01:10 +0200 Subject: [PATCH 1/6] freebsd motion build fixes. issue #267 --- configure.ac | 11 +++++++++-- logger.c | 2 ++ netcam_rtsp.c | 6 +++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index dfe8fba0..1e03d8c4 100644 --- a/configure.ac +++ b/configure.ac @@ -350,7 +350,11 @@ WITHOUT_MMAL="no") if test "${WITHOUT_MMAL}" = "no"; then HAVE_MMAL="" - LIBRASPBERRYPIDEVPATH="/opt/vc/include/interface/mmal" + if test "${FreeBSD}" != "" ; then + LIBRASPBERRYPIDEVPATH="/usr/local/include/interface/mmal" + else + LIBRASPBERRYPIDEVPATH="/opt/vc/include/interface/mmal" + fi if test -d ${LIBRASPBERRYPIDEVPATH}; then HAVE_MMAL="yes" @@ -362,7 +366,10 @@ if test "${WITHOUT_MMAL}" = "no"; then AC_SUBST(MMAL_LIBS) MMAL_OBJ="mmalcam.o raspicam/RaspiCamControl.o raspicam/RaspiCLI.o" MMAL_CFLAGS="-std=gnu99 -DHAVE_MMAL -Irasppicam -I/opt/vc/include" - MMAL_LIBS="-L/opt/vc/lib -lmmal_core -lmmal_util -lmmal_vc_client -lvcos -lvchostif -lvchiq_arm" + AS_IF([test "${FreeBSD}" != "" ], [ + MMAL_CFLAGS="${MMAL_CFLAGS} -I/usr/local/include -I/usr/local/include/interface/vcos -I/usr/local/include/interface/vcos/pthreads/ -I/usr/local/include/interface/vmcs_host/linux" + ]) + MMAL_LIBS="-L/opt/vc/lib -lmmal_core -lmmal_util -lmmal_vc_client -lvcos -lvchostif -lvchiq_arm" AC_DEFINE([HAVE_MMAL], 1, [Define to 1 if we want MMAL]) ]) fi diff --git a/logger.c b/logger.c index 96b7eb3a..6cde10ce 100644 --- a/logger.c +++ b/logger.c @@ -192,7 +192,9 @@ void motion_log(int level, unsigned int type, int errno_flag, const char *fmt, . errno_save = errno; char threadname[32] = "unknown"; +#if (!defined(__FreeBSD__)) pthread_getname_np(pthread_self(), threadname, sizeof(threadname)); +#endif /* * Prefix the message with the log level string, log type string, diff --git a/netcam_rtsp.c b/netcam_rtsp.c index c3e1a846..811a66cc 100644 --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -462,9 +462,13 @@ static int netcam_rtsp_open_context(netcam_context_ptr netcam){ * our thread name - so temporarily change our thread name to the * desired name */ { - char curtname[16]; char newtname[16]; +#if defined(__FreeBSD__) + char curtname[16] = "unknown"; +#else + char curtname[16]; pthread_getname_np(pthread_self(), curtname, sizeof(curtname)); +#endif snprintf(newtname, sizeof(newtname), "av%d%s%s", netcam->cnt->threadnr, netcam->cnt->conf.camera_name ? ":" : "", From ed1a5e6cd5a16b41ef2e37b8fc94bcdf72d1958d Mon Sep 17 00:00:00 2001 From: Sebastiaan Lokhorst Date: Fri, 9 Dec 2016 19:24:48 +0100 Subject: [PATCH 2/6] Remove unneeded MOTION_V4L2_OLD define V4L2 is defined in in current kernels --- CMakeLists.txt | 1 - config.h.in | 1 - configure.ac | 19 +++---------------- video.h | 6 +++--- video2.c | 6 ------ 5 files changed, 6 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bc698f80..64403da0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,6 @@ else(${WITH_V4L}) set(WITHOUT_V4L ON) endif(${WITH_V4L}) set(MOTION_V4L2 ${HAVE_LINUX_VIDEODEV2_H}) -set(MOTION_V4L2_OLD ${HAVE_LINUX_VIDEODEV2_H}) configure_file(config.h.in "${CMAKE_CURRENT_SOURCE_DIR}/config.h") configure_file(motion-dist.conf.in motion-dist.conf) diff --git a/config.h.in b/config.h.in index d791908b..de14c1c1 100644 --- a/config.h.in +++ b/config.h.in @@ -18,5 +18,4 @@ #undef PWCBSD #undef OLD_BKTR #cmakedefine MOTION_V4L2 -#cmakedefine MOTION_V4L2_OLD #cmakedefine WITHOUT_V4L diff --git a/configure.ac b/configure.ac index 1e03d8c4..803f97a6 100644 --- a/configure.ac +++ b/configure.ac @@ -745,7 +745,6 @@ AC_CHECK_HEADERS(stdio.h unistd.h stdint.h fcntl.h time.h signal.h sys/ioctl.h s # Check if v4l2 is available SUPPORTED_V4L2=false -SUPPORTED_V4L2_old=false if test "${V4L}" = "no"; then AC_MSG_CHECKING(for V42L support) @@ -755,7 +754,9 @@ else [SUPPORTED_V4L2=true], [SUPPORTED_V4L2=false], [#include - #ifdef HAVE_LINUX_VIDEODEV_H + #ifdef HAVE_LINUX_VIDEODEV2_H + #include + #elif HAVE_LINUX_VIDEODEV_H #include #elif HAVE_SYS_VIDEOIO_H #include @@ -767,20 +768,6 @@ else else AC_MSG_RESULT(no) fi - - # linux/videodev.h doesn't include videodev2.h - if test x$SUPPORTED_V4L2 = xfalse; then - AC_MSG_CHECKING(for V42L *old* support) - AC_MSG_RESULT(testing) - AC_CHECK_HEADERS(linux/videodev2.h,[SUPPORTED_V4L2_old=true],[], [#include ]) - fi - - - if test x$SUPPORTED_V4L2_old = xtrue; then - TEMP_CFLAGS="${TEMP_CFLAGS} -DMOTION_V4L2 -DMOTION_V4L2_OLD" - SUPPORTED_V4L2=true - fi - fi diff --git a/video.h b/video.h index 03bcf659..a39cd2c5 100644 --- a/video.h +++ b/video.h @@ -10,12 +10,12 @@ #ifndef _INCLUDE_VIDEO_H #define _INCLUDE_VIDEO_H -#define _LINUX_TIME_H 1 #include - #if !defined(WITHOUT_V4L) -#if defined(HAVE_LINUX_VIDEODEV_H) +#if defined(HAVE_LINUX_VIDEODEV2_H) +#include +#elif defined(HAVE_LINUX_VIDEODEV_H) #include #elif defined(HAVE_SYS_VIDEOIO_H) #include diff --git a/video2.c b/video2.c index 037dac8a..e828f563 100644 --- a/video2.c +++ b/video2.c @@ -73,12 +73,6 @@ #if !defined(WITHOUT_V4L) && defined(MOTION_V4L2) -#ifdef MOTION_V4L2_OLD -// Seems that is needed for some system -#include -#include -#endif - #define u8 unsigned char #define u16 unsigned short #define u32 unsigned int From 7bfae42a6d46978412e972b397dc474865f91568 Mon Sep 17 00:00:00 2001 From: Sebastiaan Lokhorst Date: Fri, 9 Dec 2016 19:27:31 +0100 Subject: [PATCH 3/6] Remove OLD_BKTR define Not used in any semi-recent or supported BSD distro. --- config.h.in | 1 - configure.ac | 1 - video_freebsd.h | 7 +------ 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/config.h.in b/config.h.in index de14c1c1..604aea12 100644 --- a/config.h.in +++ b/config.h.in @@ -16,6 +16,5 @@ /* TODO: look at these */ #undef PWCBSD -#undef OLD_BKTR #cmakedefine MOTION_V4L2 #cmakedefine WITHOUT_V4L diff --git a/configure.ac b/configure.ac index 803f97a6..bcfd794a 100644 --- a/configure.ac +++ b/configure.ac @@ -93,7 +93,6 @@ if test "${FreeBSD}" != "" && test "${PWCBSD}" = "no"; then AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) - TEMP_CFLAGS="${TEMP_CFLAGS} -DOLD_BKTR" fi # # Check to Exclude BKTR diff --git a/video_freebsd.h b/video_freebsd.h index c75692f5..eb1e064c 100644 --- a/video_freebsd.h +++ b/video_freebsd.h @@ -13,13 +13,8 @@ #ifndef WITHOUT_V4L -#ifdef __NetBSD__ +#if defined(__NetBSD__) || defined(__OpenBSD__) #include -#elif __OpenBSD__ -#include -#elif defined(OLD_BKTR) -#include -#include #else #include #include From b9b5bda2e218737a1aa64ee9bcbed848b7dbfbc8 Mon Sep 17 00:00:00 2001 From: Sebastiaan Lokhorst Date: Fri, 9 Dec 2016 19:30:11 +0100 Subject: [PATCH 4/6] Remove unneeded include --- motion.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/motion.h b/motion.h index 0e5863a8..ca81d202 100644 --- a/motion.h +++ b/motion.h @@ -49,12 +49,6 @@ #include #include #include - -#define _LINUX_TIME_H 1 -#if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) && (!defined(BSD)) -#include -#endif - #include #include "logger.h" From 7a9249447355b2899888b61000f6cb2e27a7c7b0 Mon Sep 17 00:00:00 2001 From: Sebastiaan Lokhorst Date: Fri, 9 Dec 2016 19:32:38 +0100 Subject: [PATCH 5/6] Remove code for pre-Linux 2.6.10 kernels. --- pwc-ioctl.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pwc-ioctl.h b/pwc-ioctl.h index e7f5480b..3dbbac35 100644 --- a/pwc-ioctl.h +++ b/pwc-ioctl.h @@ -55,14 +55,8 @@ #if defined(__linux__) #include #include - -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 10) -/* Compatibility for older kernel */ -typedef __u16 __le16; #endif -#endif /* ( !BSD ) */ - /* Enumeration of image sizes */ #define PSZ_SQCIF 0x00 #define PSZ_QSIF 0x01 From 07eb1a408361effe2b0af2be1e3a5e0fe3767544 Mon Sep 17 00:00:00 2001 From: Sebastiaan Lokhorst Date: Fri, 9 Dec 2016 19:33:14 +0100 Subject: [PATCH 6/6] Fix PWCBSD CMake build --- CMakeLists.txt | 11 +++++++---- config.h.in | 8 +++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 64403da0..f340a2c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,7 @@ option(WITH_MYSQL "enable MySQL database support" ${MYSQL_FOUND}) option(WITH_PGSQL "enable PostgreSQL database support" ${PostgreSQL_FOUND}) option(WITH_SQLITE3 "enable SQLite database support" ${SQLITE3_FOUND}) option(WITH_V4L "enable Video 4 Linux (2) webcam support" ON) +option(WITH_PWCBSD "enable PWC webcam support (BSD only)" OFF) set(HAVE_FFMPEG ${WITH_FFMPEG}) set(HAVE_MMAL ${WITH_MMAL}) @@ -40,6 +41,7 @@ else(${WITH_V4L}) set(WITHOUT_V4L ON) endif(${WITH_V4L}) set(MOTION_V4L2 ${HAVE_LINUX_VIDEODEV2_H}) +set(PWCBSD WITH_PWCBSD) configure_file(config.h.in "${CMAKE_CURRENT_SOURCE_DIR}/config.h") configure_file(motion-dist.conf.in motion-dist.conf) @@ -56,11 +58,12 @@ configure_file(motion.init-FreeBSD.sh.in motion.init-FreeBSD.sh) list(APPEND SRC_FILES conf.c motion.c alg.c draw.c event.c ffmpeg.c jpegutils.c logger.c md5.c netcam.c netcam_ftp.c netcam_jpeg.c netcam_rtsp.c netcam_wget.c - picture.c rotate.c stream.c track.c video2.c video.c video_common.c - vloopback_motion.c webhttpd.c) -if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") + picture.c rotate.c stream.c track.c vloopback_motion.c webhttpd.c) +if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" AND NOT(WITH_PWCBSD)) list(APPEND SRC_FILES video_freebsd.c) -endif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") +else() + list(APPEND SRC_FILES video2.c video.c video_common.c) +endif() include_directories(${JPEG_INCLUDE_DIR}) list(APPEND LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ${JPEG_LIBRARIES}) diff --git a/config.h.in b/config.h.in index 604aea12..dd3f8d32 100644 --- a/config.h.in +++ b/config.h.in @@ -8,13 +8,11 @@ #cmakedefine HAVE_MYSQL #cmakedefine HAVE_PGSQL #cmakedefine HAVE_SQLITE3 +#cmakedefine PWCBSD +#cmakedefine MOTION_V4L2 +#cmakedefine WITHOUT_V4L /* Optional headers */ #cmakedefine HAVE_LINUX_VIDEODEV_H #cmakedefine HAVE_LINUX_VIDEODEV2_H #cmakedefine HAVE_SYS_VIDEOIO_H - -/* TODO: look at these */ -#undef PWCBSD -#cmakedefine MOTION_V4L2 -#cmakedefine WITHOUT_V4L