diff --git a/Cargo.toml b/Cargo.toml index 464548d..34ae3c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "alias-view" version = "0.1.0" edition = "2024" license = "MIT" -description = "aliasOS's picture viewer" +description = "aliasOS's media viewer: pictures, video and music" publish = false [dependencies] diff --git a/README.md b/README.md index 2f19427..fc8556e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ # Alias View -aliasOS's picture viewer, which also plays video and music (ALI-2358, to replace `mpv`). It -replaces `imv` as the default for pictures. Rust, drawn on the CPU straight onto Wayland with no toolkit, in -the style of [Gannet](../gannet), aliasOS's file manager. +aliasOS's media viewer ("Media Viewer" in the launcher): pictures, and video and music +(ALI-2358, to replace `mpv`). It replaces `imv` as the default for pictures. Rust, drawn +on the CPU straight onto Wayland with no toolkit, in the style of [Gannet](../gannet), +aliasOS's file manager. alias-view FILE... # those pictures (or videos and songs), in that order alias-view FILE # that picture, then the rest of its folder @@ -70,8 +71,13 @@ file that claims more is shown at screen size where its format allows that witho holding the whole picture (baseline JPEG, PNG that isn't interlaced); zooming in then enlarges the screen copy and says why, and copying offers only the file itself. -Video: mp4, m4v, mkv, webm, mov, avi, flv, wmv, mpeg, ogv, 3gp and asf. Music: mp3, flac, -ogg, opus, m4a, aac, wav, wma, aiff, mka, wv and ape, with the cover art the file holds. +Video: mp4, m4v, f4v, lrv and lrf, mkv, webm, mov, qt and moov, avi, divx and avf, flv, +wmv, mpeg, mpg, mpe and vob, ogv, ogm, 3gp and 3gpp, 3g2, 3gp2 and 3gpp2, and asf. Music: +mp3 and mpga, mp2, flac, ogg, oga, opus and spx, m4a and f4a, aac and adts, wav, wma, aiff +and aif, mka, wv and wvp, ape, and 3ga, with the cover art the file holds. A video or song +is known by its extension, and the desktop file (`packaging/com.aliasproject.view.desktop`) +lists those extensions' MIME types, so "Open with" offers Alias View for them and +`xdg-open` can use it once it's set as the default. They play in [alias-playback](https://github.com/aliasproject/alias-playback)'s GPU helper: libmpv in a bubblewrap jail (with Landlock and a seccomp filter), decoding on the graphics card where it can (NVDEC, VA-API or V4L2, else the CPU) and drawing into diff --git a/packaging/com.aliasproject.view.desktop b/packaging/com.aliasproject.view.desktop index 7a53034..86f322c 100644 --- a/packaging/com.aliasproject.view.desktop +++ b/packaging/com.aliasproject.view.desktop @@ -1,14 +1,19 @@ -# The MIME types are the formats Alias View opens. Video and audio stay with mpv. +# The MIME types are the formats Alias View opens: pictures, then video, then music. It +# picks a video or song by its file extension (VIDEO and MUSIC in src/player/mod.rs), so +# every type here is a shared-mime-info type (or an alias of one) that files with those +# extensions are given, by name or, for the Ogg codecs, by their contents. A few names +# these types also cover aren't played: .ass (subtitles, though audio/aac claims it), +# .qtvr (QuickTime VR) and the NNN.vdr pattern (video/mpeg). [Desktop Entry] Type=Application -Name=Picture Viewer -GenericName=Picture Viewer -Comment=A very fast picture viewer +Name=Media Viewer +GenericName=Media Viewer +Comment=A very fast viewer for pictures, video and music Exec=alias-view %F Icon=com.aliasproject.view Terminal=false -Categories=Graphics;Viewer; +Categories=Graphics;Viewer;AudioVideo;Audio;Video;Player; StartupNotify=false -Keywords=alias-view;Alias View;picture;photo;image;viewer; +Keywords=alias-view;Alias View;picture;photo;image;viewer;video;movie;music;song;player; StartupWMClass=com.aliasproject.view -MimeType=image/jpeg;image/pjpeg;image/png;image/apng;image/gif;image/webp;image/bmp;image/x-bmp;image/x-ms-bmp;image/tiff;image/vnd.microsoft.icon;image/x-icon;image/avif;image/heic;image/heif;image/heic-sequence;image/heif-sequence;image/jxl;image/svg+xml;image/svg+xml-compressed; +MimeType=image/jpeg;image/pjpeg;image/png;image/apng;image/gif;image/webp;image/bmp;image/x-bmp;image/x-ms-bmp;image/tiff;image/vnd.microsoft.icon;image/x-icon;image/avif;image/heic;image/heif;image/heic-sequence;image/heif-sequence;image/jxl;image/svg+xml;image/svg+xml-compressed;video/mp4;video/x-m4v;video/matroska;video/x-matroska;video/webm;video/quicktime;video/vnd.avi;video/x-msvideo;video/avi;video/x-flv;video/x-ms-wmv;video/mpeg;video/ogg;video/x-ogm+ogg;video/x-theora+ogg;video/3gpp;video/3gpp2;application/vnd.ms-asf;video/x-ms-asf;audio/mpeg;audio/mp3;audio/x-mp3;audio/mp2;audio/x-mp2;audio/flac;audio/x-flac;audio/ogg;audio/x-vorbis+ogg;audio/x-flac+ogg;audio/x-opus+ogg;audio/x-speex+ogg;audio/mp4;audio/x-m4a;audio/aac;audio/x-aac;audio/vnd.wave;audio/wav;audio/x-wav;audio/x-ms-wma;audio/x-aiff;audio/matroska;audio/x-matroska;audio/x-wavpack;audio/x-ape; diff --git a/src/main.rs b/src/main.rs index aaa4337..875c78b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -//! Alias View: aliasOS's picture viewer. +//! Alias View: aliasOS's media viewer, for pictures, video and music. //! //! Startup is the point: the first picture is read on its own thread while the Wayland //! connection comes up, and once its size is known the window opens around it. A JPEG diff --git a/src/player/mod.rs b/src/player/mod.rs index b71cb62..e55004e 100644 --- a/src/player/mod.rs +++ b/src/player/mod.rs @@ -15,12 +15,19 @@ use crate::canvas::Rect; use crate::wl::{VIDEO_SLOTS, VideoBuffer, Wl}; use gpu::{Command, MetaField, Said, Session}; -/// The containers aliasOS sends to a video player (`install/user/mimetypes.sh`), and their -/// usual other names. -const VIDEO: &[&str] = &["mp4", "m4v", "mkv", "webm", "mov", "avi", "flv", "wmv", "mpeg", "mpg", "ogv", "ogm", "3gp", "3g2", "asf"]; +/// The containers aliasOS sends to a video player (`install/user/mimetypes.sh`), and every +/// other name shared-mime-info gives their types, so whatever the desktop file's `MimeType=` +/// brings in plays: .f4v, .lrv and .lrf are MP4; .qt and .moov QuickTime; .divx and .avf +/// AVI; .vob and .mpe MPEG; .3gpp, .3gp2 and .3gpp2 3GPP. Left out: .qtvr (QuickTime VR +/// panoramas and object movies, which libmpv can't show as they're meant to be). +const VIDEO: &[&str] = &[ + "mp4", "m4v", "f4v", "lrv", "lrf", "mkv", "webm", "mov", "qt", "moov", "avi", "divx", "avf", "flv", "wmv", "mpeg", "mpg", "mpe", "vob", "ogv", "ogm", "3gp", "3gpp", "3g2", "3gp2", "3gpp2", "asf", +]; /// Sound files. Plain `.ogg` is here: it's nearly always sound, and a video in one still -/// plays, shown as its picture. -const MUSIC: &[&str] = &["mp3", "flac", "ogg", "oga", "opus", "m4a", "aac", "wav", "wma", "aif", "aiff", "mka", "wv", "ape"]; +/// plays, shown as its picture. So are .mp2 (MPEG audio, `audio/mp2`) and .3ga (3GPP's +/// sound-only name, AMR from phone recorders), though shared-mime-info also gives them +/// video types. .mpga is MP3, .f4a MP4 audio, .adts AAC, .spx Speex in Ogg and .wvp WavPack. +const MUSIC: &[&str] = &["mp3", "mpga", "mp2", "flac", "ogg", "oga", "opus", "spx", "m4a", "f4a", "aac", "adts", "wav", "wma", "aif", "aiff", "mka", "wv", "wvp", "ape", "3ga"]; #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Kind { @@ -437,6 +444,22 @@ mod tests { assert_eq!(kind_of_name("mp4"), None); } + /// Every extension shared-mime-info gives a type in the desktop file's `MimeType=`, so a + /// file "Open with" hands over plays rather than failing as a picture. .ass (a subtitle + /// name `audio/aac` also claims), .qtvr (QuickTime VR) and `NNN.vdr` stay out. + #[test] + fn the_desktop_files_other_names_play() { + for ext in ["f4v", "lrv", "lrf", "qt", "moov", "divx", "avf", "vob", "mpe", "3gpp", "3gp2", "3gpp2"] { + assert_eq!(kind_of_name(&format!("clip.{ext}")), Some(Kind::Video), "{ext}"); + } + for ext in ["mp2", "mpga", "f4a", "adts", "spx", "wvp", "3ga"] { + assert_eq!(kind_of_name(&format!("song.{ext}")), Some(Kind::Music), "{ext}"); + } + for name in ["subs.ass", "pano.qtvr", "001.vdr"] { + assert_eq!(kind_of_name(name), None, "{name}"); + } + } + #[test] fn no_name_is_both_a_picture_and_media() { for ext in VIDEO.iter().chain(MUSIC) { diff --git a/src/wl.rs b/src/wl.rs index 115cfec..cfabe90 100644 --- a/src/wl.rs +++ b/src/wl.rs @@ -1,5 +1,5 @@ //! The Wayland connection: one window, input, shared-memory buffers, the clipboard. -//! Gannet's approach, cut down to what a picture viewer needs. Painting happens only on +//! Gannet's approach, cut down to what a media viewer needs. Painting happens only on //! request, paced by frame callbacks, and nothing here runs unless the compositor or //! the app has something to say. //!