feat: Added PipelineExt trait for all Children of Pipelines
This commit is contained in:
@@ -13,7 +13,6 @@ impl Drop for Playbin3 {
|
||||
|
||||
impl Playbin3 {
|
||||
pub fn new(name: impl AsRef<str>) -> Result<Self> {
|
||||
use gstreamer::prelude::*;
|
||||
gstreamer::ElementFactory::make("playbin3")
|
||||
.name(name.as_ref())
|
||||
.build()
|
||||
@@ -22,51 +21,33 @@ impl Playbin3 {
|
||||
}
|
||||
|
||||
pub fn with_uri(self, uri: impl AsRef<str>) -> Self {
|
||||
use gstreamer::prelude::*;
|
||||
self.inner.set_property("uri", uri.as_ref());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_video_sink(self, video_sink: &impl ChildOf<Element>) -> Self {
|
||||
use gstreamer::prelude::*;
|
||||
self.inner
|
||||
.set_property("video-sink", &video_sink.upcast_ref().inner);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_text_sink(self, text_sink: &impl ChildOf<Element>) -> Self {
|
||||
use gstreamer::prelude::*;
|
||||
self.inner
|
||||
.set_property("text-sink", &text_sink.upcast_ref().inner);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_audio_sink(self, audio_sink: &impl ChildOf<Element>) -> Self {
|
||||
use gstreamer::prelude::*;
|
||||
self.inner
|
||||
.set_property("audio-sink", &audio_sink.upcast_ref().inner);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_volume(&self, volume: f64) {
|
||||
use gstreamer::prelude::*;
|
||||
self.inner.set_property("volume", volume.clamp(1.0, 100.0))
|
||||
}
|
||||
|
||||
pub fn get_volume(&self) -> f64 {
|
||||
use gstreamer::prelude::*;
|
||||
self.inner.property::<f64>("volume")
|
||||
}
|
||||
}
|
||||
|
||||
impl core::ops::Deref for Playbin3 {
|
||||
type Target = Pipeline;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
let gp = self
|
||||
.inner
|
||||
.downcast_ref::<gstreamer::Pipeline>()
|
||||
.expect("BUG: Playbin3 must be a pipeline");
|
||||
unsafe { &*(gp as *const _ as *const Pipeline) }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user