Delivering the End of Stream

[The feature associated with this page, DirectShow, is a legacy feature. It has been superseded by MediaPlayer, IMFMediaEngine, and Audio/Video Capture in Media Foundation. Those features have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer, IMFMediaEngine and Audio/Video Capture in Media Foundation instead of DirectShow, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

When the input pin receives an end-of-stream notification, it propagates the call downstream. Any downstream filters that receive data from this input pin should also get the end-of-stream notification. Again, take the streaming lock and not the filter lock. If the filter has pending data that was not yet delivered, the filter should deliver it now, before it sends the end-of-stream notification. It should not send any data after the end of the stream.

HRESULT CMyInputPin::EndOfStream()
{
    CAutoLock lock_it(&m_csReceive);

    /* If the pin has not delivered all of the data in the stream 
       (based on what it received previously), do so now.  */

    // Propagate EndOfStream call downstream, via your output pin(s).
    for (each output pin)
    {    
        hr = pOutputPin->DeliverEndOfStream();
    }
    return S_OK;
}

The CBaseOutputPin::DeliverEndOfStream method calls IPin::EndOfStream on the downstream input pin.

Threads and Critical Sections