summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/usshcamera.rs21
1 files changed, 5 insertions, 16 deletions
diff --git a/src/bin/usshcamera.rs b/src/bin/usshcamera.rs
index 6d73e92..ea09a03 100644
--- a/src/bin/usshcamera.rs
+++ b/src/bin/usshcamera.rs
@@ -1,9 +1,9 @@
use anyhow::{anyhow, Result};
use sshcamera::v4l2::{Device as V4l2, Field};
-use sshcamera::v4l2abst::CaptStream;
use sshcamera::io::RWBundle;
+use sshcamera::source;
use std::env;
-use std::io::{self, Read as _, Write as _};
+use std::io;
fn main() -> Result<()>{
let mut args = env::args();
@@ -20,7 +20,7 @@ fn main() -> Result<()>{
let v = V4l2::open(arg1)?;
// TODO: It should be better.
- let mut c = v.captstream_builder()?
+ let c = v.captstream_builder()?
.set_pixelformat("MJPG".into())
//.set_pixelformat("YUYV".into())
.set_field(Field::None)
@@ -28,17 +28,6 @@ fn main() -> Result<()>{
assert!(["YUYV", "MJPG"].contains(&c.pixelformat().as_str()));
assert!(c.field() == Field::None);
- let mut io = RWBundle(io::stdin(), io::stdout());
- loop{
- CaptStream::next(&mut c, |frame|{
- frame.serialize(&mut io)?;
- io.flush()?;
- let mut rb = [0];
- io.read_exact(&mut rb)?;
- if rb[0] != 0x2e{
- return Err(anyhow!("protocol error"));
- }
- Ok(())
- })??;
- }
+ let io = RWBundle(io::stdin(), io::stdout());
+ source::main(c, io)
}