IMFMediaEventGenerator::BeginGetEvent 메서드(mfobjects.h)

큐의 다음 이벤트에 대한 비동기 요청을 시작합니다.

구문

HRESULT BeginGetEvent(
  [in] IMFAsyncCallback *pCallback,
  [in] IUnknown         *punkState
);

매개 변수

[in] pCallback

콜백 개체의 IMFAsyncCallback 인터페이스에 대한 포인터입니다. 클라이언트는 이 인터페이스를 구현해야 합니다.

[in] punkState

호출자가 정의한 상태 개체의 IUnknown 인터페이스에 대한 포인터입니다. 이 매개 변수는 NULL일 수 있습니다. 이 개체를 사용하여 상태 정보를 저장할 수 있습니다. 콜백이 호출될 때 개체가 호출자에게 반환됩니다.

반환 값

이 메서드는 HRESULT를 반환합니다. 가능한 값에는 다음 표에 있는 값이 포함되지만, 이에 국한되는 것은 아닙니다.

반환 코드 Description
S_OK
메서드가 성공했습니다.
E_INVALIDARG
NULL 포인터 인수입니다.
MF_E_MULTIPLE_BEGIN
동일한 콜백 포인터와 다른 상태 개체가 있는 보류 중인 요청이 있습니다.
MF_E_MULTIPLE_SUBSCRIBERS
다른 콜백 포인터가 있는 보류 중인 요청이 있습니다.
MF_E_SHUTDOWN
개체가 종료되었습니다.
MF_S_MULTIPLE_BEGIN
동일한 콜백 포인터 및 상태 개체가 있는 보류 중인 요청이 있습니다.

설명

새 이벤트를 사용할 수 있는 경우 이벤트 생성기는 IMFAsyncCallback::Invoke 메서드를 호출합니다. Invoke 메서드는 IMFMediaEventGenerator::EndGetEvent를 호출하여 IMFMediaEvent 인터페이스에 대한 포인터를 가져와서 해당 인터페이스를 사용하여 이벤트를 검사해야 합니다.

EndGetEvent를 호출하기 전에 BeginGetEvent를 두 번째로 호출하지 마세요. 첫 번째 호출이 아직 보류 중인 동안 동일한 개체에 대한 추가 호출이 실패합니다. 또한 비동기 요청이 아직 보류 중인 경우 IMFMediaEventGenerator::GetEvent 메서드가 실패합니다.

예제

다음 코드는 BeginGetEvent 메서드에 대한 IMFAsyncCallback::Invoke의 일반적인 구현을 보여줍니다. Invoke 메서드는 EndGetEvent를 호출하여 이벤트 데이터를 가져옵니다. 그런 다음 BeginGetEvent를 다시 호출하여 다른 이벤트를 요청합니다.

//////////////////////////////////////////////////////////////////////
//  Name: CEventHandler::Invoke
//  Callback for asynchronous BeginGetEvent method.
//
//  pAsyncResult: Pointer to the result.
//
//  This code example assumes that CEventHandler is a class that 
//  implements the IMFAsyncCallback interface. 
///////////////////////////////////////////////////////////////////////
HRESULT CEventHandler::Invoke(IMFAsyncResult *pAsyncResult)
{
    HRESULT hr = S_OK;
    IMFMediaEvent* pEvent = NULL;
    MediaEventType meType = MEUnknown;
    BOOL fGetAnotherEvent = TRUE;
    HRESULT hrStatus = S_OK;

    // Get the event from the event queue.
    // Assume that m_pEventGenerator is a valid pointer to the
    // event generator's IMFMediaEventGenerator interface.
    hr = m_pEventGenerator->EndGetEvent(pAsyncResult, &pEvent);

    // Get the event type.
    if (SUCCEEDED(hr))
    {
        hr = pEvent->GetType(&meType);
    }

    // Get the event status. If the operation that triggered the event 
    // did not succeed, the status is a failure code.
    if (SUCCEEDED(hr))
    {
        hr = pEvent->GetStatus(&hrStatus);
    }

    if (SUCCEEDED(hr))
    {
        // TODO: Handle the event.
    }

    // If not finished, request another event.
    // Pass in a pointer to this instance of the application's
    // CEventHandler class, which implements the callback.
    if (fGetAnotherEvent)
    {
        hr = m_pEventGenerator->BeginGetEvent(this, NULL);
    }

    SAFE_RELEASE(pEvent);
    return hr;
}

요구 사항

요구 사항
지원되는 최소 클라이언트 Windows Vista [데스크톱 앱 | UWP 앱]
지원되는 최소 서버 Windows Server 2008 [데스크톱 앱 | UWP 앱]
대상 플랫폼 Windows
헤더 mfobjects.h(Mfidl.h 포함)
라이브러리 Mfuuid.lib

추가 정보

IMFMediaEventGenerator

미디어 이벤트 생성기