summaryrefslogtreecommitdiffstats
path: root/src/plugins/directshow
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2016-07-20 15:53:34 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2016-07-21 14:03:11 +0200
commit7a5e3145550015c9c6c3e8232c8257099aa2480c (patch)
tree0b5623c19c6d2ac39a9d95befcadc957029a2446 /src/plugins/directshow
parent631b89ddde44dfc8b72b904d8c41368b2c02d037 (diff)
parent17d54a2eb57816dbc531feee80dbd25f835e733a (diff)
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts: src/plugins/directshow/player/directshowiosource.cpp One side disintermediated filling a vector; the other reduced it to one entry. src/plugins/directshow/player/directshowiosource.h One side renamed a member, the other added another adjacent to it. src/plugins/pulseaudio/qpulseaudioengine.h One side added a header, the other replaced the next with a different header. Change-Id: I3a031975f5af43ca39cca571f215c612f640b7d6
Diffstat (limited to 'src/plugins/directshow')
-rw-r--r--src/plugins/directshow/player/directshowiosource.cpp167
-rw-r--r--src/plugins/directshow/player/directshowiosource.h5
2 files changed, 42 insertions, 130 deletions
diff --git a/src/plugins/directshow/player/directshowiosource.cpp b/src/plugins/directshow/player/directshowiosource.cpp
index 9e71f34d0..4dc8bec3d 100644
--- a/src/plugins/directshow/player/directshowiosource.cpp
+++ b/src/plugins/directshow/player/directshowiosource.cpp
@@ -47,13 +47,6 @@
#include <QtCore/qcoreapplication.h>
#include <QtCore/qurl.h>
-static const GUID directshow_subtypes[] =
-{
- MEDIASUBTYPE_Avi,
- MEDIASUBTYPE_WAVE,
- MEDIASUBTYPE_NULL
-};
-
DirectShowIOSource::DirectShowIOSource(DirectShowEventLoop *loop)
: m_ref(1)
, m_state(State_Stopped)
@@ -64,26 +57,21 @@ DirectShowIOSource::DirectShowIOSource(DirectShowEventLoop *loop)
, m_allocator(0)
, m_peerPin(0)
, m_pinId(QLatin1String("Data"))
+ , m_queriedForAsyncReader(false)
{
- AM_MEDIA_TYPE type =
- {
- MEDIATYPE_Stream, // majortype
- MEDIASUBTYPE_NULL, // subtype
- TRUE, // bFixedSizeSamples
- FALSE, // bTemporalCompression
- 1, // lSampleSize
- GUID_NULL, // formattype
- 0, // pUnk
- 0, // cbFormat
- 0, // pbFormat
- };
-
- static const int count = sizeof(directshow_subtypes) / sizeof(GUID);
-
- for (int i = 0; i < count; ++i) {
- type.subtype = directshow_subtypes[i];
- m_supportedMediaTypes.append(type);
- }
+ // This filter has only one possible output type, that is, a stream of data
+ // with no particular subtype. The graph builder will try every demux/decode filters
+ // to find one able to decode the stream.
+ //
+ // The filter works in pull mode, the downstream filter is responsible for requesting
+ // samples from this one.
+
+ m_outputType.majortype = MEDIATYPE_Stream;
+ m_outputType.subtype = MEDIASUBTYPE_NULL; // Wildcard
+ m_outputType.bFixedSizeSamples = TRUE;
+ m_outputType.lSampleSize = 1;
+
+ m_supportedMediaTypes.append(m_outputType);
}
DirectShowIOSource::~DirectShowIOSource()
@@ -133,6 +121,7 @@ HRESULT DirectShowIOSource::QueryInterface(REFIID riid, void **ppvObject)
} else if (riid == IID_IPin) {
*ppvObject = static_cast<IPin *>(this);
} else if (riid == IID_IAsyncReader) {
+ m_queriedForAsyncReader = true;
*ppvObject = static_cast<IAsyncReader *>(m_reader);
} else {
*ppvObject = 0;
@@ -327,116 +316,40 @@ ULONG DirectShowIOSource::GetMiscFlags()
// IPin
HRESULT DirectShowIOSource::Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt)
{
- QMutexLocker locker(&m_mutex);
- if (!pReceivePin) {
+ if (!pReceivePin)
return E_POINTER;
- } else if (m_state != State_Stopped) {
- return VFW_E_NOT_STOPPED;
- } else if (m_peerPin) {
- return VFW_E_ALREADY_CONNECTED;
- } else {
- HRESULT hr = VFW_E_TYPE_NOT_ACCEPTED;
-
- m_peerPin = pReceivePin;
- m_peerPin->AddRef();
- if (!pmt) {
- IEnumMediaTypes *mediaTypes = 0;
- if (pReceivePin->EnumMediaTypes(&mediaTypes) == S_OK) {
- for (AM_MEDIA_TYPE *type = 0;
- mediaTypes->Next(1, &type, 0) == S_OK;
- DirectShowMediaType::deleteType(type)) {
- switch (tryConnect(pReceivePin, type)) {
- case S_OK:
- DirectShowMediaType::freeData(type);
- mediaTypes->Release();
- return S_OK;
- case VFW_E_NO_TRANSPORT:
- hr = VFW_E_NO_TRANSPORT;
- break;
- default:
- break;
- }
- }
- mediaTypes->Release();
- }
- AM_MEDIA_TYPE type =
- {
- MEDIATYPE_Stream, // majortype
- MEDIASUBTYPE_NULL, // subtype
- TRUE, // bFixedSizeSamples
- FALSE, // bTemporalCompression
- 1, // lSampleSize
- GUID_NULL, // formattype
- 0, // pUnk
- 0, // cbFormat
- 0, // pbFormat
- };
-
- static const int count = sizeof(directshow_subtypes) / sizeof(GUID);
-
- for (int i = 0; i < count; ++i) {
- type.subtype = directshow_subtypes[i];
-
- switch (tryConnect(pReceivePin, &type)) {
- case S_OK:
- return S_OK;
- case VFW_E_NO_TRANSPORT:
- hr = VFW_E_NO_TRANSPORT;
- break;
- default:
- break;
- }
- }
- } else if (pmt->majortype == MEDIATYPE_Stream && (hr = tryConnect(pReceivePin, pmt))) {
- return S_OK;
- }
-
- m_peerPin->Release();
- m_peerPin = 0;
+ QMutexLocker locker(&m_mutex);
- m_mediaType.clear();
+ if (m_state != State_Stopped)
+ return VFW_E_NOT_STOPPED;
- return hr;
- }
-}
+ if (m_peerPin)
+ return VFW_E_ALREADY_CONNECTED;
-HRESULT DirectShowIOSource::tryConnect(IPin *pin, const AM_MEDIA_TYPE *type)
-{
- m_mediaType = *type;
+ // If we get a type from the graph manager, check that we support that
+ if (pmt && (pmt->majortype != MEDIATYPE_Stream || pmt->subtype != MEDIASUBTYPE_NULL))
+ return VFW_E_TYPE_NOT_ACCEPTED;
- HRESULT hr = pin->ReceiveConnection(this, type);
+ // This filter only works in pull mode, the downstream filter must query for the
+ // AsyncReader interface during ReceiveConnection().
+ // If it doesn't, we can't connect to it.
+ m_queriedForAsyncReader = false;
+ HRESULT hr = pReceivePin->ReceiveConnection(this, pmt ? pmt : &m_outputType);
- if (!SUCCEEDED(hr)) {
+ if (SUCCEEDED(hr) && m_queriedForAsyncReader) {
+ m_peerPin = pReceivePin;
+ m_peerPin->AddRef();
+ } else {
+ pReceivePin->Disconnect();
if (m_allocator) {
m_allocator->Release();
m_allocator = 0;
}
- } else if (!m_allocator) {
- hr = VFW_E_NO_TRANSPORT;
-
- if (IMemInputPin *memPin = com_cast<IMemInputPin>(pin, IID_IMemInputPin)) {
- if ((m_allocator = com_new<IMemAllocator>(CLSID_MemoryAllocator))) {
- ALLOCATOR_PROPERTIES properties;
- if (memPin->GetAllocatorRequirements(&properties) == S_OK
- || m_allocator->GetProperties(&properties) == S_OK) {
- if (properties.cbAlign == 0)
- properties.cbAlign = 1;
-
- ALLOCATOR_PROPERTIES actualProperties;
- if (SUCCEEDED(hr = m_allocator->SetProperties(&properties, &actualProperties)))
- hr = memPin->NotifyAllocator(m_allocator, TRUE);
- }
- if (!SUCCEEDED(hr)) {
- m_allocator->Release();
- m_allocator = 0;
- }
- }
- memPin->Release();
- }
- if (!SUCCEEDED(hr))
- pin->Disconnect();
+ if (!m_queriedForAsyncReader)
+ hr = VFW_E_NO_TRANSPORT;
}
+
return hr;
}
@@ -450,6 +363,8 @@ HRESULT DirectShowIOSource::ReceiveConnection(IPin *pConnector, const AM_MEDIA_T
HRESULT DirectShowIOSource::Disconnect()
{
+ QMutexLocker locker(&m_mutex);
+
if (!m_peerPin) {
return S_FALSE;
} else if (m_state != State_Stopped) {
@@ -468,8 +383,6 @@ HRESULT DirectShowIOSource::Disconnect()
m_peerPin->Release();
m_peerPin = 0;
- m_mediaType.clear();
-
return S_OK;
}
}
@@ -507,7 +420,7 @@ HRESULT DirectShowIOSource::ConnectionMediaType(AM_MEDIA_TYPE *pmt)
return VFW_E_NOT_CONNECTED;
} else {
- DirectShowMediaType::copy(pmt, m_mediaType);
+ DirectShowMediaType::copy(pmt, m_outputType);
return S_OK;
}
diff --git a/src/plugins/directshow/player/directshowiosource.h b/src/plugins/directshow/player/directshowiosource.h
index c2add6062..efcde7a27 100644
--- a/src/plugins/directshow/player/directshowiosource.h
+++ b/src/plugins/directshow/player/directshowiosource.h
@@ -115,8 +115,6 @@ public:
HRESULT STDMETHODCALLTYPE QueryDirection(PIN_DIRECTION *pPinDir);
private:
- HRESULT tryConnect(IPin *pin, const AM_MEDIA_TYPE *type);
-
volatile LONG m_ref;
FILTER_STATE m_state;
DirectShowIOReader *m_reader;
@@ -125,10 +123,11 @@ private:
IReferenceClock *m_clock;
IMemAllocator *m_allocator;
IPin *m_peerPin;
- DirectShowMediaType m_mediaType;
+ DirectShowMediaType m_outputType;
QList<DirectShowMediaType> m_supportedMediaTypes;
QString m_filterName;
const QString m_pinId;
+ bool m_queriedForAsyncReader;
QMutex m_mutex;
};