Skip to content

Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.

Linux: HEIC and HEVC from the AppImage on a clean system, and every compat job runs

Yashwanth Kamireddi31198a35d577
diff --git a/.github/workflows/linux-compat.yml b/.github/workflows/linux-compat.yml
index b3b4844..4c93fe8 100644
--- a/.github/workflows/linux-compat.yml
+++ b/.github/workflows/linux-compat.yml
@@ -39,7 +39,9 @@ jobs:
libsecret-1-dev libheif-dev libfuse3-dev pkg-config patchelf rpm file \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-libav \
- libheif-examples libheif-plugin-x265
+ libheif-plugin-libde265 libheif-examples libheif-plugin-x265
+ # libheif-plugin-libde265 is the HEVC decoder the AppImage carries for HEIC photos
+ # (tauri.conf.json, bundle.linux.appimage.files); x265 only encodes the test's HEIC.
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 22
@@ -68,7 +70,9 @@ jobs:
mkdir compat
cp target/release/bundle/deb/*.deb target/release/bundle/rpm/*.rpm \
target/release/bundle/appimage/*.AppImage \
- target/release/examples/distro_check test.heic packaging/linux-compat/check.sh compat/
+ target/release/examples/distro_check test.heic packaging/linux-compat/check.sh \
+ crates/quince-media/tests/fixtures/black-start.mp4 \
+ crates/quince-media/tests/fixtures/hevc.mov compat/
ls -l compat
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
@@ -109,7 +113,8 @@ jobs:
run: |
chmod +x /compat/check.sh /compat/distro_check
# shellcheck disable=SC2086
- bash /compat/check.sh /compat/$PKG /compat/distro_check /compat/test.heic
+ bash /compat/check.sh /compat/$PKG /compat/distro_check /compat/test.heic \
+ /compat/black-start.mp4 /compat/hevc.mov
# The packages built on each distribution itself, from the build dependencies CONTRIBUTING
# lists for it — so a missing or renamed -devel package, a compiler that disagrees or a
@@ -127,6 +132,12 @@ jobs:
- { name: "openSUSE Tumbleweed", key: tumbleweed, image: "opensuse/tumbleweed", bundle: rpm }
container:
image: ${{ matrix.image }}
+ # openSUSE's image declares no PATH. The runner builds each step's PATH from the image's
+ # own plus what steps add (GITHUB_PATH, the rustup line below) — with none declared, a
+ # step after one adds a directory got only that directory and no /usr/bin: "exec: sh:
+ # executable file not found". Every other image here declares exactly this.
+ env:
+ PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
steps:
- name: Build dependencies, as CONTRIBUTING lists them
run: |
@@ -181,6 +192,9 @@ jobs:
- { name: "openSUSE Tumbleweed", key: tumbleweed, image: "opensuse/tumbleweed", bundle: rpm }
container:
image: ${{ matrix.image }}
+ # As in `native`: openSUSE's image declares no PATH of its own.
+ env:
+ PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
steps:
- name: Tools the artifact actions need
if: matrix.key == 'tumbleweed'
@@ -196,7 +210,8 @@ jobs:
- name: Install and run
run: |
chmod +x /compat/check.sh /compat/distro_check
- bash /compat/check.sh "$(ls /native/*.${{ matrix.bundle }})" /compat/distro_check /compat/test.heic
+ bash /compat/check.sh "$(ls /native/*.${{ matrix.bundle }})" /compat/distro_check /compat/test.heic \
+ /compat/black-start.mp4 /compat/hevc.mov
arch:
needs: build
@@ -210,6 +225,12 @@ jobs:
# the keyring check then fails for the container, not for Skykeep. With every capability
# it starts (checked under podman).
options: --cap-add=ALL
+ # bash, not the container's sh: Arch's sh is bash in POSIX mode, whose `source` looks for a
+ # bare file name only on PATH — never in the current directory — so `source PKGBUILD`
+ # failed with "file not found" from inside packaging/arch.
+ defaults:
+ run:
+ shell: bash
steps:
- name: Build tools
run: pacman -Syu --noconfirm --needed base-devel git rust nodejs npm
@@ -224,10 +245,10 @@ jobs:
chown -R builder "$GITHUB_WORKSPACE"
# The package's own dependencies, from its PKGBUILD, as makepkg -s would install them.
# shellcheck disable=SC1091
- (cd packaging/arch && source PKGBUILD && pacman -S --noconfirm --needed --asdeps "${depends[@]}" "${makedepends[@]}")
+ (cd packaging/arch && source ./PKGBUILD && pacman -S --noconfirm --needed --asdeps "${depends[@]}" "${makedepends[@]}")
su builder -c "cd '$GITHUB_WORKSPACE/packaging/arch' && CARGO_BUILD_JOBS=4 makepkg -f --noconfirm"
- name: Install and run
run: |
chmod +x /compat/check.sh /compat/distro_check
bash /compat/check.sh "$(ls "$GITHUB_WORKSPACE"/packaging/arch/skykeep-*.pkg.tar.zst)" \
- /compat/distro_check /compat/test.heic
+ /compat/distro_check /compat/test.heic /compat/black-start.mp4 /compat/hevc.mov
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index f73a24c..7b9a81f 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -46,7 +46,7 @@ jobs:
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev \
- libsecret-1-dev libheif-dev libfuse3-dev pkg-config patchelf rpm file \
+ libsecret-1-dev libheif-dev libheif-plugin-libde265 libfuse3-dev pkg-config patchelf rpm file \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-libav \
xvfb xauth dbus
diff --git a/Cargo.lock b/Cargo.lock
index fc7f9ad..eeb2a5e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3937,8 +3937,6 @@ dependencies = [
"gdk",
"glib 0.18.5",
"gstreamer",
- "gstreamer-app",
- "gstreamer-video",
"gtk",
"image",
"jiff",
@@ -4048,9 +4046,13 @@ name = "quince-media"
version = "0.1.0"
dependencies = [
"fast_image_resize",
+ "gstreamer",
+ "gstreamer-app",
+ "gstreamer-video",
"image",
"libheif-rs",
"png 0.17.16",
+ "tempfile",
]
[[package]]
@@ -4061,6 +4063,7 @@ dependencies = [
"base64 0.22.1",
"flate2",
"futures-util",
+ "gstreamer",
"image",
"jiff",
"keyring",
diff --git a/crates/quince-media/Cargo.toml b/crates/quince-media/Cargo.toml
index ccf419a..7981160 100644
--- a/crates/quince-media/Cargo.toml
+++ b/crates/quince-media/Cargo.toml
@@ -19,3 +19,14 @@ png = "0.17"
# Only what libheif 1.17 has, the oldest in the distributions Skykeep ships for (Ubuntu 24.04);
# the crate's default asks for 1.23, which none of their packages carry yet.
libheif-rs = { version = "3.0.0", default-features = false, features = ["v1_17"] }
+
+# A video's poster when Apple's is blank (poster.rs): one frame read with GStreamer, which
+# WebKitGTK already needs, so nothing new is installed. Linux only: elsewhere Apple's poster
+# stands.
+[target.'cfg(target_os = "linux")'.dependencies]
+gstreamer = "0.25"
+gstreamer-app = "0.25"
+gstreamer-video = "0.25"
+
+[dev-dependencies]
+tempfile = "3"
diff --git a/crates/quince-media/src/appimage.rs b/crates/quince-media/src/appimage.rs
new file mode 100644
index 0000000..fcf923a
--- /dev/null
+++ b/crates/quince-media/src/appimage.rs
@@ -0,0 +1,116 @@
+//! HEIC photos from the AppImage, on a computer that has no HEVC decoder of its own.
+//!
+//! libheif reads no HEIC by itself: its HEVC decoder is a plugin (libde265's), which it looks
+//! for in the directory it was built with — `/usr/lib/x86_64-linux-gnu/libheif/plugins` on the
+//! Ubuntu the AppImage is built on. The AppImage carries libheif, but the plugin directory it
+//! then searches is the host's: empty on a clean Debian or Fedora (every HEIC failed with
+//! "Unsupported codec"), and elsewhere a different libheif's plugins. So the AppImage carries
+//! the decoder too (`bundle.linux.appimage.files` in tauri.conf.json) and libheif is pointed at
+//! that copy with `LIBHEIF_PLUGIN_PATH`, which it reads when it is first initialised.
+
+use std::ffi::OsStr;
+use std::path::{Path, PathBuf};
+
+/// Where the AppImage keeps libheif's plugins, under its AppDir (tauri.conf.json).
+pub const PLUGINS: &str = "usr/lib/libheif/plugins";
+
+/// Points libheif at the AppImage's own plugins when this program runs from an AppImage.
+///
+/// Only then: `APPDIR` (set by the AppImage runtime and its AppRun) must be an absolute path
+/// that this very executable lies inside, and the plugin directory must be a real directory
+/// inside it — so a stray `APPDIR` in an ordinary install's environment, or one naming some
+/// other directory, never decides what code libheif loads. A `LIBHEIF_PLUGIN_PATH` the person
+/// set themselves is left alone.
+///
+/// Call it before any thread starts and before libheif is first used: it sets the environment.
+pub fn use_bundled_heif_plugins() {
+ if std::env::var_os("LIBHEIF_PLUGIN_PATH").is_some() {
+ return;
+ }
+ let Some(appdir) = std::env::var_os("APPDIR") else {
+ return;
+ };
+ let Ok(exe) = std::env::current_exe() else {
+ return;
+ };
+ if let Some(dir) = heif_plugin_dir(&appdir, &exe) {
+ // Before any thread starts (the caller's promise): nothing else reads the environment.
+ std::env::set_var("LIBHEIF_PLUGIN_PATH", dir);
+ }
+}
+
+/// The AppImage's plugin directory for the AppDir `appdir` and the running executable `exe`,
+/// when `exe` is inside `appdir` and the directory is there; both resolved through symlinks.
+#[must_use]
+pub fn heif_plugin_dir(appdir: &OsStr, exe: &Path) -> Option<PathBuf> {
+ let appdir = Path::new(appdir);
+ if !appdir.is_absolute() {
+ return None;
+ }
+ let root = appdir.canonicalize().ok()?;
+ let exe = exe.canonicalize().ok()?;
+ if !exe.starts_with(&root) {
+ return None;
+ }
+ let dir = root.join(PLUGINS).canonicalize().ok()?;
+ // libheif splits the variable at ':' — a path with one would name two other places.
+ let usable =
+ dir.starts_with(&root) && dir.is_dir() && !dir.as_os_str().to_string_lossy().contains(':');
+ usable.then_some(dir)
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ /// An AppDir laid out as the AppImage's: the program in usr/bin, the plugins under usr/lib.
+ fn appdir() -> (tempfile::TempDir, PathBuf) {
+ let root = tempfile::tempdir().unwrap();
+ std::fs::create_dir_all(root.path().join("usr/bin")).unwrap();
+ std::fs::create_dir_all(root.path().join(PLUGINS)).unwrap();
+ let exe = root.path().join("usr/bin/skykeep");
+ std::fs::write(&exe, b"").unwrap();
+ (root, exe)
+ }
+
+ #[test]
+ fn the_appimages_own_plugins() {
+ let (root, exe) = appdir();
+ let dir = heif_plugin_dir(root.path().as_os_str(), &exe).unwrap();
+ assert_eq!(dir, root.path().canonicalize().unwrap().join(PLUGINS));
+ }
+
+ #[test]
+ fn not_for_a_program_outside_the_appdir() {
+ let (root, _) = appdir();
+ let (_other, elsewhere) = appdir();
+ assert_eq!(heif_plugin_dir(root.path().as_os_str(), &elsewhere), None);
+ }
+
+ #[test]
+ fn not_for_a_relative_appdir() {
+ let (_root, exe) = appdir();
+ assert_eq!(heif_plugin_dir(OsStr::new("usr/.."), &exe), None);
+ assert_eq!(heif_plugin_dir(OsStr::new(""), &exe), None);
+ }
+
+ #[test]
+ fn not_when_the_appimage_carries_none() {
+ let (root, exe) = appdir();
+ std::fs::remove_dir(root.path().join(PLUGINS)).unwrap();
+ assert_eq!(heif_plugin_dir(root.path().as_os_str(), &exe), None);
+ // A file where the directory should be is not one either.
+ std::fs::write(root.path().join(PLUGINS), b"").unwrap();
+ assert_eq!(heif_plugin_dir(root.path().as_os_str(), &exe), None);
+ }
+
+ #[test]
+ fn not_through_a_link_out_of_the_appdir() {
+ let (root, exe) = appdir();
+ let outside = tempfile::tempdir().unwrap();
+ let plugins = root.path().join(PLUGINS);
+ std::fs::remove_dir(&plugins).unwrap();
+ std::os::unix::fs::symlink(outside.path(), &plugins).unwrap();
+ assert_eq!(heif_plugin_dir(root.path().as_os_str(), &exe), None);
+ }
+}
diff --git a/crates/quince-media/src/lib.rs b/crates/quince-media/src/lib.rs
index 62312e8..ec2190e 100644
--- a/crates/quince-media/src/lib.rs
+++ b/crates/quince-media/src/lib.rs
@@ -6,6 +6,13 @@
//! square is cut here, in Rust, and the interface is handed a small image that is already
//! right.
+/// Pointing libheif at the HEVC decoder an AppImage carries (Linux only).
+#[cfg(target_os = "linux")]
+pub mod appimage;
+/// A video's picture when Apple's is blank, read with GStreamer (Linux only).
+#[cfg(target_os = "linux")]
+pub mod poster;
+
/// The square of a picture its owner chose to show, in the stored image's own pixels.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Crop {
diff --git a/src-tauri/src/poster.rs b/crates/quince-media/src/poster.rs
similarity index 85%
rename from src-tauri/src/poster.rs
rename to crates/quince-media/src/poster.rs
index 34cf139..e6bded8 100644
--- a/src-tauri/src/poster.rs
+++ b/crates/quince-media/src/poster.rs
@@ -66,8 +66,8 @@ pub fn first_seen_frame(path: &std::path::Path) -> Result<Option<Vec<u8>>, Strin
let map = buffer.map_readable().map_err(|e| e.to_string())?;
let (w, h) = (info.width(), info.height());
let stride = usize::try_from(info.stride()[0]).unwrap_or(0);
- if quince_media::rgb_lightness(&map, w, h, stride) > SEEN {
- return quince_media::rgb_to_jpeg(&map, w, h, stride).map(Some);
+ if crate::rgb_lightness(&map, w, h, stride) > SEEN {
+ return crate::rgb_to_jpeg(&map, w, h, stride).map(Some);
}
}
Ok(None)
@@ -96,7 +96,7 @@ mod tests {
"poster {}x{}, lightness {mean:.1}, blank {}",
picture.width(),
picture.height(),
- quince_media::is_blank(&jpeg)
+ crate::is_blank(&jpeg)
);
}
@@ -109,7 +109,7 @@ mod tests {
let jpeg = super::first_seen_frame(&film)
.unwrap()
.expect("a frame that shows something");
- assert!(!quince_media::is_blank(&jpeg), "not the black first frame");
+ assert!(!crate::is_blank(&jpeg), "not the black first frame");
let picture = image::load_from_memory(&jpeg).unwrap();
assert_eq!(
(picture.width(), picture.height()),
@@ -117,4 +117,16 @@ mod tests {
"turned upright, as the phone recorded it"
);
}
+
+ /// An iPhone's kind of video: HEVC in a QuickTime file (`hvc1`), a made-up test pattern.
+ /// Read through gst-libav's H.265 decoder, as the AppImage carries it.
+ #[test]
+ fn an_hevc_video() {
+ let film = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/hevc.mov");
+ let jpeg = super::first_seen_frame(&film)
+ .unwrap()
+ .expect("a frame of the test pattern");
+ let picture = image::load_from_memory(&jpeg).unwrap();
+ assert_eq!((picture.width(), picture.height()), (128, 96));
+ }
}
diff --git a/src-tauri/tests/fixtures/black-start.mp4 b/crates/quince-media/tests/fixtures/black-start.mp4
similarity index 100%
rename from src-tauri/tests/fixtures/black-start.mp4
rename to crates/quince-media/tests/fixtures/black-start.mp4
diff --git a/crates/quince-media/tests/fixtures/hevc.mov b/crates/quince-media/tests/fixtures/hevc.mov
new file mode 100644
index 0000000..1cda8cd
Binary files /dev/null and b/crates/quince-media/tests/fixtures/hevc.mov differ
diff --git a/packaging/README.md b/packaging/README.md
index cc5b955..d795a03 100644
--- a/packaging/README.md
+++ b/packaging/README.md
@@ -62,6 +62,38 @@ appindicator library" without it. For the same reason the `.deb` depends on
AppImage carries `libayatana-appindicator3.so.1`, although the Linux tray is ksni's and never
loads it (`ldd` on the binary doesn't list it).
+### What the AppImage carries for photos and videos
+
+The AppImage is built on Ubuntu 24.04 and carries that system's media stack, so HEIC photos
+and H.264/HEVC videos work on a computer that has none of it:
+
+- **GStreamer 1.24** (`bundle.linux.appimage.bundleMediaFramework`): Tauri's linuxdeploy
+ GStreamer plugin copies every plugin installed on the build machine, with the libraries they
+ link — the release builds install `gstreamer1.0-plugins-base` (playbin3, decodebin,
+ videoconvert, appsink), `gstreamer1.0-plugins-good` (qtdemux for `.mov`/`.mp4`, videoflip)
+ and `gstreamer1.0-libav` (avdec_h264, avdec_h265 — FFmpeg's libavcodec 6.1 from Ubuntu's
+ universe), and its AppRun hook points GStreamer at them. Not `-bad` or `-ugly`, and no
+ openh264.
+- **libheif 1.17 with libde265's HEVC decoder** (`libheif-plugin-libde265`, listed in
+ `bundle.linux.appimage.files` with `libde265.so.0`): libheif looks for its decoder plugins
+ in the directory it was built with, which on another system is that system's (empty on a
+ clean Debian or Fedora). At start-up, before libheif is used, Skykeep sets
+ `LIBHEIF_PLUGIN_PATH` to the AppImage's own `usr/lib/libheif/plugins` — only when `APPDIR`
+ is set, is absolute, contains the running program, and the directory really is inside it
+ (`crates/quince-media/src/appimage.rs`); a `LIBHEIF_PLUGIN_PATH` you set yourself wins.
+
+Licences: GStreamer, gst-libav and libde265 are LGPL; Ubuntu's libavcodec is built with
+`--enable-gpl` (GPL-2.0-or-later), which Skykeep's GPL-3.0 allows. H.264 and HEVC are
+patent-encumbered formats in some countries; the AppImage carries exactly what Ubuntu's
+`gstreamer1.0-libav` installs — libavcodec with the libraries it links, x264 and x265 among
+them, although Skykeep only decodes. The `.deb`, `.rpm` and
+Arch package carry none of this — they use the system's own packages (Fedora and openSUSE
+users add RPM Fusion or Packman for HEVC, as the README says).
+
+The files map uses Ubuntu's multiarch paths, so `npx tauri build --bundles appimage` is meant
+for an Ubuntu/Debian machine with `libheif-plugin-libde265` installed, as the release builds
+are; elsewhere build the `.rpm` or the Arch package.
+
`linux-compat.yml` (Actions → Linux compatibility) builds the packages on Ubuntu 24.04,
Debian 13, Fedora 42, openSUSE Tumbleweed and Arch from these instructions and installs each in a
clean container of its distribution; `linux-compat/check.sh` is what it runs there.
diff --git a/packaging/linux-compat/check.sh b/packaging/linux-compat/check.sh
index dcce398..c0b9dce 100644
--- a/packaging/linux-compat/check.sh
+++ b/packaging/linux-compat/check.sh
@@ -1,19 +1,27 @@
#!/bin/bash
# Does Skykeep install and run on this distribution? Run as root in a clean container of it:
#
-# check.sh <package> <distro_check> <test.heic>
+# check.sh <package> <distro_check> <test.heic> [<video>...]
#
# <package> a .deb, .rpm, .pkg.tar.zst or .AppImage — installed with the system's own
# package manager (the .AppImage is only run), with recommends/weak
# dependencies off, so only what the package itself asks for is there;
# <distro_check> the probe's distro_check example (probe/examples/distro_check.rs);
-# <test.heic> a HEIC made for the test — never anybody's photo.
+# <test.heic> a HEIC made for the test — never anybody's photo;
+# <video> made-up test videos (crates/quince-media/tests/fixtures: black-start.mp4,
+# H.264, and hevc.mov, HEVC as an iPhone records it).
#
# Checked, each on its own line, PASS or FAIL:
# ldd the program finds every library it links;
# gst the GStreamer elements the player and poster reader load at run time are there
-# (SKIP for an AppImage on a system whose gst-inspect is newer than its GStreamer);
-# heic a HEIC decodes through the system's libheif, the app's own way;
+# (SKIP for an AppImage on a system whose gst-inspect cannot load its GStreamer:
+# the video lines below are checked through the AppImage's own GStreamer anyway);
+# heic a HEIC decodes through the system's libheif, the app's own way — for the
+# AppImage, through the libheif and HEVC decoder it carries, found as the app
+# finds them;
+# video each video's poster read the app's way (quince_media::poster) and the video
+# played to its end through playbin3, as the window's player plays it — through
+# the system's GStreamer, or the AppImage's own;
# keyring a made-up session goes into a Secret Service (gnome-keyring) and back out
# through the app's sign-in storage;
# launch started headless under Xvfb on its own session bus, the page draws
@@ -26,6 +34,7 @@
# Used by .github/workflows/linux-compat.yml, and runs the same by hand under docker.
set -u
pkg=$1 probe=$2 heic=$3
+videos=("${@:4}")
. /etc/os-release
like=" ${ID} ${ID_LIKE:-} "
fails=0
@@ -41,9 +50,11 @@ case "$like" in
# An AppImage carries its libraries but not the ones every desktop has (linuxdeploy's
# excludelist): GL, X11, fonts and text shaping, ALSA, DRM. Without them in this bare
# container gst-libav (libavcodec links them) does not load and avdec_* looks missing.
+ # libgpg-error too (under libgcrypt, on every system): libavcodec's libraries link it, and
+ # without it gst-libav — every H.264 and HEVC decoder — does not load.
[[ $pkg == *.AppImage ]] && tools+=" libgl1 libegl1 libgles2 libfontconfig1 fonts-dejavu-core \
libx11-6 libx11-xcb1 libxcb1 libxcb-dri3-0 libdrm2 libharfbuzz0b libfribidi0 libfreetype6 \
- libasound2t64"
+ libasound2t64 libgpg-error0"
# shellcheck disable=SC2086
apt-get install -y -qq --no-install-recommends $tools >/dev/null
[[ $pkg == *.deb ]] && { apt-get install -y -q --no-install-recommends "$pkg" || exit 1; }
@@ -53,7 +64,8 @@ case "$like" in
desktop-file-utils appstream which"
# As above; libGLESv2 (libglvnd-gles) too, which WebKit opens and every Fedora desktop has.
[[ $pkg == *.AppImage ]] && tools+=" mesa-libGL mesa-libEGL libglvnd-gles fontconfig \
- dejavu-sans-fonts libX11 libX11-xcb libxcb libdrm harfbuzz fribidi freetype alsa-lib"
+ dejavu-sans-fonts libX11 libX11-xcb libxcb libdrm harfbuzz fribidi freetype alsa-lib \
+ libgpg-error"
# shellcheck disable=SC2086
dnf -y -q install --setopt=install_weak_deps=False $tools
[[ $pkg == *.rpm ]] && { dnf -y install --setopt=install_weak_deps=False "$pkg" || exit 1; }
@@ -62,7 +74,7 @@ case "$like" in
# dbus-run-session is in dbus-1-daemon, not dbus-1.
tools="xvfb-run dbus-1 dbus-1-daemon gnome-keyring gstreamer-utils desktop-file-utils \
AppStream which"
- [[ $pkg == *.AppImage ]] && tools+=" Mesa-libGL1 Mesa-libEGL1 fontconfig dejavu-fonts"
+ [[ $pkg == *.AppImage ]] && tools+=" Mesa-libGL1 Mesa-libEGL1 fontconfig dejavu-fonts libgpg-error0"
# shellcheck disable=SC2086
zypper -q --non-interactive install --no-recommends $tools
[[ $pkg == *.rpm ]] && {
@@ -88,6 +100,11 @@ if [[ $pkg == *.AppImage ]]; then
prog="$root/AppRun"
bin="$root/usr/bin/skykeep"
libs="$root/usr/lib:$root/usr/lib/x86_64-linux-gnu"
+ # The probe beside the program, in the AppDir, with APPDIR set as the AppImage's AppRun sets
+ # it: it then finds the AppImage's libheif plugins exactly as the app does (only a program
+ # inside APPDIR is pointed at them).
+ cp "$probe" "$root/usr/bin/distro_check" && probe="$root/usr/bin/distro_check"
+ export APPDIR=$root
else
prog=/usr/bin/skykeep bin=/usr/bin/skykeep libs=
fi
@@ -102,21 +119,23 @@ missing=$(LD_LIBRARY_PATH=$libs ldd "$bin" | grep "not found")
# playbin3/decodebin/videoconvert/appsink: gst-plugins-base; qtdemux, videoflip: -good;
# avdec_h264 / avdec_h265: gst-libav — an iPhone's .mov/.mp4 and its H.264/HEVC video.
if [[ $pkg == *.AppImage ]]; then
- gstdir=$(find "$root" -type d -name gstreamer-1.0 -path '*lib*' | head -1)
- # As the AppImage's own GStreamer hook sets it up: its plugins, its scanner, a registry of
- # its own — and its libraries (libavcodec for gst-libav) found the way its AppRun finds them.
- export GST_PLUGIN_SYSTEM_PATH_1_0=$gstdir GST_PLUGIN_PATH_1_0= GST_REGISTRY_1_0=/tmp/appimage-registry.bin
- scanner=$(find "$root" -type f -name gst-plugin-scanner | head -1)
- [[ -n $scanner ]] && export GST_PLUGIN_SCANNER_1_0=$scanner
+ # Exactly as the AppImage's AppRun sets GStreamer up — its own hook, sourced: its plugins
+ # (usr/lib/gstreamer-1.0), its scanner — plus a registry of its own for this check. (A
+ # `find -name gstreamer-1.0` here once picked the helpers' directory,
+ # usr/lib/gstreamer1.0/gstreamer-1.0, and every element looked missing.)
+ # shellcheck disable=SC1091
+ source "$root/apprun-hooks/linuxdeploy-plugin-gstreamer.sh" || exit 1
+ export GST_REGISTRY_1_0=/tmp/appimage-registry.bin
fi
media() {
local absent= e
# The AppImage's elements are looked at with this system's gst-inspect-1.0 on the AppImage's
# own libgstreamer. A system GStreamer newer than the bundled one (Fedora 42's 1.26 against
# Ubuntu 24.04's 1.24) cannot do that ("undefined symbol"), which says nothing about the
- # AppImage; then the elements are not checked here (Ubuntu and Debian check them).
+ # AppImage; then the elements are not listed here, and the video lines below — played
+ # through the AppImage's own GStreamer by the probe, built against it — are the check.
if [[ $pkg == *.AppImage ]] && ! LD_LIBRARY_PATH=$libs gst-inspect-1.0 --version >/dev/null 2>&1; then
- echo "SKIP gst — this system's gst-inspect-1.0 cannot load the AppImage's GStreamer"
+ echo "SKIP gst — this system's gst-inspect-1.0 cannot load the AppImage's GStreamer (video below plays through it)"
else
for e in playbin3 decodebin videoconvert videoflip appsink qtdemux \
"avdec_h264|openh264dec" avdec_h265; do
@@ -127,6 +146,12 @@ media() {
fi
if out=$(LD_LIBRARY_PATH=$libs "$probe" heic "$heic" 2>&1); then pass heic "$out"
else $1 heic "$out"; fi
+ local v
+ for v in "${videos[@]}"; do
+ if out=$(LD_LIBRARY_PATH=$libs timeout 60 "$probe" video "$v" 2>&1); then
+ pass "video $(basename "$v")" "$out"
+ else $1 "video $(basename "$v")" "$(tail -3 <<<"$out")"; fi
+ done
}
# Fedora leaves HEVC out of its own repositories — libheif without its libde265 decoder, FFmpeg
# without H.265 — so an iPhone's HEIC photos and HEVC videos need RPM Fusion there (the note
@@ -163,7 +188,8 @@ elif [[ $like == *" suse "* && $pkg != *.AppImage ]]; then
else
media fail
fi
-unset GST_PLUGIN_SYSTEM_PATH_1_0 GST_PLUGIN_PATH_1_0
+unset GST_PLUGIN_SYSTEM_PATH_1_0 GST_PLUGIN_PATH_1_0 GST_PLUGIN_SCANNER_1_0 GST_PTP_HELPER_1_0 \
+ GST_REGISTRY_1_0 GST_REGISTRY_REUSE_PLUGIN_SCANNER APPDIR
# --- Keyring and launch, in one session bus with a keyring daemon on it ---------------------
export HOME=$(mktemp -d) XDG_RUNTIME_DIR=$(mktemp -d) RUST_BACKTRACE=1 SKYKEEP_TIMING=1
diff --git a/probe/Cargo.toml b/probe/Cargo.toml
index dceee22..89ccc4e 100644
--- a/probe/Cargo.toml
+++ b/probe/Cargo.toml
@@ -27,3 +27,7 @@ quince-auth = { path = "../crates/quince-auth" }
quince-core = { path = "../crates/quince-core" }
quince-icloud = { path = "../crates/quince-icloud" }
quince-media = { workspace = true }
+
+# distro_check's video check plays a file through playbin3, as the window's player does.
+[target.'cfg(target_os = "linux")'.dependencies]
+gstreamer = "0.25"
diff --git a/probe/examples/distro_check.rs b/probe/examples/distro_check.rs
index 20a4875..536818e 100644
--- a/probe/examples/distro_check.rs
+++ b/probe/examples/distro_check.rs
@@ -6,16 +6,24 @@
//! then forgotten. Its directory is a fresh temporary one, so its keyring entry is never the
//! app's own;
//! - `distro_check heic <file>`: the file decoded to a JPEG by `quince_media::heic_to_jpeg`
-//! through the system's libheif, as a HEIC photo is shown.
+//! through the system's libheif, as a HEIC photo is shown — or, run from inside an AppImage's
+//! AppDir (APPDIR set), through the libheif and HEVC decoder it carries, as the app finds them;
+//! - `distro_check video <file>`: the file's poster read by `quince_media::poster` (decodebin,
+//! videoconvert, videoflip, appsink), then played to its end through playbin3 — the window's
+//! player — with every frame decoded. Through whichever GStreamer the loader finds: the
+//! system's, or the AppImage's own with its environment (its AppRun hook) set.
use anyhow::{anyhow, bail, Result};
use quince_auth::session::Session;
fn main() -> Result<()> {
+ // As the app's main does, before any thread starts.
+ quince_media::appimage::use_bundled_heif_plugins();
let args: Vec<String> = std::env::args().collect();
match args.get(1).map(String::as_str) {
Some("keyring") => keyring(),
Some("heic") => heic(args.get(2).ok_or_else(|| anyhow!("heic <file>"))?),
- _ => bail!("usage: distro_check keyring | heic <file>"),
+ Some("video") => video(args.get(2).ok_or_else(|| anyhow!("video <file>"))?),
+ _ => bail!("usage: distro_check keyring | heic <file> | video <file>"),
}
}
@@ -59,3 +67,62 @@ fn heic(path: &str) -> Result<()> {
);
Ok(())
}
+
+fn video(path: &str) -> Result<()> {
+ use gstreamer as gst;
+ use gstreamer::prelude::*;
+ let file = std::path::Path::new(path).canonicalize()?;
+ let poster = quince_media::poster::first_seen_frame(&file)
+ .map_err(|e| anyhow!("poster: {e}"))?
+ .ok_or_else(|| anyhow!("poster: no frame that shows something"))?;
+ let picture = image::load_from_memory_with_format(&poster, image::ImageFormat::Jpeg)?;
+
+ // playbin3 to the end, every frame decoded and handed to a sink that only counts them.
+ let uri = gst::glib::filename_to_uri(&file, None).map_err(|e| anyhow!("uri: {e}"))?;
+ let frames = std::sync::Arc::new(std::sync::atomic::AtomicU64::new(0));
+ let sink = gst::ElementFactory::make("fakesink")
+ .property("sync", false)
+ .property("signal-handoffs", true)
+ .build()
+ .map_err(|e| anyhow!("fakesink: {e}"))?;
+ let counted = frames.clone();
+ sink.connect("handoff", false, move |_| {
+ counted.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
+ None
+ });
+ let player = gst::ElementFactory::make("playbin3")
+ .property("uri", uri.as_str())
+ .property("video-sink", &sink)
+ .property(
+ "audio-sink",
+ gst::ElementFactory::make("fakesink")
+ .build()
+ .map_err(|e| anyhow!("fakesink: {e}"))?,
+ )
+ .build()
+ .map_err(|e| anyhow!("playbin3: {e}"))?;
+ player
+ .set_state(gst::State::Playing)
+ .map_err(|e| anyhow!("play: {e}"))?;
+ let bus = player.bus().ok_or_else(|| anyhow!("no bus"))?;
+ let ended = bus.timed_pop_filtered(
+ gst::ClockTime::from_seconds(20),
+ &[gst::MessageType::Eos, gst::MessageType::Error],
+ );
+ let _ = player.set_state(gst::State::Null);
+ match ended.as_ref().map(|m| m.view()) {
+ Some(gst::MessageView::Eos(_)) => {}
+ Some(gst::MessageView::Error(e)) => bail!("playbin3: {} ({:?})", e.error(), e.debug()),
+ _ => bail!("playbin3: not finished in 20 s"),
+ }
+ let frames = frames.load(std::sync::atomic::Ordering::Relaxed);
+ if frames == 0 {
+ bail!("playbin3: reached the end without a frame");
+ }
+ println!(
+ "video: poster {}x{}, played to the end through playbin3 ({frames} frames)",
+ picture.width(),
+ picture.height()
+ );
+ Ok(())
+}
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index adbe82e..40514d5 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -68,11 +68,9 @@ windows = { version = "0.62", features = [
[target.'cfg(target_os = "linux")'.dependencies]
fuser = { version = "0.18", default-features = false }
-# A video's poster when Apple's is blank: one frame read with GStreamer, which WebKitGTK
-# already needs, so nothing new is installed. Linux only: elsewhere Apple's poster stands.
+# What the window's player can decode here (video.rs), asked of GStreamer, which WebKitGTK
+# plays through. The poster reader is quince-media's (poster.rs).
gstreamer = "0.25"
-gstreamer-app = "0.25"
-gstreamer-video = "0.25"
zbus = "5"
# The tray, spoken as StatusNotifierItem over D-Bus itself: a left click (Activate) opens the
# window. async-io, as zbus here runs on, not a second D-Bus runtime.
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 0f808a0..e49a803 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -36,7 +36,7 @@ mod outbox;
mod photo_cache;
mod photos;
#[cfg(target_os = "linux")]
-mod poster;
+use quince_media::poster;
mod power;
#[cfg(not(target_os = "linux"))]
mod poster {
@@ -6208,7 +6208,11 @@ fn main() {
login::note_launch();
steady_drawing();
smooth_video();
- // After the two above (they set the environment, which only a single thread may) and
+ // From an AppImage: HEIC photos through the HEVC decoder it carries (quince-media's
+ // appimage.rs), set before libheif is first used and before any thread starts.
+ #[cfg(target_os = "linux")]
+ quince_media::appimage::use_bundled_heif_plugins();
+ // After those above (they set the environment, which only a single thread may) and
// before anything opens the library, the webview its storage, or the window-state plugin
// its file: the folders moved from the old identifier, or — if they could not be — this
// launch run under the old one, from them as they are (migrate.rs).
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index 73623d2..1442488 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -149,7 +149,11 @@
}
},
"appimage": {
- "bundleMediaFramework": true
+ "bundleMediaFramework": true,
+ "files": {
+ "/usr/lib/libheif/plugins/libheif-libde265.so": "/usr/lib/x86_64-linux-gnu/libheif/plugins/libheif-libde265.so",
+ "/usr/lib/libde265.so.0": "/usr/lib/x86_64-linux-gnu/libde265.so.0"
+ }
}
}
},