v4l2-ruby 0.9.2 → 0.10.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: 9d31f555fce10530df57c6d98af41f9ad8008f666dd997a74d511ae8e41e0fec
4
+ data.tar.gz: 812507ef8f3c6fa913d2b1e1513111b630850481e21cc93a3a9d8126f6f61f22
5
5
  SHA512:
6
- metadata.gz: 300875132ad4b5c060a1eb7ddfaff65040d28a902559bb120f4ec271c13d1e9ffc3f225415fbbb6930303e8fcefc0de85780149178ba7569bc4d39f090a5d323
7
- data.tar.gz: b84fd83a6cd1f2141009a6032765be37334b9c8fa7edbf591245d7d6223984d70ebd005017262cb7a92bd61da7964e3ddee47d142965ac07c178136896c4d739
6
+ metadata.gz: 03b24506c311f989e117ef35926f93c5f2c00c593fec3810a44dc7d6c72619ae395aaf2a5dbce3ac9458526877807b40ce46194c39eeca192d4067e522bc18ad
7
+ data.tar.gz: 9a1f9fe2899bf1e1ee40cd3305b4ff54f36c6341387fc342f435cf4b570ecc82d137f31c5ae45ae59f31ec8d1930bb86c7f5de5e03f68dc7ae70857ea276b40e
@@ -297,27 +297,49 @@ rb_camera_get_controls(VALUE self)
297
297
  }
298
298
 
299
299
  static VALUE
300
- get_framerate_list(camera_t* cam, struct v4l2_frmsize_discrete* size)
300
+ get_framerate_list(camera_t* cam,
301
+ uint32_t fmt, struct v4l2_frmsize_discrete* size)
301
302
  {
302
303
  VALUE ret;
303
304
  int i;
304
-
305
305
  int err;
306
306
  struct v4l2_frmivalenum intval;
307
307
  VALUE rate;
308
+ int num;
309
+ int deno;
308
310
 
309
311
  ret = rb_ary_new();
310
312
 
311
313
  for (i = 0; ; i++) {
312
- err = camera_get_frame_rate(cam, V4L2_PIX_FMT_MJPEG,
314
+ err = camera_get_frame_rate(cam, fmt,
313
315
  size->width, size->height, i, &intval);
314
316
  if (err) break;
315
317
 
316
- if (intval.type == V4L2_FRMIVAL_TYPE_DISCRETE) {
318
+ switch (intval.type) {
319
+ case V4L2_FRMIVAL_TYPE_DISCRETE:
317
320
  rate = rb_rational_new(INT2FIX(intval.discrete.denominator),
318
321
  INT2FIX(intval.discrete.numerator));
319
322
 
320
323
  rb_ary_push(ret, rate);
324
+ break;
325
+
326
+ case V4L2_FRMIVAL_TYPE_CONTINUOUS:
327
+ case V4L2_FRMIVAL_TYPE_STEPWISE:
328
+ num = intval.stepwise.max.numerator;
329
+ deno = intval.stepwise.max.denominator;
330
+
331
+ while (num <= intval.stepwise.min.numerator) {
332
+ while (deno <= intval.stepwise.min.denominator) {
333
+ rate = rb_rational_new(INT2FIX(deno), INT2FIX(num));
334
+ rb_ary_push(ret, rate);
335
+
336
+ deno += intval.stepwise.step.denominator;
337
+ }
338
+
339
+ num += intval.stepwise.step.numerator;
340
+ deno = intval.stepwise.max.denominator;
341
+ }
342
+ break;
321
343
  }
322
344
  }
323
345
 
@@ -403,7 +425,8 @@ rb_camera_get_support_formats(VALUE self)
403
425
  }
404
426
 
405
427
  static void
406
- make_dummy_capabilities(camera_t* ptr, VALUE ary, int max_width, int max_height)
428
+ make_dummy_capabilities(camera_t* ptr, VALUE ary,
429
+ uint32_t fmt, int max_width, int max_height)
407
430
  {
408
431
  struct v4l2_frmsize_discrete dsize;
409
432
  VALUE capa;
@@ -419,7 +442,7 @@ make_dummy_capabilities(camera_t* ptr, VALUE ary, int max_width, int max_height)
419
442
  capa = rb_obj_alloc(frame_cap_klass);
420
443
  rb_ivar_set(capa, id_iv_width, INT2NUM(dsize.width));
421
444
  rb_ivar_set(capa, id_iv_height, INT2NUM(dsize.height));
422
- rb_ivar_set(capa, id_iv_rate, get_framerate_list(ptr, &dsize));
445
+ rb_ivar_set(capa, id_iv_rate, get_framerate_list(ptr, fmt, &dsize));
423
446
 
424
447
  rb_ary_push(ary, capa);
425
448
 
@@ -428,7 +451,7 @@ make_dummy_capabilities(camera_t* ptr, VALUE ary, int max_width, int max_height)
428
451
  capa = rb_obj_alloc(frame_cap_klass);
429
452
  rb_ivar_set(capa, id_iv_width, INT2NUM(dsize.width));
430
453
  rb_ivar_set(capa, id_iv_height, INT2NUM(dsize.height));
431
- rb_ivar_set(capa, id_iv_rate, get_framerate_list(ptr, &dsize));
454
+ rb_ivar_set(capa, id_iv_rate, get_framerate_list(ptr, fmt, &dsize));
432
455
 
433
456
  rb_ary_push(ary, capa);
434
457
  }
@@ -446,7 +469,7 @@ make_dummy_capabilities(camera_t* ptr, VALUE ary, int max_width, int max_height)
446
469
  capa = rb_obj_alloc(frame_cap_klass);
447
470
  rb_ivar_set(capa, id_iv_width, INT2NUM(dsize.width));
448
471
  rb_ivar_set(capa, id_iv_height, INT2NUM(dsize.height));
449
- rb_ivar_set(capa, id_iv_rate, get_framerate_list(ptr, &dsize));
472
+ rb_ivar_set(capa, id_iv_rate, get_framerate_list(ptr, fmt, &dsize));
450
473
 
451
474
  rb_ary_push(ary, capa);
452
475
 
@@ -455,7 +478,7 @@ make_dummy_capabilities(camera_t* ptr, VALUE ary, int max_width, int max_height)
455
478
  capa = rb_obj_alloc(frame_cap_klass);
456
479
  rb_ivar_set(capa, id_iv_width, INT2NUM(dsize.width));
457
480
  rb_ivar_set(capa, id_iv_height, INT2NUM(dsize.height));
458
- rb_ivar_set(capa, id_iv_rate, get_framerate_list(ptr, &dsize));
481
+ rb_ivar_set(capa, id_iv_rate, get_framerate_list(ptr, fmt, &dsize));
459
482
 
460
483
  rb_ary_push(ary, capa);
461
484
  }
@@ -463,12 +486,13 @@ make_dummy_capabilities(camera_t* ptr, VALUE ary, int max_width, int max_height)
463
486
  }
464
487
 
465
488
  static VALUE
466
- rb_camera_get_frame_capabilities(VALUE self, VALUE fmt)
489
+ rb_camera_get_frame_capabilities(VALUE self, VALUE _fmt)
467
490
  {
468
491
  VALUE ret;
469
492
  camera_t* ptr;
470
493
  int i;
471
494
  int j;
495
+ uint32_t fmt;
472
496
 
473
497
  int err;
474
498
  struct v4l2_frmsizeenum size;
@@ -477,26 +501,31 @@ rb_camera_get_frame_capabilities(VALUE self, VALUE fmt)
477
501
  VALUE list;
478
502
  VALUE rate;
479
503
 
480
- Check_Type(fmt, T_SYMBOL);
504
+ Check_Type(_fmt, T_SYMBOL);
481
505
 
482
506
  Data_Get_Struct(self, camera_t, ptr);
483
507
 
484
508
  ret = rb_ary_new();
509
+ fmt = to_pixfmt(_fmt);
485
510
 
486
511
  for (i = 0; ;i++){
487
- err = camera_get_frame_size(ptr, to_pixfmt(fmt), i, &size);
512
+ err = camera_get_frame_size(ptr, fmt, i, &size);
488
513
  if (err) break;
489
514
 
490
515
  if (size.type == V4L2_FRMSIZE_TYPE_DISCRETE) {
491
516
  capa = rb_obj_alloc(frame_cap_klass);
517
+ list = get_framerate_list(ptr, fmt, &size.discrete);
518
+
492
519
  rb_ivar_set(capa, id_iv_width, INT2NUM(size.discrete.width));
493
520
  rb_ivar_set(capa, id_iv_height, INT2NUM(size.discrete.height));
494
- rb_ivar_set(capa, id_iv_rate, get_framerate_list(ptr, &size.discrete));
521
+ rb_ivar_set(capa, id_iv_rate, list);
495
522
 
496
523
  rb_ary_push(ret, capa);
497
524
 
498
525
  } else if (size.type == V4L2_FRMSIZE_TYPE_STEPWISE) {
499
- make_dummy_capabilities(ptr, ret,
526
+ make_dummy_capabilities(ptr,
527
+ ret,
528
+ fmt,
500
529
  size.stepwise.max_width,
501
530
  size.stepwise.max_height);
502
531
  break;
@@ -1,3 +1,3 @@
1
1
  module Video4Linux2
2
- VERSION = "0.9.2"
2
+ VERSION = "0.10.0"
3
3
  end
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
36
36
 
37
37
  spec.required_ruby_version = ">= 2.4.0"
38
38
 
39
- spec.add_development_dependency "bundler", "~> 1.17"
39
+ spec.add_development_dependency "bundler", "~> 2.0.0"
40
40
  spec.add_development_dependency "rake", "~> 10.0"
41
41
  spec.add_development_dependency "rake-compiler", "~> 1.0.7"
42
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.2
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Kuwagata
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-10 00:00:00.000000000 Z
11
+ date: 2019-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.17'
19
+ version: 2.0.0
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.17'
26
+ version: 2.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement