summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerome Laheurte <jlaheurte@quividi.com>2016-04-22 14:51:31 +0200
committerTim-Philipp Müller <tim@centricular.com>2016-04-23 15:21:44 +0100
commitc7e0e8d6ab59fc410a7e9dcdfdacfbc26f6949d7 (patch)
treeb6a84c766206fc515b95ed08f849236180c27da3
parent26dfb7db834a4e0b7967b5746d63d19424e0589e (diff)
downloadgstreamer-plugins-bad-c7e0e8d6ab59fc410a7e9dcdfdacfbc26f6949d7.tar.gz
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
-rw-r--r--sys/dshowsrcwrapper/gstdshowfakesink.cpp17
-rw-r--r--sys/dshowsrcwrapper/gstdshowvideosrc.cpp6
2 files changed, 18 insertions, 5 deletions
diff --git a/sys/dshowsrcwrapper/gstdshowfakesink.cpp b/sys/dshowsrcwrapper/gstdshowfakesink.cpp
index c524c7c08..3c5fca82c 100644
--- a/sys/dshowsrcwrapper/gstdshowfakesink.cpp
+++ b/sys/dshowsrcwrapper/gstdshowfakesink.cpp
@@ -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;
+
+ VIDEOINFOHEADER *info1 = (VIDEOINFOHEADER*)pmt->pbFormat;
+ VIDEOINFOHEADER *info2 = (VIDEOINFOHEADER*)m_MediaType.pbFormat;
- return S_FALSE;
+ if (memcmp(&info1->bmiHeader, &info2->bmiHeader, sizeof(BITMAPINFOHEADER)))
+ return S_FALSE;
+
+ return S_OK;
}
HRESULT CDshowFakeSink::DoRenderSample (IMediaSample * pMediaSample)
diff --git a/sys/dshowsrcwrapper/gstdshowvideosrc.cpp b/sys/dshowsrcwrapper/gstdshowvideosrc.cpp
index e4ade97e7..9b478db5d 100644
--- a/sys/dshowsrcwrapper/gstdshowvideosrc.cpp
+++ b/sys/dshowsrcwrapper/gstdshowvideosrc.cpp
@@ -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 ();