dshowsrcwrapper: fix DirectShow caps negotiation and set capture pin caps

Some cameras (IDS) have broken DirectShow drivers which incorrectly fill some
fields in the VIDEOINFOHEADER structure; comparison between suggested and
supported media types in CBaseRenderer should ignore deprecated and/or not
essential fields; additionaly explicitely setting the mediatype for the capture
pin before trying to connect it works around another IDS driver bug, and
should have been already done anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=765428
This commit is contained in:
Jerome Laheurte 2016-04-22 14:51:31 +02:00 committed by Tim-Philipp Müller
parent 26dfb7db83
commit c7e0e8d6ab
2 changed files with 18 additions and 5 deletions

View file

@ -46,12 +46,19 @@ STDMETHODIMP
HRESULT CDshowFakeSink::CheckMediaType (const CMediaType * pmt)
{
if (pmt != NULL) {
if (*pmt == m_MediaType)
return S_OK;
}
if (!IsEqualGUID(pmt->majortype, m_MediaType.majortype) ||
!IsEqualGUID(pmt->subtype, m_MediaType.subtype) ||
!IsEqualGUID(pmt->formattype, m_MediaType.formattype) ||
(pmt->cbFormat != m_MediaType.cbFormat))
return S_FALSE;
return S_FALSE;
VIDEOINFOHEADER *info1 = (VIDEOINFOHEADER*)pmt->pbFormat;
VIDEOINFOHEADER *info2 = (VIDEOINFOHEADER*)m_MediaType.pbFormat;
if (memcmp(&info1->bmiHeader, &info2->bmiHeader, sizeof(BITMAPINFOHEADER)))
return S_FALSE;
return S_OK;
}
HRESULT CDshowFakeSink::DoRenderSample (IMediaSample * pMediaSample)

View file

@ -682,6 +682,12 @@ gst_dshowvideosrc_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
src->filter_graph->Disconnect (input_pin);
}
hres = src->pVSC->SetFormat(pin_mediatype->mediatype);
if (FAILED (hres)) {
GST_ERROR ("Failed to set capture pin format (error=0x%x)", hres);
goto error;
}
hres = src->filter_graph->ConnectDirect (pin_mediatype->capture_pin,
input_pin, pin_mediatype->mediatype);
input_pin->Release ();