FriendlyCaps: add sort func
Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
This commit is contained in:
parent
56eb78a862
commit
45ab2ecb66
2 changed files with 9 additions and 2 deletions
|
@ -27,14 +27,12 @@ public class EyeNeko.Gstreamer : Object {
|
|||
private bool can_start_stream = true;
|
||||
|
||||
private void set_up_caps (Gst.Device device) {
|
||||
FriendlyCaps best_caps = null;
|
||||
var caps = device.get_caps ();
|
||||
can_start_stream = false;
|
||||
available_caps.remove_all ();
|
||||
for (uint i = 0; i < caps.get_size (); i++) {
|
||||
var cap = new FriendlyCaps.with_struct (caps.get_structure (i));
|
||||
available_caps.append (cap);
|
||||
best_caps = (best_caps == null || cap.is_res_better (best_caps)) ? cap : best_caps;
|
||||
}
|
||||
can_start_stream = true;
|
||||
caps_selecton_model.selected = 0;
|
||||
|
|
|
@ -70,6 +70,15 @@ namespace EyeNeko {
|
|||
return (width * height == cap.width * cap.height);
|
||||
}
|
||||
|
||||
public static int sort_func (FriendlyCaps a, FriendlyCaps b) {
|
||||
if (a.width > b.width)
|
||||
return -1;
|
||||
else if (a.width == b.width)
|
||||
return a.height > b.height ? -1 : a.height == b.height ? a.fps > b.fps ? -1 : a.fps == b.fps ? 0 : 1 : 1;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
public Gst.Caps to_caps () {
|
||||
var res = new Gst.Caps.empty ();
|
||||
res.append_structure (struct.copy ());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue