diff --git "a/C:\\Qt\\Qt5.1.1\\5.1.1\\Src\\qtmultimedia\\src\\plugins\\directshow\\camera\\dscamerasession.cpp" "b/C:\\Qt\\Qt5.1.1\\5.1.1\\Src\\qtmultimedia\\src\\plugins\\directshow\\camera\\dscamerasession.patch.cpp" index 4e785e0..6352996 100644 --- "a/C:\\Qt\\Qt5.1.1\\5.1.1\\Src\\qtmultimedia\\src\\plugins\\directshow\\camera\\dscamerasession.cpp" +++ "b/C:\\Qt\\Qt5.1.1\\5.1.1\\Src\\qtmultimedia\\src\\plugins\\directshow\\camera\\dscamerasession.patch.cpp" @@ -172,6 +172,7 @@ public: DSCameraSession::DSCameraSession(QObject *parent) : QObject(parent) + , m_captureIsInProgress(false) ,m_currentImageId(0) { pBuild = NULL; @@ -223,6 +224,7 @@ int DSCameraSession::captureImage(const QString &fileName) { emit readyForCaptureChanged(false); + m_captureIsInProgress = true; // We're going to do this in one big synchronous call m_currentImageId++; if (fileName.isEmpty()) { @@ -250,7 +252,8 @@ bool DSCameraSession::deviceReady() bool DSCameraSession::pictureInProgress() { - return m_snapshot.isEmpty(); + //return m_snapshot.isEmpty(); + return m_captureIsInProgress; } int DSCameraSession::framerate() const @@ -519,7 +522,7 @@ void DSCameraSession::record() pixelF = f; if (!resolutions[pixelF].contains(m_windowSize)) { Q_ASSERT(!resolutions[pixelF].isEmpty()); - m_windowSize = resolutions[pixelF].first(); + m_windowSize = resolutions[pixelF].last(); } actualFormat = QVideoSurfaceFormat(m_windowSize, pixelF); break; @@ -580,8 +583,8 @@ void DSCameraSession::captureFrame() mutex.lock(); - image = QImage(frames.at(0)->buffer,m_windowSize.width(),m_windowSize.height(), - QImage::Format_RGB888).rgbSwapped().mirrored(true); + image = QImage(frames.at(0)->buffer,m_windowSize.width()/3.f,m_windowSize.height(), + QImage::Format_RGB888)/*.rgbSwapped().mirrored(true)*/; QVideoFrame frame(image); frame.setStartTime(frames.at(0)->time); @@ -613,6 +616,7 @@ void DSCameraSession::captureFrame() image.save(m_snapshot,"JPG"); emit imageSaved(m_currentImageId, m_snapshot); m_snapshot.clear(); + m_captureIsInProgress = false; emit readyForCaptureChanged(true); } @@ -799,6 +803,7 @@ void DSCameraSession::updateProperties() qWarning()<<"failed to get capabilities"; return; } + qDebug() << iCount << "capabilities"; QList sizes; QVideoFrame::PixelFormat f = QVideoFrame::Format_Invalid; @@ -806,6 +811,7 @@ void DSCameraSession::updateProperties() types.clear(); resolutions.clear(); + QSize maxSize; for (int iIndex = 0; iIndex < iCount; iIndex++) { hr = pConfig->GetStreamCaps(iIndex, &pmt, reinterpret_cast(&scc)); if (hr == S_OK) { @@ -817,33 +823,45 @@ void DSCameraSession::updateProperties() if (!types.contains(QVideoFrame::Format_RGB24)) { types.append(QVideoFrame::Format_RGB24); f = QVideoFrame::Format_RGB24; + qDebug() << "RGB24"; } } else if (pmt->subtype == MEDIASUBTYPE_RGB32) { if (!types.contains(QVideoFrame::Format_RGB32)) { types.append(QVideoFrame::Format_RGB32); f = QVideoFrame::Format_RGB32; + qDebug() << "RGB32"; } } else if (pmt->subtype == MEDIASUBTYPE_YUY2) { if (!types.contains(QVideoFrame::Format_YUYV)) { types.append(QVideoFrame::Format_YUYV); f = QVideoFrame::Format_YUYV; + qDebug() << "YUYV"; } } else if (pmt->subtype == MEDIASUBTYPE_MJPG) { } else if (pmt->subtype == MEDIASUBTYPE_I420) { if (!types.contains(QVideoFrame::Format_YUV420P)) { types.append(QVideoFrame::Format_YUV420P); f = QVideoFrame::Format_YUV420P; + qDebug() << "YUV420P"; } } else if (pmt->subtype == MEDIASUBTYPE_RGB555) { if (!types.contains(QVideoFrame::Format_RGB555)) { types.append(QVideoFrame::Format_RGB555); f = QVideoFrame::Format_RGB555; + qDebug() << "RGB555"; } } else if (pmt->subtype == MEDIASUBTYPE_YVU9) { } else if (pmt->subtype == MEDIASUBTYPE_UYVY) { if (!types.contains(QVideoFrame::Format_UYVY)) { types.append(QVideoFrame::Format_UYVY); f = QVideoFrame::Format_UYVY; + qDebug() << "UYVY"; + } + } else if (pmt->subtype == MEDIASUBTYPE_NV12) { + if (!types.contains(QVideoFrame::Format_NV12)) { + types.append(QVideoFrame::Format_NV12); + f = QVideoFrame::Format_NV12; + qDebug() << "NV12"; } } else { qWarning() << "UNKNOWN FORMAT: " << pmt->subtype.Data1; @@ -855,6 +873,8 @@ void DSCameraSession::updateProperties() resolutions.insert(f,sizes); } resolutions[f].append(res); + maxSize.setWidth(qMax(maxSize.width(), res.width())); + maxSize.setHeight(maxSize.width() != res.width() ? maxSize.height() : res.height()); } } } @@ -864,11 +884,11 @@ void DSCameraSession::updateProperties() // Add RGB formats and let directshow do color space conversion if required. if (!types.contains(QVideoFrame::Format_RGB24)) { types.append(QVideoFrame::Format_RGB24); - resolutions.insert(QVideoFrame::Format_RGB24, resolutions[types.first()]); + resolutions.insert(QVideoFrame::Format_RGB24, QList() << maxSize); } if (!types.contains(QVideoFrame::Format_RGB32)) { types.append(QVideoFrame::Format_RGB32); - resolutions.insert(QVideoFrame::Format_RGB32, resolutions[types.first()]); + resolutions.insert(QVideoFrame::Format_RGB32, QList() << maxSize); } } } @@ -931,7 +951,7 @@ bool DSCameraSession::setProperties() } // Set Sample Grabber config to match capture - ZeroMemory(&am_media_type, sizeof(am_media_type)); + /*ZeroMemory(&am_media_type, sizeof(am_media_type)); am_media_type.majortype = MEDIATYPE_Video; if (actualFormat.pixelFormat() == QVideoFrame::Format_RGB32) @@ -956,7 +976,7 @@ bool DSCameraSession::setProperties() if (FAILED(hr)) { qWarning()<<"failed to set video format on grabber"; return false; - } + }*/ pSG->GetConnectedMediaType(&StillMediaType);