fix(iced-video): Fix the very high ram usage
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

feat(playback): add GstPlayFlags for playbin and playbin3
This commit is contained in:
uttarayan21
2025-12-26 10:29:31 +05:30
parent 4ed15c97f0
commit a7ffa69326
13 changed files with 339 additions and 59 deletions

View File

@@ -5,7 +5,7 @@ use gst::{
caps::{Caps, CapsType},
element::ElementExt,
pipeline::PipelineExt,
playback::Playbin3,
playback::{PlayFlags, Playbin, Playbin3},
videoconvertscale::VideoConvert,
};
use std::sync::{Arc, Mutex, atomic::AtomicBool};
@@ -34,20 +34,21 @@ impl VideoSource {
appsink
.drop(true)
.sync(true)
.async_(true)
// .async_(true)
.emit_signals(true)
.caps(
Caps::builder(CapsType::Video)
.field("format", "RGBA")
.field("format", "RGB10A2_LE") // Forced for now
.build(),
);
let video_sink = videoconvert.link(&appsink).change_context(Error)?;
let playbin = gst::plugins::playback::Playbin3::new("iced-video")
let playbin = Playbin3::new("iced-video")
.change_context(Error)?
.with_uri(url.as_ref())
.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_video_sink(&video_sink);
let bus = playbin.bus().change_context(Error)?;
playbin.pause().change_context(Error)?;
@@ -90,10 +91,7 @@ impl VideoSource {
}
pub fn is_playing(&self) -> Result<bool> {
let state = self
.playbin
.state(core::time::Duration::from_millis(0))
.change_context(Error)?;
let state = self.playbin.state(None).change_context(Error)?;
Ok(state == gst::State::Playing)
}