38 lines
1.2 KiB
Rust
38 lines
1.2 KiB
Rust
use crate::priv_prelude::*;
|
|
#[doc(inline)]
|
|
pub use gstreamer_video::VideoFormat;
|
|
|
|
wrap_gst!(VideoConvert, gstreamer::Element);
|
|
parent_child!(Element, VideoConvert);
|
|
|
|
impl Sink for VideoConvert {}
|
|
impl Source for VideoConvert {}
|
|
|
|
impl VideoConvert {
|
|
pub fn new(name: impl AsRef<str>) -> Result<Self> {
|
|
use gstreamer::prelude::*;
|
|
let element = gstreamer::ElementFactory::make("videoconvert")
|
|
.name(name.as_ref())
|
|
.build()
|
|
.change_context(Error)
|
|
.attach("Failed to create videoconvert element")?;
|
|
Ok(VideoConvert { inner: element })
|
|
}
|
|
|
|
// pub fn with_caps(mut self, caps: &gstreamer::Caps) -> Self {
|
|
// use gstreamer::prelude::*;
|
|
// self.inner.set_property("caps", caps);
|
|
// self
|
|
// }
|
|
pub fn with_output_format(self, format: VideoFormat) -> Result<Self> {
|
|
use gstreamer::prelude::*;
|
|
let caps = Caps::builder(CapsType::Video)
|
|
.field("format", format.to_str())
|
|
.build();
|
|
self.inner.set_property("caps", &caps.inner);
|
|
// .change_context(Error)
|
|
// .attach("Failed to set output format on videoconvert")?;
|
|
Ok(self)
|
|
}
|
|
}
|