[chronojump] webcam get supported modes for Linux (done!)



commit 38de27b25276bfb87eaf3ebfaa2c363e1051575e
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon May 20 16:01:17 2019 +0200

    webcam get supported modes for Linux (done!)

 src/gui/preferences.cs | 29 ++++++++++++++++++++++++-----
 src/webcamFfmpeg.cs    |  2 +-
 2 files changed, 25 insertions(+), 6 deletions(-)
---
diff --git a/src/gui/preferences.cs b/src/gui/preferences.cs
index 968d6e65..c029a2df 100644
--- a/src/gui/preferences.cs
+++ b/src/gui/preferences.cs
@@ -791,15 +791,34 @@ public class PreferencesWindow
                if(cameraCode == "")
                        return;
 
-               Webcam webcamPlay = new WebcamFfmpeg (Webcam.Action.PLAYPREVIEW, UtilAll.GetOSEnum(),
-                               cameraCode, "8000x8000", "8000"); //select and impossible mode just to get an 
error on mac, this error will give us the "Supported modes"
+               string modesStr = "";
+
+               if(UtilAll.GetOSEnum() == UtilAll.OperatingSystems.LINUX)
+               {
+                       List<string> parameters = new List<string>();
+                       parameters.Add("--list-formats-ext");
+                       ExecuteProcess.Result execute_result = ExecuteProcess.run ("v4l2-ctl", parameters, 
true, true);
+                       if(! execute_result.success) {
+                               new DialogMessage("Chronojump - Modes of this webcam",
+                                               Constants.MessageTypes.WARNING, "Need to install v4l2-ctl (on 
v4l-utils) to know modes");
+                               return;
+                       }
 
-               Webcam.Result result = webcamPlay.PlayPreviewNoBackgroundWantStdoutAndStderr();
+                       modesStr = execute_result.stdout;
+               }
+               else if(UtilAll.GetOSEnum() == UtilAll.OperatingSystems.MACOSX)
+               {
+                       Webcam webcamPlay = new WebcamFfmpeg (Webcam.Action.PLAYPREVIEW, UtilAll.GetOSEnum(),
+                                       cameraCode, "8000x8000", "8000"); //select and impossible mode just 
to get an error on mac, this error will give us the "Supported modes"
+
+                       Webcam.Result result = webcamPlay.PlayPreviewNoBackgroundWantStdoutAndStderr();
+                       modesStr = result.output;
+               }
 
                //display the result (if any)
-               if(result.output != "")
+               if(modesStr != "")
                        new DialogMessage("Chronojump - Modes of this webcam",
-                                       Constants.MessageTypes.INFO, result.output);
+                                       Constants.MessageTypes.INFO, modesStr, true); //showScrolledWinBar
        }
 
        private void on_button_video_preview_clicked (object o, EventArgs args)
diff --git a/src/webcamFfmpeg.cs b/src/webcamFfmpeg.cs
index 3a0d778d..f7f2bb01 100644
--- a/src/webcamFfmpeg.cs
+++ b/src/webcamFfmpeg.cs
@@ -104,7 +104,7 @@ public class WebcamFfmpeg : Webcam
 
                return new Result (true, "");
        }
-       //used to know "Supported modes" on mac and maybe on windows
+       //used to know "Supported modes" on mac
        public override Result PlayPreviewNoBackgroundWantStdoutAndStderr() //experimental
        {
                List<string> parameters = createParametersPlayPreview();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]