fixup! GST: Add caps selector
All checks were successful
PostmarketOS Build / Prepare (push) Successful in 8s
PostmarketOS Build / Build for aarch64 (push) Successful in 44s
PostmarketOS Build / Build for x86_64 (push) Successful in 14s

WIP

Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
This commit is contained in:
Vasiliy Doylov 2025-06-21 19:08:15 +03:00
parent 8fa4ac1e51
commit de67da42ea
Signed by: NekoCWD
GPG key ID: B7BE22D44474A582
2 changed files with 10 additions and 1 deletions

View file

@ -133,7 +133,12 @@ public class EyeNeko.Gstreamer : Object {
}
construct {
caps_selecton_model.set_model (available_caps);
var srt = new Gtk.SortListModel (available_caps, new Gtk.CustomSorter ((_a, _b) => {
var a = (FriendlyCaps) _a;
var b = (FriendlyCaps) _b;
return a.is_res_better (b) ? -1 : a.is_res_same (b) ? 0 : 1;
}));
caps_selecton_model.set_model (srt);
caps_selecton_model.notify["selected-item"].connect (() => start_stream_from (current_camera));
}

View file

@ -66,6 +66,10 @@ namespace EyeNeko {
return (width * height > cap.width * cap.height);
}
public bool is_res_same (FriendlyCaps cap) {
return (width * height == cap.width * cap.height);
}
public Gst.Caps to_caps () {
var res = new Gst.Caps.empty ();
res.append_structure (struct.copy ());