From d443a3c2509889533ca812c163056bace396b586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 14 Jun 2023 20:35:58 +0200 Subject: New upstream version 0.32.1 --- src/video-support/Video.vala | 703 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 703 insertions(+) create mode 100644 src/video-support/Video.vala (limited to 'src/video-support/Video.vala') diff --git a/src/video-support/Video.vala b/src/video-support/Video.vala new file mode 100644 index 0000000..0238d7f --- /dev/null +++ b/src/video-support/Video.vala @@ -0,0 +1,703 @@ +/* Copyright 2016 Software Freedom Conservancy Inc. + * + * This software is licensed under the GNU LGPL (version 2.1 or later). + * See the COPYING file in this distribution. + */ + +public class Video : VideoSource, Flaggable, Monitorable, Dateable { + public const string TYPENAME = "video"; + + public const uint64 FLAG_TRASH = 0x0000000000000001; + public const uint64 FLAG_OFFLINE = 0x0000000000000002; + public const uint64 FLAG_FLAGGED = 0x0000000000000004; + + public class InterpretableResults { + internal Video video; + internal bool update_interpretable = false; + internal bool is_interpretable = false; + internal Gdk.Pixbuf? new_thumbnail = null; + + public InterpretableResults(Video video) { + this.video = video; + } + + public void foreground_finish() { + if (update_interpretable) + video.set_is_interpretable(is_interpretable); + + if (new_thumbnail != null) { + try { + ThumbnailCache.replace(video, ThumbnailCache.Size.BIG, new_thumbnail); + ThumbnailCache.replace(video, ThumbnailCache.Size.MEDIUM, new_thumbnail); + + video.notify_thumbnail_altered(); + } catch (Error err) { + message("Unable to update video thumbnails for %s: %s", video.to_string(), + err.message); + } + } + } + } + + private static bool normal_regen_complete; + private static bool offline_regen_complete; + public static VideoSourceCollection global; + + private VideoRow backing_row; + + public Video(VideoRow row) { + this.backing_row = row; + + // normalize user text + this.backing_row.title = prep_title(this.backing_row.title); + + if (((row.flags & FLAG_TRASH) != 0) || ((row.flags & FLAG_OFFLINE) != 0)) + rehydrate_backlinks(global, row.backlinks); + } + + public static void init(ProgressMonitor? monitor = null) { + // Must initialize static variables here. + // TODO: set values at declaration time once the following Vala bug is fixed: + // https://bugzilla.gnome.org/show_bug.cgi?id=655594 + normal_regen_complete = false; + offline_regen_complete = false; + + // initialize GStreamer, but don't pass it our actual command line arguments -- we don't + // want our end users to be able to parameterize the GStreamer configuration + unowned string[] args = null; + Gst.init(ref args); + + var registry = Gst.Registry.@get (); + + /* Update our local registr to not include vaapi stuff. This is basically to + * work-around concurrent access to VAAPI/X11 which it doesn't like, cf + * https://bugzilla.gnome.org/show_bug.cgi?id=762416 + */ + + var features = registry.feature_filter ((f) => { + return f.get_name ().has_prefix ("vaapi"); + }, false); + + foreach (var feature in features) { + debug ("Removing registry feature %s", feature.get_name ()); + registry.remove_feature (feature); + } + + global = new VideoSourceCollection(); + + Gee.ArrayList all = VideoTable.get_instance().get_all(); + Gee.ArrayList