Esempio n. 1
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="pGroup">Timeline group info</param>
    /// <param name="pCallback">Client callback</param>
    /// <param name="pEventSink">Event sync to call on file complete</param>
    /// <param name="ec">Event code to send on file completion</param>
    public AVCallback(
        MediaGroup pGroup,
        IDESCombineCB pCallback,
        IMediaEventSink pEventSink,
        EventCode ec
        )
    {
      m_pCallback = pCallback;
      m_Group = pGroup;
      m_pEventSink = pEventSink;
      m_ec = ec;

      m_iCurFrame = 0;
      m_iCurFile = 0;
      MediaFile mf = m_Group.File(m_iCurFile);
      if (mf != null)
      {
        m_CurFileName = mf.FileName;
        m_iMaxFrame = mf.LengthInFrames;
      }
      else
      {
        m_CurFileName = null;
        m_iMaxFrame = int.MaxValue;
      }
    }
Esempio n. 2
0
    /// <summary>
    /// Construct the class
    /// </summary>
    /// <remarks>
    /// The input files do not need to have the same height/width/fps.  DES will
    /// automatically convert them all to the values specified by the constructor.
    /// </remarks>
    /// <param name="FPS">Frames per second (commonly 15 or 30)</param>
    /// <param name="BitCount">Color depth: 16, 24 or 32</param>
    /// <param name="Width">Frame width (commonly 320, 640, etc)</param>
    /// <param name="Height">Frame height (commonly 240, 480, etc)</param>
    /// <param name="audio">support only audio files</param>
    /// <param name="video">support only video files</param>
    public DESCombine(double FPS, short BitCount, int Width, int Height, bool audio, bool video)
    {
      threadCompleted = true;

      // Initialize the data members
      m_State = ClassState.Constructed;

      // Create the timeline
      m_pTimeline = (IAMTimeline)new AMTimeline();

      // Set the frames per second
      int hr = m_pTimeline.SetDefaultFPS(FPS);
      DESError.ThrowExceptionForHR(hr);

      supportAudio = audio;
      supportVideo = video;

      if (supportVideo)
      {
        // Init the video group
        m_Video = new MediaGroup(GetVideoMediaType(BitCount, Width, Height), m_pTimeline, FPS);
      }

      if (supportAudio)
      {
        // Init the audio group
        m_Audio = new MediaGroup(GetAudioMediaType(), m_pTimeline, FPS);
      }

      this.ThreadFinished += new EventHandler(DESCombine_ThreadFinished);
    }
Esempio n. 3
0
    /// <summary>
    /// Release resources used by the class.
    /// </summary>
    /// <remarks>May fire events, so do not call from Form.Dispose().</remarks>
    public void Dispose()
    {
      GC.SuppressFinalize(this);

      this.ThreadFinished -= new EventHandler(DESCombine_ThreadFinished);

      if (m_Video != null)
      {
        m_Video.Dispose();
        m_Video = null;
      }
      if (m_Audio != null)
      {
        m_Audio.Dispose();
        m_Audio = null;
      }

      if (m_pTimeline != null)
      {
        Marshal.ReleaseComObject(m_pTimeline);
        m_pTimeline = null;
      }

      if (m_pRenderEngine != null)
      {
        Marshal.ReleaseComObject(m_pRenderEngine);
        m_pRenderEngine = null;
      }

#if DEBUG
      if (m_rot != null)
      {
        m_rot.Dispose();
        m_rot = null;
      }
#endif
      if (m_pControl != null)
      {
        m_pControl.Stop();
        m_pControl = null;
      }

      if (m_pGraph != null)
      {
        // End event thread.
        int hr = ((IMediaEventSink)this.m_pGraph).Notify(EventCode.UserAbort, IntPtr.Zero, IntPtr.Zero);
        DsError.ThrowExceptionForHR(hr);

        while (!threadCompleted)
        {
          Thread.Sleep(2);
        }

        Marshal.ReleaseComObject(m_pGraph);
        m_pGraph = null;
      }

      // No point in calling us from the Finalizer, we're already gone
      GC.SuppressFinalize(this);
    }