Skip to content

Latest commit

 

History

History
215 lines (178 loc) · 6.66 KB

nf-mfobjects-imfmediaeventgenerator-begingetevent.md

File metadata and controls

215 lines (178 loc) · 6.66 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:mfobjects.IMFMediaEventGenerator.BeginGetEvent
IMFMediaEventGenerator::BeginGetEvent (mfobjects.h)
Begins an asynchronous request for the next event in the queue.
BeginGetEvent
BeginGetEvent method [Media Foundation]
BeginGetEvent method [Media Foundation]
IMFMediaEventGenerator interface
IMFMediaEventGenerator interface [Media Foundation]
BeginGetEvent method
IMFMediaEventGenerator.BeginGetEvent
IMFMediaEventGenerator::BeginGetEvent
a2afddac-46e9-4928-8b5b-44f3fc7c33d3
mf.imfmediaeventgenerator_begingetevent
mfobjects/IMFMediaEventGenerator::BeginGetEvent
mf\imfmediaeventgenerator_begingetevent.htm
mf
a2afddac-46e9-4928-8b5b-44f3fc7c33d3
12/05/2018
BeginGetEvent, BeginGetEvent method [Media Foundation], BeginGetEvent method [Media Foundation],IMFMediaEventGenerator interface, IMFMediaEventGenerator interface [Media Foundation],BeginGetEvent method, IMFMediaEventGenerator.BeginGetEvent, IMFMediaEventGenerator::BeginGetEvent, a2afddac-46e9-4928-8b5b-44f3fc7c33d3, mf.imfmediaeventgenerator_begingetevent, mfobjects/IMFMediaEventGenerator::BeginGetEvent
mfobjects.h
Mfidl.h
Windows
Windows Vista [desktop apps \| UWP apps]
Windows Server 2008 [desktop apps \| UWP apps]
Mfuuid.lib
Windows
19H1
IMFMediaEventGenerator::BeginGetEvent
mfobjects/IMFMediaEventGenerator::BeginGetEvent
c++
APIRef
kbSyntax
COM
mfuuid.lib
mfuuid.dll
IMFMediaEventGenerator.BeginGetEvent

IMFMediaEventGenerator::BeginGetEvent

-description

Begins an asynchronous request for the next event in the queue.

-parameters

-param pCallback [in]

Pointer to the IMFAsyncCallback interface of a callback object. The client must implement this interface.

-param punkState [in]

Pointer to the IUnknown interface of a state object, defined by the caller. This parameter can be NULL. You can use this object to hold state information. The object is returned to the caller when the callback is invoked.

-returns

The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.

Return code Description
S_OK
The method succeeded.
E_INVALIDARG
NULL pointer argument.
MF_E_MULTIPLE_BEGIN
There is a pending request with the same callback pointer and a different state object.
MF_E_MULTIPLE_SUBSCRIBERS
There is a pending request with a different callback pointer.
MF_E_SHUTDOWN
The object was shut down.
MF_S_MULTIPLE_BEGIN
There is a pending request with the same callback pointer and state object.

-remarks

When a new event is available, the event generator calls the IMFAsyncCallback::Invoke method. The Invoke method should call IMFMediaEventGenerator::EndGetEvent to get a pointer to the IMFMediaEvent interface, and use that interface to examine the event.

Do not call BeginGetEvent a second time before calling EndGetEvent. While the first call is still pending, additional calls to the same object will fail. Also, the IMFMediaEventGenerator::GetEvent method fails if an asynchronous request is still pending.

Examples

The following code shows a typical implementation of IMFAsyncCallback::Invoke for the BeginGetEvent method. The Invoke method calls EndGetEvent to get the event data. Then it calls BeginGetEvent again to request another event.

//////////////////////////////////////////////////////////////////////
//  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;
}

-see-also

IMFMediaEventGenerator

Media Event Generators