feat(gst): enhance GStreamer integration with new modules and improved API
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:
53
gst/src/caps.rs
Normal file
53
gst/src/caps.rs
Normal file
@@ -0,0 +1,53 @@
|
||||
use crate::*;
|
||||
#[repr(transparent)]
|
||||
pub struct Caps {
|
||||
pub(crate) inner: gstreamer::caps::Caps,
|
||||
}
|
||||
|
||||
impl Caps {
|
||||
pub fn builder(cs: CapsType) -> CapsBuilder {
|
||||
CapsBuilder::new(cs)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CapsBuilder {
|
||||
inner: gstreamer::caps::Builder<gstreamer::caps::NoFeature>,
|
||||
}
|
||||
|
||||
impl CapsBuilder {
|
||||
pub fn field<V: Into<glib::Value> + Send>(mut self, name: impl AsRef<str>, value: V) -> Self {
|
||||
use gstreamer::prelude::*;
|
||||
self.inner = self.inner.field(name.as_ref(), value);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn build(self) -> Caps {
|
||||
Caps {
|
||||
inner: self.inner.build(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum CapsType {
|
||||
Video,
|
||||
Audio,
|
||||
Text,
|
||||
}
|
||||
|
||||
impl CapsType {
|
||||
pub fn as_str(&self) -> &str {
|
||||
match self {
|
||||
CapsType::Video => "video/x-raw",
|
||||
CapsType::Audio => "audio/x-raw",
|
||||
CapsType::Text => "text/x-raw",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CapsBuilder {
|
||||
pub fn new(cs: CapsType) -> Self {
|
||||
CapsBuilder {
|
||||
inner: gstreamer::Caps::builder(cs.as_str()),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user