2003-03-26 19:57:29 +08:00
|
|
|
//
|
|
|
|
// ZoneMinder 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
|
2016-12-26 23:23:16 +08:00
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2003-03-26 19:57:29 +08:00
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef ZM_CAMERA_H
|
|
|
|
#define ZM_CAMERA_H
|
|
|
|
|
2003-04-13 00:17:17 +08:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
2003-03-26 19:57:29 +08:00
|
|
|
#include "zm_image.h"
|
2017-10-23 21:51:41 +08:00
|
|
|
#include "zm_packet.h"
|
2003-03-26 19:57:29 +08:00
|
|
|
|
2016-05-14 02:51:26 +08:00
|
|
|
class Camera;
|
|
|
|
|
|
|
|
#include "zm_monitor.h"
|
|
|
|
|
2003-03-26 19:57:29 +08:00
|
|
|
//
|
|
|
|
// Abstract base class for cameras. This is intended just to express
|
|
|
|
// common attributes
|
|
|
|
//
|
2017-10-23 21:51:41 +08:00
|
|
|
class Camera {
|
2003-03-26 19:57:29 +08:00
|
|
|
protected:
|
2016-05-14 02:51:26 +08:00
|
|
|
typedef enum { LOCAL_SRC, REMOTE_SRC, FILE_SRC, FFMPEG_SRC, LIBVLC_SRC, CURL_SRC } SourceType;
|
2003-03-26 19:57:29 +08:00
|
|
|
|
2016-08-11 00:19:53 +08:00
|
|
|
unsigned int monitor_id;
|
2016-05-14 02:51:26 +08:00
|
|
|
Monitor * monitor; // Null on instantiation, set as soon as possible.
|
|
|
|
SourceType type;
|
|
|
|
unsigned int width;
|
|
|
|
unsigned int height;
|
|
|
|
unsigned int colours;
|
|
|
|
unsigned int subpixelorder;
|
|
|
|
unsigned int pixels;
|
|
|
|
unsigned int imagesize;
|
|
|
|
int brightness;
|
|
|
|
int hue;
|
|
|
|
int colour;
|
|
|
|
int contrast;
|
|
|
|
bool capture;
|
|
|
|
bool record_audio;
|
2018-04-25 02:11:27 +08:00
|
|
|
unsigned int bytes;
|
|
|
|
|
2003-03-26 19:57:29 +08:00
|
|
|
|
2017-10-23 21:51:41 +08:00
|
|
|
int mVideoStreamId;
|
|
|
|
int mAudioStreamId;
|
|
|
|
AVCodecContext *mVideoCodecContext;
|
|
|
|
AVCodecContext *mAudioCodecContext;
|
2017-11-10 05:37:02 +08:00
|
|
|
AVStream *video_stream;
|
2017-10-23 21:51:41 +08:00
|
|
|
|
2003-03-26 19:57:29 +08:00
|
|
|
public:
|
2017-10-23 21:51:41 +08:00
|
|
|
Camera(
|
|
|
|
unsigned int p_monitor_id,
|
|
|
|
SourceType p_type,
|
|
|
|
unsigned int p_width,
|
|
|
|
unsigned int p_height,
|
|
|
|
int p_colours,
|
|
|
|
int p_subpixelorder,
|
|
|
|
int p_brightness,
|
|
|
|
int p_contrast,
|
|
|
|
int p_hue,
|
|
|
|
int p_colour,
|
|
|
|
bool p_capture,
|
|
|
|
bool p_record_audio
|
|
|
|
);
|
2016-05-14 02:51:26 +08:00
|
|
|
virtual ~Camera();
|
2003-03-26 19:57:29 +08:00
|
|
|
|
2016-08-11 00:19:53 +08:00
|
|
|
unsigned int getId() const { return( monitor_id ); }
|
2016-05-14 02:51:26 +08:00
|
|
|
Monitor *getMonitor();
|
2016-09-09 21:15:04 +08:00
|
|
|
void setMonitor( Monitor *p_monitor );
|
2016-05-14 02:51:26 +08:00
|
|
|
SourceType Type() const { return( type ); }
|
|
|
|
bool IsLocal() const { return( type == LOCAL_SRC ); }
|
|
|
|
bool IsRemote() const { return( type == REMOTE_SRC ); }
|
|
|
|
bool IsFile() const { return( type == FILE_SRC ); }
|
|
|
|
bool IsFfmpeg() const { return( type == FFMPEG_SRC ); }
|
|
|
|
bool IsLibvlc() const { return( type == LIBVLC_SRC ); }
|
|
|
|
bool IscURL() const { return( type == CURL_SRC ); }
|
|
|
|
unsigned int Width() const { return( width ); }
|
|
|
|
unsigned int Height() const { return( height ); }
|
2018-04-14 23:03:08 +08:00
|
|
|
unsigned int Colours() const { return colours; }
|
2016-05-14 02:51:26 +08:00
|
|
|
unsigned int SubpixelOrder() const { return( subpixelorder ); }
|
|
|
|
unsigned int Pixels() const { return( pixels ); }
|
|
|
|
unsigned int ImageSize() const { return( imagesize ); }
|
2018-04-25 02:11:27 +08:00
|
|
|
unsigned int Bytes() const { return bytes; };
|
2003-03-26 19:57:29 +08:00
|
|
|
|
2016-05-14 02:51:26 +08:00
|
|
|
virtual int Brightness( int/*p_brightness*/=-1 ) { return( -1 ); }
|
|
|
|
virtual int Hue( int/*p_hue*/=-1 ) { return( -1 ); }
|
|
|
|
virtual int Colour( int/*p_colour*/=-1 ) { return( -1 ); }
|
|
|
|
virtual int Contrast( int/*p_contrast*/=-1 ) { return( -1 ); }
|
2003-06-25 17:47:09 +08:00
|
|
|
|
2016-05-14 02:51:26 +08:00
|
|
|
bool CanCapture() const { return( capture ); }
|
2016-06-22 01:48:32 +08:00
|
|
|
|
2018-06-15 01:28:05 +08:00
|
|
|
bool SupportsNativeVideo() const {
|
|
|
|
return (type == FFMPEG_SRC);
|
|
|
|
//return (type == FFMPEG_SRC )||(type == REMOTE_SRC);
|
|
|
|
}
|
2016-06-22 01:48:32 +08:00
|
|
|
|
2016-05-14 02:51:26 +08:00
|
|
|
virtual int PrimeCapture() { return( 0 ); }
|
|
|
|
virtual int PreCapture()=0;
|
2017-11-10 03:50:20 +08:00
|
|
|
virtual int Capture(ZMPacket &p)=0;
|
2016-05-14 02:51:26 +08:00
|
|
|
virtual int PostCapture()=0;
|
2017-11-14 06:24:28 +08:00
|
|
|
virtual AVStream *get_VideoStream() { return NULL; };
|
|
|
|
virtual AVStream *get_AudioStream() { return NULL; };
|
2017-11-15 05:16:07 +08:00
|
|
|
virtual AVCodecContext *get_VideoCodecContext() { return NULL; };
|
|
|
|
virtual AVCodecContext *get_AudioCodecContext() { return NULL; };
|
2017-11-10 03:50:20 +08:00
|
|
|
int get_VideoStreamId() { return mVideoStreamId; };
|
|
|
|
int get_AudioStreamId() { return mAudioStreamId; };
|
2018-04-17 22:02:52 +08:00
|
|
|
virtual int Close()=0;
|
2003-03-26 19:57:29 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ZM_CAMERA_H
|