refactor: move PlayFlags defaults into Playbin3 and clean up unused prelude imports
This commit is contained in:
@@ -5,7 +5,7 @@ use gst::{
|
|||||||
caps::{Caps, CapsType},
|
caps::{Caps, CapsType},
|
||||||
element::ElementExt,
|
element::ElementExt,
|
||||||
pipeline::PipelineExt,
|
pipeline::PipelineExt,
|
||||||
playback::{PlayFlags, Playbin, Playbin3},
|
playback::{PlayFlags, Playbin3},
|
||||||
videoconvertscale::VideoConvert,
|
videoconvertscale::VideoConvert,
|
||||||
};
|
};
|
||||||
use std::sync::{Arc, Mutex, atomic::AtomicBool};
|
use std::sync::{Arc, Mutex, atomic::AtomicBool};
|
||||||
@@ -48,7 +48,7 @@ impl VideoSource {
|
|||||||
.with_buffer_duration(core::time::Duration::from_secs(2))
|
.with_buffer_duration(core::time::Duration::from_secs(2))
|
||||||
.with_buffer_size(4096 * 4096 * 4 * 3)
|
.with_buffer_size(4096 * 4096 * 4 * 3)
|
||||||
.with_ring_buffer_max_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);
|
.with_video_sink(&video_sink);
|
||||||
let bus = playbin.bus().change_context(Error)?;
|
let bus = playbin.bus().change_context(Error)?;
|
||||||
playbin.pause().change_context(Error)?;
|
playbin.pause().change_context(Error)?;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
use crate::{playback::Playbin3, priv_prelude::*};
|
use crate::priv_prelude::*;
|
||||||
use gstreamer::State;
|
|
||||||
|
|
||||||
wrap_gst!(Pipeline);
|
wrap_gst!(Pipeline);
|
||||||
parent_child!(Element, Pipeline);
|
parent_child!(Element, Pipeline);
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ impl AppSink {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(name: impl AsRef<str>) -> Result<Self> {
|
pub fn new(name: impl AsRef<str>) -> Result<Self> {
|
||||||
use gstreamer::prelude::*;
|
|
||||||
let inner = gstreamer::ElementFactory::make("appsink")
|
let inner = gstreamer::ElementFactory::make("appsink")
|
||||||
.name(name.as_ref())
|
.name(name.as_ref())
|
||||||
.build()
|
.build()
|
||||||
@@ -133,7 +132,7 @@ fn test_appsink() {
|
|||||||
.build(),
|
.build(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut video_sink = video_convert
|
let video_sink = video_convert
|
||||||
.link(&appsink)
|
.link(&appsink)
|
||||||
.expect("Link videoconvert to appsink");
|
.expect("Link videoconvert to appsink");
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ impl Sink for AutoVideoSink {}
|
|||||||
|
|
||||||
impl AutoVideoSink {
|
impl AutoVideoSink {
|
||||||
pub fn new(name: impl AsRef<str>) -> Result<Self> {
|
pub fn new(name: impl AsRef<str>) -> Result<Self> {
|
||||||
use gstreamer::prelude::*;
|
|
||||||
let element = gstreamer::ElementFactory::make("autovideosink")
|
let element = gstreamer::ElementFactory::make("autovideosink")
|
||||||
.name(name.as_ref())
|
.name(name.as_ref())
|
||||||
.build()
|
.build()
|
||||||
|
|||||||
@@ -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 _: () = {
|
const _: () = {
|
||||||
use glib::types::StaticType;
|
use glib::types::StaticType;
|
||||||
impl glib::types::StaticType for PlayFlags {
|
impl glib::types::StaticType for PlayFlags {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use crate::priv_prelude::*;
|
use crate::priv_prelude::*;
|
||||||
|
use playback::PlayFlags;
|
||||||
|
|
||||||
wrap_gst!(Playbin3, gstreamer::Element);
|
wrap_gst!(Playbin3, gstreamer::Element);
|
||||||
parent_child!(Element, Playbin3);
|
parent_child!(Element, Playbin3);
|
||||||
@@ -80,3 +81,15 @@ impl Playbin3 {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Playbin3 {
|
||||||
|
pub fn default_flags() -> PlayFlags {
|
||||||
|
PlayFlags::SOFT_COLORBALANCE
|
||||||
|
| PlayFlags::DEINTERLACE
|
||||||
|
| PlayFlags::BUFFERING
|
||||||
|
| PlayFlags::SOFT_VOLUME
|
||||||
|
| PlayFlags::TEXT
|
||||||
|
| PlayFlags::AUDIO
|
||||||
|
| PlayFlags::VIDEO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ impl Source for VideoConvert {}
|
|||||||
|
|
||||||
impl VideoConvert {
|
impl VideoConvert {
|
||||||
pub fn new(name: impl AsRef<str>) -> Result<Self> {
|
pub fn new(name: impl AsRef<str>) -> Result<Self> {
|
||||||
use gstreamer::prelude::*;
|
|
||||||
let element = gstreamer::ElementFactory::make("videoconvert")
|
let element = gstreamer::ElementFactory::make("videoconvert")
|
||||||
.name(name.as_ref())
|
.name(name.as_ref())
|
||||||
.build()
|
.build()
|
||||||
|
|||||||
Reference in New Issue
Block a user