diff --git a/Cargo.lock b/Cargo.lock index 81c7396..952e64e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3049,12 +3049,15 @@ checksum = "12101ecc8225ea6d675bc70263074eab6169079621c2186fe0c66590b2df9681" name = "gst" version = "0.1.0" dependencies = [ + "bitflags 2.10.0", "error-stack", "futures", "futures-lite 2.6.1", "glib 0.21.5", + "glib-sys 0.21.5", "gstreamer 0.24.4", "gstreamer-app 0.24.4", + "gstreamer-base 0.24.4", "gstreamer-video 0.24.4", "smol", "thiserror 2.0.17", @@ -3594,17 +3597,16 @@ dependencies = [ [[package]] name = "iced" version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "000e01026c93ba643f8357a3db3ada0e6555265a377f6f9291c472f6dd701fb3" +source = "git+https://github.com/uttarayan21/iced?branch=0.14#5846d52983d7e2eecc478130ba6373f0c1f82c94" dependencies = [ "iced_core", - "iced_debug", + "iced_debug 0.14.0 (git+https://github.com/uttarayan21/iced?branch=0.14)", "iced_devtools", - "iced_futures", + "iced_futures 0.14.0 (git+https://github.com/uttarayan21/iced?branch=0.14)", "iced_renderer", - "iced_runtime", + "iced_runtime 0.14.0 (git+https://github.com/uttarayan21/iced?branch=0.14)", "iced_widget", - "iced_winit", + "iced_winit 0.14.0 (git+https://github.com/uttarayan21/iced?branch=0.14)", "image", "thiserror 2.0.17", ] @@ -3617,7 +3619,7 @@ dependencies = [ "gst", "iced", "iced_core", - "iced_futures", + "iced_futures 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "iced_renderer", "iced_wgpu", "thiserror 2.0.17", @@ -3628,8 +3630,7 @@ dependencies = [ [[package]] name = "iced_beacon" version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02a48f970444257a5e8b19def673f14f0d79c159fa851055e2a861683c3f8845" +source = "git+https://github.com/uttarayan21/iced?branch=0.14#5846d52983d7e2eecc478130ba6373f0c1f82c94" dependencies = [ "bincode", "futures", @@ -3644,8 +3645,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ab1937d699403e7e69252ae743a902bcee9f4ab2052cc4c9a46fcf34729d85" +source = "git+https://github.com/uttarayan21/iced?branch=0.14#5846d52983d7e2eecc478130ba6373f0c1f82c94" dependencies = [ "bitflags 2.10.0", "bytes", @@ -3665,21 +3665,30 @@ name = "iced_debug" version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25035ab0215a620e53f4103e36fc4e59a1fb2817e4bfc38a30ad27b4202ea0be" +dependencies = [ + "iced_core", + "iced_futures 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log", +] + +[[package]] +name = "iced_debug" +version = "0.14.0" +source = "git+https://github.com/uttarayan21/iced?branch=0.14#5846d52983d7e2eecc478130ba6373f0c1f82c94" dependencies = [ "iced_beacon", "iced_core", - "iced_futures", + "iced_futures 0.14.0 (git+https://github.com/uttarayan21/iced?branch=0.14)", "log", ] [[package]] name = "iced_devtools" version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b8e2a306ac5c583234b02f5404afdb7b7467c8f72a4a44ad3e7be30fc4b339" +source = "git+https://github.com/uttarayan21/iced?branch=0.14#5846d52983d7e2eecc478130ba6373f0c1f82c94" dependencies = [ - "iced_debug", - "iced_program", + "iced_debug 0.14.0 (git+https://github.com/uttarayan21/iced?branch=0.14)", + "iced_program 0.14.0 (git+https://github.com/uttarayan21/iced?branch=0.14)", "iced_widget", "log", ] @@ -3689,6 +3698,19 @@ name = "iced_futures" version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c0c85ccad42dfbec7293c36c018af0ea0dbcc52d137a4a9a0b0f6822a3fdf0a" +dependencies = [ + "futures", + "iced_core", + "log", + "rustc-hash 2.1.1", + "wasm-bindgen-futures", + "wasmtimer", +] + +[[package]] +name = "iced_futures" +version = "0.14.0" +source = "git+https://github.com/uttarayan21/iced?branch=0.14#5846d52983d7e2eecc478130ba6373f0c1f82c94" dependencies = [ "futures", "iced_core", @@ -3710,7 +3732,25 @@ dependencies = [ "cosmic-text 0.15.0", "half", "iced_core", - "iced_futures", + "iced_futures 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log", + "raw-window-handle", + "rustc-hash 2.1.1", + "thiserror 2.0.17", + "unicode-segmentation", +] + +[[package]] +name = "iced_graphics" +version = "0.14.0" +source = "git+https://github.com/uttarayan21/iced?branch=0.14#5846d52983d7e2eecc478130ba6373f0c1f82c94" +dependencies = [ + "bitflags 2.10.0", + "bytemuck", + "cosmic-text 0.15.0", + "half", + "iced_core", + "iced_futures 0.14.0 (git+https://github.com/uttarayan21/iced?branch=0.14)", "image", "kamadak-exif", "log", @@ -3727,17 +3767,25 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6dfafec2947cda688d8eb00dac337ba11aa60f9ef6335aed343e189d26e4a673" dependencies = [ - "iced_graphics", - "iced_runtime", + "iced_graphics 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "iced_runtime 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "iced_program" +version = "0.14.0" +source = "git+https://github.com/uttarayan21/iced?branch=0.14#5846d52983d7e2eecc478130ba6373f0c1f82c94" +dependencies = [ + "iced_graphics 0.14.0 (git+https://github.com/uttarayan21/iced?branch=0.14)", + "iced_runtime 0.14.0 (git+https://github.com/uttarayan21/iced?branch=0.14)", ] [[package]] name = "iced_renderer" version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "250cc0802408e8c077986ec56c7d07c65f423ee658a4b9fd795a1f2aae5dac05" +source = "git+https://github.com/uttarayan21/iced?branch=0.14#5846d52983d7e2eecc478130ba6373f0c1f82c94" dependencies = [ - "iced_graphics", + "iced_graphics 0.14.0 (git+https://github.com/uttarayan21/iced?branch=0.14)", "iced_tiny_skia", "iced_wgpu", "log", @@ -3752,7 +3800,19 @@ checksum = "d1889b819ce4c06674183242e336c8d49465665441396914dc07cc86f44fa8d4" dependencies = [ "bytes", "iced_core", - "iced_futures", + "iced_futures 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "raw-window-handle", + "thiserror 2.0.17", +] + +[[package]] +name = "iced_runtime" +version = "0.14.0" +source = "git+https://github.com/uttarayan21/iced?branch=0.14#5846d52983d7e2eecc478130ba6373f0c1f82c94" +dependencies = [ + "bytes", + "iced_core", + "iced_futures 0.14.0 (git+https://github.com/uttarayan21/iced?branch=0.14)", "raw-window-handle", "sipper", "thiserror 2.0.17", @@ -3761,13 +3821,12 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe0acf8b75a3bc914aff5f2329fdffc1b36eeaea29dda0e4bd232f1c62e9cc3d" +source = "git+https://github.com/uttarayan21/iced?branch=0.14#5846d52983d7e2eecc478130ba6373f0c1f82c94" dependencies = [ "bytemuck", "cosmic-text 0.15.0", - "iced_debug", - "iced_graphics", + "iced_debug 0.14.0 (git+https://github.com/uttarayan21/iced?branch=0.14)", + "iced_graphics 0.14.0 (git+https://github.com/uttarayan21/iced?branch=0.14)", "kurbo 0.10.4", "log", "rustc-hash 2.1.1", @@ -3796,8 +3855,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff144a999b0ca0f8a10257934500060240825c42e950ec0ebee9c8ae30561c13" +source = "git+https://github.com/uttarayan21/iced?branch=0.14#5846d52983d7e2eecc478130ba6373f0c1f82c94" dependencies = [ "bitflags 2.10.0", "bytemuck", @@ -3805,8 +3863,8 @@ dependencies = [ "futures", "glam", "guillotiere", - "iced_debug", - "iced_graphics", + "iced_debug 0.14.0 (git+https://github.com/uttarayan21/iced?branch=0.14)", + "iced_graphics 0.14.0 (git+https://github.com/uttarayan21/iced?branch=0.14)", "log", "lyon", "rustc-hash 2.1.1", @@ -3816,9 +3874,8 @@ dependencies = [ [[package]] name = "iced_widget" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f86f6948998a5e031849afae1bb852f3b100c71572befa0be70b19075dcb2163" +version = "0.14.2" +source = "git+https://github.com/uttarayan21/iced?branch=0.14#5846d52983d7e2eecc478130ba6373f0c1f82c94" dependencies = [ "iced_renderer", "log", @@ -3834,8 +3891,25 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b7dbedc47562d1de3b9707d939f678b88c382004b7ab5a18f7a7dd723162d75" dependencies = [ - "iced_debug", - "iced_program", + "iced_debug 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "iced_program 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log", + "rustc-hash 2.1.1", + "thiserror 2.0.17", + "tracing", + "wasm-bindgen-futures", + "web-sys", + "window_clipboard", + "winit", +] + +[[package]] +name = "iced_winit" +version = "0.14.0" +source = "git+https://github.com/uttarayan21/iced?branch=0.14#5846d52983d7e2eecc478130ba6373f0c1f82c94" +dependencies = [ + "iced_debug 0.14.0 (git+https://github.com/uttarayan21/iced?branch=0.14)", + "iced_program 0.14.0 (git+https://github.com/uttarayan21/iced?branch=0.14)", "log", "mundy", "rustc-hash 2.1.1", @@ -8091,7 +8165,7 @@ dependencies = [ "iced", "iced_video_player", "iced_wgpu", - "iced_winit", + "iced_winit 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest", "tap", "toml 0.9.8", diff --git a/Cargo.toml b/Cargo.toml index 42f3337..73c9b03 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,8 +15,13 @@ members = [ iced = { version = "0.14.0" } iced_video_player = "0.6" gst = { version = "0.1.0", path = "gst" } -# iced_video_player = { git = "https://github.com/jazzfool/iced_video_player" } -# iced_video_player = { path = "crates/iced_video_player" } +iced_wgpu = { version = "0.14.0" } + +[patch.crates-io] +iced_wgpu = { git = "https://github.com/uttarayan21/iced", branch = "0.14" } +iced_core = { git = "https://github.com/uttarayan21/iced", branch = "0.14" } +iced_renderer = { git = "https://github.com/uttarayan21/iced", branch = "0.14" } +iced = { git = "https://github.com/uttarayan21/iced", branch = "0.14" } [package] name = "jello" diff --git a/crates/iced-video/Cargo.toml b/crates/iced-video/Cargo.toml index 126c8a4..826782a 100644 --- a/crates/iced-video/Cargo.toml +++ b/crates/iced-video/Cargo.toml @@ -9,7 +9,7 @@ gst.workspace = true iced_core = "0.14.0" iced_futures = "0.14.0" iced_renderer = { version = "0.14.0", features = ["iced_wgpu"] } -iced_wgpu = "0.14.0" +iced_wgpu = { version = "0.14.0" } thiserror = "2.0.17" tracing = "0.1.43" @@ -21,3 +21,6 @@ tracing-subscriber = { version = "0.3.22", features = ["env-filter"] } debug = true [profile.release] debug = true + +# [patch.crates-io] +# iced_wgpu = { git = "https://github.com/uttarayan21/iced", branch = "0.14" } diff --git a/crates/iced-video/examples/minimal.rs b/crates/iced-video/examples/minimal.rs index de891c1..e300342 100644 --- a/crates/iced-video/examples/minimal.rs +++ b/crates/iced-video/examples/minimal.rs @@ -52,8 +52,6 @@ impl State { pub fn new() -> Self { let video = VideoHandle::new("https://jellyfin.tsuba.darksailor.dev/Items/6010382cf25273e624d305907010d773/Download?api_key=036c140222464878862231ef66a2bc9c") .expect("Failed to create video handle"); - // let video = VideoHandle::new("file:///run/user/1000/gvfs/smb-share:server=tsuba.darksailor.dev,share=nas/Movies/Spider-Man - No Way Home (2021)/Spider-Man.No.Way.Home.2021.UHD.BluRay.2160p.TrueHD.Atmos.7.1.DV.HEVC.REMUX-FraMeSToR.mkv") - // .expect("Failed to create video handle"); Self { video } } } @@ -71,8 +69,6 @@ pub fn update(state: &mut State, message: Message) -> iced::Task { match message { Message::Load => { // does stuff - // let src = state.video.source().clone(); - // iced::Task::perform(src.wait(), |_| Message::Loaded) iced::Task::none() } Message::Play => { diff --git a/crates/iced-video/src/primitive.rs b/crates/iced-video/src/primitive.rs index 53ef70b..b1bfd7b 100644 --- a/crates/iced-video/src/primitive.rs +++ b/crates/iced-video/src/primitive.rs @@ -106,6 +106,7 @@ impl iced_wgpu::Primitive for VideoFrame { .map_readable() .expect("BUG: Failed to map gst::Buffer readable"); queue.write_buffer(&video.buffer, 0, &data); + drop(data); video .ready .store(false, std::sync::atomic::Ordering::SeqCst); diff --git a/crates/iced-video/src/source.rs b/crates/iced-video/src/source.rs index 5bb04f7..9e76348 100644 --- a/crates/iced-video/src/source.rs +++ b/crates/iced-video/src/source.rs @@ -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 { - 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) } diff --git a/flake.nix b/flake.nix index a148d9b..77c1b8a 100644 --- a/flake.nix +++ b/flake.nix @@ -87,6 +87,8 @@ glib glib-networking + wrapGAppsHook4 + # bzip2_1_1 # libsysprof-capture # pcre2 @@ -181,7 +183,7 @@ else pkgs.clangStdenv; } (commonArgs // { - GST_PLUGIN_PATH = "/run/current-system/sw/lib/gstreamer-1.0/"; + # GST_PLUGIN_PATH = "/run/current-system/sw/lib/gstreamer-1.0/"; GIO_EXTRA_MODULES = "${pkgs.glib-networking}/lib/gio/modules"; packages = with pkgs; [ diff --git a/gst/Cargo.toml b/gst/Cargo.toml index 5cb1b0c..0c97b24 100644 --- a/gst/Cargo.toml +++ b/gst/Cargo.toml @@ -10,11 +10,14 @@ error-stack = "0.6" futures = "0.3.31" futures-lite = "2.6.1" glib = "0.21.5" +glib-sys = "0.21.5" gstreamer = { version = "0.24.4", features = ["v1_26"] } gstreamer-app = { version = "0.24.4", features = ["v1_26"] } gstreamer-video = { version = "0.24.4", features = ["v1_26"] } +gstreamer-base = { version = "0.24.4", features = ["v1_26"] } thiserror = "2.0" tracing = { version = "0.1", features = ["log"] } +bitflags = "2.10.0" [dev-dependencies] smol = "2.0.2" diff --git a/gst/src/pipeline.rs b/gst/src/pipeline.rs index d7b08fc..dd3291a 100644 --- a/gst/src/pipeline.rs +++ b/gst/src/pipeline.rs @@ -23,7 +23,6 @@ impl Pipeline { } /// Get the state - #[track_caller] pub fn state( &self, timeout: impl Into>, @@ -33,7 +32,6 @@ impl Pipeline { Ok(current) } - #[track_caller] pub fn play(&self) -> Result<()> { self.inner .set_state(gstreamer::State::Playing) @@ -42,7 +40,6 @@ impl Pipeline { Ok(()) } - #[track_caller] pub fn pause(&self) -> Result<()> { self.inner .set_state(gstreamer::State::Paused) @@ -51,7 +48,6 @@ impl Pipeline { Ok(()) } - #[track_caller] pub fn ready(&self) -> Result<()> { self.inner .set_state(gstreamer::State::Ready) @@ -60,7 +56,6 @@ impl Pipeline { Ok(()) } - #[track_caller] pub fn stop(&self) -> Result<()> { self.inner .set_state(gstreamer::State::Null) @@ -69,7 +64,6 @@ impl Pipeline { Ok(()) } - #[track_caller] pub fn set_state(&self, state: gstreamer::State) -> Result { let result = self .inner diff --git a/gst/src/plugins/playback.rs b/gst/src/plugins/playback.rs index 3ba5734..c42062c 100644 --- a/gst/src/plugins/playback.rs +++ b/gst/src/plugins/playback.rs @@ -2,3 +2,83 @@ pub mod playbin3; pub use playbin3::*; pub mod playbin; pub use playbin::*; + +bitflags::bitflags! { + /// Extra flags to configure the behaviour of the sinks. + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] + pub struct PlayFlags: u32 { + /// Render the video stream + const VIDEO = (1 << 0); + /// Render the audio stream + const AUDIO = (1 << 1); + /// Render subtitles + const TEXT = (1 << 2); + /// Render visualisation when no video is present + const VIS = (1 << 3); + /// Use software volume + const SOFT_VOLUME = (1 << 4); + /// Only use native audio formats + const NATIVE_AUDIO = (1 << 5); + /// Only use native video formats + const NATIVE_VIDEO = (1 << 6); + /// Attempt progressive download buffering + const DOWNLOAD = (1 << 7); + /// Buffer demuxed/parsed data + const BUFFERING = (1 << 8); + /// Deinterlace video if necessary + const DEINTERLACE = (1 << 9); + /// Use software color balance + const SOFT_COLORBALANCE = (1 << 10); + /// Force audio/video filter(s) to be applied + const FORCE_FILTERS = (1 << 11); + /// Force only software-based decoders (no effect for playbin3) + const FORCE_SW_DECODERS = (1 << 12); + } +} + +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 { + #[inline] + #[doc(alias = "gst_play_flags_get_type")] + fn static_type() -> glib::Type { + glib::Type::from_name("GstPlayFlags").expect("GstPlayFlags type not found") + } + } + + impl glib::value::ToValue for PlayFlags { + #[inline] + fn to_value(&self) -> glib::Value { + let value = self.bits().to_value(); + value + .transform_with_type(Self::static_type()) + .expect("Failed to transform PlayFlags(u32) to GstPlayFlags") + } + + #[inline] + fn value_type(&self) -> glib::Type { + Self::static_type() + } + } + + impl From for glib::Value { + #[inline] + fn from(v: PlayFlags) -> Self { + // skip_assert_initialized!(); + glib::value::ToValue::to_value(&v) + } + } +}; diff --git a/gst/src/plugins/playback/playbin.rs b/gst/src/plugins/playback/playbin.rs new file mode 100644 index 0000000..be6b963 --- /dev/null +++ b/gst/src/plugins/playback/playbin.rs @@ -0,0 +1,82 @@ +use crate::priv_prelude::*; + +wrap_gst!(Playbin, gstreamer::Element); +parent_child!(Element, Playbin); +parent_child!(Pipeline, Playbin, downcast); +parent_child!(Bin, Playbin, downcast); + +impl Drop for Playbin { + fn drop(&mut self) { + self.set_state(gstreamer::State::Null).ok(); + } +} + +impl Playbin { + pub fn new(name: impl AsRef) -> Result { + gstreamer::ElementFactory::make("playbin3") + .name(name.as_ref()) + .build() + .map(|element| Playbin { inner: element }) + .change_context(Error) + } + + pub fn with_uri(self, uri: impl AsRef) -> Self { + self.inner.set_property("uri", uri.as_ref()); + self + } + + pub fn with_buffer_duration(self, duration: impl Into>) -> Self { + let duration = match duration.into() { + Some(dur) => dur.as_secs() as i64, + None => -1, + }; + self.inner.set_property("buffer-duration", duration); + self + } + + pub fn with_buffer_size(self, size: impl Into>) -> Self { + let size = match size.into() { + Some(size) => size as i32, + None => -1, + }; + self.inner.set_property("buffer-size", size); + self + } + + /// Sets the maximum size of the ring buffer in bytes. + pub fn with_ring_buffer_max_size(self, size: u64) -> Self { + self.inner.set_property("ring-buffer-max-size", size); + self + } + + pub fn with_video_sink(self, video_sink: &impl ChildOf) -> Self { + self.inner + .set_property("video-sink", &video_sink.upcast_ref().inner); + self + } + + pub fn with_text_sink(self, text_sink: &impl ChildOf) -> Self { + self.inner + .set_property("text-sink", &text_sink.upcast_ref().inner); + self + } + + pub fn with_audio_sink(self, audio_sink: &impl ChildOf) -> Self { + self.inner + .set_property("audio-sink", &audio_sink.upcast_ref().inner); + self + } + + pub fn set_volume(&self, volume: f64) { + self.inner.set_property("volume", volume.clamp(1.0, 100.0)) + } + + pub fn get_volume(&self) -> f64 { + self.inner.property::("volume") + } + + pub fn with_flags(self, flags: playback::PlayFlags) -> Self { + self.inner.set_property("flags", flags); + self + } +} diff --git a/gst/src/plugins/playback/playbin3.rs b/gst/src/plugins/playback/playbin3.rs index fa81e28..a8f123d 100644 --- a/gst/src/plugins/playback/playbin3.rs +++ b/gst/src/plugins/playback/playbin3.rs @@ -74,4 +74,9 @@ impl Playbin3 { pub fn get_volume(&self) -> f64 { self.inner.property::("volume") } + + pub fn with_flags(self, flags: playback::PlayFlags) -> Self { + self.inner.set_property("flags", flags); + self + } } diff --git a/gst/src/sample.rs b/gst/src/sample.rs new file mode 100644 index 0000000..5ab312e --- /dev/null +++ b/gst/src/sample.rs @@ -0,0 +1,37 @@ +impl From for Sample { + fn from(inner: gstreamer::Sample) -> Self { + Sample { inner } + } +} + +#[repr(transparent)] +#[derive(Debug, Clone)] +pub struct Sample { + pub inner: gstreamer::Sample, +} + +use gstreamer::BufferRef; +impl Sample { + #[doc(alias = "empty")] + pub fn new() -> Self { + Self { + inner: gstreamer::Sample::builder().build(), + } + } + + pub fn buffer(&self) -> Option<&BufferRef> { + self.inner.buffer() + } + + pub fn caps(&self) -> Option<&gstreamer::CapsRef> { + self.inner.caps() + } + + pub fn info(&self) -> Option<&gstreamer::StructureRef> { + self.inner.info() + } + + // pub fn set_buffer(&mut self) { + // self.inner.set_buffer(None); + // } +}