From 57a4cabd78aba3d6c1dd4802b0e3baf5ed3e4758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Thu, 10 Nov 2016 17:55:15 +0100 Subject: DirectShow: Sanitize DirectShowMediaType The DirectShowMediaType is now a thin data wrapper around AM_MEDIA_TYPE and will for the most look and work the same way, with the exception that it cleans up after itself. All utility functions are now static, except clear() which, for convenience, is also provided as a non-static member function. In addition to the changes mentioned above, duplicated methods were removed, conversion for ARGB32 was added, and an attempt to make the usage of AM_MEDIA_TYPE and DirectShowMediaType was made more consistent. Change-Id: Iad32fb8eeabd9d4183e9bd10426cac3963e5d99a Reviewed-by: Yoann Lopes --- src/plugins/directshow/player/directshowiosource.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/plugins/directshow/player/directshowiosource.cpp') diff --git a/src/plugins/directshow/player/directshowiosource.cpp b/src/plugins/directshow/player/directshowiosource.cpp index 3c44dd1ed..96b4b14bf 100644 --- a/src/plugins/directshow/player/directshowiosource.cpp +++ b/src/plugins/directshow/player/directshowiosource.cpp @@ -82,7 +82,7 @@ DirectShowIOSource::DirectShowIOSource(DirectShowEventLoop *loop) // The filter works in pull mode, the downstream filter is responsible for requesting // samples from this one. // - AM_MEDIA_TYPE type = + AM_MEDIA_TYPE type { MEDIATYPE_Stream, // majortype MEDIASUBTYPE_NULL, // subtype @@ -99,7 +99,7 @@ DirectShowIOSource::DirectShowIOSource(DirectShowEventLoop *loop) for (int i = 0; i < count; ++i) { type.subtype = directshow_subtypes[i]; - m_supportedMediaTypes.append(type); + m_supportedMediaTypes.append(DirectShowMediaType(type)); } } @@ -371,12 +371,12 @@ HRESULT DirectShowIOSource::Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt) hr = pReceivePin->ReceiveConnection(this, pmt); // Update the media type for the current connection. if (SUCCEEDED(hr)) - m_connectionMediaType = *pmt; + DirectShowMediaType::copy(&m_connectionMediaType, pmt); } else if (pmt && pmt->subtype == MEDIATYPE_NULL) { // - Partial type (Stream, but no subtype specified). - m_connectionMediaType = *pmt; + DirectShowMediaType::copy(&m_connectionMediaType, pmt); // Check if the receiving pin accepts any of the streaming subtypes. for (const DirectShowMediaType &t : qAsConst(m_supportedMediaTypes)) { - m_connectionMediaType.subtype = t.subtype; + m_connectionMediaType->subtype = t->subtype; hr = pReceivePin->ReceiveConnection(this, &m_connectionMediaType); if (SUCCEEDED(hr)) break; @@ -477,7 +477,7 @@ HRESULT DirectShowIOSource::ConnectionMediaType(AM_MEDIA_TYPE *pmt) return VFW_E_NOT_CONNECTED; } else { - DirectShowMediaType::copy(pmt, m_connectionMediaType); + DirectShowMediaType::copy(pmt, &m_connectionMediaType); return S_OK; } -- cgit v1.2.3