Generating New Samples
This section describes how source filters generate media samples.
Push Model
In the push model, the source filter initiates the process, as follows:
- The source filter calls IMemAllocator::GetBuffer to retrieve an empty media sample.
- The source filter fills the media sample with data. How this occurs depends entirely on the nature of the source.
- The source filter calls IMemInputPin::Receive on the downstream input pin, passing it a pointer to the sample's IMediaSample interface.
- The downstream filter can either process the sample before returning from Receive, or else hold the sample and process it afterward. If the downstream filter holds the sample, it calls IUnknown::AddRef on the sample.
- The source filter calls IUnknown::Release on the sample.
At this point, the downstream filter might hold a reference count on the sample, so the source filter cannot simply re-use the sample. To deliver the next sample, it must call IMemAlloctor::GetBuffer again, as described in step 1.
Note To deliver multiple samples, in step 3 the source filter could call IMemInputPin::ReceiveMultiple instead.
Pull Model
In the pull model, the parser filter requests data from the source filter. The parser filter uses the IAsyncReader interface on the source filter's output pin, as follows:
- The parser filter calls IMemAllocator::GetBuffer to retrieve an empty media sample.
- It calls IAsyncReader::Request to request data from the source filter.
- While the source filter is retrieving the data, the parser calls IAsyncReader::WaitForNext. This method waits until the request from step 2 is completed.
- The parser filter processes the data (possibly by calling IMemInputPin::Receive on its own input pin) and delivers it downstream.
Steps 2 and 3 perform an asynchronous read operation. The parser can request a synchronous read operation instead, using the IAsyncReader::SyncRead or IAsyncReader::SyncReadAligned method.
Last updated on Wednesday, April 13, 2005
© 2005 Microsoft Corporation. All rights reserved.