[chronojump] webcam supported modes print ok sorted on linux
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] webcam supported modes print ok sorted on linux
- Date: Wed, 26 Jun 2019 11:04:33 +0000 (UTC)
commit 6c76a138e8a88b580821c8c7e7d0f4d7e546392f
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Jun 26 13:04:06 2019 +0200
webcam supported modes print ok sorted on linux
src/webcam/webcamFfmpegSupportedModes.cs | 31 ++++++++++++++++++++++++-------
1 file changed, 24 insertions(+), 7 deletions(-)
---
diff --git a/src/webcam/webcamFfmpegSupportedModes.cs b/src/webcam/webcamFfmpegSupportedModes.cs
index 8583026d..4bf3c27c 100644
--- a/src/webcam/webcamFfmpegSupportedModes.cs
+++ b/src/webcam/webcamFfmpegSupportedModes.cs
@@ -74,7 +74,7 @@ public class WebcamFfmpegSupportedModesLinux : WebcamFfmpegSupportedModes
//TODO: have a class that sorts resolutions and framerates
protected override string parseSupportedModes(string allOutput)
{
- string parsedAll = "Resolution:\tFramerate";
+ string parsedAll = "";
/*
* break the big string in \n strings
@@ -86,6 +86,7 @@ public class WebcamFfmpegSupportedModesLinux : WebcamFfmpegSupportedModes
);
bool foundAtLeastOne = false;
+ string currentPixelFormat = "";
WebcamSupportedModesList wsmList = new WebcamSupportedModesList();
WebcamSupportedMode currentMode = null;
@@ -95,15 +96,21 @@ public class WebcamFfmpegSupportedModesLinux : WebcamFfmpegSupportedModes
if(l.Contains("Pixel Format:"))
{
- parsedAll += "\n\n" + l + "\n";
+ //if we have a list of a previous Pixel Format, print it now
+ if(wsmList.HasRecords ())
+ {
+ parsedAll += printModesList(wsmList, currentPixelFormat);
+ //empty list
+ wsmList = new WebcamSupportedModesList();
+ }
+
+ currentPixelFormat = l;
continue;
}
string resolutionStr = matchResolution(l);
if(l.Contains("Size: Discrete") && resolutionStr != "")
{
- parsedAll += "\n" + resolutionStr + ": ";
-
if(wsmList.ModeExist(resolutionStr))
currentMode = wsmList.GetMode(resolutionStr);
else {
@@ -114,7 +121,6 @@ public class WebcamFfmpegSupportedModesLinux : WebcamFfmpegSupportedModes
if(l.Contains("Interval: Discrete") && l.Contains("fps") && matchFPS(l) != "")
{
- parsedAll += "\t" + matchFPS(l);
foundAtLeastOne = true;
if(currentMode != null)
@@ -125,12 +131,18 @@ public class WebcamFfmpegSupportedModesLinux : WebcamFfmpegSupportedModes
if(! foundAtLeastOne)
return "Not found any mode supported for your camera.";
- wsmList.Sort();
- LogB.Information("printing list:\n" + wsmList.ToString());
+ parsedAll += printModesList(wsmList, currentPixelFormat);
return parsedAll;
}
+ private string printModesList (WebcamSupportedModesList wsmList, string currentPixelFormat)
+ {
+ wsmList.Sort();
+
+ return "\n" + currentPixelFormat + "\nResolution:\tFramerates\n" + wsmList.ToString();
+ }
+
private string matchResolution(string l)
{
Match match = Regex.Match(l, @"(\d+)x(\d+)");
@@ -421,6 +433,11 @@ public class WebcamSupportedModesList
l.Add(wsm);
}
+ public bool HasRecords ()
+ {
+ return (l.Count > 0);
+ }
+
public void Sort()
{
WebcamSupportedModeSort wsms = new WebcamSupportedModeSort();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]