From f47d7c92b8445b72bf15eef2da03916592558dfa Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 1 Feb 2024 22:29:09 -0500 Subject: [PATCH] keyfork-qrcode: enforce use of MPG1 video streams --- crates/qrcode/keyfork-qrcode/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/qrcode/keyfork-qrcode/src/lib.rs b/crates/qrcode/keyfork-qrcode/src/lib.rs index 704d47e..3edbd57 100644 --- a/crates/qrcode/keyfork-qrcode/src/lib.rs +++ b/crates/qrcode/keyfork-qrcode/src/lib.rs @@ -9,6 +9,8 @@ use std::{ use v4l::{ buffer::Type, io::{userptr::Stream, traits::CaptureStream}, + video::Capture, + FourCC, Device, }; @@ -100,6 +102,9 @@ pub fn qrencode( #[cfg(feature = "decode-backend-rqrr")] pub fn scan_camera(timeout: Duration, index: usize) -> Result, QRCodeScanError> { let device = Device::new(index)?; + let mut fmt = device.format().expect("Failed to read format"); + fmt.fourcc = FourCC::new(b"MPG1"); + device.set_format(&fmt)?; let mut stream = Stream::with_buffers(&device, Type::VideoCapture, 4)?; let start = SystemTime::now(); @@ -128,6 +133,9 @@ pub fn scan_camera(timeout: Duration, index: usize) -> Result, QR #[cfg(feature = "decode-backend-zbar")] pub fn scan_camera(timeout: Duration, index: usize) -> Result, QRCodeScanError> { let device = Device::new(index)?; + let mut fmt = device.format().expect("Failed to read format"); + fmt.fourcc = FourCC::new(b"MPG1"); + device.set_format(&fmt)?; let mut stream = Stream::with_buffers(&device, Type::VideoCapture, 4)?; let start = SystemTime::now(); let mut scanner = keyfork_zbar::image_scanner::ImageScanner::new();