[chronojump] Webcam: On preferences can check if ffmpeg/ffplay are running



commit eac15dbd896c7c1e84a533848c2c9c9562e635f6
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Jun 18 18:10:30 2019 +0200

    Webcam: On preferences can check if ffmpeg/ffplay are running

 glade/preferences_win.glade | 43 +++++++++++++++++++++++++++++++++++++++++++
 src/gui/preferences.cs      | 28 ++++++++++++++++++++++++++++
 src/webcamFfmpeg.cs         | 37 +++++++++++++++++++++++--------------
 3 files changed, 94 insertions(+), 14 deletions(-)
---
diff --git a/glade/preferences_win.glade b/glade/preferences_win.glade
index db296518..9a36c971 100644
--- a/glade/preferences_win.glade
+++ b/glade/preferences_win.glade
@@ -3975,6 +3975,49 @@ Other</property>
                             <property name="position">4</property>
                           </packing>
                         </child>
+                        <child>
+                          <widget class="GtkHBox" id="hbox21">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="spacing">20</property>
+                            <child>
+                              <widget class="GtkButton" id="button_video_check_ffmpeg_ffplay_running">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">True</property>
+                                <signal name="clicked" 
handler="on_button_video_check_ffmpeg_ffplay_running_clicked" swapped="no"/>
+                                <child>
+                                  <widget class="GtkLabel" id="label11">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label" translatable="yes">Check if camera is 
running</property>
+                                  </widget>
+                                </child>
+                              </widget>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkLabel" id="label_video_check_ffmpeg_ffplay_running">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                              </widget>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </widget>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">5</property>
+                          </packing>
+                        </child>
                       </widget>
                       <packing>
                         <property name="position">1</property>
diff --git a/src/gui/preferences.cs b/src/gui/preferences.cs
index 9f63d368..7e7a1ce6 100644
--- a/src/gui/preferences.cs
+++ b/src/gui/preferences.cs
@@ -167,6 +167,7 @@ public class PreferencesWindow
        //[Widget] Gtk.VBox vbox_camera_stop_after;
        [Widget] Gtk.HBox hbox_camera_stop_after_seconds;
        [Widget] Gtk.SpinButton spin_camera_stop_after;
+       [Widget] Gtk.Label label_video_check_ffmpeg_ffplay_running;
 
        //language tab
        [Widget] Gtk.Box hbox_combo_language;
@@ -860,6 +861,33 @@ public class PreferencesWindow
                return selected;
        }
 
+       private void on_button_video_check_ffmpeg_ffplay_running_clicked(object o, EventArgs args)
+       {
+               string label_result = "Camera is not running.";
+               label_video_check_ffmpeg_ffplay_running.Text = label_result;
+
+               UtilAll.OperatingSystems os = UtilAll.GetOSEnum();
+               bool runningFfmpeg = false;
+               bool runningFfplay = false;
+
+               if(ExecuteProcess.IsRunning3 (-1, WebcamFfmpeg.GetExecutableCapture(os)))
+               {
+                       runningFfmpeg = true;
+                       label_result = "Capture (ffmpeg) is running";
+               }
+
+               if(ExecuteProcess.IsRunning3 (-1, WebcamFfmpeg.GetExecutablePlay(os)))
+               {
+                       runningFfplay = true;
+                       if(runningFfmpeg)
+                               label_result = "Capture (ffmpeg) & Play (ffplay) are running";
+                       else
+                               label_result = "Play (ffplay) is running";
+               }
+
+               label_video_check_ffmpeg_ffplay_running.Text = label_result;
+       }
+
        // ---- end of multimedia stuff
 
        // ---- Language stuff
diff --git a/src/webcamFfmpeg.cs b/src/webcamFfmpeg.cs
index 21ddd408..8abc4367 100644
--- a/src/webcamFfmpeg.cs
+++ b/src/webcamFfmpeg.cs
@@ -42,27 +42,36 @@ public class WebcamFfmpeg : Webcam
                this.videoDeviceFramerate = videoDeviceFramerate;
 
                if(action == Webcam.Action.CAPTURE)
-               {
-                       executable = "ffmpeg";
-                       if(os == UtilAll.OperatingSystems.WINDOWS)
-                               executable = System.IO.Path.Combine(Util.GetPrefixDir(), "bin/ffmpeg.exe");
-                       if(os == UtilAll.OperatingSystems.MACOSX)
-                               executable = System.IO.Path.Combine(Util.GetPrefixDir(), "bin/ffmpeg");
-               }
+                       executable = GetExecutableCapture (os);
                else // PLAYPREVIEW || PLAYFILE
-               {
-                       executable = "ffplay";
-                       if(os == UtilAll.OperatingSystems.WINDOWS)
-                               executable = System.IO.Path.Combine(Util.GetPrefixDir(), "bin/ffplay.exe");
-                       if(os == UtilAll.OperatingSystems.MACOSX)
-                               executable = System.IO.Path.Combine(Util.GetPrefixDir(), "bin/ffplay");
-               }
+                       executable = GetExecutablePlay (os);
 
                Running = false;
        }
 
        // public methods ----------------------------------
 
+       public static string GetExecutableCapture(UtilAll.OperatingSystems os)
+       {
+               string e = "ffmpeg";
+               if(os == UtilAll.OperatingSystems.WINDOWS)
+                       e = System.IO.Path.Combine(Util.GetPrefixDir(), "bin/ffmpeg.exe");
+               if(os == UtilAll.OperatingSystems.MACOSX)
+                       e = System.IO.Path.Combine(Util.GetPrefixDir(), "bin/ffmpeg");
+
+               return e;
+       }
+       public static string GetExecutablePlay(UtilAll.OperatingSystems os)
+       {
+               string e = "ffplay";
+               if(os == UtilAll.OperatingSystems.WINDOWS)
+                       e = System.IO.Path.Combine(Util.GetPrefixDir(), "bin/ffplay.exe");
+               if(os == UtilAll.OperatingSystems.MACOSX)
+                       e = System.IO.Path.Combine(Util.GetPrefixDir(), "bin/ffplay");
+
+               return e;
+       }
+
        public override Result CapturePrepare (CaptureTypes captureType)
        {
                if(process != null)


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