"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "video_loopback.c" between
motion-release-4.2.2.tar.gz and motion-Release-4.3.0.tar.gz

About: Motion monitors the video signal from one or more cameras and is able to detect motion.

video_loopback.c  (motion-release-4.2.2):video_loopback.c  (motion-Release-4.3.0)
skipping to change at line 31 skipping to change at line 31
static int vlp_open_vidpipe(void) static int vlp_open_vidpipe(void)
{ {
int pipe_fd = -1; int pipe_fd = -1;
char pipepath[255]; char pipepath[255];
char buffer[255]; char buffer[255];
DIR *dir; DIR *dir;
struct dirent *dirp; struct dirent *dirp;
const char prefix[] = "/sys/class/video4linux/"; const char prefix[] = "/sys/class/video4linux/";
int fd,tfd; int fd,tfd;
int len,min; int len,min;
int retcd;
if ((dir = opendir(prefix)) == NULL) { if ((dir = opendir(prefix)) == NULL) {
MOTION_LOG(CRT, TYPE_VIDEO, SHOW_ERRNO,_("Failed to open '%s'"), prefix) ; MOTION_LOG(CRT, TYPE_VIDEO, SHOW_ERRNO,_("Failed to open '%s'"), prefix) ;
return -1; return -1;
} }
while ((dirp = readdir(dir)) != NULL) { while ((dirp = readdir(dir)) != NULL) {
if (!strncmp(dirp->d_name, "video", 5)) { if (!strncmp(dirp->d_name, "video", 5)) {
strncpy(buffer, prefix, sizeof(buffer));
strncat(buffer, dirp->d_name, sizeof(buffer) - strlen(buffer)); retcd = snprintf(buffer, sizeof(buffer),"%s%s/name", prefix, dirp->d
strncat(buffer, "/name", sizeof(buffer) - strlen(buffer)); _name);
MOTION_LOG(NTC, TYPE_VIDEO, SHOW_ERRNO,_("Opening buffer: %s"),buffe if ((retcd<0) || (retcd >= (int)sizeof(buffer))) {
r); MOTION_LOG(NTC, TYPE_VIDEO, SHOW_ERRNO
,_("Error specifying buffer: %s"),buffer);
continue;
} else {
MOTION_LOG(NTC, TYPE_VIDEO, SHOW_ERRNO,_("Opening buffer: %s"),b
uffer);
}
if ((fd = open(buffer, O_RDONLY|O_CLOEXEC)) >= 0) { if ((fd = open(buffer, O_RDONLY|O_CLOEXEC)) >= 0) {
if ((len = read(fd, buffer, sizeof(buffer)-1)) < 0) { if ((len = read(fd, buffer, sizeof(buffer)-1)) < 0) {
close(fd); close(fd);
continue; continue;
} }
buffer[len]=0; buffer[len]=0;
MOTION_LOG(NTC, TYPE_VIDEO, SHOW_ERRNO,_("Read buffer: %s"),buff er); MOTION_LOG(NTC, TYPE_VIDEO, SHOW_ERRNO,_("Read buffer: %s"),buff er);
if (strncmp(buffer, "Loopback video device",21)) { /* weird stuf f after minor */ if (strncmp(buffer, "Loopback video device",21)) { /* weird stuf f after minor */
close(fd); close(fd);
continue; continue;
} }
min = atoi(&buffer[21]); min = atoi(&buffer[21]);
strcpy(buffer, "/dev/");
strncat(buffer, dirp->d_name, sizeof(buffer) - strlen(buffer)); retcd = snprintf(buffer,sizeof(buffer),"/dev/%s",dirp->d_name);
MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO,_("found video device '%s' if ((retcd < 0) || (retcd >= (int)sizeof(buffer))) {
%d"), buffer,min); MOTION_LOG(NTC, TYPE_VIDEO, SHOW_ERRNO
,_("Error specifying buffer: %s"),buffer);
close(fd);
continue;
} else {
MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO,_("found video device '
%s' %d"), buffer,min);
}
if ((tfd = open(buffer, O_RDWR|O_CLOEXEC)) >= 0) { if ((tfd = open(buffer, O_RDWR|O_CLOEXEC)) >= 0) {
strncpy(pipepath, buffer, sizeof(pipepath)); strncpy(pipepath, buffer, sizeof(pipepath));
if (pipe_fd >= 0) close(pipe_fd); if (pipe_fd >= 0) close(pipe_fd);
pipe_fd = tfd; pipe_fd = tfd;
break; break;
} }
} }
close(fd); close(fd);
} }
} }
 End of changes. 3 change blocks. 
9 lines changed or deleted 25 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)