summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gsttools/qgstreamervideoinputdevicecontrol.cpp9
-rw-r--r--src/multimedia/audio/qsamplecache_p.cpp5
-rw-r--r--src/multimedia/audio/qsoundeffect_pulse_p.cpp13
-rw-r--r--src/multimedia/audio/qsoundeffect_pulse_p.h5
-rw-r--r--src/multimedia/doc/qtmultimedia.qdocconf3
-rw-r--r--src/multimedia/playback/qmediaplayer.cpp12
-rw-r--r--src/multimediawidgets/qpaintervideosurface.cpp4
-rw-r--r--src/plugins/alsa/qalsaaudiooutput.cpp3
-rw-r--r--src/plugins/android/src/common/qandroidvideooutput.cpp1
-rw-r--r--src/plugins/avfoundation/camera/avfcamerasession.mm2
-rw-r--r--src/plugins/common/evr/evrcustompresenter.cpp7
-rw-r--r--src/plugins/common/evr/evrd3dpresentengine.cpp163
-rw-r--r--src/plugins/directshow/camera/dscamerasession.cpp4
-rw-r--r--src/plugins/directshow/dsserviceplugin.cpp6
-rw-r--r--src/plugins/directshow/player/directshowplayerservice.cpp31
-rw-r--r--src/plugins/directshow/player/directshowplayerservice.h4
-rw-r--r--src/plugins/gstreamer/camerabin/camerabinsession.cpp12
-rw-r--r--src/plugins/plugins.pro3
-rw-r--r--src/plugins/wasapi/qwasapiaudiodeviceinfo.cpp2
-rw-r--r--src/plugins/windowsaudio/qwindowsaudiodeviceinfo.cpp11
-rw-r--r--src/plugins/windowsaudio/qwindowsaudiooutput.cpp3
-rw-r--r--src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp4
-rw-r--r--src/qtmultimediaquicktools/qsgvideonode_rgb.cpp15
-rw-r--r--src/qtmultimediaquicktools/qsgvideonode_texture.cpp15
-rw-r--r--src/qtmultimediaquicktools/shaders/rgbvideo_swizzle.frag4
25 files changed, 205 insertions, 136 deletions
diff --git a/src/gsttools/qgstreamervideoinputdevicecontrol.cpp b/src/gsttools/qgstreamervideoinputdevicecontrol.cpp
index 2f08575aa..86e6772b7 100644
--- a/src/gsttools/qgstreamervideoinputdevicecontrol.cpp
+++ b/src/gsttools/qgstreamervideoinputdevicecontrol.cpp
@@ -90,9 +90,8 @@ int QGstreamerVideoInputDeviceControl::selectedDevice() const
void QGstreamerVideoInputDeviceControl::setSelectedDevice(int index)
{
- if (index != m_selectedDevice) {
- m_selectedDevice = index;
- emit selectedDeviceChanged(index);
- emit selectedDeviceChanged(deviceName(index));
- }
+ // Always update selected device and proxy it to clients
+ m_selectedDevice = index;
+ emit selectedDeviceChanged(index);
+ emit selectedDeviceChanged(deviceName(index));
}
diff --git a/src/multimedia/audio/qsamplecache_p.cpp b/src/multimedia/audio/qsamplecache_p.cpp
index 487346832..c76f51899 100644
--- a/src/multimedia/audio/qsamplecache_p.cpp
+++ b/src/multimedia/audio/qsamplecache_p.cpp
@@ -140,8 +140,11 @@ void QSampleCache::loadingRelease()
QMutexLocker locker(&m_loadingMutex);
m_loadingRefCount--;
if (m_loadingRefCount == 0) {
- if (m_loadingThread.isRunning())
+ if (m_loadingThread.isRunning()) {
+ m_networkAccessManager->deleteLater();
+ m_networkAccessManager = nullptr;
m_loadingThread.exit();
+ }
}
}
diff --git a/src/multimedia/audio/qsoundeffect_pulse_p.cpp b/src/multimedia/audio/qsoundeffect_pulse_p.cpp
index bf647ea1f..a86f22872 100644
--- a/src/multimedia/audio/qsoundeffect_pulse_p.cpp
+++ b/src/multimedia/audio/qsoundeffect_pulse_p.cpp
@@ -535,31 +535,34 @@ void QSoundEffectPrivate::setLoopCount(int loopCount)
qreal QSoundEffectPrivate::volume() const
{
- QReadLocker locker(&m_volumeLock);
+ QMutexLocker locker(&m_volumeLock);
return m_volume;
}
void QSoundEffectPrivate::setVolume(qreal volume)
{
- QWriteLocker locker(&m_volumeLock);
+ QMutexLocker locker(&m_volumeLock);
if (qFuzzyCompare(m_volume, volume))
return;
m_volume = qBound(qreal(0), volume, qreal(1));
+ locker.unlock();
emit volumeChanged();
}
bool QSoundEffectPrivate::isMuted() const
{
- QReadLocker locker(&m_volumeLock);
+ QMutexLocker locker(&m_volumeLock);
return m_muted;
}
void QSoundEffectPrivate::setMuted(bool muted)
{
- QWriteLocker locker(&m_volumeLock);
+ m_volumeLock.lock();
m_muted = muted;
+ m_volumeLock.unlock();
+
emit mutedChanged();
}
@@ -884,7 +887,7 @@ int QSoundEffectPrivate::writeToStream(const void *data, int size)
if (size < 1)
return 0;
- m_volumeLock.lockForRead();
+ m_volumeLock.lock();
qreal volume = m_muted ? 0 : m_volume;
m_volumeLock.unlock();
pa_free_cb_t writeDoneCb = stream_write_done_callback;
diff --git a/src/multimedia/audio/qsoundeffect_pulse_p.h b/src/multimedia/audio/qsoundeffect_pulse_p.h
index 7be88c55a..268a99326 100644
--- a/src/multimedia/audio/qsoundeffect_pulse_p.h
+++ b/src/multimedia/audio/qsoundeffect_pulse_p.h
@@ -56,7 +56,7 @@
#include <QtCore/qobject.h>
#include <QtCore/qdatetime.h>
-#include <QtCore/qreadwritelock.h>
+#include <QtCore/qmutex.h>
#include <qmediaplayer.h>
#include <pulse/pulseaudio.h>
#include "qsamplecache_p.h"
@@ -175,7 +175,8 @@ private:
bool m_resourcesAvailable;
- mutable QReadWriteLock m_volumeLock;
+ // Protects volume while PuseAudio is accessing it
+ mutable QMutex m_volumeLock;
QMediaPlayerResourceSetInterface *m_resources;
};
diff --git a/src/multimedia/doc/qtmultimedia.qdocconf b/src/multimedia/doc/qtmultimedia.qdocconf
index e3d3827c5..074fcb75e 100644
--- a/src/multimedia/doc/qtmultimedia.qdocconf
+++ b/src/multimedia/doc/qtmultimedia.qdocconf
@@ -43,6 +43,9 @@ qhp.QtMultimedia.subprojects.examples.sortPages = true
exampledirs += ../../../examples \
snippets
+manifestmeta.highlighted.names = "QtMultimedia/QML Video Shader Effects Example" \
+ "QtMultimedia/Media Player Example"
+
headerdirs += ../..
imagedirs += src/images \
diff --git a/src/multimedia/playback/qmediaplayer.cpp b/src/multimedia/playback/qmediaplayer.cpp
index 52fa6e68e..01c91babc 100644
--- a/src/multimedia/playback/qmediaplayer.cpp
+++ b/src/multimedia/playback/qmediaplayer.cpp
@@ -732,7 +732,17 @@ void QMediaPlayer::setNetworkConfigurations(const QList<QNetworkConfiguration> &
QMediaPlayer::State QMediaPlayer::state() const
{
- return d_func()->state;
+ Q_D(const QMediaPlayer);
+
+ // In case if EndOfMedia status is already received
+ // but state is not.
+ if (d->control != 0
+ && d->status == QMediaPlayer::EndOfMedia
+ && d->state != d->control->state()) {
+ return d->control->state();
+ }
+
+ return d->state;
}
QMediaPlayer::MediaStatus QMediaPlayer::mediaStatus() const
diff --git a/src/multimediawidgets/qpaintervideosurface.cpp b/src/multimediawidgets/qpaintervideosurface.cpp
index 6e93e150d..0147690e1 100644
--- a/src/multimediawidgets/qpaintervideosurface.cpp
+++ b/src/multimediawidgets/qpaintervideosurface.cpp
@@ -1254,8 +1254,8 @@ QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::paint(
if (scissorTestEnabled)
glEnable(GL_SCISSOR_TEST);
- const int width = QOpenGLContext::currentContext()->surface()->size().width();
- const int height = QOpenGLContext::currentContext()->surface()->size().height();
+ const int width = painter->viewport().width();
+ const int height = painter->viewport().height();
const QTransform transform = painter->deviceTransform();
diff --git a/src/plugins/alsa/qalsaaudiooutput.cpp b/src/plugins/alsa/qalsaaudiooutput.cpp
index cd97ae85b..ddbe04de9 100644
--- a/src/plugins/alsa/qalsaaudiooutput.cpp
+++ b/src/plugins/alsa/qalsaaudiooutput.cpp
@@ -316,9 +316,6 @@ bool QAlsaAudioOutput::open()
return false;
}
- if (!QAlsaAudioDeviceInfo::availableDevices(QAudio::AudioOutput).contains(m_device))
- return false;
-
QString dev;
#if SND_LIB_VERSION < 0x1000e // 1.0.14
if (m_device != "default")
diff --git a/src/plugins/android/src/common/qandroidvideooutput.cpp b/src/plugins/android/src/common/qandroidvideooutput.cpp
index eb41d4a8e..b425b9d89 100644
--- a/src/plugins/android/src/common/qandroidvideooutput.cpp
+++ b/src/plugins/android/src/common/qandroidvideooutput.cpp
@@ -324,7 +324,6 @@ void QAndroidTextureVideoOutput::onFrameAvailable()
if (!m_surface->isActive()) {
QVideoSurfaceFormat format(frame.size(), frame.pixelFormat(),
QAbstractVideoBuffer::GLTextureHandle);
- format.setScanLineDirection(QVideoSurfaceFormat::BottomToTop);
m_surface->start(format);
}
diff --git a/src/plugins/avfoundation/camera/avfcamerasession.mm b/src/plugins/avfoundation/camera/avfcamerasession.mm
index 0b7c0e9d8..8e3436d39 100644
--- a/src/plugins/avfoundation/camera/avfcamerasession.mm
+++ b/src/plugins/avfoundation/camera/avfcamerasession.mm
@@ -234,7 +234,7 @@ void AVFCameraSession::updateCameraDevices()
break;
case AVCaptureDevicePositionFront:
info.position = QCamera::FrontFace;
- info.orientation = 270;
+ info.orientation = 90;
break;
default:
info.position = QCamera::UnspecifiedPosition;
diff --git a/src/plugins/common/evr/evrcustompresenter.cpp b/src/plugins/common/evr/evrcustompresenter.cpp
index 958204079..b07dbe719 100644
--- a/src/plugins/common/evr/evrcustompresenter.cpp
+++ b/src/plugins/common/evr/evrcustompresenter.cpp
@@ -1350,13 +1350,6 @@ HRESULT EVRCustomPresenter::createOptimalVideoType(IMFMediaType *proposedType, I
// Modify the new type.
- // Set the pixel aspect ratio (PAR) to 1:1 (see assumption #1, above)
- // The ratio is packed in a single UINT64. A helper function is normally available for
- // that (MFSetAttributeRatio) but it's not correctly defined in MinGW 4.9.1.
- hr = mtOptimal->SetUINT64(MF_MT_PIXEL_ASPECT_RATIO, (((UINT64) 1) << 32) | ((UINT64) 1));
- if (FAILED(hr))
- goto done;
-
hr = proposedType->GetUINT64(MF_MT_FRAME_SIZE, &size);
width = int(HI32(size));
height = int(LO32(size));
diff --git a/src/plugins/common/evr/evrd3dpresentengine.cpp b/src/plugins/common/evr/evrd3dpresentengine.cpp
index fd9ccdef1..54403faba 100644
--- a/src/plugins/common/evr/evrd3dpresentengine.cpp
+++ b/src/plugins/common/evr/evrd3dpresentengine.cpp
@@ -47,6 +47,7 @@
#include <QDebug>
#include <qthread.h>
#include <private/qmediaopenglhelper_p.h>
+#include <QOffscreenSurface>
#ifdef MAYBE_ANGLE
# include <qguiapplication.h>
@@ -128,11 +129,65 @@ class OpenGLResources : public QObject
{
public:
OpenGLResources()
- : egl(new EGLWrapper)
- , eglDisplay(0)
- , eglSurface(0)
- , glTexture(0)
- {}
+ : m_egl(new EGLWrapper)
+ , m_eglDisplay(nullptr)
+ , m_eglSurface(nullptr)
+ , m_glTexture(0)
+ , m_glContext(QOpenGLContext::currentContext())
+ {
+ Q_ASSERT(m_glContext);
+ }
+
+ unsigned int glTexture() const
+ {
+ return m_glTexture;
+ }
+
+ bool createTexture(const QVideoSurfaceFormat &format, IDirect3DDevice9Ex *device,
+ IDirect3DTexture9 **texture)
+ {
+ if (!m_glContext)
+ return false;
+
+ m_glContext->functions()->glGenTextures(1, &m_glTexture);
+ QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
+ m_eglDisplay = static_cast<EGLDisplay*>(
+ nativeInterface->nativeResourceForContext("eglDisplay", m_glContext));
+ EGLConfig *eglConfig = static_cast<EGLConfig*>(
+ nativeInterface->nativeResourceForContext("eglConfig", m_glContext));
+
+ const bool hasAlpha = m_glContext->format().hasAlpha();
+
+ EGLint attribs[] = {
+ EGL_WIDTH, format.frameWidth(),
+ EGL_HEIGHT, format.frameHeight(),
+ EGL_TEXTURE_FORMAT, (hasAlpha ? EGL_TEXTURE_RGBA : EGL_TEXTURE_RGB),
+ EGL_TEXTURE_TARGET, EGL_TEXTURE_2D,
+ EGL_NONE
+ };
+
+ m_eglSurface = m_egl->createPbufferSurface(m_eglDisplay, eglConfig, attribs);
+
+ HANDLE share_handle = 0;
+ PFNEGLQUERYSURFACEPOINTERANGLEPROC eglQuerySurfacePointerANGLE =
+ reinterpret_cast<PFNEGLQUERYSURFACEPOINTERANGLEPROC>(
+ m_egl->getProcAddress("eglQuerySurfacePointerANGLE"));
+ Q_ASSERT(eglQuerySurfacePointerANGLE);
+ eglQuerySurfacePointerANGLE(
+ m_eglDisplay,
+ m_eglSurface,
+ EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, &share_handle);
+
+ device->CreateTexture(format.frameWidth(), format.frameHeight(), 1,
+ D3DUSAGE_RENDERTARGET,
+ (hasAlpha ? D3DFMT_A8R8G8B8 : D3DFMT_X8R8G8B8),
+ D3DPOOL_DEFAULT, texture, &share_handle);
+
+ m_glContext->functions()->glBindTexture(GL_TEXTURE_2D, m_glTexture);
+ m_egl->bindTexImage(m_eglDisplay, m_eglSurface, EGL_BACK_BUFFER);
+
+ return texture != NULL;
+ }
void release()
{
@@ -142,24 +197,32 @@ public:
deleteLater();
}
- EGLWrapper *egl;
- EGLDisplay *eglDisplay;
- EGLSurface eglSurface;
- unsigned int glTexture;
-
private:
+ EGLWrapper *m_egl;
+ EGLDisplay *m_eglDisplay;
+ EGLSurface m_eglSurface;
+ unsigned int m_glTexture;
+ QOpenGLContext *m_glContext;
+
~OpenGLResources()
{
- Q_ASSERT(QOpenGLContext::currentContext() != NULL);
+ QScopedPointer<QOffscreenSurface> surface;
+ if (m_glContext != QOpenGLContext::currentContext()) {
+ surface.reset(new QOffscreenSurface);
+ surface->create();
+ m_glContext->makeCurrent(surface.data());
+ }
- if (eglSurface && egl) {
- egl->releaseTexImage(eglDisplay, eglSurface, EGL_BACK_BUFFER);
- egl->destroySurface(eglDisplay, eglSurface);
+ if (m_eglSurface && m_egl) {
+ m_egl->releaseTexImage(m_eglDisplay, m_eglSurface, EGL_BACK_BUFFER);
+ m_egl->destroySurface(m_eglDisplay, m_eglSurface);
}
- if (glTexture)
- QOpenGLContext::currentContext()->functions()->glDeleteTextures(1, &glTexture);
+ if (m_glTexture)
+ m_glContext->functions()->glDeleteTextures(1, &m_glTexture);
- delete egl;
+ delete m_egl;
+ if (surface)
+ m_glContext->doneCurrent();
}
};
@@ -257,9 +320,9 @@ QVariant IMFSampleVideoBuffer::handle() const
if (handleType() != GLTextureHandle)
return handle;
- if (m_engine->m_glResources && (m_textureUpdated || m_engine->updateTexture(m_surface))) {
+ if (m_textureUpdated || m_engine->updateTexture(m_surface)) {
m_textureUpdated = true;
- handle = QVariant::fromValue<unsigned int>(m_engine->m_glResources->glTexture);
+ handle = QVariant::fromValue<unsigned int>(m_engine->m_glResources->glTexture());
}
#endif
@@ -518,6 +581,10 @@ done:
: qt_evr_pixelFormatFromD3DFormat(d3dFormat),
m_useTextureRendering ? QAbstractVideoBuffer::GLTextureHandle
: QAbstractVideoBuffer::NoHandle);
+ UINT32 horizontal = 1, vertical = 1;
+ hr = MFGetAttributeRatio(format, MF_MT_PIXEL_ASPECT_RATIO, &horizontal, &vertical);
+ if (SUCCEEDED(hr))
+ m_surfaceFormat.setPixelAspectRatio(horizontal, vertical);
} else {
releaseResources();
}
@@ -553,61 +620,11 @@ QVideoFrame D3DPresentEngine::makeVideoFrame(IMFSample *sample)
bool D3DPresentEngine::createRenderTexture()
{
- if (m_texture)
- return true;
-
- Q_ASSERT(QOpenGLContext::currentContext() != NULL);
-
- if (!m_glResources)
- m_glResources = new OpenGLResources;
-
- QOpenGLContext *currentContext = QOpenGLContext::currentContext();
- if (!currentContext)
- return false;
-
- QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
- m_glResources->eglDisplay = static_cast<EGLDisplay*>(
- nativeInterface->nativeResourceForContext("eglDisplay", currentContext));
- EGLConfig *eglConfig = static_cast<EGLConfig*>(
- nativeInterface->nativeResourceForContext("eglConfig", currentContext));
-
- currentContext->functions()->glGenTextures(1, &m_glResources->glTexture);
-
- bool hasAlpha = currentContext->format().hasAlpha();
-
- EGLint attribs[] = {
- EGL_WIDTH, m_surfaceFormat.frameWidth(),
- EGL_HEIGHT, m_surfaceFormat.frameHeight(),
- EGL_TEXTURE_FORMAT, hasAlpha ? EGL_TEXTURE_RGBA : EGL_TEXTURE_RGB,
- EGL_TEXTURE_TARGET, EGL_TEXTURE_2D,
- EGL_NONE
- };
-
- EGLSurface pbuffer = m_glResources->egl->createPbufferSurface(m_glResources->eglDisplay, eglConfig, attribs);
-
- HANDLE share_handle = 0;
- PFNEGLQUERYSURFACEPOINTERANGLEPROC eglQuerySurfacePointerANGLE =
- reinterpret_cast<PFNEGLQUERYSURFACEPOINTERANGLEPROC>(m_glResources->egl->getProcAddress("eglQuerySurfacePointerANGLE"));
- Q_ASSERT(eglQuerySurfacePointerANGLE);
- eglQuerySurfacePointerANGLE(
- m_glResources->eglDisplay,
- pbuffer,
- EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, &share_handle);
-
-
- m_device->CreateTexture(m_surfaceFormat.frameWidth(), m_surfaceFormat.frameHeight(), 1,
- D3DUSAGE_RENDERTARGET,
- hasAlpha ? D3DFMT_A8R8G8B8 : D3DFMT_X8R8G8B8,
- D3DPOOL_DEFAULT,
- &m_texture,
- &share_handle);
-
- m_glResources->eglSurface = pbuffer;
-
- QOpenGLContext::currentContext()->functions()->glBindTexture(GL_TEXTURE_2D, m_glResources->glTexture);
- m_glResources->egl->bindTexImage(m_glResources->eglDisplay, m_glResources->eglSurface, EGL_BACK_BUFFER);
+ if (m_glResources)
+ m_glResources->release();
- return m_texture != NULL;
+ m_glResources = new OpenGLResources;
+ return m_glResources->createTexture(m_surfaceFormat, m_device, &m_texture);
}
bool D3DPresentEngine::updateTexture(IDirect3DSurface9 *src)
diff --git a/src/plugins/directshow/camera/dscamerasession.cpp b/src/plugins/directshow/camera/dscamerasession.cpp
index 195712057..6590afeb9 100644
--- a/src/plugins/directshow/camera/dscamerasession.cpp
+++ b/src/plugins/directshow/camera/dscamerasession.cpp
@@ -815,8 +815,8 @@ bool DSCameraSession::configurePreviewFormat()
return false;
}
- // Set sample grabber format (always RGB32)
- static const AM_MEDIA_TYPE grabberFormat { MEDIATYPE_Video, MEDIASUBTYPE_RGB32, 0, 0, 0, FORMAT_VideoInfo, nullptr, 0, nullptr};
+ // Set sample grabber format
+ static const AM_MEDIA_TYPE grabberFormat { MEDIATYPE_Video, MEDIASUBTYPE_ARGB32, 0, 0, 0, FORMAT_VideoInfo, nullptr, 0, nullptr};
if (!m_previewSampleGrabber->setMediaType(&grabberFormat))
return false;
diff --git a/src/plugins/directshow/dsserviceplugin.cpp b/src/plugins/directshow/dsserviceplugin.cpp
index 51be7e500..cb4f0cdf9 100644
--- a/src/plugins/directshow/dsserviceplugin.cpp
+++ b/src/plugins/directshow/dsserviceplugin.cpp
@@ -123,7 +123,9 @@ QMediaServiceProviderHint::Features DSServicePlugin::supportedFeatures(
QByteArray DSServicePlugin::defaultDevice(const QByteArray &service) const
{
if (service == Q_MEDIASERVICE_CAMERA) {
+ addRefCount();
const QList<DSVideoDeviceInfo> &devs = DSVideoDeviceControl::availableDevices();
+ releaseRefCount();
if (!devs.isEmpty())
return devs.first().first;
}
@@ -135,7 +137,9 @@ QList<QByteArray> DSServicePlugin::devices(const QByteArray &service) const
QList<QByteArray> result;
if (service == Q_MEDIASERVICE_CAMERA) {
+ addRefCount();
const QList<DSVideoDeviceInfo> &devs = DSVideoDeviceControl::availableDevices();
+ releaseRefCount();
for (const DSVideoDeviceInfo &info : devs)
result.append(info.first);
}
@@ -146,7 +150,9 @@ QList<QByteArray> DSServicePlugin::devices(const QByteArray &service) const
QString DSServicePlugin::deviceDescription(const QByteArray &service, const QByteArray &device)
{
if (service == Q_MEDIASERVICE_CAMERA) {
+ addRefCount();
const QList<DSVideoDeviceInfo> &devs = DSVideoDeviceControl::availableDevices();
+ releaseRefCount();
for (const DSVideoDeviceInfo &info : devs) {
if (info.first == device)
return info.second;
diff --git a/src/plugins/directshow/player/directshowplayerservice.cpp b/src/plugins/directshow/player/directshowplayerservice.cpp
index 8ee5d67a1..2218ca5ed 100644
--- a/src/plugins/directshow/player/directshowplayerservice.cpp
+++ b/src/plugins/directshow/player/directshowplayerservice.cpp
@@ -318,18 +318,15 @@ void DirectShowPlayerService::load(const QMediaContent &media, QIODevice *stream
m_graphStatus = InvalidMedia;
m_error = QMediaPlayer::ResourceError;
} else {
- // {36b73882-c2c8-11cf-8b46-00805f6cef60}
- static const GUID iid_IFilterGraph2 = {
- 0x36b73882, 0xc2c8, 0x11cf, {0x8b, 0x46, 0x00, 0x80, 0x5f, 0x6c, 0xef, 0x60} };
m_graphStatus = Loading;
- m_graph = com_new<IFilterGraph2>(CLSID_FilterGraph, iid_IFilterGraph2);
-
if (stream)
m_pendingTasks = SetStreamSource;
else
m_pendingTasks = SetUrlSource;
+ m_pendingTasks |= CreateGraph;
+
::SetEvent(m_taskHandle);
}
@@ -340,6 +337,17 @@ void DirectShowPlayerService::load(const QMediaContent &media, QIODevice *stream
updateStatus();
}
+void DirectShowPlayerService::doCreateGraph(QMutexLocker *locker)
+{
+ Q_UNUSED(locker);
+
+ // {36b73882-c2c8-11cf-8b46-00805f6cef60}
+ static const GUID iid_IFilterGraph2 = {
+ 0x36b73882, 0xc2c8, 0x11cf, {0x8b, 0x46, 0x00, 0x80, 0x5f, 0x6c, 0xef, 0x60} };
+
+ m_graph = com_new<IFilterGraph2>(CLSID_FilterGraphNoThread, iid_IFilterGraph2);
+}
+
void DirectShowPlayerService::doSetUrlSource(QMutexLocker *locker)
{
IBaseFilter *source = 0;
@@ -1686,6 +1694,8 @@ void DirectShowPlayerService::run()
{
QMutexLocker locker(&m_mutex);
+ CoInitialize(NULL);
+
for (;;) {
while (m_pendingTasks == 0) {
DWORD result = 0;
@@ -1700,12 +1710,17 @@ void DirectShowPlayerService::run()
}
locker.relock();
- if (result == WAIT_OBJECT_0 + 1) {
+ if (m_graph && result == WAIT_OBJECT_0 + 1) {
graphEvent(&locker);
}
}
- if (m_pendingTasks & ReleaseGraph) {
+ if (m_pendingTasks & CreateGraph) {
+ m_pendingTasks ^= CreateGraph;
+ m_executingTask = CreateGraph;
+
+ doCreateGraph(&locker);
+ } else if (m_pendingTasks & ReleaseGraph) {
m_pendingTasks ^= ReleaseGraph;
m_executingTask = ReleaseGraph;
@@ -1798,6 +1813,8 @@ void DirectShowPlayerService::run()
}
m_executingTask = 0;
}
+
+ CoUninitialize();
}
QT_END_NAMESPACE
diff --git a/src/plugins/directshow/player/directshowplayerservice.h b/src/plugins/directshow/player/directshowplayerservice.h
index 01d05449e..cc7b4dd3e 100644
--- a/src/plugins/directshow/player/directshowplayerservice.h
+++ b/src/plugins/directshow/player/directshowplayerservice.h
@@ -124,6 +124,7 @@ private:
void run();
+ void doCreateGraph(QMutexLocker *locker);
void doSetUrlSource(QMutexLocker *locker);
void doSetStreamSource(QMutexLocker *locker);
void doRender(QMutexLocker *locker);
@@ -169,7 +170,8 @@ private:
ReleaseVideoProbe = 0x40000,
ReleaseFilters = ReleaseGraph | ReleaseAudioOutput
| ReleaseVideoOutput | ReleaseAudioProbe
- | ReleaseVideoProbe
+ | ReleaseVideoProbe,
+ CreateGraph = 0x80000
};
enum Event
diff --git a/src/plugins/gstreamer/camerabin/camerabinsession.cpp b/src/plugins/gstreamer/camerabin/camerabinsession.cpp
index 4941c6ef6..cfac61c01 100644
--- a/src/plugins/gstreamer/camerabin/camerabinsession.cpp
+++ b/src/plugins/gstreamer/camerabin/camerabinsession.cpp
@@ -466,6 +466,9 @@ GstElement *CameraBinSession::buildCameraSource()
#if CAMERABIN_DEBUG
qDebug() << Q_FUNC_INFO;
#endif
+ if (m_inputDevice.isEmpty())
+ return nullptr;
+
if (!m_inputDeviceHasChanged)
return m_cameraSrc;
@@ -482,7 +485,7 @@ GstElement *CameraBinSession::buildCameraSource()
if (!m_cameraSrc)
m_cameraSrc = camSrc;
- if (m_cameraSrc && !m_inputDevice.isEmpty()) {
+ if (m_cameraSrc) {
#if CAMERABIN_DEBUG
qDebug() << "set camera device" << m_inputDevice;
#endif
@@ -729,18 +732,21 @@ void CameraBinSession::setState(QCamera::State newState)
if (newState == m_pendingState)
return;
- m_pendingState = newState;
- emit pendingStateChanged(m_pendingState);
+ emit pendingStateChanged(newState);
#if CAMERABIN_DEBUG
qDebug() << Q_FUNC_INFO << newState;
#endif
setStateHelper(newState);
+ m_pendingState = newState;
}
void CameraBinSession::setStateHelper(QCamera::State state)
{
+ if (state == m_pendingState)
+ return;
+
switch (state) {
case QCamera::UnloadedState:
unload();
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index 98a1bf242..71b9ec6e1 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -40,7 +40,8 @@ win32:!winrt {
winrt {
- SUBDIRS += winrt
+ SUBDIRS += winrt \
+ audiocapture
}
unix:!mac:!android {
diff --git a/src/plugins/wasapi/qwasapiaudiodeviceinfo.cpp b/src/plugins/wasapi/qwasapiaudiodeviceinfo.cpp
index e1a46841d..53345dec8 100644
--- a/src/plugins/wasapi/qwasapiaudiodeviceinfo.cpp
+++ b/src/plugins/wasapi/qwasapiaudiodeviceinfo.cpp
@@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcMmDeviceInfo, "qt.multimedia.deviceinfo")
QWasapiAudioDeviceInfo::QWasapiAudioDeviceInfo(QByteArray dev, QAudio::Mode mode)
- : m_deviceName(dev)
+ : m_deviceName(QString::fromLocal8Bit(dev))
{
qCDebug(lcMmDeviceInfo) << __FUNCTION__ << dev << mode;
m_interface = QWasapiUtils::createOrGetInterface(dev, mode);
diff --git a/src/plugins/windowsaudio/qwindowsaudiodeviceinfo.cpp b/src/plugins/windowsaudio/qwindowsaudiodeviceinfo.cpp
index 83e9ccfc8..c054c0f76 100644
--- a/src/plugins/windowsaudio/qwindowsaudiodeviceinfo.cpp
+++ b/src/plugins/windowsaudio/qwindowsaudiodeviceinfo.cpp
@@ -238,21 +238,16 @@ void QWindowsAudioDeviceInfo::updateLists()
if (!sizez.isEmpty())
return;
- bool hasCaps = false;
DWORD fmt = 0;
if(mode == QAudio::AudioOutput) {
WAVEOUTCAPS woc;
- if (waveOutGetDevCaps(devId, &woc, sizeof(WAVEOUTCAPS)) == MMSYSERR_NOERROR) {
- hasCaps = true;
+ if (waveOutGetDevCaps(devId, &woc, sizeof(WAVEOUTCAPS)) == MMSYSERR_NOERROR)
fmt = woc.dwFormats;
- }
} else {
WAVEINCAPS woc;
- if (waveInGetDevCaps(devId, &woc, sizeof(WAVEINCAPS)) == MMSYSERR_NOERROR) {
- hasCaps = true;
+ if (waveInGetDevCaps(devId, &woc, sizeof(WAVEINCAPS)) == MMSYSERR_NOERROR)
fmt = woc.dwFormats;
- }
}
sizez.clear();
@@ -260,7 +255,7 @@ void QWindowsAudioDeviceInfo::updateLists()
channelz.clear();
typez.clear();
- if (hasCaps) {
+ if (fmt) {
// Check sample size
if ((fmt & WAVE_FORMAT_1M08)
|| (fmt & WAVE_FORMAT_1S08)
diff --git a/src/plugins/windowsaudio/qwindowsaudiooutput.cpp b/src/plugins/windowsaudio/qwindowsaudiooutput.cpp
index 815b78979..eb4caf128 100644
--- a/src/plugins/windowsaudio/qwindowsaudiooutput.cpp
+++ b/src/plugins/windowsaudio/qwindowsaudiooutput.cpp
@@ -298,10 +298,7 @@ void QWindowsAudioOutput::close()
deviceState = QAudio::StoppedState;
errorState = QAudio::NoError;
- int delay = (buffer_size-bytesFree())*1000/(settings.sampleRate()
- *settings.channelCount()*(settings.sampleSize()/8));
waveOutReset(hWaveOut);
- Sleep(delay+10);
freeBlocks(waveBlocks);
waveOutClose(hWaveOut);
diff --git a/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp b/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp
index 7030b3357..c51aec088 100644
--- a/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp
+++ b/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp
@@ -382,9 +382,9 @@ QAbstractVideoSurface *QDeclarativeVideoRendererBackend::videoSurface() const
QRectF QDeclarativeVideoRendererBackend::adjustedViewport() const
{
const QRectF viewport = m_surface->surfaceFormat().viewport();
- const QSize pixelAspectRatio = m_surface->surfaceFormat().pixelAspectRatio();
+ const QSizeF pixelAspectRatio = m_surface->surfaceFormat().pixelAspectRatio();
- if (pixelAspectRatio.height() != 0) {
+ if (pixelAspectRatio.isValid()) {
const qreal ratio = pixelAspectRatio.width() / pixelAspectRatio.height();
QRectF result = viewport;
result.setX(result.x() * ratio);
diff --git a/src/qtmultimediaquicktools/qsgvideonode_rgb.cpp b/src/qtmultimediaquicktools/qsgvideonode_rgb.cpp
index 0dfa11ab9..d039e1e0b 100644
--- a/src/qtmultimediaquicktools/qsgvideonode_rgb.cpp
+++ b/src/qtmultimediaquicktools/qsgvideonode_rgb.cpp
@@ -113,11 +113,19 @@ protected:
class QSGVideoMaterialShader_RGB_swizzle : public QSGVideoMaterialShader_RGB
{
public:
- QSGVideoMaterialShader_RGB_swizzle()
- : QSGVideoMaterialShader_RGB()
+ QSGVideoMaterialShader_RGB_swizzle(bool hasAlpha)
+ : m_hasAlpha(hasAlpha)
{
setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qtmultimediaquicktools/shaders/rgbvideo_swizzle.frag"));
}
+
+protected:
+ void initialize() override {
+ QSGVideoMaterialShader_RGB::initialize();
+ program()->setUniformValue(program()->uniformLocation("hasAlpha"), GLboolean(m_hasAlpha));
+ }
+
+ bool m_hasAlpha;
};
@@ -145,7 +153,8 @@ public:
}
QSGMaterialShader *createShader() const override {
- return needsSwizzling() ? new QSGVideoMaterialShader_RGB_swizzle
+ const bool hasAlpha = m_format.pixelFormat() == QVideoFrame::Format_ARGB32;
+ return needsSwizzling() ? new QSGVideoMaterialShader_RGB_swizzle(hasAlpha)
: new QSGVideoMaterialShader_RGB;
}
diff --git a/src/qtmultimediaquicktools/qsgvideonode_texture.cpp b/src/qtmultimediaquicktools/qsgvideonode_texture.cpp
index a26d59532..f5545afc7 100644
--- a/src/qtmultimediaquicktools/qsgvideonode_texture.cpp
+++ b/src/qtmultimediaquicktools/qsgvideonode_texture.cpp
@@ -108,11 +108,19 @@ protected:
class QSGVideoMaterialShader_Texture_swizzle : public QSGVideoMaterialShader_Texture
{
public:
- QSGVideoMaterialShader_Texture_swizzle()
- : QSGVideoMaterialShader_Texture()
+ QSGVideoMaterialShader_Texture_swizzle(bool hasAlpha)
+ : m_hasAlpha(hasAlpha)
{
setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qtmultimediaquicktools/shaders/rgbvideo_swizzle.frag"));
}
+
+protected:
+ void initialize() override {
+ QSGVideoMaterialShader_Texture::initialize();
+ program()->setUniformValue(program()->uniformLocation("hasAlpha"), GLboolean(m_hasAlpha));
+ }
+
+ int m_hasAlpha;
};
@@ -138,7 +146,8 @@ public:
}
QSGMaterialShader *createShader() const override {
- return needsSwizzling() ? new QSGVideoMaterialShader_Texture_swizzle
+ const bool hasAlpha = m_format.pixelFormat() == QVideoFrame::Format_ARGB32;
+ return needsSwizzling() ? new QSGVideoMaterialShader_Texture_swizzle(hasAlpha)
: new QSGVideoMaterialShader_Texture;
}
diff --git a/src/qtmultimediaquicktools/shaders/rgbvideo_swizzle.frag b/src/qtmultimediaquicktools/shaders/rgbvideo_swizzle.frag
index f01dc86a0..df66bde63 100644
--- a/src/qtmultimediaquicktools/shaders/rgbvideo_swizzle.frag
+++ b/src/qtmultimediaquicktools/shaders/rgbvideo_swizzle.frag
@@ -1,8 +1,10 @@
uniform sampler2D rgbTexture;
uniform lowp float opacity;
varying highp vec2 qt_TexCoord;
+uniform bool hasAlpha;
void main()
{
- gl_FragColor = vec4(texture2D(rgbTexture, qt_TexCoord).bgr, 1.0) * opacity;
+ vec4 v = texture2D(rgbTexture, qt_TexCoord);
+ gl_FragColor = vec4(v.bgr, hasAlpha ? v.a : 1.0) * opacity;
}