feat: Restructure the gst parent<->child relations

This commit is contained in:
uttarayan21
2025-12-23 01:09:01 +05:30
parent 043d1e99f0
commit 8d46bd2b85
11 changed files with 274 additions and 343 deletions

View File

@@ -1,19 +1,8 @@
use crate::priv_prelude::*;
#[derive(Debug, Clone)]
pub struct AppSink {
inner: gstreamer::Element,
}
impl IsElement for AppSink {
fn as_element(&self) -> &Element {
unsafe { core::mem::transmute(&self.inner) }
}
fn into_element(self) -> Element {
Element { inner: self.inner }
}
}
wrap_gst!(AppSink, gstreamer::Element);
parent_child!(Pipeline, AppSink, downcast); // since AppSink is an Element internaly
parent_child!(Element, AppSink);
impl Sink for AppSink {}
@@ -136,28 +125,8 @@ fn test_appsink() {
.expect("Link videoconvert to appsink");
let playbin3 = playbin3.with_video_sink(&video_sink);
playbin3.play().expect("Play video");
let bus = playbin3.bus().unwrap();
// playbin3.play().expect("Play playbin3");
std::thread::spawn({
let playbin3 = playbin3.clone();
move || {
loop {
std::thread::sleep(std::time::Duration::from_secs(5));
playbin3.play();
playbin3.wait_non_null_sync();
let sample = appsink
.try_pull_sample(core::time::Duration::from_secs(5))
.expect("Pull sample from appsink")
.expect("No sample received from appsink");
dbg!(sample.caps());
playbin3.play();
tracing::info!("Played");
}
}
});
for msg in bus.iter_timed(None) {
match msg.view() {
gstreamer::MessageView::Eos(..) => {