v4l2-ruby 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ext/v4l2/camera.h ADDED
@@ -0,0 +1,131 @@
1
+ /*
2
+ *
3
+ * Video 4 Linux V2 driver library (camera utility).
4
+ *
5
+ * Copyright (C) 2015 Hiroshi Kuwagata. All rights reserved.
6
+ *
7
+ */
8
+
9
+ /*
10
+ * $Id: camera.h 158 2017-10-26 08:51:55Z pi $
11
+ */
12
+
13
+ #ifndef __CAMERA_H__
14
+ #define __CAMERA_H__
15
+
16
+ #include <stdio.h>
17
+ #include <stdlib.h>
18
+ #include <stdint.h>
19
+
20
+ #ifdef RUBY_EXTLIB
21
+ #include <ruby.h>
22
+ #else /* defined(RUBY_EXTLIB) */
23
+ #include <pthread.h>
24
+ #endif /* !defined(RUBY_EXTLIB) */
25
+
26
+ #include <linux/videodev2.h>
27
+
28
+ #define MAX_PLANE 3
29
+
30
+ #define F_JPG_OUTPUT 1
31
+
32
+ typedef struct __mblock__ {
33
+ void* ptr;
34
+ size_t size;
35
+ size_t used;
36
+ } mblock_t;
37
+
38
+ typedef struct __camera__ {
39
+ char device[64];
40
+
41
+ char name[sizeof(((struct v4l2_capability*)NULL)->card) + 1];
42
+ char driver[sizeof(((struct v4l2_capability*)NULL)->driver) + 1];
43
+ char bus[sizeof(((struct v4l2_capability*)NULL)->bus_info) + 1];
44
+
45
+ int fd;
46
+ int format;
47
+ int width;
48
+ int height;
49
+
50
+ struct {
51
+ int num;
52
+ int denom;
53
+ } framerate;
54
+
55
+ int state;
56
+ size_t image_size;
57
+
58
+ int latest;
59
+
60
+ mblock_t mb[MAX_PLANE];
61
+ } camera_t;
62
+
63
+ #ifndef V4L2_CTRL_CLASS_JPEG
64
+ #define V4L2_CTRL_CLASS_JPEG 0x009d0000
65
+ #define V4L2_CID_JPEG_CLASS_BASE (V4L2_CTRL_CLASS_JPEG | 0x900)
66
+ #endif /* !defined(V4L2_CTRL_CLASS_JPEG) */
67
+
68
+ #ifndef V4L2_CTRL_TYPE_INTEGER_MENU
69
+ #define V4L2_CTRL_TYPE_INTEGER_MENU 9
70
+ struct __v4l2_querymenu_substitute_ {
71
+ __u32 id;
72
+ __u32 index;
73
+ union {
74
+ __u8 name[32];
75
+ __s64 value;
76
+ };
77
+ __u32 reserved;
78
+ } __attribute__ ((packed));
79
+
80
+ #define v4l2_querymenu __v4l2_querymenu_substitute_
81
+ #endif /* !defined(V4L2_CTRL_TYPE_INTEGER_MENU) */
82
+
83
+
84
+
85
+ /*
86
+ * イニシャライズ時のデフォルト設定は以下の通りです。
87
+ * format: Motion JPEG
88
+ * size: VGA
89
+ * framerate: 30/1
90
+ */
91
+ extern int camera_initialize(camera_t* cam, char dev[]);
92
+
93
+ /*
94
+ * finalized後にコンテキストを再利用する場合は、initialize()からやり直す
95
+ * 必要があります。
96
+ */
97
+ extern int camera_finalize(camera_t* cam);
98
+
99
+ extern int camera_start(camera_t* cam);
100
+ extern int camera_stop(camera_t* cam);
101
+
102
+ extern int camera_set_format(camera_t* cam, uint32_t format);
103
+ extern int camera_get_image_width(camera_t* cam, int* width);
104
+ extern int camera_set_image_width(camera_t* cam, int width);
105
+ extern int camera_get_image_height(camera_t* cam, int* height);
106
+ extern int camera_set_image_height(camera_t* cam, int height);
107
+ extern int camera_set_framerate(camera_t* cam, int num, int denom);
108
+
109
+ extern int camera_get_image_size(camera_t* cam, size_t* sz);
110
+ extern int camera_get_image(camera_t* cam, void* ptr, size_t* used);
111
+ extern int camera_check_busy(camera_t* cam, int *busy);
112
+ extern int camera_check_error(camera_t* cam, int *error);
113
+
114
+ extern int camera_get_format_desc(camera_t* cam, int i,
115
+ struct v4l2_fmtdesc* desc);
116
+
117
+ extern int camera_get_control_info(camera_t* cam, int ctrl,
118
+ struct v4l2_queryctrl* info);
119
+
120
+ extern int camera_get_frame_size(camera_t* cam, uint32_t fmt, uint32_t idx,
121
+ struct v4l2_frmsizeenum* info);
122
+ extern int camera_get_frame_rate(camera_t* cam, uint32_t fmt,
123
+ uint32_t wd, uint32_t ht, uint32_t idx,
124
+ struct v4l2_frmivalenum* dst);
125
+
126
+ extern int camera_get_menu_item(camera_t* cam, int ctrl, int index,
127
+ struct v4l2_querymenu* item);
128
+ extern int camera_set_control(camera_t* cam, uint32_t id, int32_t value);
129
+ extern int camera_get_control(camera_t* cam, uint32_t id, int32_t* value);
130
+
131
+ #endif /* !defined(__CAMERA_H__) */
@@ -0,0 +1,5 @@
1
+ require 'mkmf'
2
+
3
+ $CFLAGS="-DRUBY_EXTLIB"
4
+
5
+ create_makefile( "v4l2")