Files
zoneminder/src/zm_file_camera.cpp
Kfir Itzhak 5c418133bf Lots accomplished!
1) Delta and blend SSE and standard alogirthms inside
2) Changed event streaming to use sendfile() syscall if available
3) Direct memory capture (Less memcpys required)
4) Added macros for BGR24 and RGB32(and its variants) formats
5) Modified Monitors database table to add a target colorspace option
6) Changed most image buffer allocations to be on 16 byte boundary, work still in progress
7) Added Target colorspace instead of the old colours selection. this one also visible to local cameras
8) Replacing Y deltas option with ZM_CPU_EXTENSIONS
9) Added SSE detection code
10) Changed some code to make linking success with inlining enabled.
11) Some other changes and work still in progress for some listed above
2012-02-01 07:33:20 +02:00

92 lines
2.1 KiB
C++

//
// ZoneMinder File Camera Class Implementation, $Date$, $Revision$
// Copyright (C) 2001-2008 Philip Coombes
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
#include <syslog.h>
#include <signal.h>
#include <stdarg.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include "zm.h"
#include "zm_file_camera.h"
FileCamera::FileCamera( int p_id, const char *p_path, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) : Camera( p_id, FILE_SRC, p_width, p_height, p_colours, ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(p_colours), p_brightness, p_contrast, p_hue, p_colour, p_capture )
{
strncpy( path, p_path, sizeof(path) );
if ( capture )
{
Initialise();
}
}
FileCamera::~FileCamera()
{
if ( capture )
{
Terminate();
}
}
void FileCamera::Initialise()
{
if ( !path[0] )
{
Error( "No path specified for file image" );
exit( -1 );
}
}
void FileCamera::Terminate()
{
}
int FileCamera::PreCapture()
{
struct stat statbuf;
if ( stat( path, &statbuf ) < 0 )
{
Error( "Can't stat %s: %s", path, strerror(errno) );
return( -1 );
}
while ( (time( 0 ) - statbuf.st_mtime) < 1 )
{
usleep( 100000 );
}
return( 0 );
}
int FileCamera::Capture( Image &image )
{
return( image.ReadJpeg( path, colours, subpixelorder )?0:-1 );
}
int FileCamera::PostCapture()
{
return( 0 );
}