Skip to content

Commit 1a41fe8

Browse files
committed
v4l2 Revisions
This commit includes: 1. Consolidate functions into appropriate modules 2. Rename modules to reflect contents (v4l2, bktr, common) 3. Combines v4l2 and bktr so they can be used together 4. Implements functional prefixes 5. Uses HAVE_V4L2, HAVE_BKTR instead of WITHOUT_ 6. Include pthread_np.h for FreeBSD
1 parent ce93905 commit 1a41fe8

26 files changed

+1964
-2621
lines changed

CMakeLists.txt

+24-30
Original file line numberDiff line numberDiff line change
@@ -29,38 +29,36 @@ option(WITH_MYSQL "enable MySQL database support" ${MYSQL_FOUND})
2929
option(WITH_PGSQL "enable PostgreSQL database support" ${PostgreSQL_FOUND})
3030
option(WITH_SQLITE3 "enable SQLite database support" ${SQLITE3_FOUND})
3131
option(WITH_V4L2 "enable Video 4 Linux (2) webcam support" ON)
32-
option(WITH_PWCBSD "enable PWC webcam support (BSD only)" OFF)
32+
option(WITH_BKTR "enable BKTR support (BSD only)" OFF)
3333

3434
set(HAVE_FFMPEG ${WITH_FFMPEG})
3535
set(HAVE_MMAL ${WITH_MMAL})
3636
set(HAVE_MYSQL ${WITH_MYSQL})
3737
set(HAVE_PGSQL ${WITH_PGSQL})
3838
set(HAVE_SQLITE3 ${WITH_SQLITE3})
3939

40-
set(WITHOUT_V4L2 ON)
41-
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" AND NOT(WITH_PWCBSD))
40+
set(HAVE_V4L2 OFF)
41+
check_include_files("linux/videodev2.h" HAVE_LINUX_VIDEODEV2_H)
42+
if(HAVE_LINUX_VIDEODEV2_H AND WITH_V4L2)
43+
set(HAVE_V4L2 ON )
44+
endif(HAVE_LINUX_VIDEODEV2_H AND WITH_V4L2)
45+
46+
set(HAVE_BKTR OFF)
47+
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
4248
check_include_files("dev/bktr/ioctl_bt848.h" HAVE_FREEBSD_BT848)
4349
check_include_files("dev/bktr/ioctl_meteor.h" HAVE_FREEBSD_METEOR)
44-
if(HAVE_FREEBSD_BT848 AND HAVE_FREEBSD_METEOR AND WITH_V4L2 )
45-
set(WITHOUT_V4L2 OFF )
46-
endif(HAVE_FREEBSD_BT848 AND HAVE_FREEBSD_METEOR AND WITH_V4L2 )
47-
endif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" AND NOT(WITH_PWCBSD))
50+
if(HAVE_FREEBSD_BT848 AND HAVE_FREEBSD_METEOR AND WITH_BKTR)
51+
set(HAVE_BKTR ON )
52+
endif(HAVE_FREEBSD_BT848 AND HAVE_FREEBSD_METEOR AND WITH_BKTR)
53+
endif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
4854

4955
if(CMAKE_SYSTEM_NAME MATCHES "NetBSD" OR CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
5056
check_include_files("dev/ic/bt8xx.h" HAVE_NETOPEN_BT8XX)
51-
if(HAVE_NETOPEN_BT8XX AND WITH_V4L2)
52-
set(WITHOUT_V4L2 OFF )
53-
endif(HAVE_NETOPEN_BT8XX AND WITH_V4L2)
57+
if(HAVE_NETOPEN_BT8XX AND WITH_BKTR)
58+
set(HAVE_BKTR ON )
59+
endif(HAVE_NETOPEN_BT8XX AND WITH_BKTR)
5460
endif(CMAKE_SYSTEM_NAME MATCHES "NetBSD" OR CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
5561

56-
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
57-
check_include_files("linux/videodev2.h" HAVE_LINUX_VIDEODEV2_H)
58-
if(HAVE_LINUX_VIDEODEV2_H AND WITH_V4L2)
59-
set(WITHOUT_V4L2 OFF )
60-
endif(HAVE_LINUX_VIDEODEV2_H AND WITH_V4L2)
61-
endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
62-
63-
set(PWCBSD WITH_PWCBSD)
6462

6563
configure_file(config.h.in "${CMAKE_CURRENT_SOURCE_DIR}/config.h")
6664
configure_file(motion-dist.conf.in motion-dist.conf)
@@ -77,13 +75,8 @@ configure_file(motion.init-FreeBSD.sh.in motion.init-FreeBSD.sh)
7775
list(APPEND SRC_FILES
7876
conf.c motion.c alg.c draw.c event.c ffmpeg.c jpegutils.c logger.c md5.c
7977
netcam.c netcam_ftp.c netcam_jpeg.c netcam_rtsp.c netcam_wget.c
80-
picture.c rotate.c stream.c track.c vloopback_motion2.c webhttpd.c)
81-
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" AND NOT(WITH_PWCBSD))
82-
list(APPEND SRC_FILES video_freebsd.c)
83-
else()
84-
list(APPEND SRC_FILES video2.c video_common.c)
85-
endif()
86-
78+
picture.c rotate.c stream.c track.c video_loopback.c webhttpd.c
79+
video_v4l2.c video_common.c video_bktr.c)
8780
include_directories(${JPEG_INCLUDE_DIR})
8881
list(APPEND LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ${JPEG_LIBRARIES})
8982

@@ -122,12 +115,13 @@ message("-- Config Dir: " ${sysconfdir})
122115
message("-- Bin Dir: " ${BIN_PATH})
123116
message("-- JPEG Include Dir: " ${JPEG_INCLUDE_DIR})
124117
message("-- WITH_V4L2: " ${WITH_V4L2})
125-
message("-- Without V4L2: " ${WITHOUT_V4L2})
126-
message("-- With PWC BSD: " ${WITH_PWCBSD})
127-
message("-- MYSQL: " ${WITH_MYSQL} " Include Dir: " ${MYSQL_INCLUDE_DIRS} )
118+
message("-- HAVE_V4L2: " ${HAVE_V4L2})
119+
message("-- WITH_BKTR: " ${WITH_BKTR})
120+
message("-- HAVE_BKTR: " ${HAVE_BKTR})
121+
message("-- MYSQL: " ${WITH_MYSQL} " Include Dir: " ${MYSQL_INCLUDE_DIRS} )
128122
message("-- SQLITE3: " ${WITH_SQLITE3} " Include Dir: " ${SQLITE3_INCLUDE_DIRS} )
129-
message("-- PGSQL: " ${WITH_PGSQL} " Include Dir: " ${PostgreSQL_INCLUDE_DIRS} )
130-
message("-- FFMPEG: " ${WITH_FFMPEG} " Include Dir: " ${FFMPEG_INCLUDE_DIRS} )
123+
message("-- PGSQL: " ${WITH_PGSQL} " Include Dir: " ${PostgreSQL_INCLUDE_DIRS} )
124+
message("-- FFMPEG: " ${WITH_FFMPEG} " Include Dir: " ${FFMPEG_INCLUDE_DIRS} )
131125
message("-- MMAL: " ${WITH_MMAL} )
132126
message("-- CFLAGS: " ${CMAKE_C_FLAGS} )
133127

Makefile.in

+17-18
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ mandir = @mandir@
2424
sysconfdir = @sysconfdir@
2525
datadir = @datadir@
2626
datarootdir = @datarootdir@
27-
docdir = $(datadir)/doc/@PACKAGE_NAME@
27+
docdir = $(datadir)/doc/@PACKAGE_NAME@
2828
examplesdir = $(datadir)/@PACKAGE_NAME@/examples
2929

3030
################################################################################
@@ -34,13 +34,12 @@ examplesdir = $(datadir)/@PACKAGE_NAME@/examples
3434
CFLAGS = @CFLAGS@ -Wall -DVERSION=\"@PACKAGE_VERSION@\" -Dsysconfdir=\"$(sysconfdir)\" @FFMPEG_CFLAGS@ @MMAL_CFLAGS@
3535
LDFLAGS = @LDFLAGS@
3636
LIBS = @LIBS@ @MMAL_LIBS@ @FFMPEG_LIBS@
37-
VIDEO_OBJ = @VIDEO@
3837
OBJ = motion.o logger.o conf.o draw.o jpegutils.o \
39-
vloopback_motion2.o $(VIDEO_OBJ) \
38+
video_loopback.o video_v4l2.o video_common.o video_bktr.o \
4039
netcam.o netcam_ftp.o netcam_jpeg.o netcam_wget.o track.o \
4140
alg.o event.o picture.o rotate.o webhttpd.o \
4241
stream.o md5.o netcam_rtsp.o ffmpeg.o \
43-
@MMAL_OBJ@
42+
@MMAL_OBJ@ @SQLITE_OBJ@
4443
SRC = $(OBJ:.o=.c)
4544
DOC = CHANGELOG COPYING CREDITS README.md motion_guide.html mask1.png normal.jpg outputmotion1.jpg outputnormal1.jpg
4645
EXAMPLES = *.conf motion.service
@@ -52,10 +51,10 @@ DEPEND_FILE = .depend
5251
# ALL and PROGS build Motion and, possibly, Motion-control. #
5352
################################################################################
5453
all: progs
55-
ifneq (,$(findstring freebsd,$(VIDEO_OBJ)))
56-
@echo "Build complete, run \"gmake install\" to install Motion!"
57-
else
54+
ifeq ("@DISTRO@","Linux")
5855
@echo "Build complete, run \"make install\" to install Motion!"
56+
else
57+
@echo "Build complete, run \"gmake install\" to install Motion!"
5958
endif
6059
@echo
6160

@@ -64,16 +63,16 @@ progs: pre-build-info $(PROGS)
6463
################################################################################
6564
# PRE-BUILD-INFO outputs some general info before the build process starts. #
6665
################################################################################
67-
pre-build-info:
66+
pre-build-info:
6867
@echo "Welcome to the setup procedure for Motion, the motion detection daemon! If you get"
6968
@echo "error messages during this procedure, please report them to the mailing list. The"
7069
@echo "Motion Guide contains all information you should need to get Motion up and running."
7170
@echo
7271
@echo "Version: @PACKAGE_VERSION@"
73-
ifneq (,$(findstring freebsd,$(VIDEO_OBJ)))
74-
@echo "Platform: FreeBSD"
75-
else
72+
ifeq ("@DISTRO@","Linux")
7673
@echo "Platform: Linux (if this is incorrect, please read README.FreeBSD)"
74+
else
75+
@echo "Platform: *BSD/Darwin"
7776
endif
7877
@echo
7978

@@ -92,7 +91,7 @@ motion-objects: dep pre-mobject-info $(OBJ)
9291
@echo "--------------------------------------------------------------------------------"
9392
@echo "Motion object files compiled."
9493
@echo
95-
94+
9695
pre-mobject-info:
9796
@echo "Compiling Motion object files..."
9897
@echo "--------------------------------------------------------------------------------"
@@ -138,28 +137,28 @@ dev: distclean autotools all
138137

139138
autotools:
140139
autoconf
141-
./configure --with-developer-flags
140+
./configure --with-developer-flags
142141

143142
set-version:
144143
autoconf
145144
./configure --with-developer-flags
146145

147146
help:
148147
@echo "--------------------------------------------------------------------------------"
149-
@echo "make Build motion from local copy in your computer"
148+
@echo "make Build motion from local copy in your computer"
150149
@echo "make current Build last version of motion from svn"
151150
@echo "make dev Build motion with dev flags"
152151
@echo "make dev-git Build motion with dev flags for git"
153152
@echo "make build-commit Build last version of motion and prepare to commit to svn"
154153
@echo "make build-commit-git Build last version of motion and prepare to commit to git"
155-
@echo "make clean Clean objects"
156-
@echo "make distclean Clean everything"
154+
@echo "make clean Clean objects"
155+
@echo "make distclean Clean everything"
157156
@echo "make install Install binary , examples , docs and config files"
158157
@echo "make uninstall Uninstall all installed files"
159158
@echo "--------------------------------------------------------------------------------"
160159
@echo
161160

162-
161+
163162
################################################################################
164163
# INSTALL installs all relevant files. #
165164
################################################################################
@@ -229,7 +228,7 @@ clean: pre-build-info
229228
################################################################################
230229
# DIST restores the directory to distribution state. #
231230
################################################################################
232-
dist: distclean
231+
dist: distclean
233232
@chmod -R 644 *
234233
@chmod 755 configure
235234
@chmod 755 version.sh

README.FreeBSD

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
The following file explains how to build and run
2-
Motion on FreeBSD. It was tested on FreeBSD 10.3.
2+
Motion on FreeBSD. It was tested on FreeBSD 11.0
33

44
To build Motion on FreeBSD, you need the following packages:
5-
* autoconf
6-
* automake
7-
* ffmpeg
8-
* gcc
9-
* gmake
10-
* libjpeg-turbo
11-
* pkgconf
5+
* pkg install autoconf pkgconf automake gmake
126

137
For database backend support, also install one of the following:
148
* mysql57-client
159
* postgresql95-contrib
1610
* sqlite3
1711

18-
For PWC based webcams, also install:
19-
* pwcbsd
20-
* v4l_compat
12+
For webcams:
13+
* pkg install v4l_compat webcamd
14+
* Add cuse_load="YES" in /boot/loader.conf
15+
* Add webcamd_enable="YES" in the /etc/rc.conf
16+
* chmod 666 /dev/video0
2117

2218
Then, run the following commands:
2319
autoreconf

conf.c

+3-11
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@
2929

3030
#include "motion.h"
3131

32-
#if (defined(__FreeBSD__) && !defined(PWCBSD))
33-
#include "video_freebsd.h"
34-
#else
35-
#include "video2.h"
36-
#endif
37-
3832
#define EXTENSION ".conf"
3933

4034
#define stripnewline(x) {if ((x)[strlen(x)-1]=='\n') (x)[strlen(x) - 1] = 0; }
@@ -56,7 +50,7 @@ struct config conf_template = {
5650
.snapshot_interval = 0,
5751
.locate_motion_mode = "off",
5852
.locate_motion_style = "box",
59-
.input = IN_DEFAULT,
53+
.input = DEF_INPUT,
6054
.norm = 0,
6155
.frame_limit = DEF_MAXFRAMERATE,
6256
.quiet = 1,
@@ -102,10 +96,8 @@ struct config conf_template = {
10296
.tuner_number = 0,
10397
.timelapse = 0,
10498
.timelapse_mode = DEF_TIMELAPSE_MODE,
105-
#ifdef __FreeBSD__
106-
tuner_device: NULL,
107-
#endif
108-
.video_device = VIDEO_DEVICE,
99+
.tuner_device = NULL,
100+
.video_device = DEF_VIDEO_DEVICE,
109101
.v4l2_palette = DEF_PALETTE,
110102
.vidpipe = NULL,
111103
.filepath = NULL,

conf.h

-2
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ struct config {
8686
int tuner_number;
8787
int timelapse;
8888
const char *timelapse_mode;
89-
#ifdef __FreeBSD__
9089
const char *tuner_device;
91-
#endif
9290
const char *video_device;
9391
int v4l2_palette;
9492
const char *vidpipe;

config.h.in

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#cmakedefine HAVE_MYSQL
99
#cmakedefine HAVE_PGSQL
1010
#cmakedefine HAVE_SQLITE3
11-
#cmakedefine PWCBSD
12-
#cmakedefine WITHOUT_V4L2
11+
#cmakedefine HAVE_BKTR
12+
#cmakedefine HAVE_V4L2
1313

1414
/* Optional headers */
1515
#cmakedefine HAVE_LINUX_VIDEODEV2_H
16-
#cmakedefine HAVE_SYS_VIDEOIO_H
16+

0 commit comments

Comments
 (0)