refactor: move PlayFlags defaults into Playbin3 and clean up unused prelude imports
Some checks failed
build / checks-matrix (push) Has been cancelled
build / checks-build (push) Has been cancelled
build / codecov (push) Has been cancelled
docs / docs (push) Has been cancelled

This commit is contained in:
uttarayan21
2025-12-26 10:39:00 +05:30
parent a7ffa69326
commit fc9555873b
7 changed files with 17 additions and 21 deletions

View File

@@ -5,7 +5,7 @@ use gst::{
caps::{Caps, CapsType},
element::ElementExt,
pipeline::PipelineExt,
playback::{PlayFlags, Playbin, Playbin3},
playback::{PlayFlags, Playbin3},
videoconvertscale::VideoConvert,
};
use std::sync::{Arc, Mutex, atomic::AtomicBool};
@@ -48,7 +48,7 @@ impl VideoSource {
.with_buffer_duration(core::time::Duration::from_secs(2))
.with_buffer_size(4096 * 4096 * 4 * 3)
.with_ring_buffer_max_size(4096 * 4096 * 4 * 3)
.with_flags(PlayFlags::default() | PlayFlags::DOWNLOAD)
.with_flags(Playbin3::default_flags() | PlayFlags::DOWNLOAD)
.with_video_sink(&video_sink);
let bus = playbin.bus().change_context(Error)?;
playbin.pause().change_context(Error)?;

View File

@@ -1,5 +1,4 @@
use crate::{playback::Playbin3, priv_prelude::*};
use gstreamer::State;
use crate::priv_prelude::*;
wrap_gst!(Pipeline);
parent_child!(Element, Pipeline);

View File

@@ -16,7 +16,6 @@ impl AppSink {
}
pub fn new(name: impl AsRef<str>) -> Result<Self> {
use gstreamer::prelude::*;
let inner = gstreamer::ElementFactory::make("appsink")
.name(name.as_ref())
.build()
@@ -133,7 +132,7 @@ fn test_appsink() {
.build(),
);
let mut video_sink = video_convert
let video_sink = video_convert
.link(&appsink)
.expect("Link videoconvert to appsink");

View File

@@ -8,7 +8,6 @@ impl Sink for AutoVideoSink {}
impl AutoVideoSink {
pub fn new(name: impl AsRef<str>) -> Result<Self> {
use gstreamer::prelude::*;
let element = gstreamer::ElementFactory::make("autovideosink")
.name(name.as_ref())
.build()

View File

@@ -36,19 +36,6 @@ bitflags::bitflags! {
}
}
impl Default for PlayFlags {
/// Flags "GstPlayFlags" Default: 0x00000717, "soft-colorbalance+deinterlace+buffering+soft-volume+text+audio+video"
fn default() -> Self {
Self::SOFT_COLORBALANCE
| Self::DEINTERLACE
| Self::BUFFERING
| Self::SOFT_VOLUME
| Self::TEXT
| Self::AUDIO
| Self::VIDEO
}
}
const _: () = {
use glib::types::StaticType;
impl glib::types::StaticType for PlayFlags {

View File

@@ -1,4 +1,5 @@
use crate::priv_prelude::*;
use playback::PlayFlags;
wrap_gst!(Playbin3, gstreamer::Element);
parent_child!(Element, Playbin3);
@@ -80,3 +81,15 @@ impl Playbin3 {
self
}
}
impl Playbin3 {
pub fn default_flags() -> PlayFlags {
PlayFlags::SOFT_COLORBALANCE
| PlayFlags::DEINTERLACE
| PlayFlags::BUFFERING
| PlayFlags::SOFT_VOLUME
| PlayFlags::TEXT
| PlayFlags::AUDIO
| PlayFlags::VIDEO
}
}

View File

@@ -10,7 +10,6 @@ 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()