Question

I've asked a very similar question before for a video renderer filter.

See here: Custom DirectShow Video Renderer Filter - Dynamic Resolution Change

But this time, I need a solution for a source filter. This source filter connects directly to the video renderer. Decoder is embedded.

I'm able to get the resolution changes from the stream. I also resize the buffers when I get a new resolution. But I don't know how to notify my new resolution through the pin. Should I somehow create an instance from CMediaType, fill in the new values and call pin's SetMediaType() method or what is the proper solution? I'm currently doing this.

if(nWidth * nHeight * 3 != reader->m_RGB24BufferSize) { // if resolution changed
    reader->m_RGB24BufferSize = nWidth * nHeight * 3;
    reader->m_RGB24Buffer = (BYTE*)malloc(reader->m_RGB24BufferSize);

    reader->m_pin->m_bmpInfo.biWidth = nWidth;
    reader->m_pin->m_bmpInfo.biHeight = nHeight;
    reader->m_pin->m_bmpInfo.biSizeImage = GetBitmapSize(&reader->m_pin->m_bmpInfo);

    // Now what? How to notify the video renderer?
}

m_pin is the only output pin of the source filter here which is declared like;

class MyPin : public CSourceStream { ... };

I know the answer should be simple and there should be many examples around but since I'm a little bit confused about these subjects, I prefer a nice explanation besides the example.

Was it helpful?

Solution

You can have output pin derived from CDynamicOutputPin and perform the following when you need to send notification downstream (to the renderer) about the format change:

hr = StartUsingOutputPin();
if (SUCCEEDED(hr))
{
    hr = ChangeMediaType(&m_mt);
    StopUsingOutputPin();
}

There is an implementation of CDynamicSourceStream and matching CDynamicSource in DirectShow samples from Windows SDK that you may find helpful.

OTHER TIPS

From MSDN Dynamic Format Changes:

  1. QueryAccept (Downstream) is used when If an output pin proposes a format change to its downstream peer, but only if the new format does not require a larger buffer.

  2. ReceiveConnection is used when an output pin proposes a format change to its downstream peer, and the new format requires a larger buffer.

Did you have a chance to try any of these two?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top