コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: Webcam.cs プロジェクト: zhjh-stack/ogama
 /// <summary>
 /// Releases the resources used by the DXcapture object
 /// </summary>
 public void DisposeDxCapture()
 {
     if (this.dxCapture != null)
     {
         this.dxCapture.Dispose();
         this.dxCapture = null;
     }
 }
コード例 #3
0
ファイル: Webcam.cs プロジェクト: zhjh-stack/ogama
        /// <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));
        }
コード例 #4
0
        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();
        }
コード例 #5
0
        /// <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;
            }
        }
コード例 #6
0
ファイル: WebcamPropertiesDlg.cs プロジェクト: DeSciL/Ogama
    ///////////////////////////////////////////////////////////////////////////////
    // 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;
    }
コード例 #7
0
ファイル: DSVideoProperties.cs プロジェクト: DeSciL/Ogama
    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();
    }
コード例 #8
0
ファイル: DSVideoProperties.cs プロジェクト: DeSciL/Ogama
    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;
    }
コード例 #9
0
ファイル: DSVideoProperties.cs プロジェクト: DeSciL/Ogama
    /// <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;
      }
    }
コード例 #10
0
        ///////////////////////////////////////////////////////////////////////////////
        // 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;
        }
コード例 #11
0
ファイル: Webcam.cs プロジェクト: DeSciL/Ogama
    /// <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));
    }
コード例 #12
0
ファイル: Webcam.cs プロジェクト: DeSciL/Ogama
 /// <summary>
 /// Releases the resources used by the DXcapture object
 /// </summary>
 public void DisposeDxCapture()
 {
   if (this.dxCapture != null)
   {
     this.dxCapture.Dispose();
     this.dxCapture = null;
   }
 }