private bool TestCapturing() { if (this.dxCapture == null) { return(false); } try { //string temp = System.IO.Path.GetTempFileName(); //this.DxCapture.Filename = temp; this.dxCapture.Start(); } catch (Exception) { return(false); } finally { this.dxCapture.Stop(); this.dxCapture.Dispose(); this.dxCapture = null; } return(true); }
/// <summary> /// Releases the resources used by the DXcapture object /// </summary> public void DisposeDxCapture() { if (this.dxCapture != null) { this.dxCapture.Dispose(); this.dxCapture = null; } }
/// <summary> /// This method creates a new <see cref="DXCapture"/> /// with the given <see cref="CaptureDeviceProperties"/> /// </summary> /// <param name="captureProperties">A <see cref="CaptureDeviceProperties"/> /// to use for creating the underlying <see cref="DXCapture"/></param> private void InitializeWebcam(CaptureDeviceProperties captureProperties) { if (this.DesignMode) { return; } if (captureProperties == null) { // We dont want to initialize a webcam return; } if (captureProperties.VideoInputDevice.Name == "OgamaScreenCapture Filter") { // We dont want to initialize a webcam with the // ScreenCapture Filter return; } if (this.dxCapture != null) { this.dxCapture.Dispose(); } // If this control is attached use itself for previewing // otherwise use the given preview window if (this.Parent != null) { captureProperties.PreviewWindow = this; } this.dxCapture = new DXCapture(captureProperties); // Check the current valid CaptureMode //CaptureMode available = CaptureMode.None; //if ((captureProperties.CaptureMode & CaptureMode.Video) == CaptureMode.VideoPreview) //{ // available |= CaptureMode.Video; //} //if (audioDevice != null) //{ // available |= CaptureMode.Audio; //} this.OnWebcamAvailable(new CaptureModeEventArgs(captureProperties.CaptureMode)); }
private void RebuildDXCapture(CaptureDeviceProperties captureProperties) { if (this.dxCapture != null) { this.dxCapture.Dispose(); } if (!this.DesignMode)//this.shouldPreview && { captureProperties.PreviewWindow = this.panelPreview; } else { captureProperties.PreviewWindow = null; } this.dxCapture = new DXCapture(captureProperties); this.dxCapture.ShowPreviewWindow(); //this.dxCapture.Start(); }
/// <summary> /// The <see cref="Form.FormClosing"/> event handler of the parent form. /// Gets called when the parent form is closed. /// Has been wired in overridden <see cref="OnCreateControl()"/>. /// Stops the webcam control, to free video stream. /// </summary> /// <param name="sender">Source of the event.</param> /// <param name="e">A <see cref="FormClosingEventArgs"/> with the event data.</param> private void ParentForm_FormClosing(object sender, FormClosingEventArgs e) { this.UpdateProperties(); // Only if the purpose is recording, test the capturing //if (this.shouldPreview) { Form parent = (Form)sender; if (parent.DialogResult == DialogResult.OK && !this.dxCapture.HasValidGraph) { e.Cancel = true; string message = "Sorry, Ogama cannot initialize the capturing, " + Environment.NewLine + "please try using other compressors or devices."; MessageBox.Show(message, Application.ProductName); return; } } if (this.dxCapture != null) { this.dxCapture.Dispose(); this.dxCapture = null; } }
/////////////////////////////////////////////////////////////////////////////// // Defining Constants // /////////////////////////////////////////////////////////////////////////////// #region CONSTANTS #endregion //CONSTANTS /////////////////////////////////////////////////////////////////////////////// // Defining Variables, Enumerations, Events // /////////////////////////////////////////////////////////////////////////////// #region FIELDS #endregion //FIELDS /////////////////////////////////////////////////////////////////////////////// // Construction and Initializing methods // /////////////////////////////////////////////////////////////////////////////// #region CONSTRUCTION /// <summary> /// Initializes a new instance of the WebcamPropertiesDlg class. /// </summary> public WebcamPropertiesDlg(DXCapture capture) { InitializeComponent(); this.dsVideoProperties.DxCapture = capture; }
private bool TestCapturing() { if (this.dxCapture == null) { return false; } try { //string temp = System.IO.Path.GetTempFileName(); //this.DxCapture.Filename = temp; this.dxCapture.Start(); } catch (Exception) { return false; } finally { this.dxCapture.Stop(); this.dxCapture.Dispose(); this.dxCapture = null; } return true; }