Commit bfabb13f authored by Qt Forward Merge Bot's avatar Qt Forward Merge Bot
Browse files

Merge remote-tracking branch 'origin/5.11' into dev

Change-Id: I4f6a59c4b9af45bfc0a5aeec8092c0d4e8fd3b2e
Showing with 55 additions and 13 deletions
......@@ -126,8 +126,14 @@ QOpenGLFramebufferObject *AVFVideoFrameRenderer::initRenderer(AVPlayerLayer *lay
//Get size from AVPlayerLayer
m_targetSize = QSize(layer.bounds.size.width, layer.bounds.size.height);
QOpenGLContext *shareContext = !m_glContext && m_surface
? qobject_cast<QOpenGLContext*>(m_surface->property("GLContext").value<QObject*>())
: nullptr;
//Make sure we have an OpenGL context to make current
if (!QOpenGLContext::currentContext() && !m_glContext) {
if ((shareContext && shareContext != QOpenGLContext::currentContext())
|| (!QOpenGLContext::currentContext() && !m_glContext)) {
//Create Hidden QWindow surface to create context in this thread
m_offscreenSurface = new QWindow();
m_offscreenSurface->setSurfaceType(QWindow::OpenGLSurface);
......@@ -135,12 +141,6 @@ QOpenGLFramebufferObject *AVFVideoFrameRenderer::initRenderer(AVPlayerLayer *lay
m_offscreenSurface->setGeometry(0, 0, 1, 1);
m_offscreenSurface->create();
//Create OpenGL context and set share context from surface
QOpenGLContext *shareContext = 0;
if (m_surface) {
//QOpenGLContext *renderThreadContext = 0;
shareContext = qobject_cast<QOpenGLContext*>(m_surface->property("GLContext").value<QObject*>());
}
m_glContext = new QOpenGLContext();
m_glContext->setFormat(m_offscreenSurface->requestedFormat());
......
......@@ -51,8 +51,12 @@ DSCameraControl::DSCameraControl(QObject *parent)
, m_captureMode(QCamera::CaptureStillImage)
{
m_session = qobject_cast<DSCameraSession*>(parent);
connect(m_session, SIGNAL(statusChanged(QCamera::Status)),
this, SIGNAL(statusChanged(QCamera::Status)));
connect(m_session, &DSCameraSession::statusChanged,
[&](QCamera::Status status) {
if (status == QCamera::UnloadedStatus)
m_state = QCamera::UnloadedState;
emit statusChanged(status);
});
connect(m_session, &DSCameraSession::cameraError,
this, &DSCameraControl::error);
}
......
......@@ -76,6 +76,30 @@ DSCameraSession::DSCameraSession(QObject *parent)
{
connect(this, SIGNAL(statusChanged(QCamera::Status)),
this, SLOT(updateReadyForCapture()));
m_deviceLostEventTimer.setSingleShot(true);
connect(&m_deviceLostEventTimer, &QTimer::timeout, [&]() {
IMediaEvent *pEvent = com_cast<IMediaEvent>(m_filterGraph, IID_IMediaEvent);
if (!pEvent)
return;
long eventCode;
LONG_PTR param1;
LONG_PTR param2;
while (pEvent->GetEvent(&eventCode, &param1, &param2, 0) == S_OK) {
switch (eventCode) {
case EC_DEVICE_LOST:
unload();
break;
default:
break;
}
pEvent->FreeEventParams(eventCode, param1, param2);
}
pEvent->Release();
});
}
DSCameraSession::~DSCameraSession()
......@@ -208,8 +232,8 @@ QVariant DSCameraSession::imageProcessingParameter(
QCameraImageProcessingControl::ProcessingParameter parameter) const
{
if (!m_graphBuilder) {
qWarning() << "failed to access to the graph builder";
return QVariant();
auto it = m_pendingImageProcessingParametrs.find(parameter);
return it != m_pendingImageProcessingParametrs.end() ? it.value() : QVariant();
}
const QCameraImageProcessingControl::ProcessingParameter resultingParameter =
......@@ -249,7 +273,7 @@ void DSCameraSession::setImageProcessingParameter(
const QVariant &value)
{
if (!m_graphBuilder) {
qWarning() << "failed to access to the graph builder";
m_pendingImageProcessingParametrs.insert(parameter, value);
return;
}
......@@ -582,6 +606,10 @@ void DSCameraSession::onFrameAvailable(double time, const QByteArray &data)
m_presentMutex.lock();
// If no frames provided from ISampleGrabber for some time
// the device might be potentially unplugged.
m_deviceLostEventTimer.start(100);
// (We should be getting only RGB32 data)
int stride = m_previewSize.width() * 4;
......@@ -960,6 +988,13 @@ void DSCameraSession::updateImageProcessingParametersInfos()
}
pVideoProcAmp->Release();
for (auto it = m_pendingImageProcessingParametrs.cbegin();
it != m_pendingImageProcessingParametrs.cend();
++it) {
setImageProcessingParameter(it.key(), it.value());
}
m_pendingImageProcessingParametrs.clear();
}
bool DSCameraSession::connectGraph()
......
......@@ -44,7 +44,7 @@
#include <QTime>
#include <QUrl>
#include <QMutex>
#include <QTimer>
#include <qcamera.h>
#include <QtMultimedia/qvideoframe.h>
#include <QtMultimedia/qabstractvideosurface.h>
......@@ -229,6 +229,9 @@ private:
// Internal state
QCamera::Status m_status;
QTimer m_deviceLostEventTimer;
QMap<QCameraImageProcessingControl::ProcessingParameter, QVariant> m_pendingImageProcessingParametrs;
friend class SampleGrabberCallbackPrivate;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment