summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authordyknon dyknonr5fjp2025-02-24 21:13:53 +0900
committerdyknon dyknonr5fjp2025-02-24 21:13:53 +0900
commit4d59425948efaa3345adb02730d084dc83d559d2 (patch)
tree1c48fe8e0cea926fbf04198f0216e09818fb1e85 /src/bin
parent6ecbf0d55695335f52d6fcf2b6a22ed45f5e4d99 (diff)
32bit arch compat + binary w/o gui.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/sshcamera.rs6
-rw-r--r--src/bin/usshcamera.rs44
2 files changed, 45 insertions, 5 deletions
diff --git a/src/bin/sshcamera.rs b/src/bin/sshcamera.rs
index 02c8778..270700a 100644
--- a/src/bin/sshcamera.rs
+++ b/src/bin/sshcamera.rs
@@ -17,11 +17,7 @@ fn main() -> Result<ExitCode>{
let Some(arg1) = args.next() else{
return Err(anyhow!("Give me args"));
};
- if arg1.contains('/'){
- if args.next() != None{
- return Err(anyhow!("too many args"));
- }
-
+ if args.len() == 0{
let v = V4l2::open(arg1)?;
// TODO: It should be better.
diff --git a/src/bin/usshcamera.rs b/src/bin/usshcamera.rs
new file mode 100644
index 0000000..6d73e92
--- /dev/null
+++ b/src/bin/usshcamera.rs
@@ -0,0 +1,44 @@
+use anyhow::{anyhow, Result};
+use sshcamera::v4l2::{Device as V4l2, Field};
+use sshcamera::v4l2abst::CaptStream;
+use sshcamera::io::RWBundle;
+use std::env;
+use std::io::{self, Read as _, Write as _};
+
+fn main() -> Result<()>{
+ let mut args = env::args();
+ if args.next() == None{
+ return Err(anyhow!("arg0 is not present??"));
+ }
+ let Some(arg1) = args.next() else{
+ return Err(anyhow!("Give me args"));
+ };
+ if args.next() != None{
+ return Err(anyhow!("too many args"));
+ }
+
+ let v = V4l2::open(arg1)?;
+
+ // TODO: It should be better.
+ let mut c = v.captstream_builder()?
+ .set_pixelformat("MJPG".into())
+ //.set_pixelformat("YUYV".into())
+ .set_field(Field::None)
+ .build()?;
+ 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(())
+ })??;
+ }
+}