У меня на графике 4 фильтра DirectShow:
- Фильтр захвата для веб-камеры, которая выводит только VIH1
- Фильтр захвата для платы захвата (CB), которая выводит как VIH1, так и VIH2
- SampleGrabber2
- VMR9
Вот соответствующий код согласования типа носителя. Как я могу провести плавное согласование и предотвратить эти отключения? Я предполагаю, что это как-то связано с согласованием распределителя, но пока мне не удалось это исправить.
HRESULT CSG2InPin::CheckMediaType(const CMediaType* pmt)
{
if (!pmt) return E_POINTER;
if (IsConnected()) {
const CMediaType& cur = CurrentMediaType();
return (*pmt == cur) ? S_OK : VFW_E_TYPE_NOT_ACCEPTED;
}
// One-time probe: does the peer enumerate a VIH2 we would accept?
if (!m_peerHasVIH2Checked && m_spPeer) {
m_peerHasVIH2Checked = true;
CComPtr spEnum;
if (SUCCEEDED(m_spPeer->EnumMediaTypes(&spEnum)) && spEnum) {
AM_MEDIA_TYPE* pTry = nullptr;
while (spEnum->Next(1, &pTry, nullptr) == S_OK) {
CMediaType mt(*pTry);
if (mt.majortype == MEDIATYPE_Video &&
mt.formattype == FORMAT_VideoInfo2 &&
SUCCEEDED(m_pTransformFilter->CheckInputType(&mt))) {
m_peerHasVIH2 = true;
break;
}
}
}
}
// If the peer can do VIH2 and we’re currently being offered VIH1, decline it
// so the search advances to VIH2.
if (pmt->majortype == MEDIATYPE_Video &&
pmt->formattype == FORMAT_VideoInfo &&
m_peerHasVIH2) {
return VFW_E_TYPE_NOT_ACCEPTED; // “Prefer VIH2 if available”
}
// Otherwise, defer to the filter’s policy
return m_pTransformFilter->CheckInputType(pmt);
}
...
HRESULT CSampleGrabber2::CheckInputType(const CMediaType* mtIn)
{
if ((mtIn->majortype != MEDIATYPE_Video) ||
(mtIn->formattype != FORMAT_VideoInfo) &&
(mtIn->formattype != FORMAT_VideoInfo2))
{
return VFW_E_TYPE_NOT_ACCEPTED;
}
currentFormat = (mtIn->formattype == FORMAT_VideoInfo2) ? VIH2 : VIH;
return S_OK;
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... ting-to-re
Мобильная версия