forked from raymanfx/libv4l-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get rid of the clap dev dependency. Signed-off-by: Christopher N. Hesse <[email protected]>
- Loading branch information
Showing
16 changed files
with
120 additions
and
517 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
extern crate v4l; | ||
|
||
use v4l::context; | ||
|
||
fn main() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use std::io; | ||
|
||
use v4l::prelude::*; | ||
|
||
fn main() -> io::Result<()> { | ||
let path = "/dev/video0"; | ||
println!("Using device: {}\n", path); | ||
|
||
let dev = Device::with_path(path)?; | ||
let controls = dev.query_controls()?; | ||
|
||
for control in controls { | ||
println!("{}", control); | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,17 @@ | ||
extern crate clap; | ||
extern crate v4l; | ||
use std::io; | ||
|
||
use clap::{App, Arg}; | ||
use v4l::prelude::*; | ||
|
||
fn main() { | ||
let matches = App::new("v4l device") | ||
.version("0.2") | ||
.author("Christopher N. Hesse <[email protected]>") | ||
.about("Video4Linux device example") | ||
.arg( | ||
Arg::with_name("device") | ||
.short("d") | ||
.long("device") | ||
.value_name("INDEX or PATH") | ||
.help("Capture device node path or index (default: 0)") | ||
.takes_value(true), | ||
) | ||
.get_matches(); | ||
|
||
// Determine which device to use | ||
let mut path: String = matches | ||
.value_of("device") | ||
.unwrap_or("/dev/video0") | ||
.to_string(); | ||
if path.parse::<u64>().is_ok() { | ||
path = format!("/dev/video{}", path); | ||
} | ||
fn main() -> io::Result<()> { | ||
let path = "/dev/video0"; | ||
println!("Using device: {}\n", path); | ||
let dev = Device::with_path(path).unwrap(); | ||
|
||
let caps = dev.query_caps().unwrap(); | ||
let dev = Device::with_path(path)?; | ||
|
||
let caps = dev.query_caps()?; | ||
println!("Device capabilities:\n{}", caps); | ||
|
||
let controls = dev.query_controls().unwrap(); | ||
let controls = dev.query_controls()?; | ||
println!("Device controls:"); | ||
let mut max_name_len = 0; | ||
for ctrl in &controls { | ||
|
@@ -50,4 +28,6 @@ fn main() { | |
indent = max_name_len | ||
); | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use std::io; | ||
|
||
use v4l::prelude::*; | ||
use v4l::video::Capture; | ||
|
||
fn main() -> io::Result<()> { | ||
let path = "/dev/video0"; | ||
println!("Using device: {}\n", path); | ||
|
||
let dev = Device::with_path(path)?; | ||
|
||
let format = dev.format()?; | ||
println!("Active format:\n{}", format); | ||
|
||
let params = dev.params()?; | ||
println!("Active parameters:\n{}", params); | ||
|
||
println!("Available formats:"); | ||
for format in dev.enum_formats()? { | ||
println!(" {} ({})", format.fourcc, format.description); | ||
|
||
for framesize in dev.enum_framesizes(format.fourcc)? { | ||
for discrete in framesize.size.to_discrete() { | ||
println!(" Size: {}", discrete); | ||
|
||
for frameinterval in | ||
dev.enum_frameintervals(framesize.fourcc, discrete.width, discrete.height)? | ||
{ | ||
println!(" Interval: {}", frameinterval); | ||
} | ||
} | ||
} | ||
|
||
println!("") | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,43 @@ | ||
extern crate clap; | ||
extern crate v4l; | ||
use std::io; | ||
use std::sync::{mpsc, RwLock}; | ||
use std::thread; | ||
use std::time::Instant; | ||
|
||
use clap::{App, Arg}; | ||
use glium::index::PrimitiveType; | ||
use glium::{glutin, Surface}; | ||
use glium::{implement_vertex, program, uniform}; | ||
use std::sync::{mpsc, RwLock}; | ||
use std::thread; | ||
use std::time::Instant; | ||
use v4l::buffer::Type; | ||
use v4l::io::traits::CaptureStream; | ||
use v4l::prelude::*; | ||
use v4l::video::capture::Parameters; | ||
use v4l::video::Capture; | ||
use v4l::{Format, FourCC}; | ||
|
||
fn main() { | ||
let matches = App::new("v4l capture") | ||
.version("0.2") | ||
.author("Christopher N. Hesse <[email protected]>") | ||
.about("Video4Linux device example") | ||
.arg( | ||
Arg::with_name("device") | ||
.short("d") | ||
.long("device") | ||
.value_name("INDEX or PATH") | ||
.help("Device node path or index (default: 0)") | ||
.takes_value(true), | ||
) | ||
.arg( | ||
Arg::with_name("buffers") | ||
.short("b") | ||
.long("buffers") | ||
.value_name("INT") | ||
.help("Number of buffers to allocate (default: 4)") | ||
.takes_value(true), | ||
) | ||
.get_matches(); | ||
|
||
// Determine which device to use | ||
let mut path: String = matches | ||
.value_of("device") | ||
.unwrap_or("/dev/video0") | ||
.to_string(); | ||
if path.parse::<u64>().is_ok() { | ||
path = format!("/dev/video{}", path); | ||
} | ||
fn main() -> io::Result<()> { | ||
let path = "/dev/video0"; | ||
println!("Using device: {}\n", path); | ||
|
||
// Allocate 4 buffers by default | ||
let buffers = matches.value_of("buffers").unwrap_or("4").to_string(); | ||
let buffers = buffers.parse::<u32>().unwrap(); | ||
let buffer_count = 4; | ||
|
||
let mut format: Format; | ||
let params: Parameters; | ||
|
||
let dev = RwLock::new(Device::with_path(path.clone()).unwrap()); | ||
let dev = RwLock::new(Device::with_path(path.clone())?); | ||
{ | ||
let dev = dev.write().unwrap(); | ||
format = dev.format().unwrap(); | ||
params = dev.params().unwrap(); | ||
format = dev.format()?; | ||
params = dev.params()?; | ||
|
||
// enforce RGB3 | ||
format.fourcc = FourCC::new(b"RGB3"); | ||
format = dev.set_format(&format).unwrap(); | ||
format = dev.set_format(&format)?; | ||
|
||
if format.fourcc != FourCC::new(b"RGB3") { | ||
println!("RGB3 not supported by the device, but required by this example!"); | ||
return; | ||
return Err(io::Error::new( | ||
io::ErrorKind::Other, | ||
"RGB3 not supported by the device, but required by this example!", | ||
)); | ||
} | ||
} | ||
|
||
|
@@ -153,7 +123,8 @@ fn main() { | |
let mut dev = dev.write().unwrap(); | ||
|
||
// Setup a buffer stream | ||
let mut stream = MmapStream::with_buffers(&mut *dev, Type::VideoCapture, buffers).unwrap(); | ||
let mut stream = | ||
MmapStream::with_buffers(&mut *dev, Type::VideoCapture, buffer_count).unwrap(); | ||
|
||
loop { | ||
let (buf, _) = stream.next().unwrap(); | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.