diff --git a/Cargo.lock b/Cargo.lock index de6661d39..9e0106314 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -26,6 +26,12 @@ version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" +[[package]] +name = "atomic_refcell" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73b5e5f48b927f04e952dedc932f31995a65a0bf65ec971c74436e51bf6e970d" + [[package]] name = "atty" version = "0.2.14" @@ -81,9 +87,8 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cairo-rs" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "247e1183fa769ac22121f92276dae52f89acaf297f24b1320019f439b6e3b46f" +version = "0.17.0" +source = "git+https://github.com/gtk-rs/gtk-rs-core#346d5c25d7c76aa0fcf0e8e9a605c9d4aca4ec79" dependencies = [ "bitflags", "cairo-sys-rs", @@ -95,9 +100,8 @@ dependencies = [ [[package]] name = "cairo-sys-rs" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c48f4af05fabdcfa9658178e1326efa061853f040ce7d72e33af6885196f421" +version = "0.17.0" +source = "git+https://github.com/gtk-rs/gtk-rs-core#346d5c25d7c76aa0fcf0e8e9a605c9d4aca4ec79" dependencies = [ "glib-sys", "libc", @@ -277,6 +281,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "fragile" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" + [[package]] name = "futures" version = "0.3.25" @@ -364,9 +374,8 @@ dependencies = [ [[package]] name = "gdk-pixbuf" -version = "0.16.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3094f2b8578136d1929cade4e0fff82f573521b579e96cfc24af2458431f176" +version = "0.17.0" +source = "git+https://github.com/gtk-rs/gtk-rs-core#346d5c25d7c76aa0fcf0e8e9a605c9d4aca4ec79" dependencies = [ "bitflags", "gdk-pixbuf-sys", @@ -377,9 +386,8 @@ dependencies = [ [[package]] name = "gdk-pixbuf-sys" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3092cf797a5f1210479ea38070d9ae8a5b8e9f8f1be9f32f4643c529c7d70016" +version = "0.17.0" +source = "git+https://github.com/gtk-rs/gtk-rs-core#346d5c25d7c76aa0fcf0e8e9a605c9d4aca4ec79" dependencies = [ "gio-sys", "glib-sys", @@ -390,9 +398,8 @@ dependencies = [ [[package]] name = "gdk4" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc7fc4b05be1159056c57a08102ea494892f75ff8517f5518b0401e466f77c69" +version = "0.6.0" +source = "git+https://github.com/gtk-rs/gtk4-rs#5a8e72b4d13bdf774b1aa479338fd08074f61a4e" dependencies = [ "bitflags", "cairo-rs", @@ -406,9 +413,8 @@ dependencies = [ [[package]] name = "gdk4-sys" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c057b794185a52862037526fb95aafabce9427fb98a7e9f5fe39a6f832c92822" +version = "0.6.0" +source = "git+https://github.com/gtk-rs/gtk4-rs#5a8e72b4d13bdf774b1aa479338fd08074f61a4e" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", @@ -421,6 +427,51 @@ dependencies = [ "system-deps", ] +[[package]] +name = "gdk4-wayland" +version = "0.6.0" +source = "git+https://github.com/gtk-rs/gtk4-rs#5a8e72b4d13bdf774b1aa479338fd08074f61a4e" +dependencies = [ + "gdk4", + "gdk4-wayland-sys", + "gio", + "glib", + "libc", +] + +[[package]] +name = "gdk4-wayland-sys" +version = "0.6.0" +source = "git+https://github.com/gtk-rs/gtk4-rs#5a8e72b4d13bdf774b1aa479338fd08074f61a4e" +dependencies = [ + "glib-sys", + "libc", + "system-deps", +] + +[[package]] +name = "gdk4-x11" +version = "0.6.0" +source = "git+https://github.com/gtk-rs/gtk4-rs#5a8e72b4d13bdf774b1aa479338fd08074f61a4e" +dependencies = [ + "gdk4", + "gdk4-x11-sys", + "gio", + "glib", + "libc", +] + +[[package]] +name = "gdk4-x11-sys" +version = "0.6.0" +source = "git+https://github.com/gtk-rs/gtk4-rs#5a8e72b4d13bdf774b1aa479338fd08074f61a4e" +dependencies = [ + "gdk4-sys", + "glib-sys", + "libc", + "system-deps", +] + [[package]] name = "gettext-rs" version = "0.7.0" @@ -443,9 +494,8 @@ dependencies = [ [[package]] name = "gio" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d4a17d999e6e4e05d87c2bb05b7140d47769bc53211711a33e2f91536458714" +version = "0.17.0" +source = "git+https://github.com/gtk-rs/gtk-rs-core#346d5c25d7c76aa0fcf0e8e9a605c9d4aca4ec79" dependencies = [ "bitflags", "futures-channel", @@ -463,9 +513,8 @@ dependencies = [ [[package]] name = "gio-sys" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9b693b8e39d042a95547fc258a7b07349b1f0b48f4b2fa3108ba3c51c0b5229" +version = "0.17.0" +source = "git+https://github.com/gtk-rs/gtk-rs-core#346d5c25d7c76aa0fcf0e8e9a605c9d4aca4ec79" dependencies = [ "glib-sys", "gobject-sys", @@ -476,9 +525,8 @@ dependencies = [ [[package]] name = "glib" -version = "0.16.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5204a4217749b385cefbfb7bf3a2fcde83e4ce6d0945f64440a1f5bd4010305" +version = "0.17.0" +source = "git+https://github.com/gtk-rs/gtk-rs-core#346d5c25d7c76aa0fcf0e8e9a605c9d4aca4ec79" dependencies = [ "bitflags", "futures-channel", @@ -498,9 +546,8 @@ dependencies = [ [[package]] name = "glib-macros" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e084807350b01348b6d9dbabb724d1a0bb987f47a2c85de200e98e12e30733bf" +version = "0.17.0" +source = "git+https://github.com/gtk-rs/gtk-rs-core#346d5c25d7c76aa0fcf0e8e9a605c9d4aca4ec79" dependencies = [ "anyhow", "heck", @@ -513,9 +560,8 @@ dependencies = [ [[package]] name = "glib-sys" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61a4f46316d06bfa33a7ac22df6f0524c8be58e3db2d9ca99ccb1f357b62a65" +version = "0.17.0" +source = "git+https://github.com/gtk-rs/gtk-rs-core#346d5c25d7c76aa0fcf0e8e9a605c9d4aca4ec79" dependencies = [ "libc", "system-deps", @@ -523,9 +569,8 @@ dependencies = [ [[package]] name = "gobject-sys" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3520bb9c07ae2a12c7f2fbb24d4efc11231c8146a86956413fb1a79bb760a0f1" +version = "0.17.0" +source = "git+https://github.com/gtk-rs/gtk-rs-core#346d5c25d7c76aa0fcf0e8e9a605c9d4aca4ec79" dependencies = [ "glib-sys", "libc", @@ -534,9 +579,8 @@ dependencies = [ [[package]] name = "graphene-rs" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ecb4d347e6d09820df3bdfd89a74a8eec07753a06bb92a3aac3ad31d04447b" +version = "0.17.0" +source = "git+https://github.com/gtk-rs/gtk-rs-core#346d5c25d7c76aa0fcf0e8e9a605c9d4aca4ec79" dependencies = [ "glib", "graphene-sys", @@ -545,9 +589,8 @@ dependencies = [ [[package]] name = "graphene-sys" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9aa82337d3972b4eafdea71e607c23f47be6f27f749aab613f1ad8ddbe6dcd6" +version = "0.17.0" +source = "git+https://github.com/gtk-rs/gtk-rs-core#346d5c25d7c76aa0fcf0e8e9a605c9d4aca4ec79" dependencies = [ "glib-sys", "libc", @@ -557,9 +600,8 @@ dependencies = [ [[package]] name = "gsk4" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dcd01e485189515263f6d3ac8a624b1c0cd13c1097991e72d0cc0c145a303c0" +version = "0.6.0" +source = "git+https://github.com/gtk-rs/gtk4-rs#5a8e72b4d13bdf774b1aa479338fd08074f61a4e" dependencies = [ "bitflags", "cairo-rs", @@ -573,9 +615,8 @@ dependencies = [ [[package]] name = "gsk4-sys" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f47c49111e33020615a6c6b78d755c8b54b8504143cae1bf972bccc03eaa3f59" +version = "0.6.0" +source = "git+https://github.com/gtk-rs/gtk4-rs#5a8e72b4d13bdf774b1aa479338fd08074f61a4e" dependencies = [ "cairo-sys-rs", "gdk4-sys", @@ -587,11 +628,226 @@ dependencies = [ "system-deps", ] +[[package]] +name = "gst-plugin-gtk4" +version = "0.10.0-alpha.1" +source = "git+https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs#aa2abc50bfe6a08c5c3318c303b6acdbb661498c" +dependencies = [ + "fragile", + "gdk4-wayland", + "gdk4-x11", + "gst-plugin-version-helper", + "gstreamer", + "gstreamer-base", + "gstreamer-gl", + "gstreamer-gl-egl", + "gstreamer-gl-wayland", + "gstreamer-gl-x11", + "gstreamer-video", + "gtk4", + "once_cell", +] + +[[package]] +name = "gst-plugin-version-helper" +version = "0.10.0-alpha.1" +source = "git+https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs#aa2abc50bfe6a08c5c3318c303b6acdbb661498c" +dependencies = [ + "chrono", +] + +[[package]] +name = "gstreamer" +version = "0.20.0" +source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#b89b98b6e9615dba0a1196e4ff5bae8193062c32" +dependencies = [ + "bitflags", + "cfg-if", + "futures-channel", + "futures-core", + "futures-util", + "glib", + "gstreamer-sys", + "libc", + "muldiv", + "num-integer", + "num-rational", + "once_cell", + "option-operations", + "paste", + "pretty-hex", + "thiserror", +] + +[[package]] +name = "gstreamer-base" +version = "0.20.0" +source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#b89b98b6e9615dba0a1196e4ff5bae8193062c32" +dependencies = [ + "atomic_refcell", + "bitflags", + "cfg-if", + "glib", + "gstreamer", + "gstreamer-base-sys", + "libc", +] + +[[package]] +name = "gstreamer-base-sys" +version = "0.20.0" +source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#b89b98b6e9615dba0a1196e4ff5bae8193062c32" +dependencies = [ + "glib-sys", + "gobject-sys", + "gstreamer-sys", + "libc", + "system-deps", +] + +[[package]] +name = "gstreamer-gl" +version = "0.20.0" +source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#b89b98b6e9615dba0a1196e4ff5bae8193062c32" +dependencies = [ + "bitflags", + "byteorder", + "glib", + "gstreamer", + "gstreamer-base", + "gstreamer-gl-sys", + "gstreamer-video", + "libc", + "once_cell", +] + +[[package]] +name = "gstreamer-gl-egl" +version = "0.20.0" +source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#b89b98b6e9615dba0a1196e4ff5bae8193062c32" +dependencies = [ + "glib", + "gstreamer", + "gstreamer-gl", + "gstreamer-gl-egl-sys", + "libc", +] + +[[package]] +name = "gstreamer-gl-egl-sys" +version = "0.20.0" +source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#b89b98b6e9615dba0a1196e4ff5bae8193062c32" +dependencies = [ + "glib-sys", + "gstreamer-gl-sys", + "libc", + "system-deps", +] + +[[package]] +name = "gstreamer-gl-sys" +version = "0.20.0" +source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#b89b98b6e9615dba0a1196e4ff5bae8193062c32" +dependencies = [ + "glib-sys", + "gobject-sys", + "gstreamer-base-sys", + "gstreamer-sys", + "gstreamer-video-sys", + "libc", + "system-deps", +] + +[[package]] +name = "gstreamer-gl-wayland" +version = "0.20.0" +source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#b89b98b6e9615dba0a1196e4ff5bae8193062c32" +dependencies = [ + "glib", + "gstreamer", + "gstreamer-gl", + "gstreamer-gl-wayland-sys", + "libc", +] + +[[package]] +name = "gstreamer-gl-wayland-sys" +version = "0.20.0" +source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#b89b98b6e9615dba0a1196e4ff5bae8193062c32" +dependencies = [ + "glib-sys", + "gstreamer-gl-sys", + "libc", + "system-deps", +] + +[[package]] +name = "gstreamer-gl-x11" +version = "0.20.0" +source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#b89b98b6e9615dba0a1196e4ff5bae8193062c32" +dependencies = [ + "glib", + "gstreamer", + "gstreamer-gl", + "gstreamer-gl-x11-sys", + "libc", +] + +[[package]] +name = "gstreamer-gl-x11-sys" +version = "0.20.0" +source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#b89b98b6e9615dba0a1196e4ff5bae8193062c32" +dependencies = [ + "glib-sys", + "gstreamer-gl-sys", + "libc", + "system-deps", +] + +[[package]] +name = "gstreamer-sys" +version = "0.20.0" +source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#b89b98b6e9615dba0a1196e4ff5bae8193062c32" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "gstreamer-video" +version = "0.20.0" +source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#b89b98b6e9615dba0a1196e4ff5bae8193062c32" +dependencies = [ + "bitflags", + "cfg-if", + "futures-channel", + "glib", + "gstreamer", + "gstreamer-base", + "gstreamer-video-sys", + "libc", + "once_cell", +] + +[[package]] +name = "gstreamer-video-sys" +version = "0.20.0" +source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#b89b98b6e9615dba0a1196e4ff5bae8193062c32" +dependencies = [ + "glib-sys", + "gobject-sys", + "gstreamer-base-sys", + "gstreamer-sys", + "libc", + "system-deps", +] + [[package]] name = "gtk4" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4c61a704ecdedd1c0ca66ff0184bd19e9c488835bb391655bfe6b60f6e2e43e" +version = "0.6.0" +source = "git+https://github.com/gtk-rs/gtk4-rs#5a8e72b4d13bdf774b1aa479338fd08074f61a4e" dependencies = [ "bitflags", "cairo-rs", @@ -612,9 +868,8 @@ dependencies = [ [[package]] name = "gtk4-macros" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f57e7025a8bae8429e07aeeae9c4c3fef5d7cd14834afdd6d6d23f76984246" +version = "0.6.0" +source = "git+https://github.com/gtk-rs/gtk4-rs#5a8e72b4d13bdf774b1aa479338fd08074f61a4e" dependencies = [ "anyhow", "proc-macro-crate", @@ -626,9 +881,8 @@ dependencies = [ [[package]] name = "gtk4-sys" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42e1bb57be47aac6ce77b5281ad64389a19db5aba6db75b07f0049571ad6fe0f" +version = "0.6.0" +source = "git+https://github.com/gtk-rs/gtk4-rs#5a8e72b4d13bdf774b1aa479338fd08074f61a4e" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", @@ -765,9 +1019,8 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libadwaita" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dfa0722d4f1724f661cbf668c273c5926296ca411ed3814e206f8fd082b6c48" +version = "0.3.0" +source = "git+https://gitlab.gnome.org/World/Rust/libadwaita-rs#d84afa93c950d9253c9f1329dd9a4039ed205311" dependencies = [ "bitflags", "futures-channel", @@ -784,9 +1037,8 @@ dependencies = [ [[package]] name = "libadwaita-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de902982372b454a0081d7fd9dd567b37b73ae29c8f6da1820374d345fd95d5b" +version = "0.3.0" +source = "git+https://gitlab.gnome.org/World/Rust/libadwaita-rs#d84afa93c950d9253c9f1329dd9a4039ed205311" dependencies = [ "gdk4-sys", "gio-sys", @@ -859,6 +1111,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "muldiv" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "956787520e75e9bd233246045d19f42fb73242759cc57fba9611d940ae96d4b0" + [[package]] name = "num-integer" version = "0.1.45" @@ -925,10 +1183,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" [[package]] -name = "pango" -version = "0.16.3" +name = "option-operations" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6a83cd4015382dbb0f4fcf3ab7b277d4885711a62b2f2c1e6582a120094edad" +checksum = "7c26d27bb1aeab65138e4bf7666045169d1717febcc9ff870166be8348b223d0" +dependencies = [ + "paste", +] + +[[package]] +name = "pango" +version = "0.17.0" +source = "git+https://github.com/gtk-rs/gtk-rs-core#346d5c25d7c76aa0fcf0e8e9a605c9d4aca4ec79" dependencies = [ "bitflags", "gio", @@ -940,9 +1206,8 @@ dependencies = [ [[package]] name = "pango-sys" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e134909a9a293e04d2cc31928aa95679c5e4df954d0b85483159bd20d8f047f" +version = "0.17.0" +source = "git+https://github.com/gtk-rs/gtk-rs-core#346d5c25d7c76aa0fcf0e8e9a605c9d4aca4ec79" dependencies = [ "glib-sys", "gobject-sys", @@ -950,6 +1215,12 @@ dependencies = [ "system-deps", ] +[[package]] +name = "paste" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" + [[package]] name = "pest" version = "2.5.0" @@ -978,6 +1249,12 @@ version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" +[[package]] +name = "pretty-hex" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6fa0831dd7cc608c38a5e323422a0077678fa5744aa2be4ad91c4ece8eec8d5" + [[package]] name = "pretty_env_logger" version = "0.4.0" @@ -1263,6 +1540,9 @@ dependencies = [ "ellipse", "futures", "gettext-rs", + "gst-plugin-gtk4", + "gstreamer", + "gstreamer-video", "gtk4", "image", "indexmap", diff --git a/Cargo.toml b/Cargo.toml index 61094ce07..2a3e8864f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,12 +5,15 @@ authors = ["Marco Melorio "] edition = "2021" [dependencies] -adw = { version = "0.2", package = "libadwaita", features = ["v1_2"] } +adw = { git = "https://gitlab.gnome.org/World/Rust/libadwaita-rs", package = "libadwaita", features = ["v1_2"] } anyhow = "1.0" ellipse = "0.2" futures = { version = "0.3", default-features = false } gettext-rs = { version = "0.7", features = ["gettext-system"] } -gtk = { version = "0.5", package = "gtk4", features = ["v4_6"] } +gst = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", package = "gstreamer" } +gst_gtk = { git = "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs", package = "gst-plugin-gtk4", features = ["wayland", "x11glx", "x11egl"] } +gst_video = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", package = "gstreamer-video" } +gtk = { git = "https://github.com/gtk-rs/gtk4-rs", package = "gtk4", features = ["v4_6"] } image = { version = "0.24", default-features = false, features = ["webp"] } indexmap = "1.9" locale_config = "0.3" diff --git a/src/main.rs b/src/main.rs index 2772973b3..67fb1a001 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,6 +35,9 @@ pub(crate) static APPLICATION_OPTS: OnceCell = OnceCell::new pub(crate) static TEMP_DIR: OnceCell = OnceCell::new(); fn main() { + gst::init().unwrap(); + gst_gtk::plugin_register_static().expect("Failed to register gstgtk4 plugin"); + // Prepare i18n gettextrs::setlocale(LocaleCategory::LcAll, ""); gettextrs::bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR).expect("Unable to bind the text domain"); @@ -90,6 +93,10 @@ fn main() { } app.run(); + + unsafe { + gst::deinit(); + } } /// Global options for the application diff --git a/src/session/content/message_row/mod.rs b/src/session/content/message_row/mod.rs index f5910e1fd..e6c25f41a 100644 --- a/src/session/content/message_row/mod.rs +++ b/src/session/content/message_row/mod.rs @@ -263,7 +263,7 @@ impl MessageRow { match message_.content().0 { // FIXME: Re-enable MessageVideo when // https://github.com/melix99/telegrand/issues/410 is fixed - MessageContent::MessageAnimation(_) /*| MessageContent::MessageVideo(_)*/ => { + MessageContent::MessageAnimation(_) | MessageContent::MessageVideo(_) => { self.update_specific_content::<_, MessageVideo>(message_.clone()); } MessageContent::MessagePhoto(_) => { diff --git a/src/session/content/message_row/video.rs b/src/session/content/message_row/video.rs index 981070f47..04d085c95 100644 --- a/src/session/content/message_row/video.rs +++ b/src/session/content/message_row/video.rs @@ -1,4 +1,5 @@ use glib::clone; +use gst::prelude::*; use gtk::prelude::*; use gtk::subclass::prelude::*; use gtk::{gdk, glib, CompositeTemplate}; @@ -217,19 +218,20 @@ impl MessageVideo { fn load_video_from_path(&self, path: &str) { let imp = self.imp(); - let media = gtk::MediaFile::for_filename(path); - media.set_muted(true); - media.set_loop(true); - media.play(); + let (pipeline, paintable) = create_pipeline(path); + imp.picture.set_paintable(Some(&paintable)); - if !imp.is_animation.get() { - media.connect_timestamp_notify(clone!(@weak self as obj => move |media| { - let time = (media.duration() - media.timestamp()) / i64::pow(10, 6); - obj.update_remaining_time(time); - })); - } + // TODO: Pause the pipeline when the widget is not visible + pipeline + .set_state(gst::State::Playing) + .expect("Unable to set the pipeline to the `Playing` state"); - imp.picture.set_paintable(Some(&media)); + // if !imp.is_animation.get() { + // media.connect_timestamp_notify(clone!(@weak self as obj => move |media| { + // let time = (media.duration() - media.timestamp()) / i64::pow(10, 6); + // obj.update_remaining_time(time); + // })); + // } } fn update_remaining_time(&self, time: i64) { @@ -247,3 +249,60 @@ impl MessageVideo { } } } + +fn create_pipeline(path: &str) -> (gst::Pipeline, gdk::Paintable) { + let pipeline = gst::Pipeline::new(None); + + let src = gst::ElementFactory::make("filesrc") + .property("location", path) + .build() + .unwrap(); + + let decodebin = gst::ElementFactory::make("decodebin").build().unwrap(); + + let gtksink = gst::ElementFactory::make("gtk4paintablesink") + .build() + .unwrap(); + + // Need to set state to Ready to get a GL context + gtksink.set_state(gst::State::Ready).unwrap(); + let paintable = gtksink.property::("paintable"); + + let sink = if paintable + .property::>("gl-context") + .is_some() + { + gst::ElementFactory::make("glsinkbin") + .property("sink", >ksink) + .build() + .unwrap() + } else { + let sink = gst::Bin::default(); + let convert = gst::ElementFactory::make("videoconvert").build().unwrap(); + + sink.add(&convert).unwrap(); + sink.add(>ksink).unwrap(); + convert.link(>ksink).unwrap(); + + sink.add_pad( + &gst::GhostPad::with_target(Some("sink"), &convert.static_pad("sink").unwrap()) + .unwrap(), + ) + .unwrap(); + + sink.upcast() + }; + + decodebin.connect_pad_added(clone!(@weak sink => move |_, src_pad| { + let sink_pad = sink.static_pad("sink").unwrap(); + if !sink_pad.is_linked() { + src_pad.link(&sink_pad).unwrap(); + } + })); + + pipeline.add_many(&[&src, &decodebin, &sink]).unwrap(); + + src.link(&decodebin).unwrap(); + + (pipeline, paintable) +}