Microsoft Windows CE 3.0  

IMediaEvent Interface

Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The IMediaEventinterface supports event notification from the filter graph and filters within it to the application. It is decoupled by using a queuing scheme rather than callbacks, because events can be notified from worker threads that cannot safely call back into application code.

An event code and two DWORDvalues represent event notification information. Your application can use this for typical completion of asynchronous operations, errors that occur during asynchronous operation, or user-initiated events, such as when a user clicks a hot spot.

Filters within the filter graph and the filter graph itself raise event notifications. Possible events include playback completion or asynchronous playback errors. In addition, the filter graph provides a method to generate events at specific reference clock times. The filter graph exposes an IMediaEventSinkinterface that the filters within the graph can call to pass event notifications to the application.

Event notifications are placed in a queue. An application calls the IMediaEvent::GetEventmethod to retrieve the next notification from the queue. This method blocks until there is an event to return. The GetEventtime-out parameter ( msTimeout) allows the application to specify the time, in milliseconds, to wait for an event, including values of zero and INFINITE. After calling GetEvent, applications should always call FreeEventParamsto release any resource associated with the event.

In addition, applications can retrieve the event handle. IMediaEvent::GetEventHandlereturns a handle to a manual-reset event created by the Microsoft Win32 CreateEventfunction. This event is in a signaled state as long as there are event notifications to collect. The IMediaEvent::GetEventmethod clears the event when there are no more event notifications to collect. This enables an application to use an application programming interface (API), such as MsgWaitForMultipleObjects, to wait for events and other occurrences at the same time. This event handle will be closed when the filter graph is released; therefore, applications should ensure that they are not using it after this point.

The filter graph manager handles some events raised by filters that are not passed to the application. One example of this is the EC_REPAINTevent notification. By default the filter graph manager handles this event by pausing the filter graph and repainting the video renderer's static images. An application can override default handling for a specific event by calling the IMediaEvent::CancelDefaultHandlingmethod with the event value as a parameter. The IMediaEvent::RestoreDefaultHandlingmethod reinstates default handling for the specified event value. These methods have no effect on events that have no default handling.

If an error occurs during the transition to a running state on any filter, the IMediaControl::Runmethod returns an error value. In this case, some filters within the graph might be running successfully. The filter graph leaves it up to the application to determine whether to stop the graph in case of an error. After the IMediaControl::Runmethod has returned, event notifications report any additional errors. The EC_ERRORABORTand EC_USERABORTevent notifications indicate that playback has probably stopped in the graph (certainly in the filter that reported it). Other errors and events indicate that it is still running. Note, however, that in all cases the graph remains in running mode until the application explicitly changes it to stopped or paused mode.

If the streams in the filter graph detect the end of the stream, the streams report this by using the EC_COMPLETEevent notification. The filter graph manager asks filters if they can report EC_COMPLETE by means of seekable renderers.

A seekable renderer is one that supports the IMediaPositioninterface from the filter and that has only input pins, or whose input pins report through IPin::QueryInternalConnectionsthat they are rendered. The filter graph uses IPin::QueryInternalConnectionsand IMediaPositionto detect seekable renderers. A seekable renderer should report EC_COMPLETEwhen all seekable streams on that filter have reached the stream's end.

A renderer can produce EC_COMPLETE(and a regular filter produce EndOfStream) for one of four reasons as follows: