ffmpeg_the_third/device/
output.rs

1use std::ptr;
2
3use crate::ffi::*;
4use crate::format;
5
6pub struct AudioIter(*const AVOutputFormat);
7
8impl Iterator for AudioIter {
9    type Item = format::Output;
10
11    fn next(&mut self) -> Option<<Self as Iterator>::Item> {
12        unsafe {
13            let inner = self.0;
14
15            // Pre-5.0 FFmpeg uses a non-const pointer here
16            #[cfg(not(feature = "ffmpeg_5_0"))]
17            let inner = inner as *mut _;
18
19            let ptr = av_output_audio_device_next(inner);
20
21            if let Some(output) = format::Output::from_raw(ptr) {
22                self.0 = ptr;
23                Some(output)
24            } else {
25                None
26            }
27        }
28    }
29}
30
31pub fn audio() -> AudioIter {
32    AudioIter(ptr::null_mut())
33}
34
35pub struct VideoIter(*const AVOutputFormat);
36
37impl Iterator for VideoIter {
38    type Item = format::Output;
39
40    fn next(&mut self) -> Option<<Self as Iterator>::Item> {
41        unsafe {
42            let inner = self.0;
43
44            // Pre-5.0 FFmpeg uses a non-const pointer here
45            #[cfg(not(feature = "ffmpeg_5_0"))]
46            let inner = inner as *mut _;
47
48            let ptr = av_output_video_device_next(inner);
49
50            if let Some(output) = format::Output::from_raw(ptr) {
51                self.0 = ptr;
52                Some(output)
53            } else {
54                None
55            }
56        }
57    }
58}
59
60pub fn video() -> VideoIter {
61    VideoIter(ptr::null_mut())
62}