ffmpeg_rs/device/
output.rs

1use std::ptr;
2
3use ffi::*;
4use format;
5use Format;
6
7pub struct AudioIter(*mut AVOutputFormat);
8
9impl Iterator for AudioIter {
10    type Item = Format;
11
12    fn next(&mut self) -> Option<<Self as Iterator>::Item> {
13        unsafe {
14            let ptr = av_output_audio_device_next(self.0) as *mut AVOutputFormat;
15
16            if ptr.is_null() && !self.0.is_null() {
17                None
18            } else {
19                self.0 = ptr as *mut AVOutputFormat;
20
21                Some(Format::Output(format::Output::wrap(ptr)))
22            }
23        }
24    }
25}
26
27pub fn audio() -> AudioIter {
28    AudioIter(ptr::null_mut())
29}
30
31pub struct VideoIter(*mut AVOutputFormat);
32
33impl Iterator for VideoIter {
34    type Item = Format;
35
36    fn next(&mut self) -> Option<<Self as Iterator>::Item> {
37        unsafe {
38            let ptr = av_output_video_device_next(self.0) as *mut AVOutputFormat;
39
40            if ptr.is_null() && !self.0.is_null() {
41                None
42            } else {
43                self.0 = ptr as *mut AVOutputFormat;
44
45                Some(Format::Output(format::Output::wrap(ptr)))
46            }
47        }
48    }
49}
50
51pub fn video() -> VideoIter {
52    VideoIter(ptr::null_mut())
53}