v4l2-ruby 0.9.2 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -0
- data/README.md +1 -1
- data/Rakefile +12 -3
- data/ext/v4l2/camera.c +42 -5
- data/ext/v4l2/camera.h +10 -5
- data/ext/v4l2/v4l2.c +188 -93
- data/lib/v4l2/version.rb +1 -1
- data/pkg/.gitkeep +0 -0
- data/tests/config.yml +5 -0
- data/tests/lib/config.rb +21 -0
- data/tests/lib/test_util.rb +10 -0
- data/tests/run_unit.rb +24 -0
- data/tests/template.rb +30 -0
- data/tests/unit/capture/test_start.rb +49 -0
- data/tests/unit/config/test_set_format.rb +48 -0
- data/tests/unit/config/test_set_framerate.rb +57 -0
- data/tests/unit/config/test_set_image_size.rb +85 -0
- data/tests/unit/create_object/test_simple_create.rb +53 -0
- data/tests/unit/device_info/.test_get_bus_name.rb.swp +0 -0
- data/tests/unit/device_info/test_get_bus_name.rb +34 -0
- data/tests/unit/device_info/test_get_controls.rb +92 -0
- data/tests/unit/device_info/test_get_device_name.rb +34 -0
- data/tests/unit/device_info/test_get_driver_name.rb +34 -0
- data/tests/unit/device_info/test_get_formats.rb +58 -0
- data/tests/unit/device_info/test_get_framecap.rb +56 -0
- data/tests/unit/ractor/test_ractor.rb +67 -0
- data/v4l2-ruby.gemspec +3 -3
- metadata +36 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cd2fedcc6514a3b25e69d923538b2c044ccca1a6883ce5320fe7b2e22f4819b
|
4
|
+
data.tar.gz: 0b90ab5883e8c9835477e91e411e75a9b657b32e91a66ea52768271313af6634
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7f1da3bad3e6f4d1b45b5d8cf6c47765880ad557936de1a5fca4a829ea18930f208deb9382fbff57bab13bb33d6a74281df82226d08d00058a904ceb8d48173
|
7
|
+
data.tar.gz: e2631f2c448cd16b2ca1cb8de0ebe83e686b17397d0f56301b3b06824f6decfa120d2800d59729f3f44ab5b62b691bc0e8d52eec4c3d141fea38a99074c11ea0
|
data/.gitignore
ADDED
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -3,6 +3,15 @@ require "rake/extensiontask"
|
|
3
3
|
|
4
4
|
task :default => :spec
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
spec = Gem::Specification.load("v4l2-ruby.gemspec")
|
7
|
+
|
8
|
+
# add your default gem packing task
|
9
|
+
Gem::PackageTask.new(spec) {|pkg|}
|
10
|
+
|
11
|
+
# feed the ExtensionTask with your spec
|
12
|
+
Rake::ExtensionTask.new('v4l2-ruby', spec) { |ext|
|
13
|
+
ext.name = "v4l2"
|
14
|
+
ext.ext_dir = "ext/v4l2"
|
15
|
+
ext.cross_compile = true
|
16
|
+
ext.lib_dir = File.join(*["lib", "v4l2", ENV["FAT_DIR"]].compact)
|
17
|
+
}
|
data/ext/v4l2/camera.c
CHANGED
@@ -61,7 +61,7 @@
|
|
61
61
|
#define ST_STOPPING (6)
|
62
62
|
#define ST_FINALIZED (7)
|
63
63
|
|
64
|
-
static int xioctl(int fh,
|
64
|
+
static int xioctl(int fh, unsigned long request, void *arg)
|
65
65
|
{
|
66
66
|
int r;
|
67
67
|
|
@@ -154,7 +154,7 @@ set_format(int fd, uint32_t fcc, int wd, int ht)
|
|
154
154
|
fmt.fmt.pix.width = wd;
|
155
155
|
fmt.fmt.pix.height = ht;
|
156
156
|
fmt.fmt.pix.pixelformat = fcc;
|
157
|
-
fmt.fmt.pix.field =
|
157
|
+
fmt.fmt.pix.field = V4L2_FIELD_ANY;
|
158
158
|
|
159
159
|
err = xioctl(fd, VIDIOC_S_FMT, &fmt);
|
160
160
|
if (err < 0) {
|
@@ -1262,8 +1262,15 @@ camera_stop(camera_t* cam)
|
|
1262
1262
|
for (i = 0; i < NUM_PLANE; i++) mb_discard(cam->mb + i);
|
1263
1263
|
|
1264
1264
|
cam->fd = open(cam->device, O_RDWR);
|
1265
|
-
cam->
|
1266
|
-
|
1265
|
+
if (cam->fd >= 0) {
|
1266
|
+
cam->state = ST_INITIALIZED;
|
1267
|
+
cam->latest = -1;
|
1268
|
+
|
1269
|
+
} else {
|
1270
|
+
cam->state = ST_ERROR;
|
1271
|
+
cam->latest = -1;
|
1272
|
+
break;
|
1273
|
+
}
|
1267
1274
|
|
1268
1275
|
} else {
|
1269
1276
|
/*
|
@@ -1378,7 +1385,7 @@ camera_check_busy(camera_t* cam, int* busy)
|
|
1378
1385
|
fmt.fmt.pix.width = cam->width;
|
1379
1386
|
fmt.fmt.pix.height = cam->height;
|
1380
1387
|
fmt.fmt.pix.pixelformat = cam->format;
|
1381
|
-
fmt.fmt.pix.field =
|
1388
|
+
fmt.fmt.pix.field = V4L2_FIELD_ANY;
|
1382
1389
|
|
1383
1390
|
err = xioctl(cam->fd, VIDIOC_S_FMT, &fmt);
|
1384
1391
|
if (err >= 0) {
|
@@ -1397,6 +1404,36 @@ camera_check_busy(camera_t* cam, int* busy)
|
|
1397
1404
|
return ret;
|
1398
1405
|
}
|
1399
1406
|
|
1407
|
+
int
|
1408
|
+
camera_check_ready(camera_t* cam, int* ready)
|
1409
|
+
{
|
1410
|
+
int ret;
|
1411
|
+
int err;
|
1412
|
+
struct v4l2_format fmt;
|
1413
|
+
|
1414
|
+
do {
|
1415
|
+
/*
|
1416
|
+
* entry process
|
1417
|
+
*/
|
1418
|
+
ret = !0;
|
1419
|
+
|
1420
|
+
/*
|
1421
|
+
* check arguments
|
1422
|
+
*/
|
1423
|
+
if (cam == NULL) break;
|
1424
|
+
if (ready == NULL) break;
|
1425
|
+
|
1426
|
+
/*
|
1427
|
+
* do check (check state)
|
1428
|
+
*/
|
1429
|
+
*ready = (cam->state == ST_READY);
|
1430
|
+
|
1431
|
+
ret = 0;
|
1432
|
+
} while(0);
|
1433
|
+
|
1434
|
+
return ret;
|
1435
|
+
}
|
1436
|
+
|
1400
1437
|
int
|
1401
1438
|
camera_check_error(camera_t* cam, int* error)
|
1402
1439
|
{
|
data/ext/v4l2/camera.h
CHANGED
@@ -23,7 +23,11 @@
|
|
23
23
|
#include <pthread.h>
|
24
24
|
#endif /* !defined(RUBY_EXTLIB) */
|
25
25
|
|
26
|
+
#ifdef __OpenBSD__
|
27
|
+
#include <sys/videoio.h>
|
28
|
+
#else
|
26
29
|
#include <linux/videodev2.h>
|
30
|
+
#endif
|
27
31
|
|
28
32
|
#define MAX_PLANE 3
|
29
33
|
|
@@ -68,13 +72,13 @@ typedef struct __camera__ {
|
|
68
72
|
#ifndef V4L2_CTRL_TYPE_INTEGER_MENU
|
69
73
|
#define V4L2_CTRL_TYPE_INTEGER_MENU 9
|
70
74
|
struct __v4l2_querymenu_substitute_ {
|
71
|
-
|
72
|
-
|
75
|
+
uint32_t id;
|
76
|
+
uint32_t index;
|
73
77
|
union {
|
74
|
-
|
75
|
-
|
78
|
+
uint8_t name[32];
|
79
|
+
int64_t value;
|
76
80
|
};
|
77
|
-
|
81
|
+
uint32_t reserved;
|
78
82
|
} __attribute__ ((packed));
|
79
83
|
|
80
84
|
#define v4l2_querymenu __v4l2_querymenu_substitute_
|
@@ -109,6 +113,7 @@ extern int camera_set_framerate(camera_t* cam, int num, int denom);
|
|
109
113
|
extern int camera_get_image_size(camera_t* cam, size_t* sz);
|
110
114
|
extern int camera_get_image(camera_t* cam, void* ptr, size_t* used);
|
111
115
|
extern int camera_check_busy(camera_t* cam, int *busy);
|
116
|
+
extern int camera_check_ready(camera_t* cam, int *ready);
|
112
117
|
extern int camera_check_error(camera_t* cam, int *error);
|
113
118
|
|
114
119
|
extern int camera_get_format_desc(camera_t* cam, int i,
|