mirror of
https://github.com/TakeV-Lambda/dino.git
synced 2024-11-22 06:54:29 +00:00
Support devices with multiple framerate options in get_max_fps (#1224)
This commit is contained in:
parent
186361fd8a
commit
f25bfb0096
1 changed files with 20 additions and 2 deletions
|
@ -382,9 +382,27 @@ public class Dino.Plugins.Rtp.Plugin : RootInterface, VideoCallPlugin, Object {
|
|||
int fps = 0;
|
||||
for (int i = 0; i < device.device.caps.get_size(); i++) {
|
||||
unowned Gst.Structure structure = device.device.caps.get_structure(i);
|
||||
int num = 0, den = 0;
|
||||
if (structure.has_field("framerate") && structure.get_fraction("framerate", out num, out den)) fps = int.max(fps, num / den);
|
||||
|
||||
if (structure.has_field("framerate")) {
|
||||
Value framerate = structure.get_value("framerate");
|
||||
if (framerate.type() == typeof(Gst.Fraction)) {
|
||||
int num = Gst.Value.get_fraction_numerator(framerate);
|
||||
int den = Gst.Value.get_fraction_denominator(framerate);
|
||||
fps = int.max(fps, num / den);
|
||||
} else if (framerate.type() == typeof(Gst.ValueList)) {
|
||||
for(uint j = 0; j < Gst.ValueList.get_size(framerate); j++) {
|
||||
Value fraction = Gst.ValueList.get_value(framerate, j);
|
||||
int num = Gst.Value.get_fraction_numerator(fraction);
|
||||
int den = Gst.Value.get_fraction_denominator(fraction);
|
||||
fps = int.max(fps, num / den);
|
||||
}
|
||||
} else {
|
||||
debug("Unknown type for framerate %s on device %s", framerate.type_name(), device.display_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
debug("Max framerate for device %s: %d", device.display_name, fps);
|
||||
return fps;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue