2003-03-26 19:57:29 +08:00
|
|
|
//
|
|
|
|
// ZoneMinder Local Camera Class Interface, $Date$, $Revision$
|
2008-07-25 17:33:23 +08:00
|
|
|
// Copyright (C) 2001-2008 Philip Coombes
|
2003-03-26 19:57:29 +08:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef ZM_LOCAL_CAMERA_H
|
|
|
|
#define ZM_LOCAL_CAMERA_H
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
2008-07-21 23:20:52 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "zm.h"
|
2003-03-26 19:57:29 +08:00
|
|
|
#include "zm_camera.h"
|
2009-01-28 17:48:06 +08:00
|
|
|
#include "zm_ffmpeg.h"
|
2003-03-26 19:57:29 +08:00
|
|
|
|
2008-07-21 23:20:52 +08:00
|
|
|
#ifdef HAVE_LINUX_VIDEODEV2_H
|
|
|
|
#include <linux/videodev2.h>
|
|
|
|
#define ZM_V4L2
|
|
|
|
#endif // HAVE_LINUX_VIDEODEV2_H
|
|
|
|
#ifdef HAVE_LINUX_VIDEODEV_H
|
|
|
|
#include <linux/videodev.h>
|
|
|
|
#endif // HAVE_LINUX_VIDEODEV_H
|
|
|
|
|
2003-03-26 19:57:29 +08:00
|
|
|
//
|
|
|
|
// Class representing 'local' cameras, i.e. those which are
|
|
|
|
// directly connect to the host machine and which are accessed
|
|
|
|
// via a video interface.
|
|
|
|
//
|
|
|
|
class LocalCamera : public Camera
|
|
|
|
{
|
|
|
|
protected:
|
2008-07-21 23:20:52 +08:00
|
|
|
#ifdef ZM_V4L2
|
2009-01-28 17:48:06 +08:00
|
|
|
struct V4L2MappedBuffer
|
2008-07-21 23:20:52 +08:00
|
|
|
{
|
|
|
|
void *start;
|
|
|
|
size_t length;
|
2009-01-28 17:48:06 +08:00
|
|
|
};
|
2008-07-21 23:20:52 +08:00
|
|
|
|
|
|
|
struct V4L2Data
|
|
|
|
{
|
|
|
|
v4l2_cropcap cropcap;
|
|
|
|
v4l2_crop crop;
|
|
|
|
v4l2_format fmt;
|
|
|
|
v4l2_requestbuffers reqbufs;
|
|
|
|
V4L2MappedBuffer *buffers;
|
|
|
|
v4l2_buffer *buffer;
|
|
|
|
};
|
|
|
|
#endif // ZM_V4L2
|
|
|
|
|
|
|
|
struct V4L1Data
|
|
|
|
{
|
2009-01-28 17:48:06 +08:00
|
|
|
int active_frame;
|
2008-07-21 23:20:52 +08:00
|
|
|
int cap_frame;
|
|
|
|
int sync_frame;
|
|
|
|
video_mbuf frames;
|
|
|
|
video_mmap *buffers;
|
|
|
|
unsigned char *buffer;
|
|
|
|
};
|
|
|
|
|
2009-01-28 17:48:06 +08:00
|
|
|
#if HAVE_LIBSWSCALE
|
2009-02-09 22:54:09 +08:00
|
|
|
PixelFormat ffPixFormat;
|
2009-01-28 17:48:06 +08:00
|
|
|
AVFrame **ffPictures;
|
|
|
|
#endif // HAVE_LIBSWSCALE
|
|
|
|
|
2008-07-21 23:20:52 +08:00
|
|
|
protected:
|
|
|
|
std::string device;
|
|
|
|
int channel;
|
|
|
|
int format;
|
|
|
|
|
|
|
|
int palette;
|
|
|
|
|
|
|
|
bool device_prime;
|
|
|
|
bool channel_prime;
|
2003-03-26 19:57:29 +08:00
|
|
|
|
2008-07-21 23:20:52 +08:00
|
|
|
bool v4l2;
|
2006-10-24 22:37:34 +08:00
|
|
|
|
2003-03-26 19:57:29 +08:00
|
|
|
protected:
|
2006-10-24 22:37:34 +08:00
|
|
|
static int camera_count;
|
|
|
|
static int channel_count;
|
|
|
|
static int last_channel;
|
|
|
|
|
2008-07-21 23:20:52 +08:00
|
|
|
static int vid_fd;
|
|
|
|
|
|
|
|
#ifdef ZM_V4L2
|
|
|
|
static V4L2Data v4l2_data;
|
|
|
|
#endif // ZM_V4L2
|
|
|
|
static V4L1Data v4l1_data;
|
|
|
|
|
2006-01-22 01:58:46 +08:00
|
|
|
static unsigned char *y_table;
|
|
|
|
static signed char *uv_table;
|
|
|
|
static short *r_v_table;
|
|
|
|
static short *g_v_table;
|
|
|
|
static short *g_u_table;
|
|
|
|
static short *b_u_table;
|
2003-03-26 19:57:29 +08:00
|
|
|
|
|
|
|
public:
|
2008-07-21 23:20:52 +08:00
|
|
|
LocalCamera( int p_id, const std::string &device, int p_channel, int p_format, const std::string &p_method, int p_width, int p_height, int p_palette, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture );
|
2003-03-26 19:57:29 +08:00
|
|
|
~LocalCamera();
|
|
|
|
|
|
|
|
void Initialise();
|
|
|
|
void Terminate();
|
|
|
|
|
2008-07-21 23:20:52 +08:00
|
|
|
const std::string &Device() const { return( device ); }
|
2003-03-26 19:57:29 +08:00
|
|
|
unsigned int Channel() const { return( channel ); }
|
|
|
|
unsigned int Format() const { return( format ); }
|
|
|
|
|
2008-07-21 23:20:52 +08:00
|
|
|
int Palette() const { return( palette ); }
|
|
|
|
|
2003-06-25 17:47:09 +08:00
|
|
|
int Brightness( int p_brightness=-1 );
|
|
|
|
int Hue( int p_hue=-1 );
|
|
|
|
int Colour( int p_colour=-1 );
|
|
|
|
int Contrast( int p_contrast=-1 );
|
|
|
|
|
2006-10-24 22:37:34 +08:00
|
|
|
int PrimeCapture();
|
2003-04-13 00:17:17 +08:00
|
|
|
int PreCapture();
|
2009-01-28 17:48:06 +08:00
|
|
|
int Capture( Image &image );
|
|
|
|
int PostCapture();
|
2003-03-26 19:57:29 +08:00
|
|
|
|
2005-10-17 18:58:25 +08:00
|
|
|
static bool GetCurrentSettings( const char *device, char *output, bool verbose );
|
2003-03-26 19:57:29 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ZM_LOCAL_CAMERA_H
|