feat(gst): enhance GStreamer integration with new modules and improved API
Some checks failed
build / checks-matrix (push) Has been cancelled
build / codecov (push) Has been cancelled
docs / docs (push) Has been cancelled
build / checks-build (push) Has been cancelled

This commit introduces significant enhancements to the GStreamer integration by:
- Adding new modules for bins, caps, elements, pads, and plugins
- Implementing a more ergonomic API with helper methods like play(), pause(), ready()
- Adding support for various GStreamer plugins including app, autodetect, playback, and videoconvertscale
- Improving error handling with better context attachment
- Updating dependencies to latest versions including gstreamer-video 0.24.4
- Refactoring existing code to use modern Rust patterns and features
This commit is contained in:
uttarayan21
2025-12-17 23:35:05 +05:30
parent 21cbaff610
commit d42ef3b550
19 changed files with 619 additions and 117 deletions

52
gst/src/element.rs Normal file
View File

@@ -0,0 +1,52 @@
use crate::{Error, Pad, Result, ResultExt};
#[repr(transparent)]
pub struct Element {
pub(crate) inner: gstreamer::Element,
}
pub trait IsElement {
fn as_element(&self) -> ∈
fn into_element(self) -> Element;
fn pad(&self, name: &str) -> Option<Pad> {
use gstreamer::prelude::*;
self.as_element().inner.static_pad(name).map(Pad::from)
}
}
impl IsElement for Element {
fn as_element(&self) -> &Element {
self
}
fn into_element(self) -> Element {
self
}
}
pub trait Sink: IsElement {
fn sink_pad(&self) -> Pad {
use gstreamer::prelude::*;
self.as_element()
.pad("sink")
.map(From::from)
.expect("Sink element has no sink pad")
}
}
pub trait Source: IsElement {
fn source_pad(&self) -> Pad {
use gstreamer::prelude::*;
self.as_element()
.pad("src")
.map(From::from)
.expect("Source element has no src pad")
}
fn link<S: Sink>(&self, sink: &S) -> Result<()> {
use gstreamer::prelude::*;
self.as_element()
.inner
.link(&sink.as_element().inner)
.change_context(Error)
.attach("Failed to link source to sink")
}
}