playa_ffmpeg/device/
output.rs1use std::ptr;
2
3use crate::{Format, ffi::*, format};
4
5pub struct AudioIter(*mut AVOutputFormat);
6
7impl Iterator for AudioIter {
8 type Item = Format;
9
10 fn next(&mut self) -> Option<<Self as Iterator>::Item> {
11 unsafe {
12 #[allow(clippy::unnecessary_cast)]
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;
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 #[allow(clippy::unnecessary_cast)]
40 let ptr = av_output_video_device_next(self.0) as *mut AVOutputFormat;
41
42 if ptr.is_null() && !self.0.is_null() {
43 None
44 } else {
45 self.0 = ptr;
46
47 Some(Format::Output(format::Output::wrap(ptr)))
48 }
49 }
50 }
51}
52
53pub fn video() -> VideoIter {
54 VideoIter(ptr::null_mut())
55}