use anyhow::{Context, Result};
use gst::{Bin, GhostPad};
use crate::{
gstreamer::{add_ghost_pad, GStreamerSink},
parse_bin_from_description_with_context,
};
#[derive(Debug)]
pub struct SystemSink {
bin: Bin,
audio_sink: GhostPad,
video_sink: GhostPad,
}
impl SystemSink {
pub fn create() -> Result<Self> {
let description = r#"
name="Sytem-Sinks"
autoaudiosink
name=audio
sync=false
autovideosink
name=video
sync=false
"#;
let bin = parse_bin_from_description_with_context(description, false)?;
let audio_sink = add_ghost_pad(&bin, "audio", "sink").context("unable to add GhostPad")?;
let video_sink = add_ghost_pad(&bin, "video", "sink").context("unable to add GhostPad")?;
Ok(Self {
bin,
audio_sink,
video_sink,
})
}
}
impl GStreamerSink for SystemSink {
fn video(&self) -> GhostPad {
self.video_sink.clone()
}
fn audio(&self) -> GhostPad {
self.audio_sink.clone()
}
fn bin(&self) -> Bin {
self.bin.clone()
}
}