forked from ZoneMinder/zoneminder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzm_local_camera.h
132 lines (111 loc) · 3.64 KB
/
zm_local_camera.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//
// ZoneMinder Local Camera Class Interface, $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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
#ifndef ZM_LOCAL_CAMERA_H
#define ZM_LOCAL_CAMERA_H
#include "zm_camera.h"
#if ZM_HAS_V4L2
#include <linux/videodev2.h>
//
// 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:
struct V4L2MappedBuffer {
void *start;
size_t length;
};
struct V4L2Data {
v4l2_cropcap cropcap;
v4l2_crop crop;
v4l2_format fmt;
v4l2_requestbuffers reqbufs;
V4L2MappedBuffer *buffers;
v4l2_buffer *bufptr;
};
protected:
std::string device;
int channel;
int standard;
int palette;
bool device_prime;
bool channel_prime;
int channel_index;
unsigned int extras;
unsigned int conversion_type; /* 0 = no conversion needed, 1 = use libswscale, 2 = zm internal conversion, 3 = jpeg decoding */
convert_fptr_t conversion_fptr; /* Pointer to conversion function used */
uint32_t AutoSelectFormat(int p_colours);
static int camera_count;
static int channel_count;
static int channels[VIDEO_MAX_FRAME];
static int standards[VIDEO_MAX_FRAME];
static int vid_fd;
static int v4l_version;
bool v4l_multi_buffer;
unsigned int v4l_captures_per_frame;
static V4L2Data v4l2_data;
static AVFrame **capturePictures;
_AVPIXELFORMAT imagePixFormat;
_AVPIXELFORMAT capturePixFormat;
struct SwsContext *imgConversionContext;
AVFrame *tmpPicture;
static LocalCamera *last_camera;
public:
LocalCamera(
const Monitor *monitor,
const std::string &device,
int p_channel,
int p_format,
bool v4lmultibuffer,
unsigned int v4lcapturesperframe,
const std::string &p_method,
int p_width,
int p_height,
int p_colours,
int p_palette,
int p_brightness,
int p_contrast,
int p_hue,
int p_colour,
bool p_capture,
bool p_record_audio,
unsigned int p_extras = 0);
~LocalCamera();
void Initialise();
void Terminate();
const std::string &Device() const { return device; }
int Channel() const { return channel; }
int Standard() const { return standard; }
int Palette() const { return palette; }
int Extras() const { return extras; }
int Control(int vid_id, int newvalue=-1 );
int Brightness( int p_brightness=-1 ) override;
int Hue( int p_hue=-1 ) override;
int Colour( int p_colour=-1 ) override;
int Contrast( int p_contrast=-1 ) override;
int PrimeCapture() override;
int PreCapture() override;
int Capture(std::shared_ptr<ZMPacket> &p) override;
int PostCapture() override;
int Close() override;
static bool GetCurrentSettings(const std::string &device, char *output, int version, bool verbose);
};
#endif // ZM_HAS_V4L2
#endif // ZM_LOCAL_CAMERA_H