summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gsttools/qgstreamervideowindow.cpp2
-rw-r--r--src/multimediawidgets/qpaintervideosurface.cpp29
-rw-r--r--src/plugins/avfoundation/camera/avfcamerarenderercontrol.mm4
-rw-r--r--src/plugins/avfoundation/camera/avfmediaassetwriter.h20
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm26
-rw-r--r--src/plugins/winrt/qwinrtcameracontrol.cpp40
-rw-r--r--src/plugins/winrt/qwinrtcameracontrol.h3
-rw-r--r--src/plugins/winrt/qwinrtcameraimagecapturecontrol.cpp30
-rw-r--r--src/plugins/winrt/qwinrtcameraservice.cpp6
-rw-r--r--src/plugins/winrt/qwinrtimageencodercontrol.cpp124
-rw-r--r--src/plugins/winrt/qwinrtimageencodercontrol.h66
-rw-r--r--src/plugins/winrt/winrt.pro6
-rw-r--r--src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp11
13 files changed, 324 insertions, 43 deletions
diff --git a/src/gsttools/qgstreamervideowindow.cpp b/src/gsttools/qgstreamervideowindow.cpp
index a0697003a..ee25acc48 100644
--- a/src/gsttools/qgstreamervideowindow.cpp
+++ b/src/gsttools/qgstreamervideowindow.cpp
@@ -71,8 +71,6 @@ QGstreamerVideoWindow::QGstreamerVideoWindow(QObject *parent, const char *elemen
addProbeToPad(pad);
gst_object_unref(GST_OBJECT(pad));
}
- else
- qDebug() << "No m_videoSink available!";
}
QGstreamerVideoWindow::~QGstreamerVideoWindow()
diff --git a/src/multimediawidgets/qpaintervideosurface.cpp b/src/multimediawidgets/qpaintervideosurface.cpp
index 2dfbf3414..c9fa206a2 100644
--- a/src/multimediawidgets/qpaintervideosurface.cpp
+++ b/src/multimediawidgets/qpaintervideosurface.cpp
@@ -38,6 +38,7 @@
#include <qpainter.h>
#include <qvariant.h>
#include <qvideosurfaceformat.h>
+#include <private/qmediaopenglhelper_p.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1)
#include <qglshaderprogram.h>
@@ -261,6 +262,12 @@ protected:
void initYuv420PTextureInfo(const QSize &size);
void initYv12TextureInfo(const QSize &size);
+ bool needsSwizzling(const QVideoSurfaceFormat &format) const {
+ return !QMediaOpenGLHelper::isANGLE()
+ && (format.pixelFormat() == QVideoFrame::Format_RGB32
+ || format.pixelFormat() == QVideoFrame::Format_ARGB32);
+ }
+
#if !defined(QT_OPENGL_ES) && !defined(QT_OPENGL_DYNAMIC)
typedef void (APIENTRY *_glActiveTexture) (GLenum);
_glActiveTexture glActiveTexture;
@@ -702,7 +709,9 @@ QVideoSurfaceArbFpPainter::QVideoSurfaceArbFpPainter(QGLContext *context)
<< QVideoFrame::Format_YUV420P;
m_glPixelFormats
<< QVideoFrame::Format_RGB32
- << QVideoFrame::Format_ARGB32;
+ << QVideoFrame::Format_ARGB32
+ << QVideoFrame::Format_BGR32
+ << QVideoFrame::Format_BGRA32;
}
QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::start(const QVideoSurfaceFormat &format)
@@ -766,9 +775,14 @@ QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::start(const QVideoSurfac
switch (format.pixelFormat()) {
case QVideoFrame::Format_RGB32:
case QVideoFrame::Format_ARGB32:
+ case QVideoFrame::Format_BGR32:
+ case QVideoFrame::Format_BGRA32:
m_yuv = false;
m_textureCount = 1;
- program = qt_arbfp_rgbShaderProgram;
+ if (needsSwizzling(format))
+ program = qt_arbfp_xrgbShaderProgram;
+ else
+ program = qt_arbfp_rgbShaderProgram;
break;
default:
break;
@@ -1070,7 +1084,9 @@ QVideoSurfaceGlslPainter::QVideoSurfaceGlslPainter(QGLContext *context)
<< QVideoFrame::Format_YUV420P;
m_glPixelFormats
<< QVideoFrame::Format_RGB32
- << QVideoFrame::Format_ARGB32;
+ << QVideoFrame::Format_ARGB32
+ << QVideoFrame::Format_BGR32
+ << QVideoFrame::Format_BGRA32;
}
QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::start(const QVideoSurfaceFormat &format)
@@ -1138,9 +1154,14 @@ QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::start(const QVideoSurface
switch (format.pixelFormat()) {
case QVideoFrame::Format_RGB32:
case QVideoFrame::Format_ARGB32:
+ case QVideoFrame::Format_BGR32:
+ case QVideoFrame::Format_BGRA32:
m_yuv = false;
m_textureCount = 1;
- fragmentProgram = qt_glsl_rgbShaderProgram;
+ if (needsSwizzling(format))
+ fragmentProgram = qt_glsl_xrgbShaderProgram;
+ else
+ fragmentProgram = qt_glsl_rgbShaderProgram;
break;
default:
break;
diff --git a/src/plugins/avfoundation/camera/avfcamerarenderercontrol.mm b/src/plugins/avfoundation/camera/avfcamerarenderercontrol.mm
index dd838d9b5..529541285 100644
--- a/src/plugins/avfoundation/camera/avfcamerarenderercontrol.mm
+++ b/src/plugins/avfoundation/camera/avfcamerarenderercontrol.mm
@@ -309,8 +309,10 @@ void AVFCameraRendererControl::handleViewfinderFrame()
}
if (m_surface && frame.isValid()) {
- if (m_surface->isActive() && m_surface->surfaceFormat().pixelFormat() != frame.pixelFormat())
+ if (m_surface->isActive() && (m_surface->surfaceFormat().pixelFormat() != frame.pixelFormat()
+ || m_surface->surfaceFormat().frameSize() != frame.size())) {
m_surface->stop();
+ }
if (!m_surface->isActive()) {
QVideoSurfaceFormat format(frame.size(), frame.pixelFormat());
diff --git a/src/plugins/avfoundation/camera/avfmediaassetwriter.h b/src/plugins/avfoundation/camera/avfmediaassetwriter.h
index eae700751..4759ae0a7 100644
--- a/src/plugins/avfoundation/camera/avfmediaassetwriter.h
+++ b/src/plugins/avfoundation/camera/avfmediaassetwriter.h
@@ -70,32 +70,32 @@ QT_END_NAMESPACE
@private
AVFCameraService *m_service;
- QT_MANGLE_NAMESPACE(AVFScopedPointer)<AVAssetWriterInput> m_cameraWriterInput;
- QT_MANGLE_NAMESPACE(AVFScopedPointer)<AVCaptureDeviceInput> m_audioInput;
- QT_MANGLE_NAMESPACE(AVFScopedPointer)<AVCaptureAudioDataOutput> m_audioOutput;
- QT_MANGLE_NAMESPACE(AVFScopedPointer)<AVAssetWriterInput> m_audioWriterInput;
+ QT_PREPEND_NAMESPACE(AVFScopedPointer)<AVAssetWriterInput> m_cameraWriterInput;
+ QT_PREPEND_NAMESPACE(AVFScopedPointer)<AVCaptureDeviceInput> m_audioInput;
+ QT_PREPEND_NAMESPACE(AVFScopedPointer)<AVCaptureAudioDataOutput> m_audioOutput;
+ QT_PREPEND_NAMESPACE(AVFScopedPointer)<AVAssetWriterInput> m_audioWriterInput;
// High priority serial queue for video output:
- QT_MANGLE_NAMESPACE(AVFScopedPointer)<dispatch_queue_t> m_videoQueue;
+ QT_PREPEND_NAMESPACE(AVFScopedPointer)<dispatch_queue_t> m_videoQueue;
// Serial queue for audio output:
- QT_MANGLE_NAMESPACE(AVFScopedPointer)<dispatch_queue_t> m_audioQueue;
+ QT_PREPEND_NAMESPACE(AVFScopedPointer)<dispatch_queue_t> m_audioQueue;
// Queue to write sample buffers:
__weak dispatch_queue_t m_writerQueue;
- QT_MANGLE_NAMESPACE(AVFScopedPointer)<AVAssetWriter> m_assetWriter;
+ QT_PREPEND_NAMESPACE(AVFScopedPointer)<AVAssetWriter> m_assetWriter;
// Delegate's queue.
__weak dispatch_queue_t m_delegateQueue;
// TODO: QPointer??
QT_PREPEND_NAMESPACE(AVFMediaAssetWriterDelegate) *m_delegate;
bool m_setStartTime;
- QT_MANGLE_NAMESPACE(AVFAtomicBool) m_stopped;
+ QT_PREPEND_NAMESPACE(AVFAtomicBool) m_stopped;
bool m_stoppedInternal;
bool m_aborted;
- QT_MANGLE_NAMESPACE(QMutex) m_writerMutex;
+ QT_PREPEND_NAMESPACE(QMutex) m_writerMutex;
@public
- QT_MANGLE_NAMESPACE(AVFAtomicInt64) m_durationInMs;
+ QT_PREPEND_NAMESPACE(AVFAtomicInt64) m_durationInMs;
@private
CMTime m_startTime;
CMTime m_lastTimeStamp;
diff --git a/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm b/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm
index fe3389a43..2d6eac540 100644
--- a/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm
+++ b/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm
@@ -50,19 +50,13 @@ AVFVideoFrameRenderer::AVFVideoFrameRenderer(QAbstractVideoSurface *surface, QOb
: QObject(parent)
, m_videoLayerRenderer(0)
, m_surface(surface)
+ , m_offscreenSurface(0)
, m_glContext(0)
, m_currentBuffer(1)
, m_isContextShared(true)
{
m_fbo[0] = 0;
m_fbo[1] = 0;
-
- //Create Hidden QWindow surface to create context in this thread
- m_offscreenSurface = new QWindow();
- m_offscreenSurface->setSurfaceType(QWindow::OpenGLSurface);
- //Needs geometry to be a valid surface, but size is not important
- m_offscreenSurface->setGeometry(0, 0, 1, 1);
- m_offscreenSurface->create();
}
AVFVideoFrameRenderer::~AVFVideoFrameRenderer()
@@ -94,7 +88,8 @@ GLuint AVFVideoFrameRenderer::renderLayerToTexture(AVPlayerLayer *layer)
return 0;
renderLayerToFBO(layer, fbo);
- m_glContext->doneCurrent();
+ if (m_glContext)
+ m_glContext->doneCurrent();
return fbo->texture();
}
@@ -113,7 +108,8 @@ QImage AVFVideoFrameRenderer::renderLayerToImage(AVPlayerLayer *layer)
renderLayerToFBO(layer, fbo);
QImage fboImage = fbo->toImage();
- m_glContext->doneCurrent();
+ if (m_glContext)
+ m_glContext->doneCurrent();
return fboImage;
}
@@ -125,7 +121,14 @@ QOpenGLFramebufferObject *AVFVideoFrameRenderer::initRenderer(AVPlayerLayer *lay
m_targetSize = QSize(layer.bounds.size.width, layer.bounds.size.height);
//Make sure we have an OpenGL context to make current
- if (!m_glContext) {
+ if (!QOpenGLContext::currentContext() && !m_glContext) {
+ //Create Hidden QWindow surface to create context in this thread
+ m_offscreenSurface = new QWindow();
+ m_offscreenSurface->setSurfaceType(QWindow::OpenGLSurface);
+ //Needs geometry to be a valid surface, but size is not important
+ 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) {
@@ -151,7 +154,8 @@ QOpenGLFramebufferObject *AVFVideoFrameRenderer::initRenderer(AVPlayerLayer *lay
}
//Need current context
- m_glContext->makeCurrent(m_offscreenSurface);
+ if (m_glContext)
+ m_glContext->makeCurrent(m_offscreenSurface);
//Create the CARenderer if needed
if (!m_videoLayerRenderer) {
diff --git a/src/plugins/winrt/qwinrtcameracontrol.cpp b/src/plugins/winrt/qwinrtcameracontrol.cpp
index 12f4fb459..9013416fe 100644
--- a/src/plugins/winrt/qwinrtcameracontrol.cpp
+++ b/src/plugins/winrt/qwinrtcameracontrol.cpp
@@ -38,6 +38,7 @@
#include "qwinrtcameravideorenderercontrol.h"
#include "qwinrtvideodeviceselectorcontrol.h"
#include "qwinrtcameraimagecapturecontrol.h"
+#include "qwinrtimageencodercontrol.h"
#include <QtCore/qfunctions_winrt.h>
#include <QtCore/QCoreApplication>
@@ -75,6 +76,10 @@ QT_BEGIN_NAMESPACE
RETURN_VOID_IF_FAILED(msg); \
}
+inline uint qHash (const QSize &key) {
+ return key.width() * key.height();
+}
+
class CriticalSectionLocker
{
public:
@@ -454,6 +459,7 @@ public:
QPointer<QWinRTCameraVideoRendererControl> videoRenderer;
QPointer<QWinRTVideoDeviceSelectorControl> videoDeviceSelector;
QPointer<QWinRTCameraImageCaptureControl> imageCaptureControl;
+ QPointer<QWinRTImageEncoderControl> imageEncoderControl;
};
QWinRTCameraControl::QWinRTCameraControl(QObject *parent)
@@ -471,6 +477,7 @@ QWinRTCameraControl::QWinRTCameraControl(QObject *parent)
this, &QWinRTCameraControl::onBufferRequested);
d->videoDeviceSelector = new QWinRTVideoDeviceSelectorControl(this);
d->imageCaptureControl = new QWinRTCameraImageCaptureControl(this);
+ d->imageEncoderControl = new QWinRTImageEncoderControl(this);
}
QWinRTCameraControl::~QWinRTCameraControl()
@@ -655,16 +662,16 @@ QCameraImageCaptureControl *QWinRTCameraControl::imageCaptureControl() const
return d->imageCaptureControl;
}
-IMediaCapture *QWinRTCameraControl::handle() const
+QImageEncoderControl *QWinRTCameraControl::imageEncoderControl() const
{
Q_D(const QWinRTCameraControl);
- return d->capture.Get();
+ return d->imageEncoderControl;
}
-QSize QWinRTCameraControl::imageSize() const
+IMediaCapture *QWinRTCameraControl::handle() const
{
Q_D(const QWinRTCameraControl);
- return d->size;
+ return d->capture.Get();
}
void QWinRTCameraControl::onBufferRequested()
@@ -764,10 +771,11 @@ HRESULT QWinRTCameraControl::initialize()
Q_ASSERT_SUCCEEDED(hr);
d->size = QSize();
- ComPtr<IVideoEncodingProperties> videoEncodingProperties;
quint32 encodingPropertiesListSize;
hr = encodingPropertiesList->get_Size(&encodingPropertiesListSize);
Q_ASSERT_SUCCEEDED(hr);
+ QHash<QSize, ComPtr<IVideoEncodingProperties>> videoEncodingPropertiesList;
+ int pixelCount = 0;
for (quint32 i = 0; i < encodingPropertiesListSize; ++i) {
ComPtr<IMediaEncodingProperties> properties;
hr = encodingPropertiesList->GetAt(i, &properties);
@@ -780,21 +788,33 @@ HRESULT QWinRTCameraControl::initialize()
Q_ASSERT_SUCCEEDED(hr);
hr = videoProperties->get_Height(&height);
Q_ASSERT_SUCCEEDED(hr);
- // Choose the highest-quality format
- if (int(width * height) > d->size.width() * d->size.height()) {
- d->size = QSize(width, height);
- videoEncodingProperties = videoProperties;
+ if (d->captureMode != QCamera::CaptureStillImage && int(width * height) > pixelCount) {
+ d->size = QSize(width, height);// Choose the Highest-quality format
+ pixelCount = d->size.width() * d->size.height();
}
+ videoEncodingPropertiesList.insert(QSize(width, height), videoProperties);
}
- if (!videoEncodingProperties || d->size.isEmpty()) {
+ if (videoEncodingPropertiesList.isEmpty()) {
hr = MF_E_INVALID_FORMAT;
RETURN_HR_IF_FAILED("Failed to find a suitable video format");
}
+ if (d->captureMode == QCamera::CaptureStillImage) {
+ d->imageEncoderControl->setSupportedResolutionsList(videoEncodingPropertiesList.keys());
+ d->size = d->imageEncoderControl->imageSettings().resolution();
+ }
+
hr = RoActivateInstance(HString::MakeReference(RuntimeClass_Windows_Media_MediaProperties_MediaEncodingProfile).Get(),
&d->encodingProfile);
Q_ASSERT_SUCCEEDED(hr);
+
+ const ComPtr<IVideoEncodingProperties> videoEncodingProperties = videoEncodingPropertiesList[d->size];
+ if (!videoEncodingProperties) {
+ hr = MF_E_INVALID_FORMAT;
+ RETURN_HR_IF_FAILED("Failed to find a suitable video format properties");
+ }
+
hr = d->encodingProfile->put_Video(videoEncodingProperties.Get());
Q_ASSERT_SUCCEEDED(hr);
if (d->videoRenderer)
diff --git a/src/plugins/winrt/qwinrtcameracontrol.h b/src/plugins/winrt/qwinrtcameracontrol.h
index 95692cbc7..307667eb1 100644
--- a/src/plugins/winrt/qwinrtcameracontrol.h
+++ b/src/plugins/winrt/qwinrtcameracontrol.h
@@ -60,6 +60,7 @@ QT_BEGIN_NAMESPACE
class QVideoRendererControl;
class QVideoDeviceSelectorControl;
class QCameraImageCaptureControl;
+class QImageEncoderControl;
class QWinRTCameraControlPrivate;
class QWinRTCameraControl : public QCameraControl
@@ -83,9 +84,9 @@ public:
QVideoRendererControl *videoRenderer() const;
QVideoDeviceSelectorControl *videoDeviceSelector() const;
QCameraImageCaptureControl *imageCaptureControl() const;
+ QImageEncoderControl *imageEncoderControl() const;
ABI::Windows::Media::Capture::IMediaCapture *handle() const;
- QSize imageSize() const;
private slots:
void onBufferRequested();
diff --git a/src/plugins/winrt/qwinrtcameraimagecapturecontrol.cpp b/src/plugins/winrt/qwinrtcameraimagecapturecontrol.cpp
index 6bc5eaafc..55f553778 100644
--- a/src/plugins/winrt/qwinrtcameraimagecapturecontrol.cpp
+++ b/src/plugins/winrt/qwinrtcameraimagecapturecontrol.cpp
@@ -36,6 +36,7 @@
#include "qwinrtcameraimagecapturecontrol.h"
#include "qwinrtcameracontrol.h"
+#include "qwinrtimageencodercontrol.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QDir>
@@ -166,7 +167,7 @@ int QWinRTCameraImageCaptureControl::capture(const QString &fileName)
hr = g->encodingPropertiesFactory->CreateBmp(&request.imageFormat);
Q_ASSERT_SUCCEEDED(hr);
- const QSize imageSize = d->cameraControl->imageSize();
+ const QSize imageSize = static_cast<QWinRTImageEncoderControl*>(d->cameraControl->imageEncoderControl())->imageSettings().resolution();
hr = request.imageFormat->put_Width(imageSize.width());
Q_ASSERT_SUCCEEDED(hr);
hr = request.imageFormat->put_Height(imageSize.height());
@@ -174,6 +175,10 @@ int QWinRTCameraImageCaptureControl::capture(const QString &fileName)
hr = capture->CapturePhotoToStreamAsync(request.imageFormat.Get(), request.stream.Get(), &request.op);
Q_ASSERT_SUCCEEDED(hr);
+ if (!request.op) {
+ qErrnoWarning("Camera photo capture failed.");
+ return -1;
+ }
d->requests.insert(request.op.Get(), request);
hr = request.op->put_Completed(Callback<IAsyncActionCompletedHandler>(
@@ -266,7 +271,28 @@ HRESULT QWinRTCameraImageCaptureControl::onCaptureCompleted(IAsyncAction *asyncI
const QImage image(pixelData, pixelWidth, pixelHeight, QImage::Format_RGBA8888,
reinterpret_cast<QImageCleanupFunction>(&CoTaskMemFree), pixelData);
emit imageCaptured(request.id, image);
- if (image.save(request.fileName))
+
+ QWinRTImageEncoderControl *imageEncoderControl = static_cast<QWinRTImageEncoderControl*>(d->cameraControl->imageEncoderControl());
+ int imageQuality = 100;
+ switch (imageEncoderControl->imageSettings().quality()) {
+ case QMultimedia::VeryLowQuality:
+ imageQuality = 20;
+ break;
+ case QMultimedia::LowQuality:
+ imageQuality = 40;
+ break;
+ case QMultimedia::NormalQuality:
+ imageQuality = 60;
+ break;
+ case QMultimedia::HighQuality:
+ imageQuality = 80;
+ break;
+ case QMultimedia::VeryHighQuality:
+ imageQuality = 100;
+ break;
+ }
+
+ if (image.save(request.fileName, imageEncoderControl->imageSettings().codec().toLatin1().data(), imageQuality))
emit imageSaved(request.id, request.fileName);
else
emit error(request.id, QCameraImageCapture::ResourceError, tr("Image saving failed"));
diff --git a/src/plugins/winrt/qwinrtcameraservice.cpp b/src/plugins/winrt/qwinrtcameraservice.cpp
index a73cddbe5..be67b4742 100644
--- a/src/plugins/winrt/qwinrtcameraservice.cpp
+++ b/src/plugins/winrt/qwinrtcameraservice.cpp
@@ -44,6 +44,7 @@
#include <QtMultimedia/QCameraImageCaptureControl>
#include <QtMultimedia/QVideoRendererControl>
#include <QtMultimedia/QVideoDeviceSelectorControl>
+#include <QtMultimedia/QImageEncoderControl>
QT_BEGIN_NAMESPACE
@@ -90,6 +91,11 @@ QMediaControl *QWinRTCameraService::requestControl(const char *name)
return d->cameraControl->imageCaptureControl();
}
+ if (qstrcmp(name, QImageEncoderControl_iid) == 0) {
+ if (d->cameraControl)
+ return d->cameraControl->imageEncoderControl();
+ }
+
return Q_NULLPTR;
}
diff --git a/src/plugins/winrt/qwinrtimageencodercontrol.cpp b/src/plugins/winrt/qwinrtimageencodercontrol.cpp
new file mode 100644
index 000000000..0ab7a7cfb
--- /dev/null
+++ b/src/plugins/winrt/qwinrtimageencodercontrol.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd and/or its subsidiary(-ies).
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwinrtimageencodercontrol.h"
+QT_BEGIN_NAMESPACE
+
+class QWinRTImageEncoderControlPrivate
+{
+public:
+ QList<QSize> supportedResolutions;
+ QImageEncoderSettings imageEncoderSetting;
+};
+
+QWinRTImageEncoderControl::QWinRTImageEncoderControl(QObject *parent)
+ : QImageEncoderControl(parent), d_ptr(new QWinRTImageEncoderControlPrivate)
+{
+}
+
+QStringList QWinRTImageEncoderControl::supportedImageCodecs() const
+{
+ return QStringList() << QStringLiteral("jpeg");
+}
+
+QString QWinRTImageEncoderControl::imageCodecDescription(const QString &codecName) const
+{
+ if (codecName == QStringLiteral("jpeg"))
+ return tr("JPEG image");
+
+ return QString();
+}
+
+QList<QSize> QWinRTImageEncoderControl::supportedResolutions(const QImageEncoderSettings &settings, bool *continuous) const
+{
+ Q_UNUSED(settings);
+ Q_D(const QWinRTImageEncoderControl);
+
+ if (continuous)
+ *continuous = false;
+
+ return d->supportedResolutions;
+}
+
+QImageEncoderSettings QWinRTImageEncoderControl::imageSettings() const
+{
+ Q_D(const QWinRTImageEncoderControl);
+ return d->imageEncoderSetting;
+}
+
+void QWinRTImageEncoderControl::setImageSettings(const QImageEncoderSettings &settings)
+{
+ Q_D(QWinRTImageEncoderControl);
+ if (d->imageEncoderSetting == settings)
+ return;
+
+ d->imageEncoderSetting = settings;
+ applySettings();
+}
+
+void QWinRTImageEncoderControl::setSupportedResolutionsList(const QList<QSize> resolution)
+{
+ Q_D(QWinRTImageEncoderControl);
+ d->supportedResolutions = resolution;
+ applySettings();
+}
+
+void QWinRTImageEncoderControl::applySettings()
+{
+ Q_D(QWinRTImageEncoderControl);
+ d->imageEncoderSetting.setCodec(QStringLiteral("jpeg"));
+
+ QSize requestResolution = d->imageEncoderSetting.resolution();
+ if (d->supportedResolutions.isEmpty() || d->supportedResolutions.contains(requestResolution))
+ return;
+
+ if (!requestResolution.isValid())
+ requestResolution = QSize(0, 0);// Find the minimal available resolution
+
+ // Find closest resolution from the list
+ const int pixelCount = requestResolution.width() * requestResolution.height();
+ int minPixelCountGap = -1;
+ for (int i = 0; i < d->supportedResolutions.size(); ++i) {
+ int gap = qAbs(pixelCount - d->supportedResolutions.at(i).width() * d->supportedResolutions.at(i).height());
+ if (gap < minPixelCountGap || minPixelCountGap < 0) {
+ minPixelCountGap = gap;
+ requestResolution = d->supportedResolutions.at(i);
+ }
+ }
+ d->imageEncoderSetting.setResolution(requestResolution);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/winrt/qwinrtimageencodercontrol.h b/src/plugins/winrt/qwinrtimageencodercontrol.h
new file mode 100644
index 000000000..7682e7626
--- /dev/null
+++ b/src/plugins/winrt/qwinrtimageencodercontrol.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd and/or its subsidiary(-ies).
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINRTIMAGEENCODERCONTROL_H
+#define QWINRTIMAGEENCODERCONTROL_H
+
+#include <qimageencodercontrol.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWinRTImageEncoderControlPrivate;
+class QWinRTImageEncoderControl : public QImageEncoderControl
+{
+public:
+ explicit QWinRTImageEncoderControl(QObject *parent = 0);
+
+ QStringList supportedImageCodecs() const Q_DECL_OVERRIDE;
+ QString imageCodecDescription(const QString &codecName) const Q_DECL_OVERRIDE;
+ QList<QSize> supportedResolutions(const QImageEncoderSettings &settings, bool *continuous = 0) const Q_DECL_OVERRIDE;
+ QImageEncoderSettings imageSettings() const Q_DECL_OVERRIDE;
+ void setImageSettings(const QImageEncoderSettings &settings) Q_DECL_OVERRIDE;
+
+ void setSupportedResolutionsList(const QList<QSize> resolution);
+ void applySettings();
+
+private:
+ QScopedPointer<QWinRTImageEncoderControlPrivate> d_ptr;
+ Q_DECLARE_PRIVATE(QWinRTImageEncoderControl)
+};
+
+QT_END_NAMESPACE
+
+#endif // QWINRTIMAGEENCODERCONTROL_H
diff --git a/src/plugins/winrt/winrt.pro b/src/plugins/winrt/winrt.pro
index 04db71e75..58c2371f9 100644
--- a/src/plugins/winrt/winrt.pro
+++ b/src/plugins/winrt/winrt.pro
@@ -18,7 +18,8 @@ HEADERS += \
qwinrtmediaplayerservice.h \
qwinrtplayerrenderercontrol.h \
qwinrtserviceplugin.h \
- qwinrtvideodeviceselectorcontrol.h
+ qwinrtvideodeviceselectorcontrol.h \
+ qwinrtimageencodercontrol.h
SOURCES += \
qwinrtabstractvideorenderercontrol.cpp \
@@ -31,7 +32,8 @@ SOURCES += \
qwinrtmediaplayerservice.cpp \
qwinrtplayerrenderercontrol.cpp \
qwinrtserviceplugin.cpp \
- qwinrtvideodeviceselectorcontrol.cpp
+ qwinrtvideodeviceselectorcontrol.cpp \
+ qwinrtimageencodercontrol.cpp
OTHER_FILES += \
winrt.json
diff --git a/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp b/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp
index f4efe47e7..de4cabfaf 100644
--- a/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp
+++ b/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp
@@ -420,6 +420,17 @@ QList<QVideoFrame::PixelFormat> QSGVideoItemSurface::supportedPixelFormats(
{
QList<QVideoFrame::PixelFormat> formats;
+ static bool noGLTextures = false;
+ static bool noGLTexturesChecked = false;
+ if (handleType == QAbstractVideoBuffer::GLTextureHandle) {
+ if (!noGLTexturesChecked) {
+ noGLTexturesChecked = true;
+ noGLTextures = qEnvironmentVariableIsSet("QT_QUICK_NO_TEXTURE_VIDEOFRAMES");
+ }
+ if (noGLTextures)
+ return formats;
+ }
+
foreach (QSGVideoNodeFactoryInterface* factory, m_backend->m_videoNodeFactories)
formats.append(factory->supportedPixelFormats(handleType));