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
private bool webcamStarting = false;
private bool checkWebcamFileStarted = false;
public bool WebcamStarting {
get { return webcamStarting; }
set { webcamStarting = value; }
}
......
......@@ -5739,8 +5739,7 @@ public partial class ChronoJumpWindow
if(action == encoderActions.CAPTURE)
{
webcamManage = new WebcamManage();
bool camStarted = webcamStart (WebcamManage.GuiContactsEncoder.ENCODER, 1);
if(camStarted)
if(webcamStart (WebcamManage.GuiContactsEncoder.ENCODER, 1))
webcamEncoderFileStarted = WebcamEncoderFileStarted.NEEDTOCHECK;
else
webcamEncoderFileStarted = WebcamEncoderFileStarted.NOCAMERA;
......
......@@ -107,16 +107,24 @@ public partial class ChronoJumpWindow
button_video_preview_visibile (guiContactsEncoder, false);
string errorMessage = "";
if(ncams == 1 && webcamManage.RecordPrepare(preferences.videoDevice, preferences.videoDeviceResolution, preferences.videoDeviceFramerate).success)
if(ncams == 1)
{
webcamManage.RecordStart(1);
//label_video_feedback.Text = "Preparing camera";
if(! webcamManage.RecordPrepare(preferences.videoDevice, preferences.videoDeviceResolution, preferences.videoDeviceFramerate).success)
return false;
if(! webcamManage.RecordStart(1))
return false;
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);
//label_video_feedback.Text = "Preparing camera";
if(! webcamManage.RecordPrepare(preferences.videoDevice, "/dev/video1", preferences.videoDeviceResolution, preferences.videoDeviceFramerate).success)
return false;
if(! webcamManage.RecordStart(2))
return false;
label_video_feedback_text (guiContactsEncoder, "Preparing camera");
}
//TODO depending on errorMessage:
......@@ -218,6 +226,9 @@ public partial class ChronoJumpWindow
//can pass a -1 uniqueID if test is cancelled
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;
if(testType == Constants.TestTypes.ENCODER)
{
......
......@@ -225,15 +225,15 @@ public class WebcamManage
return result;
}
public void RecordStart (int ncams)
public bool RecordStart (int ncams)
{
recordStartDo (ref webcam);
return recordStartDo (ref webcam);
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)
......
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