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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be244fd6bc1590054d5f177e8eea4e446f1f526b1d0d3bee2a9ff91bb0eb9fb9
4
- data.tar.gz: d31e3955aca0938c4e4a131323877c44c55d223ef14e8366c2beba30768f78fb
3
+ metadata.gz: 8cd2fedcc6514a3b25e69d923538b2c044ccca1a6883ce5320fe7b2e22f4819b
4
+ data.tar.gz: 0b90ab5883e8c9835477e91e411e75a9b657b32e91a66ea52768271313af6634
5
5
  SHA512:
6
- metadata.gz: 300875132ad4b5c060a1eb7ddfaff65040d28a902559bb120f4ec271c13d1e9ffc3f225415fbbb6930303e8fcefc0de85780149178ba7569bc4d39f090a5d323
7
- data.tar.gz: b84fd83a6cd1f2141009a6032765be37334b9c8fa7edbf591245d7d6223984d70ebd005017262cb7a92bd61da7964e3ddee47d142965ac07c178136896c4d739
6
+ metadata.gz: a7f1da3bad3e6f4d1b45b5d8cf6c47765880ad557936de1a5fca4a829ea18930f208deb9382fbff57bab13bb33d6a74281df82226d08d00058a904ceb8d48173
7
+ data.tar.gz: e2631f2c448cd16b2ca1cb8de0ebe83e686b17397d0f56301b3b06824f6decfa120d2800d59729f3f44ab5b62b691bc0e8d52eec4c3d141fea38a99074c11ea0
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ .rbenv-gemsets
2
+ .ruby-version
3
+ Gemfile.lock
4
+ pkg/*
5
+ tags
data/README.md CHANGED
@@ -19,7 +19,7 @@ Or install it yourself as:
19
19
 
20
20
  ## Usage
21
21
 
22
- ```
22
+ ```ruby
23
23
  #! /usr/bin/env ruby
24
24
  # coding: utf-8
25
25
 
data/Rakefile CHANGED
@@ -3,6 +3,15 @@ require "rake/extensiontask"
3
3
 
4
4
  task :default => :spec
5
5
 
6
- Rake::ExtensionTask.new("v4l2") do |ext|
7
- ext.lib_dir = "lib/v4l2"
8
- end
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, int request, void *arg)
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 = V4L2_FIELD_INTERLACED;
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->state = ST_INITIALIZED;
1266
- cam->latest = -1;
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 = V4L2_FIELD_INTERLACED;
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
- __u32 id;
72
- __u32 index;
75
+ uint32_t id;
76
+ uint32_t index;
73
77
  union {
74
- __u8 name[32];
75
- __s64 value;
78
+ uint8_t name[32];
79
+ int64_t value;
76
80
  };
77
- __u32 reserved;
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,