aboutsummaryrefslogtreecommitdiffstats
path: root/app/capturing.h
blob: 599cd5c2ad6705dfb5b3e467b4644914bd47c690 (plain)
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
/*
 * Copyright (C) 2019 DENSO TEN Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


#ifndef CAPTURING_H
#define CAPTURING_H


class CapturingItem
{

public:
	CapturingItem();
	~CapturingItem();
	int open_device(int dev);
	int init_device(void);
	void start_capturing(void);
	void close_device(void);
	unsigned char* snap_frame(void);
	int width(void) const
	{
		return _width;
	}

	int height(void) const
	{
		return _height;
	}


private:
	struct buffer {
		void *start;
		size_t length;
	};

	std::string _dev_name;
	int _fd;
	struct buffer *p_buffers;
	unsigned int n_buffers;
	int _fps_count;
	int _framerate;
	int _timeout; /* secs */
	int _left;
	int _top;
	int _width;
	int _height;

	void errno_exit(const char *s);
	int xioctl(int fh, int request, void *arg);
	void uninit_device(void);
	void init_read(unsigned int buffer_size);
	void init_mmap(void);
	void init_userp(unsigned int buffer_size);
	int read_frame(void);
};
#endif	/* CAPTURING_H */