Commit e0032699 authored by Xavier de Blas's avatar Xavier de Blas

minor improvements on webcam start/stop

parent a13702fb
...@@ -615,6 +615,7 @@ public class EventExecute ...@@ -615,6 +615,7 @@ public class EventExecute
private bool webcamStarting = false; private bool webcamStarting = false;
private bool checkWebcamFileStarted = false; private bool checkWebcamFileStarted = false;
public bool WebcamStarting { public bool WebcamStarting {
get { return webcamStarting; }
set { webcamStarting = value; } set { webcamStarting = value; }
} }
......
...@@ -5739,8 +5739,7 @@ public partial class ChronoJumpWindow ...@@ -5739,8 +5739,7 @@ public partial class ChronoJumpWindow
if(action == encoderActions.CAPTURE) if(action == encoderActions.CAPTURE)
{ {
webcamManage = new WebcamManage(); webcamManage = new WebcamManage();
bool camStarted = webcamStart (WebcamManage.GuiContactsEncoder.ENCODER, 1); if(webcamStart (WebcamManage.GuiContactsEncoder.ENCODER, 1))
if(camStarted)
webcamEncoderFileStarted = WebcamEncoderFileStarted.NEEDTOCHECK; webcamEncoderFileStarted = WebcamEncoderFileStarted.NEEDTOCHECK;
else else
webcamEncoderFileStarted = WebcamEncoderFileStarted.NOCAMERA; webcamEncoderFileStarted = WebcamEncoderFileStarted.NOCAMERA;
......
...@@ -107,16 +107,24 @@ public partial class ChronoJumpWindow ...@@ -107,16 +107,24 @@ public partial class ChronoJumpWindow
button_video_preview_visibile (guiContactsEncoder, false); button_video_preview_visibile (guiContactsEncoder, false);
string errorMessage = ""; string errorMessage = "";
if(ncams == 1 && webcamManage.RecordPrepare(preferences.videoDevice, preferences.videoDeviceResolution, preferences.videoDeviceFramerate).success) if(ncams == 1)
{ {
webcamManage.RecordStart(1); if(! webcamManage.RecordPrepare(preferences.videoDevice, preferences.videoDeviceResolution, preferences.videoDeviceFramerate).success)
//label_video_feedback.Text = "Preparing camera"; return false;
if(! webcamManage.RecordStart(1))
return false;
label_video_feedback_text (guiContactsEncoder, "Preparing camera"); label_video_feedback_text (guiContactsEncoder, "Preparing camera");
} }
else if(ncams == 2 && webcamManage.RecordPrepare(preferences.videoDevice, "/dev/video1", preferences.videoDeviceResolution, preferences.videoDeviceFramerate).success) else if(ncams == 2)
{ {
webcamManage.RecordStart(2); if(! webcamManage.RecordPrepare(preferences.videoDevice, "/dev/video1", preferences.videoDeviceResolution, preferences.videoDeviceFramerate).success)
//label_video_feedback.Text = "Preparing camera"; return false;
if(! webcamManage.RecordStart(2))
return false;
label_video_feedback_text (guiContactsEncoder, "Preparing camera"); label_video_feedback_text (guiContactsEncoder, "Preparing camera");
} }
//TODO depending on errorMessage: //TODO depending on errorMessage:
...@@ -218,6 +226,9 @@ public partial class ChronoJumpWindow ...@@ -218,6 +226,9 @@ public partial class ChronoJumpWindow
//can pass a -1 uniqueID if test is cancelled //can pass a -1 uniqueID if test is cancelled
private void webcamEnd (Constants.TestTypes testType, int uniqueID) private void webcamEnd (Constants.TestTypes testType, int uniqueID)
{ {
if(! currentEventExecute.WebcamStarting) //no need to stop camera because it is not recording
return;
WebcamManage.GuiContactsEncoder guiContactsEncoder = WebcamManage.GuiContactsEncoder.CONTACTS; WebcamManage.GuiContactsEncoder guiContactsEncoder = WebcamManage.GuiContactsEncoder.CONTACTS;
if(testType == Constants.TestTypes.ENCODER) if(testType == Constants.TestTypes.ENCODER)
{ {
......
...@@ -225,15 +225,15 @@ public class WebcamManage ...@@ -225,15 +225,15 @@ public class WebcamManage
return result; return result;
} }
public void RecordStart (int ncams) public bool RecordStart (int ncams)
{ {
recordStartDo (ref webcam); return recordStartDo (ref webcam);
if(ncams > 1) if(ncams > 1)
recordStartDo (ref webcam2); return recordStartDo (ref webcam2);
} }
private void recordStartDo (ref Webcam webcam) private bool recordStartDo (ref Webcam webcam)
{ {
webcam.VideoCaptureStart(); return webcam.VideoCaptureStart().success;
} }
public Webcam.Result RecordEnd(int ncam) public Webcam.Result RecordEnd(int ncam)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment