[chronojump] label_video_feedback shows info when video file start growing



commit 593a3ffafba81195ed4a6bbfcdea441518fe944d
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Mar 14 16:02:12 2019 +0100

    label_video_feedback shows info when video file start growing

 glade/app1.glade         | 30 ++++++++++++++++++------------
 src/execute/event.cs     | 22 +++++++++++++++++++++-
 src/gui/chronojump.cs    | 27 +++++++++++++++++----------
 src/gui/eventExecute.cs  |  1 +
 src/gui/usefulObjects.cs |  3 +++
 src/webcam.cs            |  6 ++++++
 src/webcamFfmpeg.cs      |  3 +++
 7 files changed, 69 insertions(+), 23 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 14573e1e..c4ee4854 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -1863,6 +1863,12 @@
                                                             <placeholder/>
                                                             </child>
                                                             <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkLabel" 
id="label_start_selector_jumps">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -20446,18 +20452,6 @@ Concentric</property>
                                                             <placeholder/>
                                                             </child>
                                                             <child>
-                                                            <placeholder/>
-                                                            </child>
-                                                            <child>
-                                                            <placeholder/>
-                                                            </child>
-                                                            <child>
-                                                            <placeholder/>
-                                                            </child>
-                                                            <child>
-                                                            <placeholder/>
-                                                            </child>
-                                                            <child>
                                                             <widget class="GtkCheckButton" 
id="checkbutton_force_sensor_ai_b">
                                                             <property name="width_request">30</property>
                                                             <property name="visible">True</property>
@@ -20615,6 +20609,12 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -28961,6 +28961,12 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/src/execute/event.cs b/src/execute/event.cs
index 543fafb1..3a2bb1ac 100644
--- a/src/execute/event.cs
+++ b/src/execute/event.cs
@@ -353,7 +353,21 @@ public class EventExecute
                }
                
                // <-------------------------- end of races specific
-               
+
+               //camera stuff: show something when record really starts
+               if(webcamStarting)
+               {
+                       if(! checkWebcamFileStarted)
+                       {
+                               if(WebcamManage.RecordingFileStarted ())
+                               {
+                                       LogB.Information("WebcamManage.RecodingFileStarted");
+                                       UtilGtk.PrintLabelWithTooltip(egd.Label_video_feedback, "Recording 
video.");
+                                       checkWebcamFileStarted = true;
+                               }
+                       }
+               }
+
                //check if it should finish by time
                if(shouldFinishByTime()) {
                        finish = true;
@@ -598,6 +612,12 @@ public class EventExecute
                get { return eventDone; }
        }
        
+       private bool webcamStarting = false;
+       private bool checkWebcamFileStarted = false;
+       public bool WebcamStarting {
+               set { webcamStarting = value; }
+       }
+
        // multi Chronopic stuff
        public int Chronopics { get { return chronopics; } }
 
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index c2b407ad..93a34542 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -4288,12 +4288,12 @@ public partial class ChronoJumpWindow
                if(ncams == 1 && webcamManage.RecordPrepare(preferences.videoDevice).success)
                {
                        webcamManage.RecordStart(1);
-                       label_video_feedback.Text = "Rec.";
+                       label_video_feedback.Text = "Preparing camera";
                }
                else if(ncams == 2 && webcamManage.RecordPrepare(preferences.videoDevice, 
"/dev/video1").success)
                {
                        webcamManage.RecordStart(2);
-                       label_video_feedback.Text = "Rec.";
+                       label_video_feedback.Text = "Preparing camera";
                }
                //TODO depending on errorMessage:
                //new DialogMessage(Constants.MessageTypes.WARNING, result.error);
@@ -4447,6 +4447,7 @@ public partial class ChronoJumpWindow
                //UtilGtk.ChronopicColors(viewport_chronopics, label_chronopics, label_connected_chronopics, 
chronopicWin.Connected);
 
                webcamStart (1);
+               currentEventExecute.WebcamStarting = (preferences.videoOn && webcamManage != null); //to show 
info on label_video_feedback
 
                if (! canCaptureC)
                        currentEventExecute.SimulateInitValues(rand);
@@ -4455,7 +4456,7 @@ public partial class ChronoJumpWindow
                        currentEventExecute.Manage();
                else 
                        currentEventExecute.ManageFall();
-               
+
                thisJumpIsSimple = true; //used by: on_event_execute_update_graph_in_progress_clicked
                currentEventExecute.FakeButtonUpdateGraph.Clicked += 
                        new EventHandler(on_event_execute_update_graph_in_progress_clicked);
@@ -4756,14 +4757,15 @@ public partial class ChronoJumpWindow
                
                //webcamStart (2);
                webcamStart (1);
-               
+               currentEventExecute.WebcamStarting = (preferences.videoOn && webcamManage != null); //to show 
info on label_video_feedback
+
                //suitable for limited by jump and time
                //simulated always simulate limited by jumps
                if(! canCaptureC)
                        currentEventExecute.SimulateInitValues(rand);
                
                currentEventExecute.Manage();
-               
+
                thisJumpIsSimple = false; //used by: on_event_execute_update_graph_in_progress_clicked
                currentEventExecute.FakeButtonUpdateGraph.Clicked += 
                        new EventHandler(on_event_execute_update_graph_in_progress_clicked);
@@ -4903,6 +4905,7 @@ public partial class ChronoJumpWindow
                                );
 
                webcamStart (1);
+               currentEventExecute.WebcamStarting = (preferences.videoOn && webcamManage != null); //to show 
info on label_video_feedback
 
                if (! canCaptureC)
                        currentEventExecute.SimulateInitValues(rand);
@@ -5037,6 +5040,7 @@ public partial class ChronoJumpWindow
                                );
 
                webcamStart (1);
+               currentEventExecute.WebcamStarting = (preferences.videoOn && webcamManage != null); //to show 
info on label_video_feedback
 
                //suitable for limited by tracks and time
                if(! canCaptureC)
@@ -5257,6 +5261,7 @@ public partial class ChronoJumpWindow
                                );
 
                webcamStart (1);
+               currentEventExecute.WebcamStarting = (preferences.videoOn && webcamManage != null); //to show 
info on label_video_feedback
 
                if (! canCaptureC)
                        currentEventExecute.SimulateInitValues(rand);
@@ -5416,6 +5421,7 @@ public partial class ChronoJumpWindow
                                );
                
                webcamStart (1);
+               currentEventExecute.WebcamStarting = (preferences.videoOn && webcamManage != null); //to show 
info on label_video_feedback
 
                if(! canCaptureC)
                        currentEventExecute.SimulateInitValues(rand);
@@ -5703,6 +5709,7 @@ public partial class ChronoJumpWindow
                                );
 
                webcamStart (1);
+               currentEventExecute.WebcamStarting = (preferences.videoOn && webcamManage != null); //to show 
info on label_video_feedback
 
                //mark to only get inside on_multi_chronopic_finished one time
                multiFinishing = false;
@@ -6114,7 +6121,7 @@ LogB.Debug("mc finished 5");
         */
 
        //TODO: manage different playVideo. Playing is very different than capturing, separate it.
-       Webcam webcam;
+       Webcam webcamPlay;
 
        private void on_button_video_preview_clicked (object o, EventArgs args)
        {
@@ -6123,8 +6130,8 @@ LogB.Debug("mc finished 5");
        private void playPreview ()
        {
                //constructor for playpreview
-               webcam = new WebcamFfmpeg (Webcam.Action.PLAYPREVIEW, UtilAll.GetOSEnum(), 
preferences.videoDevice);
-               Webcam.Result result = webcam.PlayPreview ();
+               webcamPlay = new WebcamFfmpeg (Webcam.Action.PLAYPREVIEW, UtilAll.GetOSEnum(), 
preferences.videoDevice);
+               Webcam.Result result = webcamPlay.PlayPreview ();
        }
 
        private void on_button_video_debug_clicked (object o, EventArgs args)
@@ -6142,8 +6149,8 @@ LogB.Debug("mc finished 5");
        private void playVideo (string fileName)
        {
                //constructor for playpreview
-               webcam = new WebcamFfmpeg (Webcam.Action.PLAYFILE, UtilAll.GetOSEnum(), "");
-               Webcam.Result result = webcam.PlayFile (fileName);
+               webcamPlay = new WebcamFfmpeg (Webcam.Action.PLAYFILE, UtilAll.GetOSEnum(), "");
+               Webcam.Result result = webcamPlay.PlayFile (fileName);
 
                /*
                 * TODO: reimplement this with ffmpeg
diff --git a/src/gui/eventExecute.cs b/src/gui/eventExecute.cs
index 5847dc31..b4bd3567 100644
--- a/src/gui/eventExecute.cs
+++ b/src/gui/eventExecute.cs
@@ -251,6 +251,7 @@ public partial class ChronoJumpWindow
                                event_execute_button_cancel, event_execute_button_finish, 
                                event_execute_label_message,  
                                event_execute_label_event_value,  event_execute_label_time_value,
+                               label_video_feedback,
                                event_execute_progressbar_event,  event_execute_progressbar_time);
                
                return executingGraphData;
diff --git a/src/gui/usefulObjects.cs b/src/gui/usefulObjects.cs
index 10e9db91..f19285af 100644
--- a/src/gui/usefulObjects.cs
+++ b/src/gui/usefulObjects.cs
@@ -31,6 +31,7 @@ public class ExecutingGraphData
        public Gtk.Label Label_message;
        public Gtk.Label Label_event_value;
        public Gtk.Label Label_time_value;
+       public Gtk.Label Label_video_feedback;
        public Gtk.ProgressBar Progressbar_event;
        public Gtk.ProgressBar Progressbar_time;
        
@@ -38,6 +39,7 @@ public class ExecutingGraphData
                        Gtk.Button Button_cancel, Gtk.Button Button_finish, 
                        Gtk.Label Label_message,
                        Gtk.Label Label_event_value, Gtk.Label Label_time_value,
+                       Gtk.Label Label_video_feedback,
                        Gtk.ProgressBar Progressbar_event, Gtk.ProgressBar Progressbar_time) 
        {
                this.Button_cancel =  Button_cancel;
@@ -45,6 +47,7 @@ public class ExecutingGraphData
                this.Label_message =  Label_message;
                this.Label_event_value =  Label_event_value;
                this.Label_time_value =  Label_time_value;
+               this.Label_video_feedback = Label_video_feedback;
                this.Progressbar_event =  Progressbar_event;
                this.Progressbar_time =  Progressbar_time;
        }
diff --git a/src/webcam.cs b/src/webcam.cs
index c51ff555..191df103 100644
--- a/src/webcam.cs
+++ b/src/webcam.cs
@@ -271,4 +271,10 @@ public class WebcamManage
        {
                return webcam.ExitAndFinish (sessionID, testType, testID);
        }
+
+       public static bool RecordingFileStarted ()
+       {
+               FileInfo file = new FileInfo(Util.GetVideoTempFileName());
+               return (file.Exists && file.Length > 0);
+       }
 }
diff --git a/src/webcamFfmpeg.cs b/src/webcamFfmpeg.cs
index e2f9a069..b41769bd 100644
--- a/src/webcamFfmpeg.cs
+++ b/src/webcamFfmpeg.cs
@@ -131,6 +131,9 @@ public class WebcamFfmpeg : Webcam
 
        public override Result VideoCaptureStart()
        {
+               //Delete temp video if exists
+               deleteTempFiles();
+
                process = new Process();
                List<string> parameters = createParametersOnlyCapture();
                //List<string> parameters = createParametersCaptureAndDelayedView();


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