
* Add avformat_close_input call to clean up AVFormantContext * Format code with rustfmt * Fix clippy lint double_parens * Fix clippy lint deref_addrof * Fix clippy lint identity_conversion * Fix clippy lint match_ref_pats * Fix clippy lint cast_lossless * Fix clippy lint cmp_null * Fix clippy lint clone_on_ref_ptr * Fix clippy lint map_clone * Fix clippy lint needless_borrow * Fix clippy lint needless_pass_by_value * Fix clippy lints for examples * Fix clippy lint unused_io_amount * Fix clippy lint new_without_default * Ignore inline_always clippy lint * Add vim temp files to .gitignore
54 lines
1.1 KiB
Rust
54 lines
1.1 KiB
Rust
use std::ptr;
|
|
|
|
use ffi::*;
|
|
use format;
|
|
use Format;
|
|
|
|
pub struct AudioIter(*mut AVOutputFormat);
|
|
|
|
impl Iterator for AudioIter {
|
|
type Item = Format;
|
|
|
|
fn next(&mut self) -> Option<<Self as Iterator>::Item> {
|
|
unsafe {
|
|
let ptr = av_output_audio_device_next(self.0);
|
|
|
|
if ptr.is_null() && !self.0.is_null() {
|
|
None
|
|
} else {
|
|
self.0 = ptr;
|
|
|
|
Some(Format::Output(format::Output::wrap(ptr)))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn audio() -> AudioIter {
|
|
AudioIter(ptr::null_mut())
|
|
}
|
|
|
|
pub struct VideoIter(*mut AVOutputFormat);
|
|
|
|
impl Iterator for VideoIter {
|
|
type Item = Format;
|
|
|
|
fn next(&mut self) -> Option<<Self as Iterator>::Item> {
|
|
unsafe {
|
|
let ptr = av_output_video_device_next(self.0);
|
|
|
|
if ptr.is_null() && !self.0.is_null() {
|
|
None
|
|
} else {
|
|
self.0 = ptr;
|
|
|
|
Some(Format::Output(format::Output::wrap(ptr)))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn video() -> VideoIter {
|
|
VideoIter(ptr::null_mut())
|
|
}
|