summaryrefslogtreecommitdiffstats
path: root/src/plugins/directshow/camera
diff options
context:
space:
mode:
authorVal Doroshchuk <valentyn.doroshchuk@qt.io>2020-09-22 13:04:44 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-09-24 10:10:06 +0000
commit67cac1524f56af09289eb76b5e2a38ca6d2a78c6 (patch)
tree4d0df139806d510e7823ce5886ca50c51d156e88 /src/plugins/directshow/camera
parent9862bf04d18d8453c5bf2667768c0b8fbafe512c (diff)
DirectShow: Use also pin category when negotiating
The pin should be negotiated once and use PIN_CATEGORY_CAPTURE. The same logic is implemented in chromium. Change-Id: I89ac13c1a7e982c1011b2a872e853ee5bc2036b2 Reviewed-by: Andy Shaw <andy.shaw@qt.io> (cherry picked from commit bf82ab669c53c4b9abb724e197252a788323095e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/plugins/directshow/camera')
-rw-r--r--src/plugins/directshow/camera/dscamerasession.cpp66
-rw-r--r--src/plugins/directshow/camera/dscamerasession.h2
2 files changed, 31 insertions, 37 deletions
diff --git a/src/plugins/directshow/camera/dscamerasession.cpp b/src/plugins/directshow/camera/dscamerasession.cpp
index 7703aa498..e47142be1 100644
--- a/src/plugins/directshow/camera/dscamerasession.cpp
+++ b/src/plugins/directshow/camera/dscamerasession.cpp
@@ -428,6 +428,7 @@ bool DSCameraSession::unload()
SAFE_RELEASE(m_nullRendererFilter);
SAFE_RELEASE(m_filterGraph);
SAFE_RELEASE(m_graphBuilder);
+ SAFE_RELEASE(m_outputPin);
setStatus(QCamera::UnloadedStatus);
@@ -781,6 +782,9 @@ bool DSCameraSession::createFilterGraph()
goto failed;
}
+ if (!DirectShowUtils::getPin(m_sourceFilter, PINDIR_OUTPUT, PIN_CATEGORY_CAPTURE, &m_outputPin, &hr))
+ qWarning() << "Failed to get the pin for the video control:" << hr;
+
// Sample grabber filter
if (!m_previewSampleGrabber) {
m_previewSampleGrabber = new DirectShowSampleGrabber(this);
@@ -1055,24 +1059,18 @@ void DSCameraSession::updateSourceCapabilities()
reinterpret_cast<void**>(&pVideoControl));
if (FAILED(hr)) {
qWarning() << "Failed to get the video control";
- } else {
- IPin *pPin = nullptr;
- if (!DirectShowUtils::getPin(m_sourceFilter, PINDIR_OUTPUT, &pPin, &hr)) {
- qWarning() << "Failed to get the pin for the video control";
- } else {
- long supportedModes;
- hr = pVideoControl->GetCaps(pPin, &supportedModes);
- if (FAILED(hr)) {
- qWarning() << "Failed to get the supported modes of the video control";
- } else if (supportedModes & VideoControlFlag_FlipHorizontal) {
- long mode;
- hr = pVideoControl->GetMode(pPin, &mode);
- if (FAILED(hr))
- qWarning() << "Failed to get the mode of the video control";
- else if (supportedModes & VideoControlFlag_FlipHorizontal)
- m_needsHorizontalMirroring = (mode & VideoControlFlag_FlipHorizontal);
- }
- pPin->Release();
+ } else if (m_outputPin) {
+ long supportedModes;
+ hr = pVideoControl->GetCaps(m_outputPin, &supportedModes);
+ if (FAILED(hr)) {
+ qWarning() << "Failed to get the supported modes of the video control";
+ } else if (supportedModes & VideoControlFlag_FlipHorizontal) {
+ long mode;
+ hr = pVideoControl->GetMode(m_outputPin, &mode);
+ if (FAILED(hr))
+ qWarning() << "Failed to get the mode of the video control";
+ else if (supportedModes & VideoControlFlag_FlipHorizontal)
+ m_needsHorizontalMirroring = (mode & VideoControlFlag_FlipHorizontal);
}
pVideoControl->Release();
}
@@ -1107,28 +1105,22 @@ void DSCameraSession::updateSourceCapabilities()
QList<QCamera::FrameRateRange> frameRateRanges;
- if (pVideoControl) {
- IPin *pPin = nullptr;
- if (!DirectShowUtils::getPin(m_sourceFilter, PINDIR_OUTPUT, &pPin, &hr)) {
- qWarning() << "Failed to get the pin for the video control";
- } else {
- long listSize = 0;
- LONGLONG *frameRates = nullptr;
- SIZE size = { resolution.width(), resolution.height() };
- hr = pVideoControl->GetFrameRateList(pPin, iIndex, size, &listSize, &frameRates);
- if (hr == S_OK && listSize > 0 && frameRates) {
- for (long i = 0; i < listSize; ++i) {
- qreal fr = qreal(10000000) / frameRates[i];
- frameRateRanges.append(QCamera::FrameRateRange(fr, fr));
- }
-
- // Make sure higher frame rates come first
- std::sort(frameRateRanges.begin(), frameRateRanges.end(), qt_frameRateRangeGreaterThan);
+ if (pVideoControl && m_outputPin) {
+ long listSize = 0;
+ LONGLONG *frameRates = nullptr;
+ SIZE size = { resolution.width(), resolution.height() };
+ hr = pVideoControl->GetFrameRateList(m_outputPin, iIndex, size, &listSize, &frameRates);
+ if (hr == S_OK && listSize > 0 && frameRates) {
+ for (long i = 0; i < listSize; ++i) {
+ qreal fr = qreal(10000000) / frameRates[i];
+ frameRateRanges.append(QCamera::FrameRateRange(fr, fr));
}
- CoTaskMemFree(frameRates);
- pPin->Release();
+ // Make sure higher frame rates come first
+ std::sort(frameRateRanges.begin(), frameRateRanges.end(), qt_frameRateRangeGreaterThan);
}
+
+ CoTaskMemFree(frameRates);
}
if (frameRateRanges.isEmpty()) {
diff --git a/src/plugins/directshow/camera/dscamerasession.h b/src/plugins/directshow/camera/dscamerasession.h
index 5e7d026c2..9f88163b9 100644
--- a/src/plugins/directshow/camera/dscamerasession.h
+++ b/src/plugins/directshow/camera/dscamerasession.h
@@ -231,6 +231,8 @@ private:
QMap<QCameraImageProcessingControl::ProcessingParameter, QVariant> m_pendingImageProcessingParametrs;
+ IPin *m_outputPin = nullptr;
+
friend class SampleGrabberCallbackPrivate;
};