Merge remote-tracking branch 'origin/5.4' into dev
Conflicts: .qmake.conf Change-Id: I31e377cdccf8bf5c1ea8143faf2001ac99608c27
This commit is contained in:
@@ -616,6 +616,8 @@ QVector<QGstUtils::CameraInfo> QGstUtils::enumerateCameras(GstElementFactory *fa
|
||||
} else {
|
||||
driver = QByteArray((const char*)vcap.driver);
|
||||
name = QString::fromUtf8((const char*)vcap.card);
|
||||
if (name.isEmpty())
|
||||
name = entryInfo.fileName();
|
||||
}
|
||||
//qDebug() << "found camera: " << name;
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ protected:
|
||||
|
||||
private Q_SLOTS:
|
||||
void _q_updateMediaObject();
|
||||
void _q_updateCameraInfo();
|
||||
void _q_updateNativeSize();
|
||||
void _q_updateGeometry();
|
||||
void _q_screenOrientationChanged(int);
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QScreen>
|
||||
#include <qpa/qplatformscreen.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@@ -63,9 +62,8 @@ int QVideoOutputOrientationHandler::currentOrientation() const
|
||||
void QVideoOutputOrientationHandler::screenOrientationChanged(Qt::ScreenOrientation orientation)
|
||||
{
|
||||
const QScreen *screen = QGuiApplication::primaryScreen();
|
||||
const QPlatformScreen *platformScreen = screen->handle();
|
||||
|
||||
const int angle = (360 - screen->angleBetween(platformScreen->nativeOrientation(), orientation)) % 360;
|
||||
const int angle = (360 - screen->angleBetween(screen->nativeOrientation(), orientation)) % 360;
|
||||
|
||||
if (angle == m_currentOrientation)
|
||||
return;
|
||||
|
||||
@@ -96,7 +96,9 @@ QVideoSurfaceGenericPainter::QVideoSurfaceGenericPainter()
|
||||
<< QVideoFrame::Format_ARGB32
|
||||
<< QVideoFrame::Format_RGB565;
|
||||
// The raster formats should be a subset of the GL formats.
|
||||
#ifndef QT_NO_OPENGL
|
||||
if (QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGLES)
|
||||
#endif
|
||||
m_imagePixelFormats << QVideoFrame::Format_RGB24;
|
||||
}
|
||||
|
||||
@@ -137,7 +139,9 @@ QAbstractVideoSurface::Error QVideoSurfaceGenericPainter::start(const QVideoSurf
|
||||
const QAbstractVideoBuffer::HandleType t = format.handleType();
|
||||
if (t == QAbstractVideoBuffer::NoHandle) {
|
||||
bool ok = m_imageFormat != QImage::Format_Invalid && !m_imageSize.isEmpty();
|
||||
#ifndef QT_NO_OPENGL
|
||||
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES)
|
||||
#endif
|
||||
ok &= format.pixelFormat() != QVideoFrame::Format_RGB24;
|
||||
if (ok)
|
||||
return QAbstractVideoSurface::NoError;
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
|
||||
#include "qopenslesengine.h"
|
||||
#include <qbuffer.h>
|
||||
#include <private/qaudiohelpers_p.h>
|
||||
#include <qdebug.h>
|
||||
|
||||
#ifdef ANDROID
|
||||
@@ -70,6 +71,7 @@ QOpenSLESAudioInput::QOpenSLESAudioInput(const QByteArray &device)
|
||||
, m_errorState(QAudio::NoError)
|
||||
, m_deviceState(QAudio::StoppedState)
|
||||
, m_lastNotifyTime(0)
|
||||
, m_volume(1.0)
|
||||
, m_bufferSize(0)
|
||||
, m_periodSize(0)
|
||||
, m_intervalTime(1000)
|
||||
@@ -395,9 +397,19 @@ void QOpenSLESAudioInput::writeDataToDevice(const char *data, int size)
|
||||
{
|
||||
m_processedBytes += size;
|
||||
|
||||
QByteArray outData;
|
||||
|
||||
// Apply volume
|
||||
if (m_volume < 1.0f) {
|
||||
outData.resize(size);
|
||||
QAudioHelperInternal::qMultiplySamples(m_volume, m_format, data, outData.data(), size);
|
||||
} else {
|
||||
outData.append(data, size);
|
||||
}
|
||||
|
||||
if (m_pullMode) {
|
||||
// write buffer to the QIODevice
|
||||
if (m_audioSource->write(data, size) < 0) {
|
||||
if (m_audioSource->write(outData) < 0) {
|
||||
stop();
|
||||
m_errorState = QAudio::IOError;
|
||||
Q_EMIT errorChanged(m_errorState);
|
||||
@@ -405,7 +417,7 @@ void QOpenSLESAudioInput::writeDataToDevice(const char *data, int size)
|
||||
} else {
|
||||
// emits readyRead() so user will call read() on QIODevice to get some audio data
|
||||
if (m_bufferIODevice != 0) {
|
||||
m_pushBuffer.append(data, size);
|
||||
m_pushBuffer.append(outData);
|
||||
Q_EMIT m_bufferIODevice->readyRead();
|
||||
}
|
||||
}
|
||||
@@ -478,13 +490,12 @@ qint64 QOpenSLESAudioInput::elapsedUSecs() const
|
||||
|
||||
void QOpenSLESAudioInput::setVolume(qreal vol)
|
||||
{
|
||||
// Volume interface is not available for the recorder on Android
|
||||
Q_UNUSED(vol);
|
||||
m_volume = vol;
|
||||
}
|
||||
|
||||
qreal QOpenSLESAudioInput::volume() const
|
||||
{
|
||||
return qreal(1.0);
|
||||
return m_volume;
|
||||
}
|
||||
|
||||
void QOpenSLESAudioInput::reset()
|
||||
|
||||
@@ -113,6 +113,7 @@ private:
|
||||
QAudio::State m_deviceState;
|
||||
QTime m_clockStamp;
|
||||
qint64 m_lastNotifyTime;
|
||||
qreal m_volume;
|
||||
int m_bufferSize;
|
||||
int m_periodSize;
|
||||
int m_intervalTime;
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include <QtCore/qfunctions_winrt.h>
|
||||
#include <QtCore/QGlobalStatic>
|
||||
#include <QtCore/QMetaMethod>
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtGui/QOpenGLContext>
|
||||
#include <QtGui/QOpenGLTexture>
|
||||
#include <QtMultimedia/QAbstractVideoBuffer>
|
||||
@@ -181,7 +182,7 @@ enum DirtyState {
|
||||
class QWinRTAbstractVideoRendererControlPrivate
|
||||
{
|
||||
public:
|
||||
QAbstractVideoSurface *surface;
|
||||
QPointer<QAbstractVideoSurface> surface;
|
||||
QVideoSurfaceFormat format;
|
||||
|
||||
DirtyState dirtyState;
|
||||
@@ -219,7 +220,6 @@ QWinRTAbstractVideoRendererControl::QWinRTAbstractVideoRendererControl(const QSi
|
||||
{
|
||||
Q_D(QWinRTAbstractVideoRendererControl);
|
||||
|
||||
d->surface = Q_NULLPTR;
|
||||
d->format = QVideoSurfaceFormat(size, QVideoFrame::Format_BGRA32,
|
||||
QAbstractVideoBuffer::GLTextureHandle);
|
||||
d->dirtyState = TextureDirty;
|
||||
@@ -310,6 +310,16 @@ void QWinRTAbstractVideoRendererControl::setSize(const QSize &size)
|
||||
d->dirtyState = TextureDirty;
|
||||
}
|
||||
|
||||
void QWinRTAbstractVideoRendererControl::setScanLineDirection(QVideoSurfaceFormat::Direction scanLineDirection)
|
||||
{
|
||||
Q_D(QWinRTAbstractVideoRendererControl);
|
||||
|
||||
if (d->format.scanLineDirection() == scanLineDirection)
|
||||
return;
|
||||
|
||||
d->format.setScanLineDirection(scanLineDirection);
|
||||
}
|
||||
|
||||
void QWinRTAbstractVideoRendererControl::setActive(bool active)
|
||||
{
|
||||
Q_D(QWinRTAbstractVideoRendererControl);
|
||||
@@ -330,6 +340,8 @@ void QWinRTAbstractVideoRendererControl::setActive(bool active)
|
||||
}
|
||||
|
||||
d->renderThread.requestInterruption();
|
||||
if (d->surface && d->surface->isActive())
|
||||
d->surface->stop();
|
||||
}
|
||||
|
||||
void QWinRTAbstractVideoRendererControl::present()
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#define QWINRTABSTRACTVIDEORENDERERCONTROL_H
|
||||
|
||||
#include <QtMultimedia/QVideoRendererControl>
|
||||
#include <QtMultimedia/QVideoSurfaceFormat>
|
||||
|
||||
struct ID3D11Device;
|
||||
struct ID3D11Texture2D;
|
||||
@@ -63,6 +64,8 @@ public:
|
||||
QSize size() const;
|
||||
void setSize(const QSize &size);
|
||||
|
||||
void setScanLineDirection(QVideoSurfaceFormat::Direction direction);
|
||||
|
||||
void setActive(bool active);
|
||||
|
||||
virtual bool render(ID3D11Texture2D *texture) = 0;
|
||||
|
||||
@@ -677,6 +677,9 @@ HRESULT QWinRTCameraControl::initialize()
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (d->videoDeviceSelector->cameraPosition(deviceName) == QCamera::FrontFace)
|
||||
d->videoRenderer->setScanLineDirection(QVideoSurfaceFormat::BottomToTop);
|
||||
|
||||
ComPtr<IMediaCaptureInitializationSettings> settings;
|
||||
hr = RoActivateInstance(HString::MakeReference(RuntimeClass_Windows_Media_Capture_MediaCaptureInitializationSettings).Get(),
|
||||
&settings);
|
||||
@@ -708,7 +711,20 @@ HRESULT QWinRTCameraControl::initialize()
|
||||
hr = videoDeviceController.As(&deviceController);
|
||||
Q_ASSERT_SUCCEEDED(hr);
|
||||
ComPtr<IVectorView<IMediaEncodingProperties *>> encodingPropertiesList;
|
||||
hr = deviceController->GetAvailableMediaStreamProperties(MediaStreamType_Photo, &encodingPropertiesList);
|
||||
MediaStreamType mediaStreamType;
|
||||
switch (d->captureMode) {
|
||||
default:
|
||||
case QCamera::CaptureViewfinder:
|
||||
mediaStreamType = MediaStreamType_VideoPreview;
|
||||
break;
|
||||
case QCamera::CaptureStillImage:
|
||||
mediaStreamType = MediaStreamType_Photo;
|
||||
break;
|
||||
case QCamera::CaptureVideo:
|
||||
mediaStreamType = MediaStreamType_VideoRecord;
|
||||
break;
|
||||
}
|
||||
hr = deviceController->GetAvailableMediaStreamProperties(mediaStreamType, &encodingPropertiesList);
|
||||
Q_ASSERT_SUCCEEDED(hr);
|
||||
|
||||
d->size = QSize();
|
||||
@@ -721,12 +737,12 @@ HRESULT QWinRTCameraControl::initialize()
|
||||
hr = encodingPropertiesList->GetAt(i, &properties);
|
||||
Q_ASSERT_SUCCEEDED(hr);
|
||||
ComPtr<IVideoEncodingProperties> videoProperties;
|
||||
hr = properties.As(&videoEncodingProperties);
|
||||
hr = properties.As(&videoProperties);
|
||||
Q_ASSERT_SUCCEEDED(hr);
|
||||
UINT32 width, height;
|
||||
hr = videoEncodingProperties->get_Width(&width);
|
||||
hr = videoProperties->get_Width(&width);
|
||||
Q_ASSERT_SUCCEEDED(hr);
|
||||
hr = videoEncodingProperties->get_Height(&height);
|
||||
hr = videoProperties->get_Height(&height);
|
||||
Q_ASSERT_SUCCEEDED(hr);
|
||||
// Choose the highest-quality format
|
||||
if (int(width * height) > d->size.width() * d->size.height()) {
|
||||
|
||||
@@ -337,7 +337,17 @@ QCamera::Position QWinRTVideoDeviceSelectorControl::cameraPosition(const QString
|
||||
|
||||
int QWinRTVideoDeviceSelectorControl::cameraOrientation(const QString &deviceName)
|
||||
{
|
||||
#ifdef Q_OS_WINPHONE
|
||||
switch (cameraPosition(deviceName)) {
|
||||
case QCamera::FrontFace:
|
||||
case QCamera::BackFace:
|
||||
return 270;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#else
|
||||
Q_UNUSED(deviceName);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -161,8 +161,10 @@ void QDeclarativeVideoOutput::setSource(QObject *source)
|
||||
if (source == m_source.data())
|
||||
return;
|
||||
|
||||
if (m_source && m_sourceType == MediaObjectSource)
|
||||
if (m_source && m_sourceType == MediaObjectSource) {
|
||||
disconnect(m_source.data(), 0, this, SLOT(_q_updateMediaObject()));
|
||||
disconnect(m_source.data(), 0, this, SLOT(_q_updateCameraInfo()));
|
||||
}
|
||||
|
||||
if (m_backend)
|
||||
m_backend->releaseSource();
|
||||
@@ -183,6 +185,20 @@ void QDeclarativeVideoOutput::setSource(QObject *source)
|
||||
Qt::DirectConnection, 0);
|
||||
|
||||
}
|
||||
|
||||
int deviceIdPropertyIndex = metaObject->indexOfProperty("deviceId");
|
||||
if (deviceIdPropertyIndex != -1) { // Camera source
|
||||
const QMetaProperty deviceIdProperty = metaObject->property(deviceIdPropertyIndex);
|
||||
|
||||
if (deviceIdProperty.hasNotifySignal()) {
|
||||
QMetaMethod method = deviceIdProperty.notifySignal();
|
||||
QMetaObject::connect(m_source.data(), method.methodIndex(),
|
||||
this, this->metaObject()->indexOfSlot("_q_updateCameraInfo()"),
|
||||
Qt::DirectConnection, 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
m_sourceType = MediaObjectSource;
|
||||
} else if (metaObject->indexOfProperty("videoSurface") != -1) {
|
||||
// Make sure our backend is a QDeclarativeVideoRendererBackend
|
||||
@@ -269,25 +285,38 @@ void QDeclarativeVideoOutput::_q_updateMediaObject()
|
||||
|
||||
m_mediaObject.clear();
|
||||
m_service.clear();
|
||||
m_cameraInfo = QCameraInfo();
|
||||
|
||||
if (mediaObject) {
|
||||
if (QMediaService *service = mediaObject->service()) {
|
||||
if (createBackend(service)) {
|
||||
m_service = service;
|
||||
m_mediaObject = mediaObject;
|
||||
const QCamera *camera = qobject_cast<const QCamera *>(mediaObject);
|
||||
if (camera) {
|
||||
m_cameraInfo = QCameraInfo(*camera);
|
||||
|
||||
// The camera position and orientation need to be taken into account for
|
||||
// the viewport auto orientation
|
||||
if (m_autoOrientation)
|
||||
_q_screenOrientationChanged(m_screenOrientationHandler->currentOrientation());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_q_updateCameraInfo();
|
||||
}
|
||||
|
||||
void QDeclarativeVideoOutput::_q_updateCameraInfo()
|
||||
{
|
||||
if (m_mediaObject) {
|
||||
const QCamera *camera = qobject_cast<const QCamera *>(m_mediaObject);
|
||||
if (camera) {
|
||||
QCameraInfo info(*camera);
|
||||
|
||||
if (m_cameraInfo != info) {
|
||||
m_cameraInfo = info;
|
||||
|
||||
// The camera position and orientation need to be taken into account for
|
||||
// the viewport auto orientation
|
||||
if (m_autoOrientation)
|
||||
_q_screenOrientationChanged(m_screenOrientationHandler->currentOrientation());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
m_cameraInfo = QCameraInfo();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Reference in New Issue
Block a user