v4l2-ruby 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/v4l2/v4l2.c +66 -22
- data/lib/v4l2/version.rb +1 -1
- data/v4l2-ruby.gemspec +5 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be244fd6bc1590054d5f177e8eea4e446f1f526b1d0d3bee2a9ff91bb0eb9fb9
|
4
|
+
data.tar.gz: d31e3955aca0938c4e4a131323877c44c55d223ef14e8366c2beba30768f78fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 300875132ad4b5c060a1eb7ddfaff65040d28a902559bb120f4ec271c13d1e9ffc3f225415fbbb6930303e8fcefc0de85780149178ba7569bc4d39f090a5d323
|
7
|
+
data.tar.gz: b84fd83a6cd1f2141009a6032765be37334b9c8fa7edbf591245d7d6223984d70ebd005017262cb7a92bd61da7964e3ddee47d142965ac07c178136896c4d739
|
data/ext/v4l2/v4l2.c
CHANGED
@@ -16,6 +16,7 @@
|
|
16
16
|
#define N(x) (sizeof((x))/sizeof(*(x)))
|
17
17
|
|
18
18
|
extern rb_encoding* rb_utf8_encoding(void);
|
19
|
+
extern rb_encoding* rb_default_internal_encoding(void);
|
19
20
|
|
20
21
|
static VALUE module;
|
21
22
|
static VALUE camera_klass;
|
@@ -153,9 +154,12 @@ get_menu_list(camera_t* ptr, int ctrl, int min, int max)
|
|
153
154
|
err = camera_get_menu_item(ptr, ctrl, i, &item);
|
154
155
|
if (!err) {
|
155
156
|
VALUE tmp;
|
157
|
+
VALUE name;
|
156
158
|
|
157
|
-
tmp
|
158
|
-
|
159
|
+
tmp = rb_obj_alloc(menu_item_klass);
|
160
|
+
name = rb_enc_str_new_cstr((const char*)item.name, rb_utf8_encoding());
|
161
|
+
|
162
|
+
rb_ivar_set(tmp, id_iv_name, name);
|
159
163
|
rb_ivar_set(tmp, id_iv_index, INT2FIX(item.index));
|
160
164
|
|
161
165
|
rb_ary_push(ret, tmp);
|
@@ -178,9 +182,12 @@ get_int_menu_list(camera_t* ptr, int ctrl, int min, int max)
|
|
178
182
|
err = camera_get_menu_item(ptr, ctrl, i, &item);
|
179
183
|
if (!err) {
|
180
184
|
VALUE tmp;
|
185
|
+
VALUE name;
|
186
|
+
|
187
|
+
tmp = rb_obj_alloc(menu_item_klass);
|
188
|
+
name = rb_enc_sprintf(rb_utf8_encoding(), "%lld", item.value);
|
181
189
|
|
182
|
-
tmp
|
183
|
-
rb_ivar_set(tmp, id_iv_name, rb_sprintf("%lld", item.value));
|
190
|
+
rb_ivar_set(tmp, id_iv_name, name);
|
184
191
|
rb_ivar_set(tmp, id_iv_index, INT2FIX(item.index));
|
185
192
|
|
186
193
|
rb_ary_push(ret, tmp);
|
@@ -194,6 +201,7 @@ static VALUE
|
|
194
201
|
get_control_info(camera_t* ptr, int ctrl)
|
195
202
|
{
|
196
203
|
VALUE ret;
|
204
|
+
VALUE name;
|
197
205
|
int err;
|
198
206
|
struct v4l2_queryctrl info;
|
199
207
|
|
@@ -202,8 +210,11 @@ get_control_info(camera_t* ptr, int ctrl)
|
|
202
210
|
if (!err) {
|
203
211
|
switch (info.type) {
|
204
212
|
case V4L2_CTRL_TYPE_INTEGER:
|
205
|
-
ret
|
206
|
-
|
213
|
+
ret = rb_obj_alloc(integer_klass);
|
214
|
+
name = rb_enc_str_new_cstr((const char*)info.name,
|
215
|
+
rb_utf8_encoding());
|
216
|
+
|
217
|
+
rb_ivar_set(ret, id_iv_name, name);
|
207
218
|
rb_ivar_set(ret, id_iv_id, INT2NUM(info.id));
|
208
219
|
rb_ivar_set(ret, id_iv_min, INT2FIX(info.minimum));
|
209
220
|
rb_ivar_set(ret, id_iv_max, INT2FIX(info.maximum));
|
@@ -212,15 +223,21 @@ get_control_info(camera_t* ptr, int ctrl)
|
|
212
223
|
break;
|
213
224
|
|
214
225
|
case V4L2_CTRL_TYPE_BOOLEAN:
|
215
|
-
ret
|
216
|
-
|
226
|
+
ret = rb_obj_alloc(boolean_klass);
|
227
|
+
name = rb_enc_str_new_cstr((const char*)info.name,
|
228
|
+
rb_utf8_encoding());
|
229
|
+
|
230
|
+
rb_ivar_set(ret, id_iv_name, name);
|
217
231
|
rb_ivar_set(ret, id_iv_id, INT2NUM(info.id));
|
218
232
|
rb_ivar_set(ret, id_iv_default, (info.default_value)? Qtrue: Qfalse);
|
219
233
|
break;
|
220
234
|
|
221
235
|
case V4L2_CTRL_TYPE_MENU:
|
222
|
-
ret
|
223
|
-
|
236
|
+
ret = rb_obj_alloc(menu_klass);
|
237
|
+
name = rb_enc_str_new_cstr((const char*)info.name,
|
238
|
+
rb_utf8_encoding());
|
239
|
+
|
240
|
+
rb_ivar_set(ret, id_iv_name, name);
|
224
241
|
rb_ivar_set(ret, id_iv_id, INT2NUM(info.id));
|
225
242
|
rb_ivar_set(ret, id_iv_default, INT2FIX(info.default_value));
|
226
243
|
rb_ivar_set(ret, id_iv_items,
|
@@ -228,8 +245,11 @@ get_control_info(camera_t* ptr, int ctrl)
|
|
228
245
|
break;
|
229
246
|
|
230
247
|
case V4L2_CTRL_TYPE_INTEGER_MENU:
|
231
|
-
ret
|
232
|
-
|
248
|
+
ret = rb_obj_alloc(menu_klass);
|
249
|
+
name = rb_enc_str_new_cstr((const char*)info.name,
|
250
|
+
rb_utf8_encoding());
|
251
|
+
|
252
|
+
rb_ivar_set(ret, id_iv_name, name);
|
233
253
|
rb_ivar_set(ret, id_iv_id, INT2NUM(info.id));
|
234
254
|
rb_ivar_set(ret, id_iv_default, INT2FIX(info.default_value));
|
235
255
|
rb_ivar_set(ret, id_iv_items,
|
@@ -352,6 +372,7 @@ rb_camera_get_support_formats(VALUE self)
|
|
352
372
|
|
353
373
|
VALUE fmt;
|
354
374
|
VALUE fcc;
|
375
|
+
VALUE str;
|
355
376
|
|
356
377
|
Data_Get_Struct(self, camera_t, ptr);
|
357
378
|
|
@@ -362,13 +383,18 @@ rb_camera_get_support_formats(VALUE self)
|
|
362
383
|
if (err) break;
|
363
384
|
|
364
385
|
fmt = rb_obj_alloc(fmt_desc_klass);
|
365
|
-
fcc =
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
386
|
+
fcc = rb_enc_sprintf(rb_utf8_encoding(),
|
387
|
+
"%c%c%c%c",
|
388
|
+
desc.pixelformat >> 0 & 0xff,
|
389
|
+
desc.pixelformat >> 8 & 0xff,
|
390
|
+
desc.pixelformat >> 16 & 0xff,
|
391
|
+
desc.pixelformat >> 24 & 0xff);
|
392
|
+
|
393
|
+
str = rb_enc_str_new_cstr((const char*)desc.description,
|
394
|
+
rb_utf8_encoding());
|
395
|
+
|
370
396
|
rb_ivar_set(fmt, id_iv_fcc, fcc);
|
371
|
-
rb_ivar_set(fmt, id_iv_desc,
|
397
|
+
rb_ivar_set(fmt, id_iv_desc, str);
|
372
398
|
|
373
399
|
rb_ary_push(ret, fmt);
|
374
400
|
}
|
@@ -481,14 +507,32 @@ rb_camera_get_frame_capabilities(VALUE self, VALUE fmt)
|
|
481
507
|
}
|
482
508
|
|
483
509
|
static VALUE
|
484
|
-
rb_camera_set_control(VALUE self, VALUE id, VALUE
|
510
|
+
rb_camera_set_control(VALUE self, VALUE id, VALUE _val)
|
485
511
|
{
|
486
512
|
camera_t* ptr;
|
487
513
|
int err;
|
514
|
+
int val;
|
488
515
|
|
489
516
|
Data_Get_Struct(self, camera_t, ptr);
|
490
517
|
|
491
|
-
|
518
|
+
switch (TYPE(_val)) {
|
519
|
+
case T_TRUE:
|
520
|
+
val = 1;
|
521
|
+
break;
|
522
|
+
|
523
|
+
case T_FALSE:
|
524
|
+
val = 0;
|
525
|
+
break;
|
526
|
+
|
527
|
+
case T_FIXNUM:
|
528
|
+
val = FIX2INT(_val);
|
529
|
+
break;
|
530
|
+
|
531
|
+
default:
|
532
|
+
rb_raise(rb_eTypeError, "invalid type of control value");
|
533
|
+
}
|
534
|
+
|
535
|
+
err = camera_set_control(ptr, FIX2INT(id), val);
|
492
536
|
if (err) {
|
493
537
|
rb_raise(rb_eRuntimeError, "set control failed.");
|
494
538
|
}
|
@@ -953,8 +997,8 @@ Init_v4l2()
|
|
953
997
|
id_iv_driver = rb_intern_const("@driver");
|
954
998
|
id_iv_bus = rb_intern_const("@bus");
|
955
999
|
id_iv_id = rb_intern_const("@id");
|
956
|
-
id_iv_min = rb_intern_const("@
|
957
|
-
id_iv_max = rb_intern_const("@
|
1000
|
+
id_iv_min = rb_intern_const("@min");
|
1001
|
+
id_iv_max = rb_intern_const("@max");
|
958
1002
|
id_iv_step = rb_intern_const("@step");
|
959
1003
|
id_iv_default = rb_intern_const("@default");
|
960
1004
|
id_iv_items = rb_intern_const("@items");
|
data/lib/v4l2/version.rb
CHANGED
data/v4l2-ruby.gemspec
CHANGED
@@ -12,6 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.summary = %q{V4L2 insterface library for ruby}
|
13
13
|
spec.description = %q{V4L2 insterface library for ruby}
|
14
14
|
spec.homepage = "https://github.com/kwgt/v4l2-ruby"
|
15
|
+
spec.license = "MIT"
|
15
16
|
|
16
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
18
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
@@ -27,12 +28,15 @@ Gem::Specification.new do |spec|
|
|
27
28
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
28
29
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
29
30
|
end
|
31
|
+
|
30
32
|
spec.bindir = "exe"
|
31
33
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
34
|
spec.extensions = ["ext/v4l2/extconf.rb"]
|
33
35
|
spec.require_paths = ["lib"]
|
34
36
|
|
37
|
+
spec.required_ruby_version = ">= 2.4.0"
|
38
|
+
|
35
39
|
spec.add_development_dependency "bundler", "~> 1.17"
|
36
40
|
spec.add_development_dependency "rake", "~> 10.0"
|
37
|
-
spec.add_development_dependency "rake-compiler"
|
41
|
+
spec.add_development_dependency "rake-compiler", "~> 1.0.7"
|
38
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: v4l2-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroshi Kuwagata
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: rake-compiler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 1.0.7
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 1.0.7
|
55
55
|
description: V4L2 insterface library for ruby
|
56
56
|
email:
|
57
57
|
- kgt9221@gmail.com
|
@@ -72,7 +72,8 @@ files:
|
|
72
72
|
- lib/v4l2/version.rb
|
73
73
|
- v4l2-ruby.gemspec
|
74
74
|
homepage: https://github.com/kwgt/v4l2-ruby
|
75
|
-
licenses:
|
75
|
+
licenses:
|
76
|
+
- MIT
|
76
77
|
metadata:
|
77
78
|
homepage_uri: https://github.com/kwgt/v4l2-ruby
|
78
79
|
post_install_message:
|
@@ -83,15 +84,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
83
84
|
requirements:
|
84
85
|
- - ">="
|
85
86
|
- !ruby/object:Gem::Version
|
86
|
-
version:
|
87
|
+
version: 2.4.0
|
87
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
89
|
requirements:
|
89
90
|
- - ">="
|
90
91
|
- !ruby/object:Gem::Version
|
91
92
|
version: '0'
|
92
93
|
requirements: []
|
93
|
-
|
94
|
-
rubygems_version: 2.7.6
|
94
|
+
rubygems_version: 3.0.3
|
95
95
|
signing_key:
|
96
96
|
specification_version: 4
|
97
97
|
summary: V4L2 insterface library for ruby
|