blob: 1add8cd3d1921801b768acda147830e22223ec21 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
use anyhow::{anyhow, Result};
use sshcamera::v4l2::{Device as V4l2, Field};
use sshcamera::v4l2cairo::V4l2Cairo;
use sshcamera::gtk;
use sshcamera::v4l2abst::RemoteCam;
use sshcamera::io::RWBundle;
use sshcamera::source;
use gtk4::glib::ExitCode;
use std::env;
use std::io;
use std::process::{Command, Stdio};
fn main() -> Result<ExitCode>{
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.len() == 0{
let v = V4l2::open(arg1)?;
// TODO: It should be better.
let 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 io = RWBundle(io::stdin(), io::stdout());
source::main(c, io).and(Ok(ExitCode::SUCCESS))
}else{
let child = Command::new(arg1)
.args(args)
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()?;
let io = RWBundle(child.stdout.unwrap(), child.stdin.unwrap());
let v2c = V4l2Cairo::new(RemoteCam::new(io));
gtk::main(v2c)
}
}
|