コード例 #1
0
// Called when the presentation clock stops.
HRESULT STDMETHODCALLTYPE EVRCustomPresenter::OnClockStop(MFTIME hnssSystemTime)
{
  Log("EVRCustomPresenter::OnClockStop");

  HRESULT hr = S_OK;

  CAutoLock lock(this);

  // We cannot stop after shutdown
  hr = CheckShutdown();
  CHECK_HR(hr, "EVRCustomPresenter::OnClockStop cannot stop after shutdown");

  // set render state to stop and flush queue
  if (m_RenderState != RENDER_STATE_STOPPED)
  {
    m_RenderState = RENDER_STATE_STOPPED;
    Flush();

    // If we are in the middle of frame-stepping, cancel it now.
    if (m_FrameStep.state != FRAMESTEP_NONE)
    {
      CancelFrameStep();
    }
  }

  return hr;
}
コード例 #2
0
// Called when the rate changes on the presentation clock.
HRESULT STDMETHODCALLTYPE EVRCustomPresenter::OnClockSetRate(MFTIME hnsSystemTime, float fRate)
{
  Log("EVRCustomPresenter::OnClockSetRate (rate=%f)", fRate);

  HRESULT hr = S_OK;

  CAutoLock lock(this);

  // We cannot set the rate after shutdown.
  hr = CheckShutdown();
  CHECK_HR(hr, "EVRCustomPresenter::OnClockRestart cannot set rate after shutdown");

  // If the rate is changing from zero (scrubbing) to non-zero, cancel the frame-step operation.
  if ((m_fRate == 0.0f) && (fRate != 0.0f))
  {
    CancelFrameStep();
    m_FrameStep.samples.Clear();
  }

  m_fRate = fRate;

  // Tell the scheduler about the new rate.
  m_scheduler.SetClockRate(fRate);

  return hr;
}
コード例 #3
0
// Sends a message to the video presenter.
HRESULT STDMETHODCALLTYPE EVRCustomPresenter::ProcessMessage(MFVP_MESSAGE_TYPE eMessage, ULONG_PTR ulParam)
{
  // Albert: Don't produce so much log output
  //Log("EVRCustomPresenter::ProcessMessage");

  HRESULT hr = S_OK;

  CAutoLock lock(this);

  hr = CheckShutdown();
  CHECK_HR(hr, "EVRCustomPresenter::ProcessMessage presenter is shutdown");

  switch (eMessage)
  {
    // Flush all pending samples.
    case MFVP_MESSAGE_FLUSH:
      Log("ProcessMessage: MFVP_MESSAGE_FLUSH");
      hr = Flush();
    break;

    // Renegotiate the media type with the mixer.
    case MFVP_MESSAGE_INVALIDATEMEDIATYPE:
      Log("ProcessMessage: MFVP_MESSAGE_INVALIDATEMEDIATYPE");
      hr = RenegotiateMediaType();
    break;

    // The mixer received a new input sample. 
    case MFVP_MESSAGE_PROCESSINPUTNOTIFY:
      // Albert: Don't produce so much log output
      //Log("ProcessMessage: MFVP_MESSAGE_PROCESSINPUTNOTIFY");
      hr = ProcessInputNotify();
    break;

    // Streaming is about to start.
    case MFVP_MESSAGE_BEGINSTREAMING:
      Log("ProcessMessage: MFVP_MESSAGE_BEGINSTREAMING");
      hr = BeginStreaming();
    break;

    // Streaming has ended. (The EVR has stopped.)
    case MFVP_MESSAGE_ENDSTREAMING:
      Log("ProcessMessage: MFVP_MESSAGE_ENDSTREAMING");
      hr = EndStreaming();
    break;

    // All input streams have ended.
    case MFVP_MESSAGE_ENDOFSTREAM:
      Log("ProcessMessage: MFVP_MESSAGE_ENDOFSTREAM");
      // Set the end of stream flag. 
      m_bEndStreaming = TRUE; 
      // Check if it's time to send the EC_COMPLETE event to the EVR.
      hr = CheckEndOfStream();
    break;

    // Frame-stepping is starting.
    case MFVP_MESSAGE_STEP:
      Log("ProcessMessage: MFVP_MESSAGE_STEP");
      hr = PrepareFrameStep(LODWORD(ulParam));
    break;

    // Cancels frame-stepping.
    case MFVP_MESSAGE_CANCELSTEP:
      Log("ProcessMessage: MFVP_MESSAGE_CANCELSTEP");
      hr = CancelFrameStep();
    break;

    // Unknown message. (This case should never occur.)
    default:
      Log("ProcessMessage: Unknown Message");
      hr = E_INVALIDARG;
    break;
  }

  return hr;
}