自定义DirectShow源代码过滤器 - 动态更改分辨率 [英] Custom DirectShow Source Filter - Dynamic Resolution Change
问题描述
以前我曾经问过一个非常类似的问题,用于视频渲染过滤器。
请参阅:自定义DirectShow视频渲染器过滤器 - 动态分辨率更改</a>
时间,我需要一个源过滤器的解决方案。此源过滤器直接连接到视频渲染器。解码器是嵌入式的。
我能够从流中获取分辨率更改。当我得到一个新的决议时,我也调整缓冲区。但是我不知道如何通过这个引脚来通知我的新决议。我应该以某种方式从 CMediaType
创建一个实例,填入新值并调用pin SetMediaType()
方法,或者适当的解决方案?
pre $ if $分辨率更改
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);
//现在是什么?如何通知视频渲染器?
$ / code>
m_pin
是只有在这里声明的源过滤器的输出引脚;
class MyPin:public CSourceStream {...}
我知道答案应该很简单,应该有很多例子,但因为我有点对这些主题有点困惑,除了这个例子,我更喜欢一个很好的解释。 $ c> CDynamicOutputPin ,并在需要向格式更改发送下游(至渲染器)的通知时执行以下操作:
hr = StartUsingOutputPin();
if(SUCCEEDED(hr))
{
hr = ChangeMediaType(& m_mt);
StopUsingOutputPin();
$ b 有一个实现 CDynamicSourceStream
和匹配 CDynamicSource
从Windows SDK的DirectShow示例,您可能会发现有帮助。
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.
解决方案 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.
这篇关于自定义DirectShow源代码过滤器 - 动态更改分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!