diff options
Diffstat (limited to 'src')
188 files changed, 1658 insertions, 998 deletions
diff --git a/src/gsttools/gsttools.pro b/src/gsttools/gsttools.pro index ca111b3f2..b13479ce7 100644 --- a/src/gsttools/gsttools.pro +++ b/src/gsttools/gsttools.pro @@ -15,12 +15,6 @@ QMAKE_USE += gstreamer qtConfig(resourcepolicy): \ QMAKE_USE += libresourceqt5 -# Header files must go inside source directory of a module -# to be installed by syncqt. -INCLUDEPATH += ../multimedia/gsttools_headers/ -INCLUDEPATH += ../plugins/gstreamer/mediaplayer/ -VPATH += ../multimedia/gsttools_headers/ - PRIVATE_HEADERS += \ qgstreamerbushelper_p.h \ qgstreamermessage_p.h \ diff --git a/src/multimedia/gsttools_headers/gstvideoconnector_p.h b/src/gsttools/gstvideoconnector_p.h index a38ca2e65..a38ca2e65 100644 --- a/src/multimedia/gsttools_headers/gstvideoconnector_p.h +++ b/src/gsttools/gstvideoconnector_p.h diff --git a/src/multimedia/gsttools_headers/qgstappsrc_p.h b/src/gsttools/qgstappsrc_p.h index c7e87037d..c7e87037d 100644 --- a/src/multimedia/gsttools_headers/qgstappsrc_p.h +++ b/src/gsttools/qgstappsrc_p.h diff --git a/src/multimedia/gsttools_headers/qgstbufferpoolinterface_p.h b/src/gsttools/qgstbufferpoolinterface_p.h index 45e573262..45e573262 100644 --- a/src/multimedia/gsttools_headers/qgstbufferpoolinterface_p.h +++ b/src/gsttools/qgstbufferpoolinterface_p.h diff --git a/src/multimedia/gsttools_headers/qgstcodecsinfo_p.h b/src/gsttools/qgstcodecsinfo_p.h index 33ab3de4b..33ab3de4b 100644 --- a/src/multimedia/gsttools_headers/qgstcodecsinfo_p.h +++ b/src/gsttools/qgstcodecsinfo_p.h diff --git a/src/multimedia/gsttools_headers/qgstreameraudioinputselector_p.h b/src/gsttools/qgstreameraudioinputselector_p.h index 0c193fda9..0c193fda9 100644 --- a/src/multimedia/gsttools_headers/qgstreameraudioinputselector_p.h +++ b/src/gsttools/qgstreameraudioinputselector_p.h diff --git a/src/multimedia/gsttools_headers/qgstreameraudioprobecontrol_p.h b/src/gsttools/qgstreameraudioprobecontrol_p.h index 4fc5c7704..4fc5c7704 100644 --- a/src/multimedia/gsttools_headers/qgstreameraudioprobecontrol_p.h +++ b/src/gsttools/qgstreameraudioprobecontrol_p.h diff --git a/src/multimedia/gsttools_headers/qgstreamerbufferprobe_p.h b/src/gsttools/qgstreamerbufferprobe_p.h index 35644f934..35644f934 100644 --- a/src/multimedia/gsttools_headers/qgstreamerbufferprobe_p.h +++ b/src/gsttools/qgstreamerbufferprobe_p.h diff --git a/src/multimedia/gsttools_headers/qgstreamerbushelper_p.h b/src/gsttools/qgstreamerbushelper_p.h index c7d06faf8..c7d06faf8 100644 --- a/src/multimedia/gsttools_headers/qgstreamerbushelper_p.h +++ b/src/gsttools/qgstreamerbushelper_p.h diff --git a/src/multimedia/gsttools_headers/qgstreamermessage_p.h b/src/gsttools/qgstreamermessage_p.h index 2f9d1745c..2f9d1745c 100644 --- a/src/multimedia/gsttools_headers/qgstreamermessage_p.h +++ b/src/gsttools/qgstreamermessage_p.h diff --git a/src/multimedia/gsttools_headers/qgstreamermirtexturerenderer_p.h b/src/gsttools/qgstreamermirtexturerenderer_p.h index 62150f7e1..62150f7e1 100644 --- a/src/multimedia/gsttools_headers/qgstreamermirtexturerenderer_p.h +++ b/src/gsttools/qgstreamermirtexturerenderer_p.h diff --git a/src/multimedia/gsttools_headers/qgstreamerplayercontrol_p.h b/src/gsttools/qgstreamerplayercontrol_p.h index e2252ea52..e2252ea52 100644 --- a/src/multimedia/gsttools_headers/qgstreamerplayercontrol_p.h +++ b/src/gsttools/qgstreamerplayercontrol_p.h diff --git a/src/multimedia/gsttools_headers/qgstreamerplayersession_p.h b/src/gsttools/qgstreamerplayersession_p.h index b613793c4..b613793c4 100644 --- a/src/multimedia/gsttools_headers/qgstreamerplayersession_p.h +++ b/src/gsttools/qgstreamerplayersession_p.h diff --git a/src/multimedia/gsttools_headers/qgstreamervideoinputdevicecontrol_p.h b/src/gsttools/qgstreamervideoinputdevicecontrol_p.h index b660cc7b3..b660cc7b3 100644 --- a/src/multimedia/gsttools_headers/qgstreamervideoinputdevicecontrol_p.h +++ b/src/gsttools/qgstreamervideoinputdevicecontrol_p.h diff --git a/src/multimedia/gsttools_headers/qgstreamervideooverlay_p.h b/src/gsttools/qgstreamervideooverlay_p.h index f2ca8a23b..f2ca8a23b 100644 --- a/src/multimedia/gsttools_headers/qgstreamervideooverlay_p.h +++ b/src/gsttools/qgstreamervideooverlay_p.h diff --git a/src/multimedia/gsttools_headers/qgstreamervideoprobecontrol_p.h b/src/gsttools/qgstreamervideoprobecontrol_p.h index b15b6099c..b15b6099c 100644 --- a/src/multimedia/gsttools_headers/qgstreamervideoprobecontrol_p.h +++ b/src/gsttools/qgstreamervideoprobecontrol_p.h diff --git a/src/multimedia/gsttools_headers/qgstreamervideorenderer_p.h b/src/gsttools/qgstreamervideorenderer_p.h index d87bfcb8f..d87bfcb8f 100644 --- a/src/multimedia/gsttools_headers/qgstreamervideorenderer_p.h +++ b/src/gsttools/qgstreamervideorenderer_p.h diff --git a/src/multimedia/gsttools_headers/qgstreamervideorendererinterface_p.h b/src/gsttools/qgstreamervideorendererinterface_p.h index 231c843db..231c843db 100644 --- a/src/multimedia/gsttools_headers/qgstreamervideorendererinterface_p.h +++ b/src/gsttools/qgstreamervideorendererinterface_p.h diff --git a/src/gsttools/qgstreamervideowidget.cpp b/src/gsttools/qgstreamervideowidget.cpp index 633f39fa2..bb85e1eb7 100644 --- a/src/gsttools/qgstreamervideowidget.cpp +++ b/src/gsttools/qgstreamervideowidget.cpp @@ -53,7 +53,7 @@ public: { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QPalette palette; - palette.setColor(QPalette::Background, Qt::black); + palette.setColor(QPalette::Window, Qt::black); setPalette(palette); } @@ -80,7 +80,7 @@ public: void paint_helper() { QPainter painter(this); - painter.fillRect(rect(), palette().background()); + painter.fillRect(rect(), palette().window()); } protected: diff --git a/src/multimedia/gsttools_headers/qgstreamervideowidget_p.h b/src/gsttools/qgstreamervideowidget_p.h index 1ddb738df..1ddb738df 100644 --- a/src/multimedia/gsttools_headers/qgstreamervideowidget_p.h +++ b/src/gsttools/qgstreamervideowidget_p.h diff --git a/src/multimedia/gsttools_headers/qgstreamervideowindow_p.h b/src/gsttools/qgstreamervideowindow_p.h index 5f893f10e..5f893f10e 100644 --- a/src/multimedia/gsttools_headers/qgstreamervideowindow_p.h +++ b/src/gsttools/qgstreamervideowindow_p.h diff --git a/src/multimedia/gsttools_headers/qgsttools_global_p.h b/src/gsttools/qgsttools_global_p.h index babcd3aaf..babcd3aaf 100644 --- a/src/multimedia/gsttools_headers/qgsttools_global_p.h +++ b/src/gsttools/qgsttools_global_p.h diff --git a/src/gsttools/qgstutils.cpp b/src/gsttools/qgstutils.cpp index 58dd6e5fe..06f277766 100644 --- a/src/gsttools/qgstutils.cpp +++ b/src/gsttools/qgstutils.cpp @@ -686,6 +686,67 @@ QVector<QGstUtils::CameraInfo> QGstUtils::enumerateCameras(GstElementFactory *fa camerasCacheAgeTimer.restart(); #endif // linux_v4l +#if GST_CHECK_VERSION(1,4,0) && (defined(Q_OS_WIN) || defined(Q_OS_MACOS)) + if (!devices.isEmpty()) + return devices; + +#if defined(Q_OS_WIN) + const char *propName = "device-path"; + auto deviceDesc = [](GValue *value) { + gchar *desc = g_value_dup_string(value); + const QString id = QLatin1String(desc); + g_free(desc); + return id; + }; +#elif defined(Q_OS_MACOS) + const char *propName = "device-index"; + auto deviceDesc = [](GValue *value) { + return QString::number(g_value_get_int(value)); + }; +#endif + + QGstUtils::initializeGst(); + GstDeviceMonitor *monitor = gst_device_monitor_new(); + auto caps = gst_caps_new_empty_simple("video/x-raw"); + gst_device_monitor_add_filter(monitor, "Video/Source", caps); + gst_caps_unref(caps); + + GList *devs = gst_device_monitor_get_devices(monitor); + while (devs) { + GstDevice *dev = reinterpret_cast<GstDevice*>(devs->data); + GstElement *element = gst_device_create_element(dev, nullptr); + if (element) { + gchar *name = gst_device_get_display_name(dev); + const QString deviceName = QLatin1String(name); + g_free(name); + GParamSpec *prop = g_object_class_find_property(G_OBJECT_GET_CLASS(element), propName); + if (prop) { + GValue value = G_VALUE_INIT; + g_value_init(&value, prop->value_type); + g_object_get_property(G_OBJECT(element), prop->name, &value); + const QString deviceId = deviceDesc(&value); + g_value_unset(&value); + + CameraInfo device = { + deviceId, + deviceName, + 0, + QCamera::UnspecifiedPosition, + QByteArray() + }; + + devices.append(device); + } + + gst_object_unref(element); + } + + gst_object_unref(dev); + devs = g_list_delete_link(devs, devs); + } + gst_object_unref(monitor); +#endif // GST_CHECK_VERSION(1,4,0) && (defined(Q_OS_WIN) || defined(Q_OS_MACOS)) + return devices; } @@ -1474,6 +1535,37 @@ QString QGstUtils::fileExtensionForMimeType(const QString &mimeType) return extension; } +#if GST_CHECK_VERSION(0,10,30) +QVariant QGstUtils::fromGStreamerOrientation(const QVariant &value) +{ + // Note gstreamer tokens either describe the counter clockwise rotation of the + // image or the clockwise transform to apply to correct the image. The orientation + // value returned is the clockwise rotation of the image. + const QString token = value.toString(); + if (token == QStringLiteral("rotate-90")) + return 270; + if (token == QStringLiteral("rotate-180")) + return 180; + if (token == QStringLiteral("rotate-270")) + return 90; + return 0; +} + +QVariant QGstUtils::toGStreamerOrientation(const QVariant &value) +{ + switch (value.toInt()) { + case 90: + return QStringLiteral("rotate-270"); + case 180: + return QStringLiteral("rotate-180"); + case 270: + return QStringLiteral("rotate-90"); + default: + return QStringLiteral("rotate-0"); + } +} +#endif + void qt_gst_object_ref_sink(gpointer object) { #if GST_CHECK_VERSION(0,10,24) diff --git a/src/multimedia/gsttools_headers/qgstutils_p.h b/src/gsttools/qgstutils_p.h index 24d3e889d..387a2e27a 100644 --- a/src/multimedia/gsttools_headers/qgstutils_p.h +++ b/src/gsttools/qgstutils_p.h @@ -148,6 +148,11 @@ namespace QGstUtils { Q_GSTTOOLS_EXPORT QPair<qreal, qreal> structureFrameRateRange(const GstStructure *s); Q_GSTTOOLS_EXPORT QString fileExtensionForMimeType(const QString &mimeType); + +#if GST_CHECK_VERSION(0,10,30) + Q_GSTTOOLS_EXPORT QVariant fromGStreamerOrientation(const QVariant &value); + Q_GSTTOOLS_EXPORT QVariant toGStreamerOrientation(const QVariant &value); +#endif } Q_GSTTOOLS_EXPORT void qt_gst_object_ref_sink(gpointer object); diff --git a/src/multimedia/gsttools_headers/qgstvideobuffer_p.h b/src/gsttools/qgstvideobuffer_p.h index c67c57021..6681070da 100644 --- a/src/multimedia/gsttools_headers/qgstvideobuffer_p.h +++ b/src/gsttools/qgstvideobuffer_p.h @@ -78,6 +78,7 @@ public: ~QGstVideoBuffer(); + GstBuffer *buffer() const { return m_buffer; } MapMode mapMode() const override; #if GST_CHECK_VERSION(1,0,0) diff --git a/src/multimedia/gsttools_headers/qgstvideorendererplugin_p.h b/src/gsttools/qgstvideorendererplugin_p.h index df36dbe09..df36dbe09 100644 --- a/src/multimedia/gsttools_headers/qgstvideorendererplugin_p.h +++ b/src/gsttools/qgstvideorendererplugin_p.h diff --git a/src/multimedia/gsttools_headers/qgstvideorenderersink_p.h b/src/gsttools/qgstvideorenderersink_p.h index d2417a7c9..d2417a7c9 100644 --- a/src/multimedia/gsttools_headers/qgstvideorenderersink_p.h +++ b/src/gsttools/qgstvideorenderersink_p.h diff --git a/src/multimedia/gsttools_headers/qvideosurfacegstsink_p.h b/src/gsttools/qvideosurfacegstsink_p.h index 961cf91d2..961cf91d2 100644 --- a/src/multimedia/gsttools_headers/qvideosurfacegstsink_p.h +++ b/src/gsttools/qvideosurfacegstsink_p.h diff --git a/src/imports/multimedia/multimedia.cpp b/src/imports/multimedia/multimedia.cpp index e63eecc49..f9170f790 100644 --- a/src/imports/multimedia/multimedia.cpp +++ b/src/imports/multimedia/multimedia.cpp @@ -92,17 +92,17 @@ public: qmlRegisterType<QDeclarativeCamera>(uri, 5, 0, "Camera"); qmlRegisterType<QDeclarativeTorch>(uri, 5, 0, "Torch"); qmlRegisterUncreatableType<QDeclarativeCameraCapture>(uri, 5, 0, "CameraCapture", - trUtf8("CameraCapture is provided by Camera")); + tr("CameraCapture is provided by Camera")); qmlRegisterUncreatableType<QDeclarativeCameraRecorder>(uri, 5, 0, "CameraRecorder", - trUtf8("CameraRecorder is provided by Camera")); + tr("CameraRecorder is provided by Camera")); qmlRegisterUncreatableType<QDeclarativeCameraExposure>(uri, 5, 0, "CameraExposure", - trUtf8("CameraExposure is provided by Camera")); + tr("CameraExposure is provided by Camera")); qmlRegisterUncreatableType<QDeclarativeCameraFocus>(uri, 5, 0, "CameraFocus", - trUtf8("CameraFocus is provided by Camera")); + tr("CameraFocus is provided by Camera")); qmlRegisterUncreatableType<QDeclarativeCameraFlash>(uri, 5, 0, "CameraFlash", - trUtf8("CameraFlash is provided by Camera")); + tr("CameraFlash is provided by Camera")); qmlRegisterUncreatableType<QDeclarativeCameraImageProcessing>(uri, 5, 0, "CameraImageProcessing", - trUtf8("CameraImageProcessing is provided by Camera")); + tr("CameraImageProcessing is provided by Camera")); // 5.2 types qmlRegisterType<QDeclarativeVideoOutput, 2>(uri, 5, 2, "VideoOutput"); @@ -116,10 +116,10 @@ public: qmlRegisterSingletonType<QDeclarativeMultimediaGlobal>(uri, 5, 4, "QtMultimedia", multimedia_global_object); qmlRegisterType<QDeclarativeCamera, 1>(uri, 5, 4, "Camera"); qmlRegisterUncreatableType<QDeclarativeCameraViewfinder>(uri, 5, 4, "CameraViewfinder", - trUtf8("CameraViewfinder is provided by Camera")); + tr("CameraViewfinder is provided by Camera")); // 5.5 types - qmlRegisterUncreatableType<QDeclarativeCameraImageProcessing, 1>(uri, 5, 5, "CameraImageProcessing", trUtf8("CameraImageProcessing is provided by Camera")); + qmlRegisterUncreatableType<QDeclarativeCameraImageProcessing, 1>(uri, 5, 5, "CameraImageProcessing", tr("CameraImageProcessing is provided by Camera")); qmlRegisterType<QDeclarativeCamera, 2>(uri, 5, 5, "Camera"); // 5.6 types @@ -131,7 +131,7 @@ public: // 5.7 types qmlRegisterType<QDeclarativePlaylist, 1>(uri, 5, 7, "Playlist"); qmlRegisterUncreatableType<QDeclarativeCameraImageProcessing, 2>(uri, 5, 7, "CameraImageProcessing", - trUtf8("CameraImageProcessing is provided by Camera")); + tr("CameraImageProcessing is provided by Camera")); // 5.8 types (nothing new, re-register one of the types) qmlRegisterType<QSoundEffect>(uri, 5, 8, "SoundEffect"); @@ -140,19 +140,19 @@ public: qmlRegisterType<QDeclarativeAudio, 2>(uri, 5, 9, "Audio"); qmlRegisterType<QDeclarativeAudio, 2>(uri, 5, 9, "MediaPlayer"); qmlRegisterUncreatableType<QDeclarativeCameraCapture, 1>(uri, 5, 9, "CameraCapture", - trUtf8("CameraCapture is provided by Camera")); + tr("CameraCapture is provided by Camera")); qmlRegisterUncreatableType<QDeclarativeCameraFlash, 1>(uri, 5, 9, "CameraFlash", - trUtf8("CameraFlash is provided by Camera")); + tr("CameraFlash is provided by Camera")); // 5.11 types qmlRegisterType<QDeclarativeAudio, 3>(uri, 5, 11, "Audio"); qmlRegisterType<QDeclarativeAudio, 3>(uri, 5, 11, "MediaPlayer"); qmlRegisterUncreatableType<QDeclarativeCameraFocus, 1>(uri, 5, 11, "CameraFocus", - trUtf8("CameraFocus is provided by Camera")); + tr("CameraFocus is provided by Camera")); qmlRegisterUncreatableType<QDeclarativeCameraExposure, 1>(uri, 5, 11, "CameraExposure", - trUtf8("CameraExposure is provided by Camera")); + tr("CameraExposure is provided by Camera")); qmlRegisterUncreatableType<QDeclarativeCameraImageProcessing, 3>(uri, 5, 11, "CameraImageProcessing", - trUtf8("CameraImageProcessing is provided by Camera")); + tr("CameraImageProcessing is provided by Camera")); qmlRegisterType<QDeclarativeMediaMetaData>(); qmlRegisterType<QAbstractVideoFilter>(); diff --git a/src/imports/multimedia/qdeclarativecamera.cpp b/src/imports/multimedia/qdeclarativecamera.cpp index e9c708a21..c255f45d8 100644 --- a/src/imports/multimedia/qdeclarativecamera.cpp +++ b/src/imports/multimedia/qdeclarativecamera.cpp @@ -181,8 +181,8 @@ QDeclarativeCamera::QDeclarativeCamera(QObject *parent) : m_pendingState(ActiveState), m_componentComplete(false) { - m_camera = new QCamera; - m_currentCameraInfo = QCameraInfo(*m_camera); + m_currentCameraInfo = QCameraInfo::defaultCamera(); + m_camera = new QCamera(m_currentCameraInfo); m_imageCapture = new QDeclarativeCameraCapture(m_camera); m_videoRecorder = new QDeclarativeCameraRecorder(m_camera); diff --git a/src/imports/multimedia/qdeclarativecamerafocus.cpp b/src/imports/multimedia/qdeclarativecamerafocus.cpp index 1dd216467..61c22c066 100644 --- a/src/imports/multimedia/qdeclarativecamerafocus.cpp +++ b/src/imports/multimedia/qdeclarativecamerafocus.cpp @@ -397,10 +397,6 @@ void QDeclarativeCameraFocus::updateFocusZones() FocusZonesModel::FocusZonesModel(QObject *parent) :QAbstractListModel(parent) { - QHash<int, QByteArray> roles; - roles[StatusRole] = "status"; - roles[AreaRole] = "area"; - setRoleNames(roles); } int FocusZonesModel::rowCount(const QModelIndex &parent) const @@ -427,6 +423,12 @@ QVariant FocusZonesModel::data(const QModelIndex &index, int role) const return QVariant(); } +QHash<int,QByteArray> FocusZonesModel::roleNames() const +{ + return {{StatusRole, QByteArrayLiteral("status")}, + {AreaRole, QByteArrayLiteral("area")}}; +} + void FocusZonesModel::setFocusZones(const QCameraFocusZoneList &zones) { beginResetModel(); diff --git a/src/imports/multimedia/qdeclarativecamerafocus_p.h b/src/imports/multimedia/qdeclarativecamerafocus_p.h index e3a1c28b7..bd5d54d48 100644 --- a/src/imports/multimedia/qdeclarativecamerafocus_p.h +++ b/src/imports/multimedia/qdeclarativecamerafocus_p.h @@ -145,6 +145,7 @@ public: int rowCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + QHash<int,QByteArray> roleNames() const override; public slots: void setFocusZones(const QCameraFocusZoneList &zones); diff --git a/src/multimedia/audio/qaudiobuffer.cpp b/src/multimedia/audio/qaudiobuffer.cpp index 849d79ab3..f3e7ae670 100644 --- a/src/multimedia/audio/qaudiobuffer.cpp +++ b/src/multimedia/audio/qaudiobuffer.cpp @@ -85,7 +85,7 @@ public: static QAudioBufferPrivate *acquire(QAudioBufferPrivate *other) { if (!other) - return 0; + return nullptr; // Ref the other (if there are extant data() pointers, they will // also point here - it's a feature, not a bug, like QByteArray) @@ -131,7 +131,7 @@ public: } } } else - mBuffer = 0; + mBuffer = nullptr; } ~QMemoryAudioBufferProvider() @@ -178,7 +178,7 @@ QAudioBufferPrivate *QAudioBufferPrivate::clone() } } - return 0; + return nullptr; } /*! @@ -199,7 +199,7 @@ QAudioBufferPrivate *QAudioBufferPrivate::clone() Create a new, empty, invalid buffer. */ QAudioBuffer::QAudioBuffer() - : d(0) + : d(nullptr) { } @@ -244,7 +244,7 @@ QAudioBuffer::QAudioBuffer(const QByteArray &data, const QAudioFormat &format, q int frameCount = format.framesForBytes(data.size()); d = new QAudioBufferPrivate(new QMemoryAudioBufferProvider(data.constData(), frameCount, format, startTime)); } else - d = 0; + d = nullptr; } /*! @@ -259,9 +259,9 @@ QAudioBuffer::QAudioBuffer(const QByteArray &data, const QAudioFormat &format, q QAudioBuffer::QAudioBuffer(int numFrames, const QAudioFormat &format, qint64 startTime) { if (format.isValid()) - d = new QAudioBufferPrivate(new QMemoryAudioBufferProvider(0, numFrames, format, startTime)); + d = new QAudioBufferPrivate(new QMemoryAudioBufferProvider(nullptr, numFrames, format, startTime)); else - d = 0; + d = nullptr; } /*! @@ -394,7 +394,7 @@ qint64 QAudioBuffer::startTime() const const void* QAudioBuffer::constData() const { if (!isValid()) - return 0; + return nullptr; return d->mProvider->constData(); } @@ -417,7 +417,7 @@ const void* QAudioBuffer::constData() const const void* QAudioBuffer::data() const { if (!isValid()) - return 0; + return nullptr; return d->mProvider->constData(); } @@ -456,7 +456,7 @@ const void* QAudioBuffer::data() const void *QAudioBuffer::data() { if (!isValid()) - return 0; + return nullptr; if (d->mCount.load() != 1) { // Can't share a writable buffer @@ -465,7 +465,7 @@ void *QAudioBuffer::data() // This shouldn't happen if (!newd) - return 0; + return nullptr; d->deref(); d = newd; @@ -489,7 +489,7 @@ void *QAudioBuffer::data() return memBuffer->writableData(); } - return 0; + return nullptr; } // Template helper classes worth documenting diff --git a/src/multimedia/audio/qaudiodecoder.cpp b/src/multimedia/audio/qaudiodecoder.cpp index ea1d0e56d..b4ba854e1 100644 --- a/src/multimedia/audio/qaudiodecoder.cpp +++ b/src/multimedia/audio/qaudiodecoder.cpp @@ -84,8 +84,8 @@ class QAudioDecoderPrivate : public QMediaObjectPrivate public: QAudioDecoderPrivate() - : provider(0) - , control(0) + : provider(nullptr) + , control(nullptr) , state(QAudioDecoder::StoppedState) , error(QAudioDecoder::NoError) {} @@ -135,7 +135,7 @@ QAudioDecoder::QAudioDecoder(QObject *parent) d->provider = QMediaServiceProvider::defaultServiceProvider(); if (d->service) { d->control = qobject_cast<QAudioDecoderControl*>(d->service->requestControl(QAudioDecoderControl_iid)); - if (d->control != 0) { + if (d->control != nullptr) { connect(d->control, SIGNAL(stateChanged(QAudioDecoder::State)), SLOT(_q_stateChanged(QAudioDecoder::State))); connect(d->control, SIGNAL(error(int,QString)), SLOT(_q_error(int,QString))); @@ -205,7 +205,7 @@ void QAudioDecoder::start() { Q_D(QAudioDecoder); - if (d->control == 0) { + if (d->control == nullptr) { QMetaObject::invokeMethod(this, "_q_error", Qt::QueuedConnection, Q_ARG(int, QAudioDecoder::ServiceMissingError), Q_ARG(QString, tr("The QAudioDecoder object does not have a valid service"))); @@ -226,7 +226,7 @@ void QAudioDecoder::stop() { Q_D(QAudioDecoder); - if (d->control != 0) + if (d->control != nullptr) d->control->stop(); } @@ -256,7 +256,7 @@ void QAudioDecoder::setSourceFilename(const QString &fileName) { Q_D(QAudioDecoder); - if (d->control != 0) + if (d->control != nullptr) d_func()->control->setSourceFilename(fileName); } @@ -269,7 +269,7 @@ QIODevice *QAudioDecoder::sourceDevice() const Q_D(const QAudioDecoder); if (d->control) return d->control->sourceDevice(); - return 0; + return nullptr; } /*! @@ -285,7 +285,7 @@ void QAudioDecoder::setSourceDevice(QIODevice *device) { Q_D(QAudioDecoder); - if (d->control != 0) + if (d->control != nullptr) d_func()->control->setSourceDevice(device); } @@ -327,7 +327,7 @@ void QAudioDecoder::setAudioFormat(const QAudioFormat &format) if (state() != QAudioDecoder::StoppedState) return; - if (d->control != 0) + if (d->control != nullptr) d_func()->control->setAudioFormat(format); } diff --git a/src/multimedia/audio/qaudiodevicefactory.cpp b/src/multimedia/audio/qaudiodevicefactory.cpp index b1788f28a..cf770c468 100644 --- a/src/multimedia/audio/qaudiodevicefactory.cpp +++ b/src/multimedia/audio/qaudiodevicefactory.cpp @@ -77,7 +77,7 @@ class QNullInputDevice : public QAbstractAudioInput { public: void start(QIODevice*) override { qWarning()<<"using null input device, none available";} - QIODevice* start() override { qWarning()<<"using null input device, none available"; return 0; } + QIODevice *start() override { qWarning()<<"using null input device, none available"; return nullptr; } void stop() override {} void reset() override {} void suspend() override {} @@ -102,7 +102,7 @@ class QNullOutputDevice : public QAbstractAudioOutput { public: void start(QIODevice*) override {qWarning()<<"using null output device, none available";} - QIODevice* start() override { qWarning()<<"using null output device, none available"; return 0; } + QIODevice *start() override { qWarning()<<"using null output device, none available"; return nullptr; } void stop() override {} void reset() override {} void suspend() override {} @@ -194,7 +194,7 @@ QAudioDeviceInfo QAudioDeviceFactory::defaultDevice(QAudio::Mode mode) QAbstractAudioDeviceInfo* QAudioDeviceFactory::audioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode) { - QAbstractAudioDeviceInfo *rc = 0; + QAbstractAudioDeviceInfo *rc = nullptr; #if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) QAudioSystemFactoryInterface* plugin = @@ -204,7 +204,7 @@ QAbstractAudioDeviceInfo* QAudioDeviceFactory::audioDeviceInfo(const QString &re rc = plugin->createDeviceInfo(handle, mode); #endif - return rc == 0 ? new QNullDeviceInfo() : rc; + return rc == nullptr ? new QNullDeviceInfo() : rc; } QAbstractAudioInput* QAudioDeviceFactory::createDefaultInputDevice(QAudioFormat const &format) diff --git a/src/multimedia/audio/qaudiodeviceinfo.cpp b/src/multimedia/audio/qaudiodeviceinfo.cpp index f4f548017..b8cac18eb 100644 --- a/src/multimedia/audio/qaudiodeviceinfo.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo.cpp @@ -57,7 +57,7 @@ class QAudioDeviceInfoPrivate : public QSharedData public: QAudioDeviceInfoPrivate() : mode(QAudio::AudioOutput) - , info(0) + , info(nullptr) { } @@ -67,7 +67,7 @@ public: if (!handle.isEmpty()) info = QAudioDeviceFactory::audioDeviceInfo(realm, handle, mode); else - info = NULL; + info = nullptr; } QAudioDeviceInfoPrivate(const QAudioDeviceInfoPrivate &other): @@ -213,7 +213,7 @@ bool QAudioDeviceInfo::operator !=(const QAudioDeviceInfo &other) const */ bool QAudioDeviceInfo::isNull() const { - return d->info == 0; + return d->info == nullptr; } /*! diff --git a/src/multimedia/audio/qaudioprobe.cpp b/src/multimedia/audio/qaudioprobe.cpp index 23687c3cb..b6fe86b11 100644 --- a/src/multimedia/audio/qaudioprobe.cpp +++ b/src/multimedia/audio/qaudioprobe.cpp @@ -156,7 +156,7 @@ bool QAudioProbe::setSource(QMediaObject *source) } } - return (!source || d->probee != 0); + return (!source || d->probee != nullptr); } /*! @@ -176,7 +176,7 @@ bool QAudioProbe::setSource(QMediaObject *source) */ bool QAudioProbe::setSource(QMediaRecorder *mediaRecorder) { - QMediaObject *source = mediaRecorder ? mediaRecorder->mediaObject() : 0; + QMediaObject *source = mediaRecorder ? mediaRecorder->mediaObject() : nullptr; bool result = setSource(source); if (!mediaRecorder) @@ -195,7 +195,7 @@ bool QAudioProbe::setSource(QMediaRecorder *mediaRecorder) */ bool QAudioProbe::isActive() const { - return d->probee != 0; + return d->probee != nullptr; } /*! diff --git a/src/multimedia/audio/qsamplecache_p.cpp b/src/multimedia/audio/qsamplecache_p.cpp index c956d764b..945fabe52 100644 --- a/src/multimedia/audio/qsamplecache_p.cpp +++ b/src/multimedia/audio/qsamplecache_p.cpp @@ -97,7 +97,7 @@ QT_BEGIN_NAMESPACE QSampleCache::QSampleCache(QObject *parent) : QObject(parent) - , m_networkAccessManager(0) + , m_networkAccessManager(nullptr) , m_mutex(QMutex::Recursive) , m_capacity(0) , m_usage(0) @@ -327,8 +327,8 @@ void QSample::cleanup() if (m_stream) m_stream->deleteLater(); - m_waveDecoder = 0; - m_stream = 0; + m_waveDecoder = nullptr; + m_stream = nullptr; } // Called in application thread @@ -429,8 +429,8 @@ void QSample::onReady() // Called in application thread, then moved to loader thread QSample::QSample(const QUrl& url, QSampleCache *parent) : m_parent(parent) - , m_stream(0) - , m_waveDecoder(0) + , m_stream(nullptr) + , m_waveDecoder(nullptr) , m_url(url) , m_sampleReadLength(0) , m_state(Creating) diff --git a/src/multimedia/audio/qsamplecache_p.h b/src/multimedia/audio/qsamplecache_p.h index d3a348528..094e3281e 100644 --- a/src/multimedia/audio/qsamplecache_p.h +++ b/src/multimedia/audio/qsamplecache_p.h @@ -127,7 +127,7 @@ class Q_MULTIMEDIA_EXPORT QSampleCache : public QObject public: friend class QSample; - QSampleCache(QObject *parent = 0); + QSampleCache(QObject *parent = nullptr); ~QSampleCache(); QSample* requestSample(const QUrl& url); diff --git a/src/multimedia/audio/qsoundeffect.cpp b/src/multimedia/audio/qsoundeffect.cpp index f093373ce..09085dca9 100644 --- a/src/multimedia/audio/qsoundeffect.cpp +++ b/src/multimedia/audio/qsoundeffect.cpp @@ -111,20 +111,34 @@ QT_BEGIN_NAMESPACE sound effects. */ +static QSoundEffectPrivate *initPrivate(QSoundEffect *self, QSoundEffectPrivate *d) +{ + QObject::connect(d, &QSoundEffectPrivate::loopsRemainingChanged, self, &QSoundEffect::loopsRemainingChanged); + QObject::connect(d, &QSoundEffectPrivate::volumeChanged, self, &QSoundEffect::volumeChanged); + QObject::connect(d, &QSoundEffectPrivate::mutedChanged, self, &QSoundEffect::mutedChanged); + QObject::connect(d, &QSoundEffectPrivate::loadedChanged, self, &QSoundEffect::loadedChanged); + QObject::connect(d, &QSoundEffectPrivate::playingChanged, self, &QSoundEffect::playingChanged); + QObject::connect(d, &QSoundEffectPrivate::statusChanged, self, &QSoundEffect::statusChanged); + QObject::connect(d, &QSoundEffectPrivate::categoryChanged, self, &QSoundEffect::categoryChanged); + + return d; +} /*! Creates a QSoundEffect with the given \a parent. */ -QSoundEffect::QSoundEffect(QObject *parent) : - QObject(parent) +QSoundEffect::QSoundEffect(QObject *parent) + : QObject(parent) + , d(initPrivate(this, new QSoundEffectPrivate(this))) +{ +} + +/*! + Creates a QSoundEffect with the given \a audioDevice and \a parent. +*/ +QSoundEffect::QSoundEffect(const QAudioDeviceInfo &audioDevice, QObject *parent) + : QObject(parent) + , d(initPrivate(this, new QSoundEffectPrivate(audioDevice, this))) { - d = new QSoundEffectPrivate(this); - connect(d, &QSoundEffectPrivate::loopsRemainingChanged, this, &QSoundEffect::loopsRemainingChanged); - connect(d, &QSoundEffectPrivate::volumeChanged, this, &QSoundEffect::volumeChanged); - connect(d, &QSoundEffectPrivate::mutedChanged, this, &QSoundEffect::mutedChanged); - connect(d, &QSoundEffectPrivate::loadedChanged, this, &QSoundEffect::loadedChanged); - connect(d, &QSoundEffectPrivate::playingChanged, this, &QSoundEffect::playingChanged); - connect(d, &QSoundEffectPrivate::statusChanged, this, &QSoundEffect::statusChanged); - connect(d, &QSoundEffectPrivate::categoryChanged, this, &QSoundEffect::categoryChanged); } /*! diff --git a/src/multimedia/audio/qsoundeffect.h b/src/multimedia/audio/qsoundeffect.h index b1c5fd22b..1185afe07 100644 --- a/src/multimedia/audio/qsoundeffect.h +++ b/src/multimedia/audio/qsoundeffect.h @@ -50,6 +50,7 @@ QT_BEGIN_NAMESPACE class QSoundEffectPrivate; +class QAudioDeviceInfo; class Q_MULTIMEDIA_EXPORT QSoundEffect : public QObject { @@ -81,6 +82,7 @@ public: }; explicit QSoundEffect(QObject *parent = nullptr); + explicit QSoundEffect(const QAudioDeviceInfo &audioDevice, QObject *parent = nullptr); ~QSoundEffect(); static QStringList supportedMimeTypes(); diff --git a/src/multimedia/audio/qsoundeffect_pulse_p.cpp b/src/multimedia/audio/qsoundeffect_pulse_p.cpp index bbaf405b6..075e639a8 100644 --- a/src/multimedia/audio/qsoundeffect_pulse_p.cpp +++ b/src/multimedia/audio/qsoundeffect_pulse_p.cpp @@ -58,7 +58,7 @@ #include <private/qaudiohelpers_p.h> #include <private/qmediaresourcepolicy_p.h> #include <private/qmediaresourceset_p.h> - +#include <QAudioDeviceInfo> #include <unistd.h> //#define QT_PA_DEBUG @@ -360,6 +360,12 @@ QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent): this, &QSoundEffectPrivate::handleAvailabilityChanged); } +QSoundEffectPrivate::QSoundEffectPrivate(const QAudioDeviceInfo &audioDevice, QObject *parent) + : QSoundEffectPrivate(parent) +{ + m_sinkName = audioDevice.deviceName(); +} + void QSoundEffectPrivate::handleAvailabilityChanged(bool available) { m_resourcesAvailable = available; @@ -1005,8 +1011,9 @@ void QSoundEffectPrivate::createPulseStream() } m_pulseStream = stream; - if (pa_stream_connect_playback(m_pulseStream, nullptr, nullptr, - PA_STREAM_START_CORKED, nullptr, nullptr) < 0) { + if (pa_stream_connect_playback(m_pulseStream, + m_sinkName.isEmpty() ? nullptr : m_sinkName.toLatin1().constData(), + nullptr, PA_STREAM_START_CORKED, nullptr, nullptr) < 0) { qWarning("QSoundEffect(pulseaudio): Failed to connect stream, error = %s", pa_strerror(pa_context_errno(pulseDaemon()->context()))); } diff --git a/src/multimedia/audio/qsoundeffect_pulse_p.h b/src/multimedia/audio/qsoundeffect_pulse_p.h index 8f74d67e7..e0073f0d5 100644 --- a/src/multimedia/audio/qsoundeffect_pulse_p.h +++ b/src/multimedia/audio/qsoundeffect_pulse_p.h @@ -73,6 +73,7 @@ class QSoundEffectPrivate : public QObject Q_OBJECT public: explicit QSoundEffectPrivate(QObject* parent); + explicit QSoundEffectPrivate(const QAudioDeviceInfo &audioDevice, QObject *parent); ~QSoundEffectPrivate(); static QStringList supportedMimeTypes(); @@ -150,6 +151,7 @@ private: static void stream_adjust_prebuffer_callback(pa_stream *s, int success, void *userdata); pa_stream *m_pulseStream = nullptr; + QString m_sinkName; int m_sinkInputId = -1; pa_sample_spec m_pulseSpec; int m_pulseBufferSize = 0; diff --git a/src/multimedia/audio/qsoundeffect_qaudio_p.cpp b/src/multimedia/audio/qsoundeffect_qaudio_p.cpp index d7a19eeec..ac4dd9cf9 100644 --- a/src/multimedia/audio/qsoundeffect_qaudio_p.cpp +++ b/src/multimedia/audio/qsoundeffect_qaudio_p.cpp @@ -66,6 +66,12 @@ QSoundEffectPrivate::QSoundEffectPrivate(QObject *parent): { } +QSoundEffectPrivate::QSoundEffectPrivate(const QAudioDeviceInfo &audioDevice, QObject *parent) + : QObject(parent) + , d(new PrivateSoundSource(this, audioDevice)) +{ +} + QSoundEffectPrivate::~QSoundEffectPrivate() { } @@ -309,8 +315,9 @@ void QSoundEffectPrivate::setCategory(const QString &category) } } -PrivateSoundSource::PrivateSoundSource(QSoundEffectPrivate *s): - QIODevice(s) +PrivateSoundSource::PrivateSoundSource(QSoundEffectPrivate *s, const QAudioDeviceInfo &audioDevice) + : QIODevice(s) + , m_audioDevice(audioDevice) { soundeffect = s; m_category = QLatin1String("game"); @@ -328,7 +335,10 @@ void PrivateSoundSource::sampleReady() disconnect(m_sample, &QSample::error, this, &PrivateSoundSource::decoderError); disconnect(m_sample, &QSample::ready, this, &PrivateSoundSource::sampleReady); if (!m_audioOutput) { - m_audioOutput = new QAudioOutput(m_sample->format()); + if (m_audioDevice.isNull()) + m_audioOutput = new QAudioOutput(m_sample->format()); + else + m_audioOutput = new QAudioOutput(m_audioDevice, m_sample->format()); connect(m_audioOutput, &QAudioOutput::stateChanged, this, &PrivateSoundSource::stateChanged); if (!m_muted) m_audioOutput->setVolume(m_volume); diff --git a/src/multimedia/audio/qsoundeffect_qaudio_p.h b/src/multimedia/audio/qsoundeffect_qaudio_p.h index c02a85969..a3a48f60d 100644 --- a/src/multimedia/audio/qsoundeffect_qaudio_p.h +++ b/src/multimedia/audio/qsoundeffect_qaudio_p.h @@ -66,7 +66,7 @@ class PrivateSoundSource : public QIODevice friend class QSoundEffectPrivate; Q_OBJECT public: - PrivateSoundSource(QSoundEffectPrivate *s); + PrivateSoundSource(QSoundEffectPrivate *s, const QAudioDeviceInfo &audioDevice = QAudioDeviceInfo()); ~PrivateSoundSource() {} qint64 readData(char *data, qint64 len) override; @@ -90,7 +90,7 @@ private: bool m_sampleReady = false; qint64 m_offset = 0; QString m_category; - + QAudioDeviceInfo m_audioDevice; QSoundEffectPrivate *soundeffect = nullptr; }; @@ -102,6 +102,7 @@ class QSoundEffectPrivate : public QObject public: explicit QSoundEffectPrivate(QObject *parent); + explicit QSoundEffectPrivate(const QAudioDeviceInfo &audioDevice, QObject *parent); ~QSoundEffectPrivate(); static QStringList supportedMimeTypes(); diff --git a/src/multimedia/audio/qwavedecoder_p.h b/src/multimedia/audio/qwavedecoder_p.h index 0f1cef599..3be0dbaa6 100644 --- a/src/multimedia/audio/qwavedecoder_p.h +++ b/src/multimedia/audio/qwavedecoder_p.h @@ -64,7 +64,7 @@ class QWaveDecoder : public QIODevice Q_OBJECT public: - explicit QWaveDecoder(QIODevice *source, QObject *parent = 0); + explicit QWaveDecoder(QIODevice *source, QObject *parent = nullptr); ~QWaveDecoder(); QAudioFormat audioFormat() const; diff --git a/src/multimedia/camera/qcamera.cpp b/src/multimedia/camera/qcamera.cpp index c7d64155c..46c6af9ff 100644 --- a/src/multimedia/camera/qcamera.cpp +++ b/src/multimedia/camera/qcamera.cpp @@ -206,12 +206,12 @@ void QCameraPrivate::initControls() error = QCamera::NoError; } else { - control = 0; - locksControl = 0; - deviceControl = 0; - infoControl = 0; - viewfinderSettingsControl = 0; - viewfinderSettingsControl2 = 0; + control = nullptr; + locksControl = nullptr; + deviceControl = nullptr; + infoControl = nullptr; + viewfinderSettingsControl = nullptr; + viewfinderSettingsControl2 = nullptr; error = QCamera::ServiceMissingError; errorString = QCamera::tr("The camera service is missing"); @@ -241,16 +241,16 @@ void QCameraPrivate::clear() provider->releaseService(service); } - cameraExposure = 0; - cameraFocus = 0; - imageProcessing = 0; - control = 0; - locksControl = 0; - deviceControl = 0; - infoControl = 0; - viewfinderSettingsControl = 0; - viewfinderSettingsControl2 = 0; - service = 0; + cameraExposure = nullptr; + cameraFocus = nullptr; + imageProcessing = nullptr; + control = nullptr; + locksControl = nullptr; + deviceControl = nullptr; + infoControl = nullptr; + viewfinderSettingsControl = nullptr; + viewfinderSettingsControl2 = nullptr; + service = nullptr; } void QCameraPrivate::updateLockStatus() @@ -328,7 +328,7 @@ QCamera::QCamera(QObject *parent): d->init(); // Select the default camera - if (d->service != 0 && d->deviceControl) + if (d->service != nullptr && d->deviceControl) d->deviceControl->setSelectedDevice(d->deviceControl->defaultDevice()); } @@ -362,9 +362,17 @@ QCamera::QCamera(const QByteArray& deviceName, QObject *parent): // The camera should not be used if device with requested name does not exist. if (!found) { - if (d->service && d->control) - d->service->releaseControl(d->control); + if (d->service) { + if (d->control) + d->service->releaseControl(d->control); + if (d->deviceControl) + d->service->releaseControl(d->deviceControl); + if (d->infoControl) + d->service->releaseControl(d->infoControl); + } d->control = nullptr; + d->deviceControl = nullptr; + d->infoControl = nullptr; d->error = QCamera::ServiceMissingError; d->errorString = QCamera::tr("The camera service is missing"); } @@ -401,7 +409,7 @@ QCamera::QCamera(QCamera::Position position, QObject *parent) Q_D(QCamera); d->init(); - if (d->service != 0 && d->deviceControl) { + if (d->service != nullptr && d->deviceControl) { bool selectDefault = true; if (d->infoControl && position != UnspecifiedPosition) { @@ -435,7 +443,7 @@ QCamera::~QCamera() QMultimedia::AvailabilityStatus QCamera::availability() const { Q_D(const QCamera); - if (d->control == NULL) + if (d->control == nullptr) return QMultimedia::ServiceMissing; if (d->deviceControl && d->deviceControl->deviceCount() == 0) @@ -489,7 +497,7 @@ void QCamera::setViewfinder(QVideoWidget *viewfinder) // We don't know (in this library) that QVideoWidget inherits QObject QObject *viewFinderObject = reinterpret_cast<QObject*>(viewfinder); - d->viewfinder = viewFinderObject && bind(viewFinderObject) ? viewFinderObject : 0; + d->viewfinder = viewFinderObject && bind(viewFinderObject) ? viewFinderObject : nullptr; } /*! @@ -510,7 +518,7 @@ void QCamera::setViewfinder(QGraphicsVideoItem *viewfinder) // but QObject inheritance depends on QObject coming first, so try this out. QObject *viewFinderObject = reinterpret_cast<QObject*>(viewfinder); - d->viewfinder = viewFinderObject && bind(viewFinderObject) ? viewFinderObject : 0; + d->viewfinder = viewFinderObject && bind(viewFinderObject) ? viewFinderObject : nullptr; } /*! @@ -530,14 +538,14 @@ void QCamera::setViewfinder(QAbstractVideoSurface *surface) if (d->viewfinder) unbind(d->viewfinder); - d->viewfinder = 0; + d->viewfinder = nullptr; if (surface && bind(&d->surfaceViewfinder)) d->viewfinder = &d->surfaceViewfinder; } else if (!surface) { //unbind the surfaceViewfinder if null surface is set unbind(&d->surfaceViewfinder); - d->viewfinder = 0; + d->viewfinder = nullptr; } } diff --git a/src/multimedia/camera/qcamera_p.h b/src/multimedia/camera/qcamera_p.h index 49b4376b2..99759dbd3 100644 --- a/src/multimedia/camera/qcamera_p.h +++ b/src/multimedia/camera/qcamera_p.h @@ -71,18 +71,18 @@ class QCameraPrivate : public QMediaObjectPrivate public: QCameraPrivate(): QMediaObjectPrivate(), - provider(0), - control(0), - deviceControl(0), - locksControl(0), - infoControl(0), - viewfinderSettingsControl(0), - viewfinderSettingsControl2(0), - cameraExposure(0), - cameraFocus(0), - imageProcessing(0), - viewfinder(0), - capture(0), + provider(nullptr), + control(nullptr), + deviceControl(nullptr), + locksControl(nullptr), + infoControl(nullptr), + viewfinderSettingsControl(nullptr), + viewfinderSettingsControl2(nullptr), + cameraExposure(nullptr), + cameraFocus(nullptr), + imageProcessing(nullptr), + viewfinder(nullptr), + capture(nullptr), state(QCamera::UnloadedState), error(QCamera::NoError), requestedLocks(QCamera::NoLock), diff --git a/src/multimedia/camera/qcameraexposure.cpp b/src/multimedia/camera/qcameraexposure.cpp index d289aed33..91950c7d2 100644 --- a/src/multimedia/camera/qcameraexposure.cpp +++ b/src/multimedia/camera/qcameraexposure.cpp @@ -98,8 +98,8 @@ void QCameraExposurePrivate::initControls() Q_Q(QCameraExposure); QMediaService *service = camera->service(); - exposureControl = 0; - flashControl = 0; + exposureControl = nullptr; + flashControl = nullptr; if (service) { exposureControl = qobject_cast<QCameraExposureControl *>(service->requestControl(QCameraExposureControl_iid)); flashControl = qobject_cast<QCameraFlashControl *>(service->requestControl(QCameraFlashControl_iid)); @@ -217,7 +217,7 @@ QCameraExposure::~QCameraExposure() */ bool QCameraExposure::isAvailable() const { - return d_func()->exposureControl != 0; + return d_func()->exposureControl != nullptr; } diff --git a/src/multimedia/camera/qcamerafocus.cpp b/src/multimedia/camera/qcamerafocus.cpp index 848b33df8..e73a8ea46 100644 --- a/src/multimedia/camera/qcamerafocus.cpp +++ b/src/multimedia/camera/qcamerafocus.cpp @@ -339,8 +339,8 @@ void QCameraFocusPrivate::initControls() { Q_Q(QCameraFocus); - focusControl = 0; - zoomControl = 0; + focusControl = nullptr; + zoomControl = nullptr; QMediaService *service = camera->service(); if (service) { @@ -348,7 +348,7 @@ void QCameraFocusPrivate::initControls() zoomControl = qobject_cast<QCameraZoomControl *>(service->requestControl(QCameraZoomControl_iid)); } - available = focusControl != 0; + available = focusControl != nullptr; if (!focusControl) focusControl = new QCameraFocusFakeFocusControl(q); diff --git a/src/multimedia/camera/qcameraimagecapture.cpp b/src/multimedia/camera/qcameraimagecapture.cpp index cedae2609..8f364a686 100644 --- a/src/multimedia/camera/qcameraimagecapture.cpp +++ b/src/multimedia/camera/qcameraimagecapture.cpp @@ -117,11 +117,11 @@ public: }; QCameraImageCapturePrivate::QCameraImageCapturePrivate(): - mediaObject(0), - control(0), - encoderControl(0), - captureDestinationControl(0), - bufferFormatControl(0), + mediaObject(nullptr), + control(nullptr), + encoderControl(nullptr), + captureDestinationControl(nullptr), + bufferFormatControl(nullptr), error(QCameraImageCapture::NoError) { } @@ -144,11 +144,11 @@ void QCameraImageCapturePrivate::_q_readyChanged(bool ready) void QCameraImageCapturePrivate::_q_serviceDestroyed() { - mediaObject = 0; - control = 0; - encoderControl = 0; - captureDestinationControl = 0; - bufferFormatControl = 0; + mediaObject = nullptr; + control = nullptr; + encoderControl = nullptr; + captureDestinationControl = nullptr; + bufferFormatControl = nullptr; } /*! @@ -284,11 +284,11 @@ bool QCameraImageCapture::setMediaObject(QMediaObject *mediaObject) } // without QCameraImageCaptureControl discard the media object - d->mediaObject = 0; - d->control = 0; - d->encoderControl = 0; - d->captureDestinationControl = 0; - d->bufferFormatControl = 0; + d->mediaObject = nullptr; + d->control = nullptr; + d->encoderControl = nullptr; + d->captureDestinationControl = nullptr; + d->bufferFormatControl = nullptr; return false; } @@ -298,7 +298,7 @@ bool QCameraImageCapture::setMediaObject(QMediaObject *mediaObject) */ bool QCameraImageCapture::isAvailable() const { - if (d_func()->control != NULL) + if (d_func()->control != nullptr) return true; else return false; @@ -309,7 +309,7 @@ bool QCameraImageCapture::isAvailable() const */ QMultimedia::AvailabilityStatus QCameraImageCapture::availability() const { - if (d_func()->control != NULL) + if (d_func()->control != nullptr) return QMultimedia::Available; else return QMultimedia::ServiceMissing; diff --git a/src/multimedia/camera/qcameraimageprocessing.cpp b/src/multimedia/camera/qcameraimageprocessing.cpp index 737b74b73..c2cefeae7 100644 --- a/src/multimedia/camera/qcameraimageprocessing.cpp +++ b/src/multimedia/camera/qcameraimageprocessing.cpp @@ -130,7 +130,7 @@ void QCameraImageProcessingPrivate::initControls() if (service) imageControl = qobject_cast<QCameraImageProcessingControl *>(service->requestControl(QCameraImageProcessingControl_iid)); - available = (imageControl != 0); + available = (imageControl != nullptr); if (!imageControl) imageControl = new QCameraImageProcessingFakeControl(q_ptr); diff --git a/src/multimedia/configure.json b/src/multimedia/configure.json index 025ff7d66..6d56af5ed 100644 --- a/src/multimedia/configure.json +++ b/src/multimedia/configure.json @@ -9,10 +9,10 @@ "options": { "alsa": "boolean", "evr": { "type": "boolean" }, + "directshow": { "type": "boolean" }, + "wmf": { "type": "boolean" }, "gstreamer": { "type": "optionalString", "values": [ "no", "yes", "0.10", "1.0" ] }, - "pulseaudio": "boolean", - "mediaplayer-backend": { "type": "string", "values": [ "directshow", "wmf" ] }, - "wmf-backend": { "type": "void", "name": "mediaplayer-backend", "value": "wmf" } + "pulseaudio": "boolean" } }, @@ -53,7 +53,9 @@ "test": "gstreamer", "sources": [ { "type": "pkgConfig", - "args": "gstreamer-1.0 gstreamer-base-1.0 gstreamer-audio-1.0 gstreamer-video-1.0 gstreamer-pbutils-1.0" } + "args": "gstreamer-1.0 gstreamer-base-1.0 gstreamer-audio-1.0 gstreamer-video-1.0 gstreamer-pbutils-1.0" }, + { "libs": "-lgstreamer-1.0 -lgstbase-1.0 -lgstaudio-1.0 -lgstvideo-1.0 -lgstpbutils-1.0 -lglib-2.0 -lgobject-2.0", + "condition": "config.win32 || config.macos" } ] }, "gstreamer_app_0_10": { @@ -71,7 +73,8 @@ "test": "gstreamer_appsrc", "use": "gstreamer_1_0", "sources": [ - { "type": "pkgConfig", "args": "gstreamer-app-1.0" } + { "type": "pkgConfig", "args": "gstreamer-app-1.0" }, + { "libs": "-lgstapp-1.0", "condition": "config.win32 || config.macos" } ] }, "gstreamer_photography_0_10": { @@ -188,13 +191,6 @@ "condition": "config.win32 && libs.directshow", "output": [ "feature", "privateFeature" ] }, - "directshow-player": { - "label": "DirectShow", - "enable": "input.mediaplayer-backend == 'directshow'", - "disable": "input.mediaplayer-backend == 'wmf'", - "condition": "features.directshow && !features.wmf-player", - "output": [ "privateFeature" ] - }, "evr": { "label": "evr.h", "condition": "config.win32 && tests.evr", @@ -284,13 +280,6 @@ "label": "Windows Media Foundation", "condition": "config.win32 && libs.wmf", "output": [ "privateFeature" ] - }, - "wmf-player": { - "label": "Windows Media Foundation", - "enable": "input.mediaplayer-backend == 'wmf'", - "disable": "input.mediaplayer-backend != 'wmf'", - "condition": "features.wmf", - "output": [ "privateFeature" ] } }, @@ -312,14 +301,7 @@ "avfoundation", "wasapi", "directshow", - "wmf", - { - "message": "Media player backend", - "type": "firstAvailableFeature", - "args": "directshow-player wmf-player", - "condition": "config.win32" - } - + "wmf" ] } ] diff --git a/src/multimedia/controls/qmediaplaylistcontrol_p.h b/src/multimedia/controls/qmediaplaylistcontrol_p.h index 721a471c4..93c5a3e25 100644 --- a/src/multimedia/controls/qmediaplaylistcontrol_p.h +++ b/src/multimedia/controls/qmediaplaylistcontrol_p.h @@ -90,7 +90,7 @@ Q_SIGNALS: void playbackModeChanged(QMediaPlaylist::PlaybackMode mode); protected: - QMediaPlaylistControl(QObject* parent = 0); + QMediaPlaylistControl(QObject *parent = nullptr); }; #define QMediaPlaylistControl_iid "org.qt-project.qt.mediaplaylistcontrol/5.0" diff --git a/src/multimedia/controls/qmediaplaylistsourcecontrol_p.h b/src/multimedia/controls/qmediaplaylistsourcecontrol_p.h index 18bf91d5b..a98ee8738 100644 --- a/src/multimedia/controls/qmediaplaylistsourcecontrol_p.h +++ b/src/multimedia/controls/qmediaplaylistsourcecontrol_p.h @@ -73,7 +73,7 @@ Q_SIGNALS: void playlistChanged(QMediaPlaylist* playlist); protected: - QMediaPlaylistSourceControl(QObject* parent = 0); + QMediaPlaylistSourceControl(QObject *parent = nullptr); }; #define QMediaPlaylistSourceControl_iid "org.qt-project.qt.mediaplaylistsourcecontrol/5.0" diff --git a/src/multimedia/playback/qmediacontent.cpp b/src/multimedia/playback/qmediacontent.cpp index fe377b969..95116d02f 100644 --- a/src/multimedia/playback/qmediacontent.cpp +++ b/src/multimedia/playback/qmediacontent.cpp @@ -61,14 +61,24 @@ public: isPlaylistOwned(false) {} +#if QT_DEPRECATED_SINCE(6, 0) QMediaContentPrivate(const QMediaResourceList &r): - resources(r), isPlaylistOwned(false) - {} + { + for (auto &item : r) + requests << item.request(); + } +#endif + + QMediaContentPrivate(const QNetworkRequest &r): + isPlaylistOwned(false) + { + requests << r; + } QMediaContentPrivate(const QMediaContentPrivate &other): QSharedData(other), - resources(other.resources), + requests(other.requests), playlist(other.playlist), isPlaylistOwned(false) {} @@ -77,7 +87,7 @@ public: playlist(pls), isPlaylistOwned(isOwn) { - resources << QMediaResource(url); + requests << QNetworkRequest(url); } ~QMediaContentPrivate() @@ -88,11 +98,10 @@ public: bool operator ==(const QMediaContentPrivate &other) const { - return resources == other.resources && playlist == other.playlist; + return requests == other.requests && playlist == other.playlist; } - QMediaResourceList resources; - + QList<QNetworkRequest> requests; QPointer<QMediaPlaylist> playlist; bool isPlaylistOwned; private: @@ -103,20 +112,19 @@ private: /*! \class QMediaContent - \brief The QMediaContent class provides access to the resources relating to a media content. + \brief The QMediaContent class provides access to the resource relating to a media content. \inmodule QtMultimedia \ingroup multimedia \ingroup multimedia_playback QMediaContent is used within the multimedia framework as the logical handle - to media content. A QMediaContent object is composed of one or more - \l {QMediaResource}s where each resource provides the URL and format - information of a different encoding of the content. + to media content. A QMediaContent object contains a \l {QNetworkRequest} + which provides the URL of the content. - A non-null QMediaContent will always have a primary or canonical reference to - the content available through the canonicalUrl() or canonicalResource() - methods, any additional resources are optional. + A non-null QMediaContent will always have a reference to + the content available through the canonicalUrl() or canonicalRequest() + methods. Alternatively QMediaContent can represent a playlist and contain a pointer to a valid QMediaPlaylist object. In this case URL is optional and can either be empty @@ -139,7 +147,7 @@ QMediaContent::QMediaContent() QMediaContent::QMediaContent(const QUrl &url): d(new QMediaContentPrivate) { - d->resources << QMediaResource(url); + d->requests << QNetworkRequest(url); } /*! @@ -152,20 +160,25 @@ QMediaContent::QMediaContent(const QUrl &url): QMediaContent::QMediaContent(const QNetworkRequest &request): d(new QMediaContentPrivate) { - d->resources << QMediaResource(request); + d->requests << request; } +#if QT_DEPRECATED_SINCE(6, 0) /*! + \obsolete + Constructs a media content with \a resource providing a reference to the content. */ QMediaContent::QMediaContent(const QMediaResource &resource): d(new QMediaContentPrivate) { - d->resources << resource; + d->requests << resource.request(); } /*! + \obsolete + Constructs a media content with \a resources providing a reference to the content. */ @@ -173,6 +186,7 @@ QMediaContent::QMediaContent(const QMediaResourceList &resources): d(new QMediaContentPrivate(resources)) { } +#endif /*! Constructs a copy of the media content \a other. @@ -221,8 +235,8 @@ QMediaContent& QMediaContent::operator=(const QMediaContent &other) bool QMediaContent::operator==(const QMediaContent &other) const { - return (d.constData() == 0 && other.d.constData() == 0) || - (d.constData() != 0 && other.d.constData() != 0 && + return (d.constData() == 0 && other.d.constData() == nullptr) || + (d.constData() != 0 && other.d.constData() != nullptr && *d.constData() == *other.d.constData()); } @@ -241,7 +255,7 @@ bool QMediaContent::operator!=(const QMediaContent &other) const bool QMediaContent::isNull() const { - return d.constData() == 0; + return d.constData() == nullptr; } /*! @@ -250,7 +264,7 @@ bool QMediaContent::isNull() const QUrl QMediaContent::canonicalUrl() const { - return canonicalResource().url(); + return canonicalRequest().url(); } /*! @@ -259,31 +273,38 @@ QUrl QMediaContent::canonicalUrl() const QNetworkRequest QMediaContent::canonicalRequest() const { - return canonicalResource().request(); + return (d && !d->requests.isEmpty()) ? d->requests.first() : QNetworkRequest(); } +#if QT_DEPRECATED_SINCE(6, 0) /*! + \obsolete + Returns a QMediaResource that represents that canonical resource for this media content. */ QMediaResource QMediaContent::canonicalResource() const { - return d.constData() != 0 - ? d->resources.value(0) - : QMediaResource(); + return (d && !d->requests.isEmpty()) ? d->requests.first() : QMediaResource(); } /*! + \obsolete + Returns a list of alternative resources for this media content. The first item in this list is always the canonical resource. */ QMediaResourceList QMediaContent::resources() const { - return d.constData() != 0 - ? d->resources - : QMediaResourceList(); + QMediaResourceList list; + if (d) { + for (auto &item : d->requests) + list << item; + } + return list; } +#endif // #if QT_DEPRECATED_SINCE(6, 0) /*! Returns a playlist for this media content or 0 if this QMediaContent is not a playlist. @@ -291,9 +312,9 @@ QMediaResourceList QMediaContent::resources() const QMediaPlaylist *QMediaContent::playlist() const { - return d.constData() != 0 + return d.constData() != nullptr ? d->playlist.data() - : 0; + : nullptr; } QT_END_NAMESPACE diff --git a/src/multimedia/playback/qmediacontent.h b/src/multimedia/playback/qmediacontent.h index f7c086752..5193a1fcc 100644 --- a/src/multimedia/playback/qmediacontent.h +++ b/src/multimedia/playback/qmediacontent.h @@ -58,8 +58,10 @@ public: QMediaContent(); QMediaContent(const QUrl &contentUrl); QMediaContent(const QNetworkRequest &contentRequest); - QMediaContent(const QMediaResource &contentResource); - QMediaContent(const QMediaResourceList &resources); +#if QT_DEPRECATED_SINCE(6, 0) + QT_DEPRECATED QMediaContent(const QMediaResource &contentResource); + QT_DEPRECATED QMediaContent(const QMediaResourceList &resources); +#endif QMediaContent(const QMediaContent &other); QMediaContent(QMediaPlaylist *playlist, const QUrl &contentUrl = QUrl(), bool takeOwnership = false); ~QMediaContent(); @@ -73,9 +75,10 @@ public: QUrl canonicalUrl() const; QNetworkRequest canonicalRequest() const; - QMediaResource canonicalResource() const; - - QMediaResourceList resources() const; +#if QT_DEPRECATED_SINCE(6, 0) + QT_DEPRECATED QMediaResource canonicalResource() const; + QT_DEPRECATED QMediaResourceList resources() const; +#endif QMediaPlaylist *playlist() const; private: diff --git a/src/multimedia/playback/qmedianetworkplaylistprovider_p.h b/src/multimedia/playback/qmedianetworkplaylistprovider_p.h index 3d1ffe66a..6b5220935 100644 --- a/src/multimedia/playback/qmedianetworkplaylistprovider_p.h +++ b/src/multimedia/playback/qmedianetworkplaylistprovider_p.h @@ -61,10 +61,10 @@ class Q_MULTIMEDIA_EXPORT QMediaNetworkPlaylistProvider : public QMediaPlaylistP { Q_OBJECT public: - QMediaNetworkPlaylistProvider(QObject *parent=0); + QMediaNetworkPlaylistProvider(QObject *parent = nullptr); ~QMediaNetworkPlaylistProvider(); - bool load(const QNetworkRequest &request, const char *format = 0) override; + bool load(const QNetworkRequest &request, const char *format = nullptr) override; int mediaCount() const override; QMediaContent media(int pos) const override; diff --git a/src/multimedia/playback/qmediaplayer.cpp b/src/multimedia/playback/qmediaplayer.cpp index e90035cce..81d525ea8 100644 --- a/src/multimedia/playback/qmediaplayer.cpp +++ b/src/multimedia/playback/qmediaplayer.cpp @@ -109,12 +109,12 @@ class QMediaPlayerPrivate : public QMediaObjectPrivate public: QMediaPlayerPrivate() - : provider(0) - , control(0) - , audioRoleControl(0) - , customAudioRoleControl(0) - , playlist(0) - , networkAccessControl(0) + : provider(nullptr) + , control(nullptr) + , audioRoleControl(nullptr) + , customAudioRoleControl(nullptr) + , playlist(nullptr) + , networkAccessControl(nullptr) , state(QMediaPlayer::StoppedState) , status(QMediaPlayer::UnknownMediaStatus) , error(QMediaPlayer::NoError) @@ -148,7 +148,7 @@ public: QMediaPlaylist *parentPlaylist(QMediaPlaylist *pls); bool isInChain(const QUrl &url); - void setMedia(const QMediaContent &media, QIODevice *stream = 0); + void setMedia(const QMediaContent &media, QIODevice *stream = nullptr); void setPlaylist(QMediaPlaylist *playlist); void setPlaylistMedia(); @@ -175,7 +175,7 @@ QMediaPlaylist *QMediaPlayerPrivate::parentPlaylist(QMediaPlaylist *pls) for (QMediaPlaylist *current = rootMedia.playlist(); current && current != pls; current = current->currentMedia().playlist()) if (current->currentMedia().playlist() == pls) return current; - return 0; + return nullptr; } bool QMediaPlayerPrivate::isInChain(const QUrl &url) @@ -309,7 +309,7 @@ void QMediaPlayerPrivate::_q_updateMedia(const QMediaContent &media) const QMediaPlayer::State currentState = state; - setMedia(media, 0); + setMedia(media, nullptr); if (!media.isNull()) { switch (currentState) { @@ -329,8 +329,8 @@ void QMediaPlayerPrivate::_q_updateMedia(const QMediaContent &media) void QMediaPlayerPrivate::_q_playlistDestroyed() { - playlist = 0; - setMedia(QMediaContent(), 0); + playlist = nullptr; + setMedia(QMediaContent(), nullptr); } void QMediaPlayerPrivate::setMedia(const QMediaContent &media, QIODevice *stream) @@ -360,7 +360,7 @@ void QMediaPlayerPrivate::setMedia(const QMediaContent &media, QIODevice *stream // on the backend side since we can't load the new one and we want to be in the // InvalidMedia status. ignoreNextStatusChange = QMediaPlayer::NoMedia; - control->setMedia(QMediaContent(), 0); + control->setMedia(QMediaContent(), nullptr); } else if (hasStreamPlaybackFeature) { control->setMedia(media, file.data()); @@ -386,7 +386,7 @@ void QMediaPlayerPrivate::setMedia(const QMediaContent &media, QIODevice *stream tempFile->close(); file.reset(tempFile); - control->setMedia(QMediaContent(QUrl::fromLocalFile(file->fileName())), 0); + control->setMedia(QMediaContent(QUrl::fromLocalFile(file->fileName())), nullptr); #else qWarning("Qt was built with -no-feature-temporaryfile: playback from resource file is not supported!"); #endif @@ -447,13 +447,13 @@ void QMediaPlayerPrivate::setPlaylistMedia() // media is not changed, // frontend needs to emit currentMediaChanged bool isSameMedia = (q->currentMedia() == playlist->currentMedia()); - setMedia(playlist->currentMedia(), 0); + setMedia(playlist->currentMedia(), nullptr); if (isSameMedia) { emit q->currentMediaChanged(q->currentMedia()); } } } else { - setMedia(QMediaContent(), 0); + setMedia(QMediaContent(), nullptr); } } @@ -545,7 +545,7 @@ void QMediaPlayerPrivate::_q_handlePlaylistLoadFailed() if (playlist) playlist->next(); else - setMedia(QMediaContent(), 0); + setMedia(QMediaContent(), nullptr); } static QMediaService *playerService(QMediaPlayer::Flags flags) @@ -583,12 +583,12 @@ QMediaPlayer::QMediaPlayer(QObject *parent, QMediaPlayer::Flags flags): Q_D(QMediaPlayer); d->provider = QMediaServiceProvider::defaultServiceProvider(); - if (d->service == 0) { + if (d->service == nullptr) { d->error = ServiceMissingError; } else { d->control = qobject_cast<QMediaPlayerControl*>(d->service->requestControl(QMediaPlayerControl_iid)); d->networkAccessControl = qobject_cast<QMediaNetworkAccessControl*>(d->service->requestControl(QMediaNetworkAccessControl_iid)); - if (d->control != 0) { + if (d->control != nullptr) { connect(d->control, SIGNAL(mediaChanged(QMediaContent)), SLOT(_q_handleMediaChanged(QMediaContent))); connect(d->control, SIGNAL(stateChanged(QMediaPlayer::State)), SLOT(_q_stateChanged(QMediaPlayer::State))); connect(d->control, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), @@ -631,7 +631,7 @@ QMediaPlayer::QMediaPlayer(QObject *parent, QMediaPlayer::Flags flags): } } } - if (d->networkAccessControl != 0) { + if (d->networkAccessControl != nullptr) { connect(d->networkAccessControl, SIGNAL(configurationChanged(QNetworkConfiguration)), this, SIGNAL(networkConfigurationChanged(QNetworkConfiguration))); } @@ -688,7 +688,7 @@ const QIODevice *QMediaPlayer::mediaStream() const if (d->control && d->qrcMedia.isNull()) return d->control->mediaStream(); - return 0; + return nullptr; } QMediaPlaylist *QMediaPlayer::playlist() const @@ -740,7 +740,7 @@ QMediaPlayer::State QMediaPlayer::state() const // In case if EndOfMedia status is already received // but state is not. - if (d->control != 0 + if (d->control != nullptr && d->status == QMediaPlayer::EndOfMedia && d->state != d->control->state()) { return d->control->state(); @@ -758,7 +758,7 @@ qint64 QMediaPlayer::duration() const { Q_D(const QMediaPlayer); - if (d->control != 0) + if (d->control != nullptr) return d->control->duration(); return -1; @@ -768,7 +768,7 @@ qint64 QMediaPlayer::position() const { Q_D(const QMediaPlayer); - if (d->control != 0) + if (d->control != nullptr) return d->control->position(); return 0; @@ -778,7 +778,7 @@ int QMediaPlayer::volume() const { Q_D(const QMediaPlayer); - if (d->control != 0) + if (d->control != nullptr) return d->control->volume(); return 0; @@ -788,7 +788,7 @@ bool QMediaPlayer::isMuted() const { Q_D(const QMediaPlayer); - if (d->control != 0) + if (d->control != nullptr) return d->control->isMuted(); return false; @@ -798,7 +798,7 @@ int QMediaPlayer::bufferStatus() const { Q_D(const QMediaPlayer); - if (d->control != 0) + if (d->control != nullptr) return d->control->bufferStatus(); return 0; @@ -808,7 +808,7 @@ bool QMediaPlayer::isAudioAvailable() const { Q_D(const QMediaPlayer); - if (d->control != 0) + if (d->control != nullptr) return d->control->isAudioAvailable(); return false; @@ -818,7 +818,7 @@ bool QMediaPlayer::isVideoAvailable() const { Q_D(const QMediaPlayer); - if (d->control != 0) + if (d->control != nullptr) return d->control->isVideoAvailable(); return false; @@ -828,7 +828,7 @@ bool QMediaPlayer::isSeekable() const { Q_D(const QMediaPlayer); - if (d->control != 0) + if (d->control != nullptr) return d->control->isSeekable(); return false; @@ -838,7 +838,7 @@ qreal QMediaPlayer::playbackRate() const { Q_D(const QMediaPlayer); - if (d->control != 0) + if (d->control != nullptr) return d->control->playbackRate(); return 0.0; @@ -883,7 +883,7 @@ void QMediaPlayer::play() { Q_D(QMediaPlayer); - if (d->control == 0) { + if (d->control == nullptr) { QMetaObject::invokeMethod(this, "_q_error", Qt::QueuedConnection, Q_ARG(int, QMediaPlayer::ServiceMissingError), Q_ARG(QString, tr("The QMediaPlayer object does not have a valid service"))); @@ -921,7 +921,7 @@ void QMediaPlayer::pause() { Q_D(QMediaPlayer); - if (d->control != 0) + if (d->control != nullptr) d->control->pause(); } @@ -933,7 +933,7 @@ void QMediaPlayer::stop() { Q_D(QMediaPlayer); - if (d->control != 0) + if (d->control != nullptr) d->control->stop(); // If media player didn't stop in response to control. @@ -952,7 +952,7 @@ void QMediaPlayer::setPosition(qint64 position) { Q_D(QMediaPlayer); - if (d->control == 0) + if (d->control == nullptr) return; d->control->setPosition(qMax(position, 0ll)); @@ -962,7 +962,7 @@ void QMediaPlayer::setVolume(int v) { Q_D(QMediaPlayer); - if (d->control == 0) + if (d->control == nullptr) return; int clamped = qBound(0, v, 100); @@ -976,7 +976,7 @@ void QMediaPlayer::setMuted(bool muted) { Q_D(QMediaPlayer); - if (d->control == 0 || muted == isMuted()) + if (d->control == nullptr || muted == isMuted()) return; d->control->setMuted(muted); @@ -986,7 +986,7 @@ void QMediaPlayer::setPlaybackRate(qreal rate) { Q_D(QMediaPlayer); - if (d->control != 0) + if (d->control != nullptr) d->control->setPlaybackRate(rate); } @@ -1014,7 +1014,7 @@ void QMediaPlayer::setMedia(const QMediaContent &media, QIODevice *stream) QMediaContent oldMedia = d->rootMedia; d->disconnectPlaylist(); - d->playlist = 0; + d->playlist = nullptr; d->rootMedia = media; d->nestedPlaylists = 0; @@ -1100,7 +1100,7 @@ void QMediaPlayer::setVideoOutput(QVideoWidget *output) // We don't know (in this library) that QVideoWidget inherits QObject QObject *outputObject = reinterpret_cast<QObject*>(output); - d->videoOutput = outputObject && bind(outputObject) ? outputObject : 0; + d->videoOutput = outputObject && bind(outputObject) ? outputObject : nullptr; } /*! @@ -1122,7 +1122,7 @@ void QMediaPlayer::setVideoOutput(QGraphicsVideoItem *output) // but QObject inheritance depends on QObject coming first, so try this out. QObject *outputObject = reinterpret_cast<QObject*>(output); - d->videoOutput = outputObject && bind(outputObject) ? outputObject : 0; + d->videoOutput = outputObject && bind(outputObject) ? outputObject : nullptr; } /*! @@ -1142,14 +1142,14 @@ void QMediaPlayer::setVideoOutput(QAbstractVideoSurface *surface) if (d->videoOutput) unbind(d->videoOutput); - d->videoOutput = 0; + d->videoOutput = nullptr; if (surface && bind(&d->surfaceOutput)) d->videoOutput = &d->surfaceOutput; } else if (!surface) { //unbind the surfaceOutput if null surface is set unbind(&d->surfaceOutput); - d->videoOutput = 0; + d->videoOutput = nullptr; } } @@ -1168,7 +1168,7 @@ QAudio::Role QMediaPlayer::audioRole() const { Q_D(const QMediaPlayer); - if (d->audioRoleControl != NULL) + if (d->audioRoleControl != nullptr) return d->audioRoleControl->audioRole(); return QAudio::UnknownRole; diff --git a/src/multimedia/playback/qmediaplaylist.cpp b/src/multimedia/playback/qmediaplaylist.cpp index 97fe75044..7618827da 100644 --- a/src/multimedia/playback/qmediaplaylist.cpp +++ b/src/multimedia/playback/qmediaplaylist.cpp @@ -124,7 +124,7 @@ QMediaPlaylist::QMediaPlaylist(QObject *parent) d->q_ptr = this; d->networkPlaylistControl = new QMediaNetworkPlaylistControl(this); - setMediaObject(0); + setMediaObject(nullptr); } /*! @@ -163,9 +163,9 @@ bool QMediaPlaylist::setMediaObject(QMediaObject *mediaObject) return true; QMediaService *service = mediaObject - ? mediaObject->service() : 0; + ? mediaObject->service() : nullptr; - QMediaPlaylistControl *newControl = 0; + QMediaPlaylistControl *newControl = nullptr; if (service) newControl = qobject_cast<QMediaPlaylistControl*>(service->requestControl(QMediaPlaylistControl_iid)); diff --git a/src/multimedia/playback/qmediaplaylist_p.h b/src/multimedia/playback/qmediaplaylist_p.h index 8e081dd67..16fce00a9 100644 --- a/src/multimedia/playback/qmediaplaylist_p.h +++ b/src/multimedia/playback/qmediaplaylist_p.h @@ -78,9 +78,9 @@ class QMediaPlaylistPrivate Q_DECLARE_PUBLIC(QMediaPlaylist) public: QMediaPlaylistPrivate() - :mediaObject(0), - control(0), - networkPlaylistControl(0), + :mediaObject(nullptr), + control(nullptr), + networkPlaylistControl(nullptr), error(QMediaPlaylist::NoError) { } @@ -98,10 +98,10 @@ public: void _q_mediaObjectDeleted() { Q_Q(QMediaPlaylist); - mediaObject = 0; + mediaObject = nullptr; if (control != networkPlaylistControl) - control = 0; - q->setMediaObject(0); + control = nullptr; + q->setMediaObject(nullptr); } QMediaObject *mediaObject; diff --git a/src/multimedia/playback/qmediaplaylistioplugin_p.h b/src/multimedia/playback/qmediaplaylistioplugin_p.h index 1e157d135..50bdcf9c0 100644 --- a/src/multimedia/playback/qmediaplaylistioplugin_p.h +++ b/src/multimedia/playback/qmediaplaylistioplugin_p.h @@ -106,7 +106,7 @@ class Q_MULTIMEDIA_EXPORT QMediaPlaylistIOPlugin : public QObject, public QMedia Q_OBJECT Q_INTERFACES(QMediaPlaylistIOInterface) public: - explicit QMediaPlaylistIOPlugin(QObject *parent = 0); + explicit QMediaPlaylistIOPlugin(QObject *parent = nullptr); ~QMediaPlaylistIOPlugin(); bool canRead(QIODevice *device, const QByteArray &format = QByteArray() ) const override = 0; diff --git a/src/multimedia/playback/qmediaplaylistnavigator.cpp b/src/multimedia/playback/qmediaplaylistnavigator.cpp index 0966c9396..120f621f5 100644 --- a/src/multimedia/playback/qmediaplaylistnavigator.cpp +++ b/src/multimedia/playback/qmediaplaylistnavigator.cpp @@ -63,7 +63,7 @@ class QMediaPlaylistNavigatorPrivate Q_DECLARE_NON_CONST_PUBLIC(QMediaPlaylistNavigator) public: QMediaPlaylistNavigatorPrivate() - :playlist(0), + :playlist(nullptr), currentPos(-1), lastValidPos(-1), playbackMode(QMediaPlaylist::Sequential), diff --git a/src/multimedia/playback/qmediaplaylistnavigator_p.h b/src/multimedia/playback/qmediaplaylistnavigator_p.h index 3899c42d9..2ac03a62c 100644 --- a/src/multimedia/playback/qmediaplaylistnavigator_p.h +++ b/src/multimedia/playback/qmediaplaylistnavigator_p.h @@ -67,7 +67,7 @@ class Q_MULTIMEDIA_EXPORT QMediaPlaylistNavigator : public QObject Q_PROPERTY(QMediaContent currentItem READ currentItem) public: - QMediaPlaylistNavigator(QMediaPlaylistProvider *playlist, QObject *parent = 0); + QMediaPlaylistNavigator(QMediaPlaylistProvider *playlist, QObject *parent = nullptr); virtual ~QMediaPlaylistNavigator(); QMediaPlaylistProvider *playlist() const; diff --git a/src/multimedia/playback/qmediaplaylistprovider_p.h b/src/multimedia/playback/qmediaplaylistprovider_p.h index 899c7c8bc..ed27612b9 100644 --- a/src/multimedia/playback/qmediaplaylistprovider_p.h +++ b/src/multimedia/playback/qmediaplaylistprovider_p.h @@ -70,12 +70,12 @@ class Q_MULTIMEDIA_EXPORT QMediaPlaylistProvider : public QObject { Q_OBJECT public: - QMediaPlaylistProvider(QObject *parent=0); + QMediaPlaylistProvider(QObject *parent = nullptr); virtual ~QMediaPlaylistProvider(); - virtual bool load(const QNetworkRequest &request, const char *format = 0); - virtual bool load(QIODevice * device, const char *format = 0); - virtual bool save(const QUrl &location, const char *format = 0); + virtual bool load(const QNetworkRequest &request, const char *format = nullptr); + virtual bool load(QIODevice *device, const char *format = nullptr); + virtual bool save(const QUrl &location, const char *format = nullptr); virtual bool save(QIODevice * device, const char *format); virtual int mediaCount() const = 0; diff --git a/src/multimedia/playback/qmediaresource.cpp b/src/multimedia/playback/qmediaresource.cpp index 0a59b0de8..181b37525 100644 --- a/src/multimedia/playback/qmediaresource.cpp +++ b/src/multimedia/playback/qmediaresource.cpp @@ -39,6 +39,8 @@ #include "qmediaresource.h" +#if QT_DEPRECATED_SINCE(6, 0) + #include <QtCore/qsize.h> #include <QtCore/qurl.h> #include <QtCore/qvariant.h> @@ -61,6 +63,7 @@ Q_CONSTRUCTOR_FUNCTION(qRegisterMediaResourceMetaTypes) \inmodule QtMultimedia \ingroup multimedia \ingroup multimedia_playback + \obsolete A media resource is composed of a \l {url()}{URL} containing the location of the resource and a set of properties that describe the @@ -418,3 +421,4 @@ void QMediaResource::setResolution(int width, int height) } QT_END_NAMESPACE +#endif // #if QT_DEPRECATED_SINCE(6, 0) diff --git a/src/multimedia/playback/qmediaresource.h b/src/multimedia/playback/qmediaresource.h index 9740166c6..8cded3128 100644 --- a/src/multimedia/playback/qmediaresource.h +++ b/src/multimedia/playback/qmediaresource.h @@ -46,6 +46,8 @@ #include <QtMultimedia/qtmultimediaglobal.h> +#if QT_DEPRECATED_SINCE(6, 0) + QT_BEGIN_NAMESPACE // Class forward declaration required for QDoc bug @@ -124,4 +126,6 @@ QT_END_NAMESPACE Q_DECLARE_METATYPE(QMediaResource) Q_DECLARE_METATYPE(QMediaResourceList) +#endif // #if QT_DEPRECATED_SINCE(6, 0) + #endif diff --git a/src/multimedia/playback/qplaylistfileparser.cpp b/src/multimedia/playback/qplaylistfileparser.cpp index 0d33f040d..92e7f97e8 100644 --- a/src/multimedia/playback/qplaylistfileparser.cpp +++ b/src/multimedia/playback/qplaylistfileparser.cpp @@ -273,7 +273,7 @@ class QPlaylistFileParserPrivate public: QPlaylistFileParserPrivate(QPlaylistFileParser *q) : q_ptr(q) - , m_stream(0) + , m_stream(nullptr) , m_type(QPlaylistFileParser::UNKNOWN) , m_scanIndex(0) , m_lineIndex(-1) @@ -299,9 +299,10 @@ public: struct ParserJob { QIODevice *m_stream; - QMediaResource m_resource; - bool isValid() const { return m_stream || !m_resource.isNull(); } - void reset() { m_stream = 0; m_resource = QMediaResource(); } + QMediaContent m_media; + QString m_mimeType; + bool isValid() const { return m_stream || !m_media.isNull(); } + void reset() { m_stream = nullptr; m_media = QMediaContent(); m_mimeType = QString(); } } m_pendingJob; int m_scanIndex; int m_lineIndex; @@ -498,22 +499,12 @@ QPlaylistFileParser::FileType QPlaylistFileParser::findPlaylistType(const QStrin /* * Delegating */ -void QPlaylistFileParser::start(const QMediaContent &media, QIODevice *stream) +void QPlaylistFileParser::start(const QMediaContent &media, QIODevice *stream, const QString &mimeType) { - const QMediaResource &mediaResource = media.canonicalResource(); - const QString &mimeType = mediaResource.mimeType(); - - if (stream) { - start(stream, mediaResource.mimeType()); - } else { - const QNetworkRequest &request = mediaResource.request(); - const QUrl &url = mediaResource.url(); - - if (request.url().isValid()) - start(request, mimeType); - else - start(QNetworkRequest(url), mimeType); - } + if (stream) + start(stream, mimeType); + else + start(media.canonicalRequest(), mimeType); } void QPlaylistFileParser::start(QIODevice *stream, const QString &mimeType) @@ -528,7 +519,7 @@ void QPlaylistFileParser::start(QIODevice *stream, const QString &mimeType) if (!d->m_currentParser.isNull()) { abort(); - d->m_pendingJob = { stream, QMediaResource(QUrl(), mimeType) }; + d->m_pendingJob = { stream, QUrl(), mimeType }; return; } @@ -551,7 +542,7 @@ void QPlaylistFileParser::start(const QNetworkRequest& request, const QString &m if (!d->m_currentParser.isNull()) { abort(); - d->m_pendingJob = { nullptr, QMediaResource(request, mimeType) }; + d->m_pendingJob = { nullptr, request, mimeType }; return; } @@ -604,7 +595,7 @@ void QPlaylistFileParserPrivate::handleParserFinished() m_source.reset(); if (m_pendingJob.isValid()) - q->start(m_pendingJob.m_resource, m_pendingJob.m_stream); + q->start(m_pendingJob.m_media, m_pendingJob.m_stream, m_pendingJob.m_mimeType); } void QPlaylistFileParserPrivate::abort() diff --git a/src/multimedia/playback/qplaylistfileparser_p.h b/src/multimedia/playback/qplaylistfileparser_p.h index 927dbb739..cf96ccdbf 100644 --- a/src/multimedia/playback/qplaylistfileparser_p.h +++ b/src/multimedia/playback/qplaylistfileparser_p.h @@ -66,7 +66,7 @@ class Q_MULTIMEDIA_EXPORT QPlaylistFileParser : public QObject { Q_OBJECT public: - QPlaylistFileParser(QObject *parent = 0); + QPlaylistFileParser(QObject *parent = nullptr); ~QPlaylistFileParser(); enum FileType @@ -86,7 +86,7 @@ public: NetworkError }; - void start(const QMediaContent &media, QIODevice *stream = 0); + void start(const QMediaContent &media, QIODevice *stream = nullptr, const QString &mimeType = QString()); void start(const QNetworkRequest &request, const QString &mimeType = QString()); void abort(); @@ -109,7 +109,7 @@ private: const QString& mime); static FileType findPlaylistType(const QString &suffix, const QString& mime, - const char *data = 0, + const char *data = nullptr, quint32 size = 0); Q_DISABLE_COPY(QPlaylistFileParser) diff --git a/src/multimedia/qmediacontrol.h b/src/multimedia/qmediacontrol.h index cff42e3ca..48ae44f8a 100644 --- a/src/multimedia/qmediacontrol.h +++ b/src/multimedia/qmediacontrol.h @@ -68,7 +68,7 @@ private: Q_DECLARE_PRIVATE(QMediaControl) }; -template <typename T> const char *qmediacontrol_iid() { return 0; } +template <typename T> const char *qmediacontrol_iid() { return nullptr; } #define Q_MEDIA_DECLARE_CONTROL(Class, IId) \ template <> inline const char *qmediacontrol_iid<Class *>() { return IId; } diff --git a/src/multimedia/qmediametadata.cpp b/src/multimedia/qmediametadata.cpp index 0f3d3defd..0b2343443 100644 --- a/src/multimedia/qmediametadata.cpp +++ b/src/multimedia/qmediametadata.cpp @@ -105,6 +105,7 @@ Q_DEFINE_METADATA(CoverArtUrlLarge); // Image/Video Q_DEFINE_METADATA(Resolution); Q_DEFINE_METADATA(PixelAspectRatio); +Q_DEFINE_METADATA(Orientation); // Video Q_DEFINE_METADATA(VideoFrameRate); @@ -124,7 +125,6 @@ Q_DEFINE_METADATA(CameraManufacturer); Q_DEFINE_METADATA(CameraModel); Q_DEFINE_METADATA(Event); Q_DEFINE_METADATA(Subject); -Q_DEFINE_METADATA(Orientation); Q_DEFINE_METADATA(ExposureTime); Q_DEFINE_METADATA(FNumber); Q_DEFINE_METADATA(ExposureProgram); @@ -239,6 +239,7 @@ Q_DEFINE_METADATA(ThumbnailImage); Image and video attributes \row \li Resolution \li The dimensions of an image or video. \li QSize \row \li PixelAspectRatio \li The pixel aspect ratio of an image or video. \li QSize + \row \li Orientation \li Orientation of an image or video. \li int (degrees) \header \li {3,1} Video attributes @@ -262,7 +263,6 @@ Q_DEFINE_METADATA(ThumbnailImage); \row \li CameraModel \li The model of the camera used to capture the media. \li QString \row \li Event \li The event during which the media was captured. \li QString \row \li Subject \li The subject of the media. \li QString - \row \li Orientation \li Orientation of image. \li int (degrees) \row \li ExposureTime \li Exposure time, given in seconds. \li qreal \row \li FNumber \li The F Number. \li int \row \li ExposureProgram diff --git a/src/multimedia/qmediaobject.cpp b/src/multimedia/qmediaobject.cpp index 71b2d148c..a12cab404 100644 --- a/src/multimedia/qmediaobject.cpp +++ b/src/multimedia/qmediaobject.cpp @@ -127,7 +127,7 @@ QMediaObject::~QMediaObject() QMultimedia::AvailabilityStatus QMediaObject::availability() const { - if (d_func()->service == 0) + if (d_func()->service == nullptr) return QMultimedia::ServiceMissing; if (d_func()->availabilityControl) @@ -216,7 +216,7 @@ void QMediaObject::unbind(QObject *object) QMediaBindableInterface *helper = qobject_cast<QMediaBindableInterface*>(object); if (helper && helper->mediaObject() == this) - helper->setMediaObject(0); + helper->setMediaObject(nullptr); else qWarning() << "QMediaObject: Trying to unbind not connected helper object"; } @@ -395,7 +395,7 @@ void QMediaObject::setupControls() { Q_D(QMediaObject); - if (d->service != 0) { + if (d->service != nullptr) { d->metaDataControl = qobject_cast<QMetaDataReaderControl*>( d->service->requestControl(QMetaDataReaderControl_iid)); diff --git a/src/multimedia/qmediaobject_p.h b/src/multimedia/qmediaobject_p.h index 3e663e03d..85caf9a50 100644 --- a/src/multimedia/qmediaobject_p.h +++ b/src/multimedia/qmediaobject_p.h @@ -73,7 +73,7 @@ class QMediaObjectPrivate Q_DECLARE_PUBLIC(QMediaObject) public: - QMediaObjectPrivate(): service(0), metaDataControl(0), availabilityControl(0), notifyTimer(0), q_ptr(0) {} + QMediaObjectPrivate() : service(nullptr), metaDataControl(nullptr), availabilityControl(nullptr), notifyTimer(nullptr), q_ptr(nullptr) {} virtual ~QMediaObjectPrivate() {} void _q_notify(); diff --git a/src/multimedia/qmediapluginloader.cpp b/src/multimedia/qmediapluginloader.cpp index bd3c525f4..78ba3207f 100644 --- a/src/multimedia/qmediapluginloader.cpp +++ b/src/multimedia/qmediapluginloader.cpp @@ -68,11 +68,11 @@ QStringList QMediaPluginLoader::keys() const QObject* QMediaPluginLoader::instance(QString const &key) { if (!m_metadata.contains(key)) - return 0; + return nullptr; int idx = m_metadata.value(key).first().value(QStringLiteral("index")).toDouble(); if (idx < 0) - return 0; + return nullptr; return m_factoryLoader->instance(idx); } @@ -82,6 +82,7 @@ QList<QObject*> QMediaPluginLoader::instances(QString const &key) if (!m_metadata.contains(key)) return QList<QObject*>(); + QList<QString> keys; QList<QObject *> objects; const auto list = m_metadata.value(key); for (const QJsonObject &jsonobj : list) { @@ -91,10 +92,39 @@ QList<QObject*> QMediaPluginLoader::instances(QString const &key) QObject *object = m_factoryLoader->instance(idx); if (!objects.contains(object)) { + QJsonArray arr = jsonobj.value(QStringLiteral("Keys")).toArray(); + keys.append(!arr.isEmpty() ? arr.at(0).toString() : QStringLiteral("")); objects.append(object); } } + static const bool showDebug = qEnvironmentVariableIntValue("QT_DEBUG_PLUGINS"); + static const QStringList preferredPlugins = + qEnvironmentVariable("QT_MULTIMEDIA_PREFERRED_PLUGINS").split(QLatin1Char(','), QString::SkipEmptyParts); + for (int i = preferredPlugins.size() - 1; i >= 0; --i) { + auto name = preferredPlugins[i]; + bool found = false; + for (int j = 0; j < keys.size(); ++j) { + if (!keys[j].startsWith(name)) + continue; + + auto obj = objects[j]; + objects.removeAt(j); + objects.prepend(obj); + auto k = keys[j]; + keys.removeAt(j); + keys.prepend(k); + found = true; + break; + } + + if (showDebug && !found) + qWarning() << "QMediaPluginLoader: pattern" << name << "did not match any loaded plugin"; + } + + if (showDebug) + qDebug() << "QMediaPluginLoader: loaded plugins for key" << key << ":" << keys; + return objects; } diff --git a/src/multimedia/qmediaresourcepolicy_p.cpp b/src/multimedia/qmediaresourcepolicy_p.cpp index 1577f11af..14dc15968 100644 --- a/src/multimedia/qmediaresourcepolicy_p.cpp +++ b/src/multimedia/qmediaresourcepolicy_p.cpp @@ -84,7 +84,7 @@ QObject* QMediaResourcePolicy::createResourceSet(const QString& interfaceId) QMediaResourceSetFactoryInterface *factory = qobject_cast<QMediaResourceSetFactoryInterface*>(resourcePolicyLoader() ->instance(QLatin1String("default"))); - QObject* obj = 0; + QObject *obj = nullptr; if (factory) obj = factory->create(interfaceId); diff --git a/src/multimedia/qmediaresourcepolicyplugin_p.h b/src/multimedia/qmediaresourcepolicyplugin_p.h index 7b53c3b3a..e37551390 100644 --- a/src/multimedia/qmediaresourcepolicyplugin_p.h +++ b/src/multimedia/qmediaresourcepolicyplugin_p.h @@ -72,7 +72,7 @@ class Q_MULTIMEDIA_EXPORT QMediaResourcePolicyPlugin : public QObject, public QM Q_INTERFACES(QMediaResourceSetFactoryInterface) public: - QMediaResourcePolicyPlugin(QObject *parent = 0); + QMediaResourcePolicyPlugin(QObject *parent = nullptr); ~QMediaResourcePolicyPlugin(); }; diff --git a/src/multimedia/qmediaresourceset_p.h b/src/multimedia/qmediaresourceset_p.h index a0158877f..5ad4ca7aa 100644 --- a/src/multimedia/qmediaresourceset_p.h +++ b/src/multimedia/qmediaresourceset_p.h @@ -80,7 +80,7 @@ Q_SIGNALS: void availabilityChanged(bool available); protected: - QMediaPlayerResourceSetInterface(QObject *parent = 0); + QMediaPlayerResourceSetInterface(QObject *parent = nullptr); }; QT_END_NAMESPACE diff --git a/src/multimedia/qmediaserviceprovider.cpp b/src/multimedia/qmediaserviceprovider.cpp index 21e34bd49..023c13008 100644 --- a/src/multimedia/qmediaserviceprovider.cpp +++ b/src/multimedia/qmediaserviceprovider.cpp @@ -56,7 +56,7 @@ class QMediaServiceProviderHintPrivate : public QSharedData { public: QMediaServiceProviderHintPrivate(QMediaServiceProviderHint::Type type) - :type(type), cameraPosition(QCamera::UnspecifiedPosition), features(0) + :type(type), cameraPosition(QCamera::UnspecifiedPosition), features(nullptr) { } @@ -309,7 +309,7 @@ class QPluginServiceProvider : public QMediaServiceProvider QByteArray type; QMediaServiceProviderPlugin *plugin; - MediaServiceData() : plugin(0) { } + MediaServiceData() : plugin(nullptr) { } }; QMap<const QMediaService*, MediaServiceData> mediaServiceData; @@ -329,7 +329,7 @@ public: } if (!plugins.isEmpty()) { - QMediaServiceProviderPlugin *plugin = 0; + QMediaServiceProviderPlugin *plugin = nullptr; switch (hint.type()) { case QMediaServiceProviderHint::Null: @@ -423,9 +423,9 @@ public: break; } - if (plugin != 0) { + if (plugin != nullptr) { QMediaService *service = plugin->create(key); - if (service != 0) { + if (service != nullptr) { MediaServiceData d; d.type = type; d.plugin = plugin; @@ -437,15 +437,15 @@ public: } qWarning() << "defaultServiceProvider::requestService(): no service found for -" << key; - return 0; + return nullptr; } void releaseService(QMediaService *service) override { - if (service != 0) { + if (service != nullptr) { MediaServiceData d = mediaServiceData.take(service); - if (d.plugin != 0) + if (d.plugin != nullptr) d.plugin->release(service); } } @@ -576,8 +576,11 @@ public: const QMediaServiceDefaultDeviceInterface *iface = qobject_cast<QMediaServiceDefaultDeviceInterface*>(obj); - if (iface) - return iface->defaultDevice(serviceType); + if (iface) { + QByteArray name = iface->defaultDevice(serviceType); + if (!name.isEmpty()) + return name; + } } // if QMediaServiceDefaultDeviceInterface is not implemented, return the @@ -704,7 +707,7 @@ QMediaServiceProviderHint::Features QMediaServiceProvider::supportedFeatures(con { Q_UNUSED(service); - return QMediaServiceProviderHint::Features(0); + return QMediaServiceProviderHint::Features(nullptr); } /*! @@ -798,7 +801,7 @@ int QMediaServiceProvider::cameraOrientation(const QByteArray &device) const return 0; } -static QMediaServiceProvider *qt_defaultMediaServiceProvider = 0; +static QMediaServiceProvider *qt_defaultMediaServiceProvider = nullptr; /*! Sets a media service \a provider as the default. @@ -817,7 +820,7 @@ void QMediaServiceProvider::setDefaultServiceProvider(QMediaServiceProvider *pro */ QMediaServiceProvider *QMediaServiceProvider::defaultServiceProvider() { - return qt_defaultMediaServiceProvider != 0 + return qt_defaultMediaServiceProvider != nullptr ? qt_defaultMediaServiceProvider : static_cast<QMediaServiceProvider *>(pluginProvider()); } diff --git a/src/multimedia/qtmultimediaquicktools_headers/qdeclarativevideooutput_p.h b/src/multimedia/qtmultimediaquicktools_headers/qdeclarativevideooutput_p.h index 465821cb1..894796dfb 100644 --- a/src/multimedia/qtmultimediaquicktools_headers/qdeclarativevideooutput_p.h +++ b/src/multimedia/qtmultimediaquicktools_headers/qdeclarativevideooutput_p.h @@ -79,9 +79,19 @@ class Q_MULTIMEDIAQUICK_EXPORT QDeclarativeVideoOutput : public QQuickItem Q_PROPERTY(QRectF sourceRect READ sourceRect NOTIFY sourceRectChanged) Q_PROPERTY(QRectF contentRect READ contentRect NOTIFY contentRectChanged) Q_PROPERTY(QQmlListProperty<QAbstractVideoFilter> filters READ filters); + Q_PROPERTY(FlushMode flushMode READ flushMode WRITE setFlushMode NOTIFY flushModeChanged) + Q_ENUMS(FlushMode) Q_ENUMS(FillMode) public: + + enum FlushMode + { + EmptyFrame, + FirstFrame, + LastFrame + }; + enum FillMode { Stretch = Qt::IgnoreAspectRatio, @@ -125,6 +135,9 @@ public: QQmlListProperty<QAbstractVideoFilter> filters(); + FlushMode flushMode() const { return m_flushMode; } + void setFlushMode(FlushMode mode); + Q_SIGNALS: void sourceChanged(); void fillModeChanged(QDeclarativeVideoOutput::FillMode); @@ -132,6 +145,7 @@ Q_SIGNALS: void autoOrientationChanged(); void sourceRectChanged(); void contentRectChanged(); + void flushModeChanged(); protected: QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override; @@ -175,6 +189,7 @@ private: QScopedPointer<QDeclarativeVideoBackend> m_backend; QList<QAbstractVideoFilter *> m_filters; + FlushMode m_flushMode = EmptyFrame; }; QT_END_NAMESPACE diff --git a/src/multimedia/radio/qradiodata.cpp b/src/multimedia/radio/qradiodata.cpp index 9ed6cb522..d71488b52 100644 --- a/src/multimedia/radio/qradiodata.cpp +++ b/src/multimedia/radio/qradiodata.cpp @@ -95,14 +95,14 @@ public: }; QRadioDataPrivate::QRadioDataPrivate() - : mediaObject(0) - , control(0) + : mediaObject(nullptr) + , control(nullptr) {} void QRadioDataPrivate::_q_serviceDestroyed() { - mediaObject = 0; - control = 0; + mediaObject = nullptr; + control = nullptr; } /*! @@ -211,8 +211,8 @@ bool QRadioData::setMediaObject(QMediaObject *mediaObject) } // without QRadioDataControl discard the media object - d->mediaObject = 0; - d->control = 0; + d->mediaObject = nullptr; + d->control = nullptr; return false; } @@ -228,7 +228,7 @@ QMultimedia::AvailabilityStatus QRadioData::availability() const { Q_D(const QRadioData); - if (d->control == 0) + if (d->control == nullptr) return QMultimedia::ServiceMissing; return d->mediaObject->availability(); @@ -244,7 +244,7 @@ QString QRadioData::stationId() const { Q_D(const QRadioData); - if (d->control != 0) + if (d->control != nullptr) return d->control->stationId(); return QString(); } @@ -259,7 +259,7 @@ QRadioData::ProgramType QRadioData::programType() const { Q_D(const QRadioData); - if (d->control != 0) + if (d->control != nullptr) return d->control->programType(); return QRadioData::Undefined; @@ -275,7 +275,7 @@ QString QRadioData::programTypeName() const { Q_D(const QRadioData); - if (d->control != 0) + if (d->control != nullptr) return d->control->programTypeName(); return QString(); } @@ -290,7 +290,7 @@ QString QRadioData::stationName() const { Q_D(const QRadioData); - if (d->control != 0) + if (d->control != nullptr) return d->control->stationName(); return QString(); } @@ -305,7 +305,7 @@ QString QRadioData::radioText() const { Q_D(const QRadioData); - if (d->control != 0) + if (d->control != nullptr) return d->control->radioText(); return QString(); } @@ -320,7 +320,7 @@ bool QRadioData::isAlternativeFrequenciesEnabled() const { Q_D(const QRadioData); - if (d->control != 0) + if (d->control != nullptr) return d->control->isAlternativeFrequenciesEnabled(); return false; } @@ -329,7 +329,7 @@ void QRadioData::setAlternativeFrequenciesEnabled( bool enabled ) { Q_D(const QRadioData); - if (d->control != 0) + if (d->control != nullptr) return d->control->setAlternativeFrequenciesEnabled(enabled); } @@ -343,7 +343,7 @@ QRadioData::Error QRadioData::error() const { Q_D(const QRadioData); - if (d->control != 0) + if (d->control != nullptr) return d->control->error(); return QRadioData::ResourceError; } @@ -357,7 +357,7 @@ QString QRadioData::errorString() const { Q_D(const QRadioData); - if (d->control != 0) + if (d->control != nullptr) return d->control->errorString(); return QString(); } diff --git a/src/multimedia/radio/qradiotuner.cpp b/src/multimedia/radio/qradiotuner.cpp index 3206b4ee5..cc9abdbf8 100644 --- a/src/multimedia/radio/qradiotuner.cpp +++ b/src/multimedia/radio/qradiotuner.cpp @@ -88,7 +88,7 @@ Q_CONSTRUCTOR_FUNCTION(qRegisterRadioTunerMetaTypes) class QRadioTunerPrivate : public QMediaObjectPrivate { public: - QRadioTunerPrivate():provider(0), control(0), radioData(0) {} + QRadioTunerPrivate():provider(nullptr), control(nullptr), radioData(nullptr) {} QMediaServiceProvider *provider; QRadioTunerControl* control; QRadioData *radioData; @@ -112,9 +112,9 @@ QRadioTuner::QRadioTuner(QObject *parent): d->provider = QMediaServiceProvider::defaultServiceProvider(); - if (d->service != 0) { + if (d->service != nullptr) { d->control = qobject_cast<QRadioTunerControl*>(d->service->requestControl(QRadioTunerControl_iid)); - if (d->control != 0) { + if (d->control != nullptr) { connect(d->control, SIGNAL(stateChanged(QRadioTuner::State)), SIGNAL(stateChanged(QRadioTuner::State))); connect(d->control, SIGNAL(bandChanged(QRadioTuner::Band)), SIGNAL(bandChanged(QRadioTuner::Band))); connect(d->control, SIGNAL(frequencyChanged(int)), SIGNAL(frequencyChanged(int))); @@ -154,7 +154,7 @@ QRadioTuner::~QRadioTuner() */ QMultimedia::AvailabilityStatus QRadioTuner::availability() const { - if (d_func()->control == 0) + if (d_func()->control == nullptr) return QMultimedia::ServiceMissing; if (!d_func()->control->isAntennaConnected()) @@ -187,7 +187,7 @@ QRadioTuner::Band QRadioTuner::band() const { Q_D(const QRadioTuner); - if (d->control != 0) + if (d->control != nullptr) return d->control->band(); return QRadioTuner::FM; @@ -202,7 +202,7 @@ int QRadioTuner::frequency() const { Q_D(const QRadioTuner); - if (d->control != 0) + if (d->control != nullptr) return d->control->frequency(); return 0; @@ -217,7 +217,7 @@ int QRadioTuner::frequencyStep(QRadioTuner::Band band) const { Q_D(const QRadioTuner); - if(d->control != 0) + if (d->control != nullptr) return d->control->frequencyStep(band); return 0; @@ -231,7 +231,7 @@ QPair<int,int> QRadioTuner::frequencyRange(QRadioTuner::Band band) const { Q_D(const QRadioTuner); - if(d->control != 0) + if (d->control != nullptr) return d->control->frequencyRange(band); return qMakePair<int,int>(0,0); @@ -246,7 +246,7 @@ bool QRadioTuner::isStereo() const { Q_D(const QRadioTuner); - if (d->control != 0) + if (d->control != nullptr) return d->control->isStereo(); return false; @@ -262,7 +262,7 @@ QRadioTuner::StereoMode QRadioTuner::stereoMode() const { Q_D(const QRadioTuner); - if (d->control != 0) + if (d->control != nullptr) return d->control->stereoMode(); return QRadioTuner::Auto; @@ -272,7 +272,7 @@ void QRadioTuner::setStereoMode(QRadioTuner::StereoMode mode) { Q_D(QRadioTuner); - if (d->control != 0) + if (d->control != nullptr) return d->control->setStereoMode(mode); } @@ -286,7 +286,7 @@ bool QRadioTuner::isBandSupported(QRadioTuner::Band band) const { Q_D(const QRadioTuner); - if (d->control != 0) + if (d->control != nullptr) return d->control->isBandSupported(band); return false; @@ -300,7 +300,7 @@ void QRadioTuner::start() { Q_D(const QRadioTuner); - if (d->control != 0) + if (d->control != nullptr) d->control->start(); } @@ -312,7 +312,7 @@ void QRadioTuner::stop() { Q_D(const QRadioTuner); - if (d->control != 0) + if (d->control != nullptr) d->control->stop(); } @@ -325,7 +325,7 @@ int QRadioTuner::signalStrength() const { Q_D(const QRadioTuner); - if (d->control != 0) + if (d->control != nullptr) return d->control->signalStrength(); return 0; @@ -341,7 +341,7 @@ int QRadioTuner::volume() const { Q_D(const QRadioTuner); - if (d->control != 0) + if (d->control != nullptr) return d->control->volume(); return 0; @@ -356,7 +356,7 @@ bool QRadioTuner::isMuted() const { Q_D(const QRadioTuner); - if (d->control != 0) + if (d->control != nullptr) return d->control->isMuted(); return false; @@ -372,7 +372,7 @@ void QRadioTuner::setBand(QRadioTuner::Band band) { Q_D(QRadioTuner); - if (d->control != 0) + if (d->control != nullptr) d->control->setBand(band); } @@ -387,7 +387,7 @@ void QRadioTuner::setFrequency(int frequency) { Q_D(QRadioTuner); - if (d->control != 0) + if (d->control != nullptr) d->control->setFrequency(frequency); } @@ -395,7 +395,7 @@ void QRadioTuner::setVolume(int volume) { Q_D(QRadioTuner); - if (d->control != 0) + if (d->control != nullptr) d->control->setVolume(volume); } @@ -403,7 +403,7 @@ void QRadioTuner::setMuted(bool muted) { Q_D(QRadioTuner); - if (d->control != 0) + if (d->control != nullptr) d->control->setMuted(muted); } @@ -418,7 +418,7 @@ bool QRadioTuner::isSearching() const { Q_D(const QRadioTuner); - if (d->control != 0) + if (d->control != nullptr) return d->control->isSearching(); return false; @@ -432,7 +432,7 @@ bool QRadioTuner::isAntennaConnected() const { Q_D(const QRadioTuner); - if (d->control != 0) + if (d->control != nullptr) return d->control->isAntennaConnected(); return false; @@ -448,7 +448,7 @@ void QRadioTuner::searchForward() { Q_D(QRadioTuner); - if (d->control != 0) + if (d->control != nullptr) d->control->searchForward(); } @@ -462,7 +462,7 @@ void QRadioTuner::searchBackward() { Q_D(QRadioTuner); - if (d->control != 0) + if (d->control != nullptr) d->control->searchBackward(); } @@ -490,7 +490,7 @@ void QRadioTuner::searchAllStations(QRadioTuner::SearchMode searchMode) { Q_D(const QRadioTuner); - if (d->control != 0) + if (d->control != nullptr) d->control->searchAllStations(searchMode); } @@ -504,7 +504,7 @@ void QRadioTuner::cancelSearch() { Q_D(QRadioTuner); - if (d->control != 0) + if (d->control != nullptr) d->control->cancelSearch(); } @@ -518,7 +518,7 @@ QRadioTuner::Error QRadioTuner::error() const { Q_D(const QRadioTuner); - if (d->control != 0) + if (d->control != nullptr) return d->control->error(); return QRadioTuner::ResourceError; @@ -534,7 +534,7 @@ QString QRadioTuner::errorString() const { Q_D(const QRadioTuner); - if (d->control != 0) + if (d->control != nullptr) return d->control->errorString(); return QString(); diff --git a/src/multimedia/recording/qaudiorecorder.cpp b/src/multimedia/recording/qaudiorecorder.cpp index 1d3e5ba7f..dcbdabc17 100644 --- a/src/multimedia/recording/qaudiorecorder.cpp +++ b/src/multimedia/recording/qaudiorecorder.cpp @@ -96,11 +96,11 @@ public: void initControls() { Q_Q(QAudioRecorder); - audioInputSelector = 0; + audioInputSelector = nullptr; - QMediaService *service = mediaObject ? mediaObject->service() : 0; + QMediaService *service = mediaObject ? mediaObject->service() : nullptr; - if (service != 0) + if (service != nullptr) audioInputSelector = qobject_cast<QAudioInputSelectorControl*>(service->requestControl(QAudioInputSelectorControl_iid)); if (audioInputSelector) { @@ -113,8 +113,8 @@ public: QAudioRecorderPrivate(): QMediaRecorderPrivate(), - provider(0), - audioInputSelector(0) {} + provider(nullptr), + audioInputSelector(nullptr) {} QMediaServiceProvider *provider; QAudioInputSelectorControl *audioInputSelector; @@ -128,7 +128,7 @@ public: */ QAudioRecorder::QAudioRecorder(QObject *parent): - QMediaRecorder(*new QAudioRecorderPrivate, 0, parent) + QMediaRecorder(*new QAudioRecorderPrivate, nullptr, parent) { Q_D(QAudioRecorder); d->provider = QMediaServiceProvider::defaultServiceProvider(); @@ -145,9 +145,9 @@ QAudioRecorder::QAudioRecorder(QObject *parent): QAudioRecorder::~QAudioRecorder() { Q_D(QAudioRecorder); - QMediaService *service = d->mediaObject ? d->mediaObject->service() : 0; + QMediaService *service = d->mediaObject ? d->mediaObject->service() : nullptr; QMediaObject *mediaObject = d->mediaObject; - setMediaObject(0); + setMediaObject(nullptr); if (service && d->audioInputSelector) service->releaseControl(d->audioInputSelector); diff --git a/src/multimedia/recording/qmediarecorder.cpp b/src/multimedia/recording/qmediarecorder.cpp index 3bab3dada..2b7729481 100644 --- a/src/multimedia/recording/qmediarecorder.cpp +++ b/src/multimedia/recording/qmediarecorder.cpp @@ -89,15 +89,15 @@ Q_CONSTRUCTOR_FUNCTION(qRegisterMediaRecorderMetaTypes) QMediaRecorderPrivate::QMediaRecorderPrivate(): - mediaObject(0), - control(0), - formatControl(0), - audioControl(0), - videoControl(0), - metaDataControl(0), - availabilityControl(0), + mediaObject(nullptr), + control(nullptr), + formatControl(nullptr), + audioControl(nullptr), + videoControl(nullptr), + metaDataControl(nullptr), + availabilityControl(nullptr), settingsChanged(false), - notifyTimer(0), + notifyTimer(nullptr), state(QMediaRecorder::StoppedState), error(QMediaRecorder::NoError) { @@ -135,13 +135,13 @@ void QMediaRecorderPrivate::_q_error(int error, const QString &errorString) void QMediaRecorderPrivate::_q_serviceDestroyed() { - mediaObject = 0; - control = 0; - formatControl = 0; - audioControl = 0; - videoControl = 0; - metaDataControl = 0; - availabilityControl = 0; + mediaObject = nullptr; + control = nullptr; + formatControl = nullptr; + audioControl = nullptr; + videoControl = nullptr; + metaDataControl = nullptr; + availabilityControl = nullptr; settingsChanged = true; } @@ -328,12 +328,12 @@ bool QMediaRecorder::setMediaObject(QMediaObject *object) } } - d->control = 0; - d->formatControl = 0; - d->audioControl = 0; - d->videoControl = 0; - d->metaDataControl = 0; - d->availabilityControl = 0; + d->control = nullptr; + d->formatControl = nullptr; + d->audioControl = nullptr; + d->videoControl = nullptr; + d->metaDataControl = nullptr; + d->availabilityControl = nullptr; d->mediaObject = object; @@ -407,7 +407,7 @@ bool QMediaRecorder::setMediaObject(QMediaObject *object) } } - d->mediaObject = 0; + d->mediaObject = nullptr; return false; } @@ -453,7 +453,7 @@ bool QMediaRecorder::isAvailable() const */ QMultimedia::AvailabilityStatus QMediaRecorder::availability() const { - if (d_func()->control == NULL) + if (d_func()->control == nullptr) return QMultimedia::ServiceMissing; if (d_func()->availabilityControl) diff --git a/src/multimedia/video/qabstractvideobuffer.cpp b/src/multimedia/video/qabstractvideobuffer.cpp index 50e38a98c..f0dd6d2eb 100644 --- a/src/multimedia/video/qabstractvideobuffer.cpp +++ b/src/multimedia/video/qabstractvideobuffer.cpp @@ -126,7 +126,7 @@ int QAbstractVideoBufferPrivate::map( Constructs an abstract video buffer of the given \a type. */ QAbstractVideoBuffer::QAbstractVideoBuffer(HandleType type) - : d_ptr(0) + : d_ptr(nullptr) , m_type(type) { } @@ -328,7 +328,7 @@ uchar *QAbstractPlanarVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPe *bytesPerLine = strides[0]; return data[0]; } else { - return 0; + return nullptr; } } diff --git a/src/multimedia/video/qabstractvideobuffer_p.h b/src/multimedia/video/qabstractvideobuffer_p.h index 9e3ced9b5..4877d3120 100644 --- a/src/multimedia/video/qabstractvideobuffer_p.h +++ b/src/multimedia/video/qabstractvideobuffer_p.h @@ -64,7 +64,7 @@ class QAbstractVideoBufferPrivate { public: QAbstractVideoBufferPrivate() - : q_ptr(0) + : q_ptr(nullptr) {} virtual ~QAbstractVideoBufferPrivate() diff --git a/src/multimedia/video/qimagevideobuffer.cpp b/src/multimedia/video/qimagevideobuffer.cpp index f407e02d0..28dacefc6 100644 --- a/src/multimedia/video/qimagevideobuffer.cpp +++ b/src/multimedia/video/qimagevideobuffer.cpp @@ -96,7 +96,7 @@ uchar *QImageVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine) return d->image.bits(); } else { - return 0; + return nullptr; } } diff --git a/src/multimedia/video/qmemoryvideobuffer.cpp b/src/multimedia/video/qmemoryvideobuffer.cpp index 1b52bb7cd..e05210d9d 100644 --- a/src/multimedia/video/qmemoryvideobuffer.cpp +++ b/src/multimedia/video/qmemoryvideobuffer.cpp @@ -112,7 +112,7 @@ uchar *QMemoryVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine) return reinterpret_cast<uchar *>(d->data.data()); } else { - return 0; + return nullptr; } } diff --git a/src/multimedia/video/qvideoframe.cpp b/src/multimedia/video/qvideoframe.cpp index bbb87b63b..e94b838f9 100644 --- a/src/multimedia/video/qvideoframe.cpp +++ b/src/multimedia/video/qvideoframe.cpp @@ -75,7 +75,7 @@ public: , planeCount(0) , pixelFormat(QVideoFrame::Format_Invalid) , fieldType(QVideoFrame::ProgressiveFrame) - , buffer(0) + , buffer(nullptr) , mappedCount(0) { memset(data, 0, sizeof(data)); @@ -90,7 +90,7 @@ public: , planeCount(0) , pixelFormat(format) , fieldType(QVideoFrame::ProgressiveFrame) - , buffer(0) + , buffer(nullptr) , mappedCount(0) { memset(data, 0, sizeof(data)); @@ -195,6 +195,9 @@ private: \value Format_BGRA32_Premultiplied The frame is stored using a premultiplied 32bit BGRA format. + \value Format_ABGR32 + The frame is stored using a 32-bit ABGR format (0xAABBGGRR). + \value Format_BGR32 The frame is stored using a 32-bit BGR format (0xBBGGRRff). @@ -401,6 +404,15 @@ QVideoFrame::~QVideoFrame() } /*! + \return underlying video buffer or \c null if there is none. + \since 5.13 +*/ +QAbstractVideoBuffer *QVideoFrame::buffer() const +{ + return d->buffer; +} + +/*! Identifies whether a video frame is valid. An invalid frame has no video buffer associated with it. @@ -409,7 +421,7 @@ QVideoFrame::~QVideoFrame() */ bool QVideoFrame::isValid() const { - return d->buffer != 0; + return d->buffer != nullptr; } /*! @@ -485,7 +497,7 @@ void QVideoFrame::setFieldType(QVideoFrame::FieldType field) bool QVideoFrame::isMapped() const { - return d->buffer != 0 && d->buffer->mapMode() != QAbstractVideoBuffer::NotMapped; + return d->buffer != nullptr && d->buffer->mapMode() != QAbstractVideoBuffer::NotMapped; } /*! @@ -504,7 +516,7 @@ bool QVideoFrame::isMapped() const */ bool QVideoFrame::isWritable() const { - return d->buffer != 0 && (d->buffer->mapMode() & QAbstractVideoBuffer::WriteOnly); + return d->buffer != nullptr && (d->buffer->mapMode() & QAbstractVideoBuffer::WriteOnly); } /*! @@ -520,7 +532,7 @@ bool QVideoFrame::isWritable() const */ bool QVideoFrame::isReadable() const { - return d->buffer != 0 && (d->buffer->mapMode() & QAbstractVideoBuffer::ReadOnly); + return d->buffer != nullptr && (d->buffer->mapMode() & QAbstractVideoBuffer::ReadOnly); } /*! @@ -530,7 +542,7 @@ bool QVideoFrame::isReadable() const */ QAbstractVideoBuffer::MapMode QVideoFrame::mapMode() const { - return d->buffer != 0 ? d->buffer->mapMode() : QAbstractVideoBuffer::NotMapped; + return d->buffer != nullptr ? d->buffer->mapMode() : QAbstractVideoBuffer::NotMapped; } /*! @@ -584,7 +596,7 @@ bool QVideoFrame::map(QAbstractVideoBuffer::MapMode mode) } } - Q_ASSERT(d->data[0] == 0); + Q_ASSERT(d->data[0] == nullptr); Q_ASSERT(d->bytesPerLine[0] == 0); Q_ASSERT(d->planeCount == 0); Q_ASSERT(d->mappedBytes == 0); @@ -606,6 +618,7 @@ bool QVideoFrame::map(QAbstractVideoBuffer::MapMode mode) case Format_ARGB8565_Premultiplied: case Format_BGRA32: case Format_BGRA32_Premultiplied: + case Format_ABGR32: case Format_BGR32: case Format_BGR24: case Format_BGR565: @@ -763,7 +776,7 @@ uchar *QVideoFrame::bits() */ uchar *QVideoFrame::bits(int plane) { - return plane >= 0 && plane < d->planeCount ? d->data[plane] : 0; + return plane >= 0 && plane < d->planeCount ? d->data[plane] : nullptr; } /*! @@ -794,7 +807,7 @@ const uchar *QVideoFrame::bits() const */ const uchar *QVideoFrame::bits(int plane) const { - return plane >= 0 && plane < d->planeCount ? d->data[plane] : 0; + return plane >= 0 && plane < d->planeCount ? d->data[plane] : nullptr; } /*! @@ -832,7 +845,7 @@ int QVideoFrame::planeCount() const */ QVariant QVideoFrame::handle() const { - return d->buffer != 0 ? d->buffer->handle() : QVariant(); + return d->buffer != nullptr ? d->buffer->handle() : QVariant(); } /*! @@ -1035,6 +1048,7 @@ static VideoFrameConvertFunc qConvertFuncs[QVideoFrame::NPixelFormats] = { /* Format_ARGB8565_Premultiplied */ nullptr, // Not needed /* Format_BGRA32 */ qt_convert_BGRA32_to_ARGB32, /* Format_BGRA32_Premultiplied */ qt_convert_BGRA32_to_ARGB32, + /* Format_ABGR32 */ nullptr, /* Format_BGR32 */ qt_convert_BGRA32_to_ARGB32, /* Format_BGR24 */ qt_convert_BGR24_to_ARGB32, /* Format_BGR565 */ qt_convert_BGR565_to_ARGB32, @@ -1102,7 +1116,7 @@ QImage qt_imageFromVideoFrame(const QVideoFrame &f) // Formats supported by QImage don't need conversion QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(frame.pixelFormat()); if (imageFormat != QImage::Format_Invalid) { - result = QImage(frame.bits(), frame.width(), frame.height(), imageFormat).copy(); + result = QImage(frame.bits(), frame.width(), frame.height(), frame.bytesPerLine(), imageFormat).copy(); } // Load from JPG @@ -1157,6 +1171,8 @@ QDebug operator<<(QDebug dbg, QVideoFrame::PixelFormat pf) return dbg << "Format_BGRA32"; case QVideoFrame::Format_BGRA32_Premultiplied: return dbg << "Format_BGRA32_Premultiplied"; + case QVideoFrame::Format_ABGR32: + return dbg << "Format_ABGR32"; case QVideoFrame::Format_BGR32: return dbg << "Format_BGR32"; case QVideoFrame::Format_BGR24: diff --git a/src/multimedia/video/qvideoframe.h b/src/multimedia/video/qvideoframe.h index be7517c7c..375f80dac 100644 --- a/src/multimedia/video/qvideoframe.h +++ b/src/multimedia/video/qvideoframe.h @@ -75,6 +75,7 @@ public: Format_ARGB8565_Premultiplied, Format_BGRA32, Format_BGRA32_Premultiplied, + Format_ABGR32, Format_BGR32, Format_BGR24, Format_BGR565, @@ -119,6 +120,7 @@ public: bool operator==(const QVideoFrame &other) const; bool operator!=(const QVideoFrame &other) const; + QAbstractVideoBuffer *buffer() const; bool isValid() const; PixelFormat pixelFormat() const; diff --git a/src/multimedia/video/qvideooutputorientationhandler_p.h b/src/multimedia/video/qvideooutputorientationhandler_p.h index b5cfc089b..d04a781ab 100644 --- a/src/multimedia/video/qvideooutputorientationhandler_p.h +++ b/src/multimedia/video/qvideooutputorientationhandler_p.h @@ -61,7 +61,7 @@ class Q_MULTIMEDIA_EXPORT QVideoOutputOrientationHandler : public QObject { Q_OBJECT public: - explicit QVideoOutputOrientationHandler(QObject *parent = 0); + explicit QVideoOutputOrientationHandler(QObject *parent = nullptr); int currentOrientation() const; diff --git a/src/multimedia/video/qvideoprobe.cpp b/src/multimedia/video/qvideoprobe.cpp index b1531df63..f7995b297 100644 --- a/src/multimedia/video/qvideoprobe.cpp +++ b/src/multimedia/video/qvideoprobe.cpp @@ -161,7 +161,7 @@ bool QVideoProbe::setSource(QMediaObject *source) } } - return (!source || d->probee != 0); + return (!source || d->probee != nullptr); } /*! @@ -179,7 +179,7 @@ bool QVideoProbe::setSource(QMediaObject *source) */ bool QVideoProbe::setSource(QMediaRecorder *mediaRecorder) { - QMediaObject *source = mediaRecorder ? mediaRecorder->mediaObject() : 0; + QMediaObject *source = mediaRecorder ? mediaRecorder->mediaObject() : nullptr; bool result = setSource(source); if (!mediaRecorder) @@ -198,7 +198,7 @@ bool QVideoProbe::setSource(QMediaRecorder *mediaRecorder) */ bool QVideoProbe::isActive() const { - return d->probee != 0; + return d->probee != nullptr; } /*! diff --git a/src/multimedia/video/qvideosurfaceoutput.cpp b/src/multimedia/video/qvideosurfaceoutput.cpp index feb956dd0..ebc9e1cb6 100644 --- a/src/multimedia/video/qvideosurfaceoutput.cpp +++ b/src/multimedia/video/qvideosurfaceoutput.cpp @@ -55,7 +55,7 @@ QVideoSurfaceOutput::QVideoSurfaceOutput(QObject*parent) QVideoSurfaceOutput::~QVideoSurfaceOutput() { if (m_control) { - m_control.data()->setSurface(0); + m_control.data()->setSurface(nullptr); m_service.data()->releaseControl(m_control.data()); } } @@ -76,7 +76,7 @@ void QVideoSurfaceOutput::setVideoSurface(QAbstractVideoSurface *surface) bool QVideoSurfaceOutput::setMediaObject(QMediaObject *object) { if (m_control) { - m_control.data()->setSurface(0); + m_control.data()->setSurface(nullptr); m_service.data()->releaseControl(m_control.data()); } m_control.clear(); diff --git a/src/multimedia/video/qvideosurfaceoutput_p.h b/src/multimedia/video/qvideosurfaceoutput_p.h index a1b24abbf..5d050bcb0 100644 --- a/src/multimedia/video/qvideosurfaceoutput_p.h +++ b/src/multimedia/video/qvideosurfaceoutput_p.h @@ -67,7 +67,7 @@ class QVideoSurfaceOutput : public QObject, public QMediaBindableInterface Q_OBJECT Q_INTERFACES(QMediaBindableInterface) public: - QVideoSurfaceOutput(QObject*parent = 0); + QVideoSurfaceOutput(QObject *parent = nullptr); ~QVideoSurfaceOutput(); QMediaObject *mediaObject() const override; diff --git a/src/multimediawidgets/qvideowidget.cpp b/src/multimediawidgets/qvideowidget.cpp index ad72eae6a..7d26a8534 100644 --- a/src/multimediawidgets/qvideowidget.cpp +++ b/src/multimediawidgets/qvideowidget.cpp @@ -627,7 +627,7 @@ QVideoWidget::QVideoWidget(QVideoWidgetPrivate &dd, QWidget *parent) d_ptr->q_ptr = this; QPalette palette = QWidget::palette(); - palette.setColor(QPalette::Background, Qt::black); + palette.setColor(QPalette::Window, Qt::black); setPalette(palette); } diff --git a/src/plugins/android/jar/src/org/qtproject/qt5/android/multimedia/QtAndroidMediaPlayer.java b/src/plugins/android/jar/src/org/qtproject/qt5/android/multimedia/QtAndroidMediaPlayer.java index 647cc7fe0..6569a7b8d 100644 --- a/src/plugins/android/jar/src/org/qtproject/qt5/android/multimedia/QtAndroidMediaPlayer.java +++ b/src/plugins/android/jar/src/org/qtproject/qt5/android/multimedia/QtAndroidMediaPlayer.java @@ -46,6 +46,7 @@ import java.io.FileInputStream; // API is level is < 9 unless marked otherwise. import android.content.Context; import android.media.MediaPlayer; +import android.media.AudioAttributes; import android.net.Uri; import android.util.Log; import java.io.FileDescriptor; @@ -65,6 +66,7 @@ public class QtAndroidMediaPlayer native public void onStateChangedNative(int state, long id); private MediaPlayer mMediaPlayer = null; + private AudioAttributes mAudioAttributes = null; private Uri mUri = null; private final long mID; private final Context mContext; @@ -235,6 +237,7 @@ public class QtAndroidMediaPlayer setState(State.Idle); // Make sure the new media player has the volume that was set on the QMediaPlayer setVolumeHelper(mMuted ? 0 : mVolume); + setAudioAttributes(mMediaPlayer, mAudioAttributes); } } @@ -547,4 +550,26 @@ public class QtAndroidMediaPlayer setState(State.Uninitialized); } + + public void setAudioAttributes(int type, int usage) + { + mAudioAttributes = new AudioAttributes.Builder() + .setUsage(usage) + .setContentType(type) + .build(); + + setAudioAttributes(mMediaPlayer, mAudioAttributes); + } + + static private void setAudioAttributes(MediaPlayer player, AudioAttributes attr) + { + if (player == null || attr == null) + return; + + try { + player.setAudioAttributes(attr); + } catch (final IllegalArgumentException e) { + Log.d(TAG, "" + e.getMessage()); + } + } } diff --git a/src/plugins/android/src/common/qandroidvideooutput.cpp b/src/plugins/android/src/common/qandroidvideooutput.cpp index a8351aadb..083ceff24 100644 --- a/src/plugins/android/src/common/qandroidvideooutput.cpp +++ b/src/plugins/android/src/common/qandroidvideooutput.cpp @@ -320,7 +320,7 @@ void QAndroidTextureVideoOutput::onFrameAvailable() return; QAbstractVideoBuffer *buffer = new AndroidTextureVideoBuffer(this, m_nativeSize); - QVideoFrame frame(buffer, m_nativeSize, QVideoFrame::Format_BGR32); + QVideoFrame frame(buffer, m_nativeSize, QVideoFrame::Format_ABGR32); if (m_surface->isActive() && (m_surface->surfaceFormat().pixelFormat() != frame.pixelFormat() || m_surface->surfaceFormat().frameSize() != frame.size())) { diff --git a/src/plugins/android/src/mediaplayer/mediaplayer.pri b/src/plugins/android/src/mediaplayer/mediaplayer.pri index 9f758a993..3a9cef3a1 100644 --- a/src/plugins/android/src/mediaplayer/mediaplayer.pri +++ b/src/plugins/android/src/mediaplayer/mediaplayer.pri @@ -4,10 +4,14 @@ HEADERS += \ $$PWD/qandroidmediaplayercontrol.h \ $$PWD/qandroidmediaservice.h \ $$PWD/qandroidmetadatareadercontrol.h \ + $$PWD/qandroidaudiorolecontrol.h \ + $$PWD/qandroidcustomaudiorolecontrol.h \ $$PWD/qandroidmediaplayervideorenderercontrol.h SOURCES += \ $$PWD/qandroidmediaplayercontrol.cpp \ $$PWD/qandroidmediaservice.cpp \ $$PWD/qandroidmetadatareadercontrol.cpp \ + $$PWD/qandroidaudiorolecontrol.cpp \ + $$PWD/qandroidcustomaudiorolecontrol.cpp \ $$PWD/qandroidmediaplayervideorenderercontrol.cpp diff --git a/src/plugins/android/src/mediaplayer/qandroidaudiorolecontrol.cpp b/src/plugins/android/src/mediaplayer/qandroidaudiorolecontrol.cpp new file mode 100644 index 000000000..5879b0cb9 --- /dev/null +++ b/src/plugins/android/src/mediaplayer/qandroidaudiorolecontrol.cpp @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qandroidaudiorolecontrol.h" + +QT_BEGIN_NAMESPACE + +QAndroidAudioRoleControl::QAndroidAudioRoleControl(QObject *parent) + : QAudioRoleControl(parent) +{ +} + +QAudio::Role QAndroidAudioRoleControl::audioRole() const +{ + return m_role; +} + +void QAndroidAudioRoleControl::setAudioRole(QAudio::Role role) +{ + if (m_role == role) + return; + + m_role = role; + emit audioRoleChanged(m_role); +} + +QList<QAudio::Role> QAndroidAudioRoleControl::supportedAudioRoles() const +{ + return QList<QAudio::Role>() + << QAudio::VoiceCommunicationRole + << QAudio::MusicRole + << QAudio::VideoRole + << QAudio::SonificationRole + << QAudio::AlarmRole + << QAudio::NotificationRole + << QAudio::RingtoneRole + << QAudio::AccessibilityRole + << QAudio::GameRole; +} + +QT_END_NAMESPACE diff --git a/src/plugins/android/src/mediaplayer/qandroidaudiorolecontrol.h b/src/plugins/android/src/mediaplayer/qandroidaudiorolecontrol.h new file mode 100644 index 000000000..89219e026 --- /dev/null +++ b/src/plugins/android/src/mediaplayer/qandroidaudiorolecontrol.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QANDROIDAUDIOROLECONTROL_H +#define QANDROIDAUDIOROLECONTROL_H + +#include <qaudiorolecontrol.h> + +QT_BEGIN_NAMESPACE + +class QAndroidAudioRoleControl : public QAudioRoleControl +{ + Q_OBJECT +public: + explicit QAndroidAudioRoleControl(QObject *parent = nullptr); + + QAudio::Role audioRole() const override; + void setAudioRole(QAudio::Role role) override; + QList<QAudio::Role> supportedAudioRoles() const override; + +private: + QAudio::Role m_role = QAudio::UnknownRole; +}; + +QT_END_NAMESPACE + +#endif // QANDROIDAUDIOROLECONTROL_H diff --git a/src/plugins/android/src/mediaplayer/qandroidcustomaudiorolecontrol.cpp b/src/plugins/android/src/mediaplayer/qandroidcustomaudiorolecontrol.cpp new file mode 100644 index 000000000..cb7b5d0af --- /dev/null +++ b/src/plugins/android/src/mediaplayer/qandroidcustomaudiorolecontrol.cpp @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qandroidcustomaudiorolecontrol.h" + +QT_BEGIN_NAMESPACE + +QAndroidCustomAudioRoleControl::QAndroidCustomAudioRoleControl(QObject *parent) + : QCustomAudioRoleControl(parent) +{ +} + +QString QAndroidCustomAudioRoleControl::customAudioRole() const +{ + return m_role; +} + +void QAndroidCustomAudioRoleControl::setCustomAudioRole(const QString &role) +{ + if (m_role == role) + return; + + m_role = role; + emit customAudioRoleChanged(m_role); +} + +QStringList QAndroidCustomAudioRoleControl::supportedCustomAudioRoles() const +{ + return QStringList() + << "CONTENT_TYPE_MOVIE" + << "CONTENT_TYPE_MUSIC" + << "CONTENT_TYPE_SONIFICATION" + << "CONTENT_TYPE_SPEECH" + << "USAGE_ALARM" + << "USAGE_ASSISTANCE_ACCESSIBILITY" + << "USAGE_ASSISTANCE_NAVIGATION_GUIDANCE" + << "USAGE_ASSISTANCE_SONIFICATION" + << "USAGE_ASSISTANT" + << "USAGE_GAME" + << "USAGE_MEDIA" + << "USAGE_NOTIFICATION" + << "USAGE_NOTIFICATION_COMMUNICATION_DELAYED" + << "USAGE_NOTIFICATION_COMMUNICATION_INSTANT" + << "USAGE_NOTIFICATION_COMMUNICATION_REQUEST" + << "USAGE_NOTIFICATION_EVENT" + << "USAGE_NOTIFICATION_RINGTONE" + << "USAGE_VOICE_COMMUNICATION" + << "USAGE_VOICE_COMMUNICATION_SIGNALLING"; +} + +QT_END_NAMESPACE diff --git a/src/plugins/android/src/mediaplayer/qandroidcustomaudiorolecontrol.h b/src/plugins/android/src/mediaplayer/qandroidcustomaudiorolecontrol.h new file mode 100644 index 000000000..4604ebe67 --- /dev/null +++ b/src/plugins/android/src/mediaplayer/qandroidcustomaudiorolecontrol.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QANDROIDCUSTOMAUDIOROLECONTROL_H +#define QANDROIDCUSTOMAUDIOROLECONTROL_H + +#include <qcustomaudiorolecontrol.h> + +QT_BEGIN_NAMESPACE + +class QAndroidCustomAudioRoleControl : public QCustomAudioRoleControl +{ + Q_OBJECT +public: + explicit QAndroidCustomAudioRoleControl(QObject *parent = nullptr); + + QString customAudioRole() const override; + void setCustomAudioRole(const QString &role) override; + QStringList supportedCustomAudioRoles() const override; + +private: + QString m_role; +}; + +QT_END_NAMESPACE + +#endif // QANDROIDCUSTOMAUDIOROLECONTROL_H diff --git a/src/plugins/android/src/mediaplayer/qandroidmediaplayercontrol.cpp b/src/plugins/android/src/mediaplayer/qandroidmediaplayercontrol.cpp index df1463a87..4bfcce5bc 100644 --- a/src/plugins/android/src/mediaplayer/qandroidmediaplayercontrol.cpp +++ b/src/plugins/android/src/mediaplayer/qandroidmediaplayercontrol.cpp @@ -250,6 +250,16 @@ void QAndroidMediaPlayerControl::setMuted(bool muted) Q_EMIT mutedChanged(muted); } +void QAndroidMediaPlayerControl::setAudioRole(QAudio::Role role) +{ + mMediaPlayer->setAudioRole(role); +} + +void QAndroidMediaPlayerControl::setCustomAudioRole(const QString &role) +{ + mMediaPlayer->setCustomAudioRole(role); +} + int QAndroidMediaPlayerControl::bufferStatus() const { return mBufferFilled ? 100 : 0; diff --git a/src/plugins/android/src/mediaplayer/qandroidmediaplayercontrol.h b/src/plugins/android/src/mediaplayer/qandroidmediaplayercontrol.h index 119add7f8..35f56145f 100644 --- a/src/plugins/android/src/mediaplayer/qandroidmediaplayercontrol.h +++ b/src/plugins/android/src/mediaplayer/qandroidmediaplayercontrol.h @@ -85,6 +85,8 @@ public Q_SLOTS: void stop() override; void setVolume(int volume) override; void setMuted(bool muted) override; + void setAudioRole(QAudio::Role role); + void setCustomAudioRole(const QString &role); private Q_SLOTS: void onVideoOutputReady(bool ready); diff --git a/src/plugins/android/src/mediaplayer/qandroidmediaservice.cpp b/src/plugins/android/src/mediaplayer/qandroidmediaservice.cpp index 2688f3550..c057f530a 100644 --- a/src/plugins/android/src/mediaplayer/qandroidmediaservice.cpp +++ b/src/plugins/android/src/mediaplayer/qandroidmediaservice.cpp @@ -41,16 +41,26 @@ #include "qandroidmediaplayercontrol.h" #include "qandroidmetadatareadercontrol.h" +#include "qandroidaudiorolecontrol.h" +#include "qandroidcustomaudiorolecontrol.h" #include "qandroidmediaplayervideorenderercontrol.h" QT_BEGIN_NAMESPACE QAndroidMediaService::QAndroidMediaService(QObject *parent) : QMediaService(parent) + , mAudioRoleControl(nullptr) + , mCustomAudioRoleControl(nullptr) , mVideoRendererControl(0) { mMediaControl = new QAndroidMediaPlayerControl; mMetadataControl = new QAndroidMetaDataReaderControl; + mAudioRoleControl = new QAndroidAudioRoleControl; + mCustomAudioRoleControl = new QAndroidCustomAudioRoleControl; + connect(mAudioRoleControl, &QAndroidAudioRoleControl::audioRoleChanged, + mMediaControl, &QAndroidMediaPlayerControl::setAudioRole); + connect(mCustomAudioRoleControl, &QAndroidCustomAudioRoleControl::customAudioRoleChanged, + mMediaControl, &QAndroidMediaPlayerControl::setCustomAudioRole); connect(mMediaControl, SIGNAL(mediaChanged(QMediaContent)), mMetadataControl, SLOT(onMediaChanged(QMediaContent))); connect(mMediaControl, SIGNAL(metaDataUpdated()), @@ -60,6 +70,8 @@ QAndroidMediaService::QAndroidMediaService(QObject *parent) QAndroidMediaService::~QAndroidMediaService() { delete mVideoRendererControl; + delete mCustomAudioRoleControl; + delete mAudioRoleControl; delete mMetadataControl; delete mMediaControl; } @@ -72,6 +84,12 @@ QMediaControl *QAndroidMediaService::requestControl(const char *name) if (qstrcmp(name, QMetaDataReaderControl_iid) == 0) return mMetadataControl; + if (qstrcmp(name, QAudioRoleControl_iid) == 0) + return mAudioRoleControl; + + if (qstrcmp(name, QCustomAudioRoleControl_iid) == 0) + return mCustomAudioRoleControl; + if (qstrcmp(name, QVideoRendererControl_iid) == 0) { if (!mVideoRendererControl) { mVideoRendererControl = new QAndroidMediaPlayerVideoRendererControl(mMediaControl); diff --git a/src/plugins/android/src/mediaplayer/qandroidmediaservice.h b/src/plugins/android/src/mediaplayer/qandroidmediaservice.h index f78d05ddd..788c11098 100644 --- a/src/plugins/android/src/mediaplayer/qandroidmediaservice.h +++ b/src/plugins/android/src/mediaplayer/qandroidmediaservice.h @@ -46,6 +46,8 @@ QT_BEGIN_NAMESPACE class QAndroidMediaPlayerControl; class QAndroidMetaDataReaderControl; +class QAndroidAudioRoleControl; +class QAndroidCustomAudioRoleControl; class QAndroidMediaPlayerVideoRendererControl; class QAndroidMediaService : public QMediaService @@ -61,6 +63,8 @@ public: private: QAndroidMediaPlayerControl *mMediaControl; QAndroidMetaDataReaderControl *mMetadataControl; + QAndroidAudioRoleControl *mAudioRoleControl; + QAndroidCustomAudioRoleControl *mCustomAudioRoleControl; QAndroidMediaPlayerVideoRendererControl *mVideoRendererControl; }; diff --git a/src/plugins/android/src/wrappers/jni/androidmediaplayer.cpp b/src/plugins/android/src/wrappers/jni/androidmediaplayer.cpp index b81f98cbd..79685e16f 100644 --- a/src/plugins/android/src/wrappers/jni/androidmediaplayer.cpp +++ b/src/plugins/android/src/wrappers/jni/androidmediaplayer.cpp @@ -223,6 +223,95 @@ void AndroidMediaPlayer::setDisplay(AndroidSurfaceTexture *surfaceTexture) surfaceTexture ? surfaceTexture->surfaceHolder() : 0); } +void AndroidMediaPlayer::setAudioRole(QAudio::Role role) +{ + QString str; + switch (role) { + case QAudio::MusicRole: + str = QLatin1String("CONTENT_TYPE_MUSIC"); + break; + case QAudio::VideoRole: + str = QLatin1String("CONTENT_TYPE_MOVIE"); + break; + case QAudio::VoiceCommunicationRole: + str = QLatin1String("USAGE_VOICE_COMMUNICATION"); + break; + case QAudio::AlarmRole: + str = QLatin1String("USAGE_ALARM"); + break; + case QAudio::NotificationRole: + str = QLatin1String("USAGE_NOTIFICATION"); + break; + case QAudio::RingtoneRole: + str = QLatin1String("USAGE_NOTIFICATION_RINGTONE"); + break; + case QAudio::AccessibilityRole: + str = QLatin1String("USAGE_ASSISTANCE_ACCESSIBILITY"); + break; + case QAudio::SonificationRole: + str = QLatin1String("CONTENT_TYPE_SONIFICATION"); + break; + case QAudio::GameRole: + str = QLatin1String("USAGE_GAME"); + break; + default: + break; + } + + setCustomAudioRole(str); +} + +void AndroidMediaPlayer::setCustomAudioRole(const QString &role) +{ + QStringList roles = role.split(",", QString::SkipEmptyParts); + + int type = 0; // CONTENT_TYPE_UNKNOWN + int usage = 0; // USAGE_UNKNOWN + for (int i = 0; i < qMin(2, roles.size()); ++i) { + auto r = roles[i]; + if (r == QLatin1String("CONTENT_TYPE_MOVIE")) + type = 3; + else if (r == QLatin1String("CONTENT_TYPE_MUSIC")) + type = 2; + else if (r == QLatin1String("CONTENT_TYPE_SONIFICATION")) + type = 4; + else if (r == QLatin1String("CONTENT_TYPE_SPEECH")) + type = 1; + else if (r == QLatin1String("USAGE_ALARM")) + usage = 4; + else if (r == QLatin1String("USAGE_ASSISTANCE_ACCESSIBILITY")) + usage = 11; + else if (r == QLatin1String("USAGE_ASSISTANCE_NAVIGATION_GUIDANCE")) + usage = 12; + else if (r == QLatin1String("USAGE_ASSISTANCE_SONIFICATION")) + usage = 13; + else if (r == QLatin1String("USAGE_ASSISTANT")) + usage = 16; + else if (r == QLatin1String("USAGE_GAME")) + usage = 14; + else if (r == QLatin1String("USAGE_MEDIA")) + usage = 1; + else if (r == QLatin1String("USAGE_NOTIFICATION")) + usage = 5; + else if (r == QLatin1String("USAGE_NOTIFICATION_COMMUNICATION_DELAYED")) + usage = 9; + else if (r == QLatin1String("USAGE_NOTIFICATION_COMMUNICATION_INSTANT")) + usage = 8; + else if (r == QLatin1String("USAGE_NOTIFICATION_COMMUNICATION_REQUEST")) + usage = 7; + else if (r == QLatin1String("USAGE_NOTIFICATION_EVENT")) + usage = 10; + else if (r == QLatin1String("USAGE_NOTIFICATION_RINGTONE")) + usage = 6; + else if (r == QLatin1String("USAGE_VOICE_COMMUNICATION")) + usage = 2; + else if (r == QLatin1String("USAGE_VOICE_COMMUNICATION_SIGNALLING")) + usage = 3; + } + + mMediaPlayer.callMethod<void>("setAudioAttributes", "(II)V", jint(type), jint(usage)); +} + static void onErrorNative(JNIEnv *env, jobject thiz, jint what, jint extra, jlong id) { Q_UNUSED(env); diff --git a/src/plugins/android/src/wrappers/jni/androidmediaplayer.h b/src/plugins/android/src/wrappers/jni/androidmediaplayer.h index a7284bb0c..14cbf49bc 100644 --- a/src/plugins/android/src/wrappers/jni/androidmediaplayer.h +++ b/src/plugins/android/src/wrappers/jni/androidmediaplayer.h @@ -42,6 +42,7 @@ #include <QObject> #include <QtCore/private/qjni_p.h> +#include <QAudio> QT_BEGIN_NAMESPACE @@ -116,6 +117,8 @@ public: void setVolume(int volume); bool setPlaybackRate(qreal rate); void setDisplay(AndroidSurfaceTexture *surfaceTexture); + void setAudioRole(QAudio::Role role); + void setCustomAudioRole(const QString &role); static bool initJNI(JNIEnv *env); diff --git a/src/plugins/android/videonode/qandroidsgvideonodeplugin.cpp b/src/plugins/android/videonode/qandroidsgvideonodeplugin.cpp index e69c9c16e..d70c8100b 100644 --- a/src/plugins/android/videonode/qandroidsgvideonodeplugin.cpp +++ b/src/plugins/android/videonode/qandroidsgvideonodeplugin.cpp @@ -48,7 +48,7 @@ QList<QVideoFrame::PixelFormat> QAndroidSGVideoNodeFactoryPlugin::supportedPixel QList<QVideoFrame::PixelFormat> pixelFormats; if (handleType == QAbstractVideoBuffer::GLTextureHandle) - pixelFormats.append(QVideoFrame::Format_BGR32); + pixelFormats.append(QVideoFrame::Format_ABGR32); return pixelFormats; } diff --git a/src/plugins/avfoundation/camera/avfaudioencodersettingscontrol.h b/src/plugins/avfoundation/camera/avfaudioencodersettingscontrol.h index 4ba987e53..94aa6a8f0 100644 --- a/src/plugins/avfoundation/camera/avfaudioencodersettingscontrol.h +++ b/src/plugins/avfoundation/camera/avfaudioencodersettingscontrol.h @@ -56,7 +56,7 @@ public: QStringList supportedAudioCodecs() const override; QString codecDescription(const QString &codecName) const override; - QList<int> supportedSampleRates(const QAudioEncoderSettings &settings, bool *continuous = 0) const override; + QList<int> supportedSampleRates(const QAudioEncoderSettings &settings, bool *continuous = nullptr) const override; QAudioEncoderSettings audioSettings() const override; void setAudioSettings(const QAudioEncoderSettings &settings) override; diff --git a/src/plugins/avfoundation/camera/avfaudioinputselectorcontrol.h b/src/plugins/avfoundation/camera/avfaudioinputselectorcontrol.h index 80669d242..a902a71f9 100644 --- a/src/plugins/avfoundation/camera/avfaudioinputselectorcontrol.h +++ b/src/plugins/avfoundation/camera/avfaudioinputselectorcontrol.h @@ -54,16 +54,16 @@ class AVFAudioInputSelectorControl : public QAudioInputSelectorControl { Q_OBJECT public: - AVFAudioInputSelectorControl(AVFCameraService *service, QObject *parent = 0); + AVFAudioInputSelectorControl(AVFCameraService *service, QObject *parent = nullptr); ~AVFAudioInputSelectorControl(); - QList<QString> availableInputs() const; - QString inputDescription(const QString &name) const; - QString defaultInput() const; - QString activeInput() const; + QList<QString> availableInputs() const override; + QString inputDescription(const QString &name) const override; + QString defaultInput() const override; + QString activeInput() const override; public Q_SLOTS: - void setActiveInput(const QString &name); + void setActiveInput(const QString &name) override; public: //device changed since the last createCaptureDevice() diff --git a/src/plugins/avfoundation/camera/avfaudioinputselectorcontrol.mm b/src/plugins/avfoundation/camera/avfaudioinputselectorcontrol.mm index b6228290d..de29fd970 100644 --- a/src/plugins/avfoundation/camera/avfaudioinputselectorcontrol.mm +++ b/src/plugins/avfoundation/camera/avfaudioinputselectorcontrol.mm @@ -102,7 +102,7 @@ void AVFAudioInputSelectorControl::setActiveInput(const QString &name) AVCaptureDevice *AVFAudioInputSelectorControl::createCaptureDevice() { m_dirty = false; - AVCaptureDevice *device = 0; + AVCaptureDevice *device = nullptr; if (!m_activeInput.isEmpty()) { device = [AVCaptureDevice deviceWithUniqueID: diff --git a/src/plugins/avfoundation/camera/avfcameracontrol.h b/src/plugins/avfoundation/camera/avfcameracontrol.h index 7489e6cb3..df371e864 100644 --- a/src/plugins/avfoundation/camera/avfcameracontrol.h +++ b/src/plugins/avfoundation/camera/avfcameracontrol.h @@ -53,19 +53,19 @@ class AVFCameraControl : public QCameraControl { Q_OBJECT public: - AVFCameraControl(AVFCameraService *service, QObject *parent = 0); + AVFCameraControl(AVFCameraService *service, QObject *parent = nullptr); ~AVFCameraControl(); - QCamera::State state() const; - void setState(QCamera::State state); + QCamera::State state() const override; + void setState(QCamera::State state) override; - QCamera::Status status() const; + QCamera::Status status() const override; - QCamera::CaptureModes captureMode() const; - void setCaptureMode(QCamera::CaptureModes); - bool isCaptureModeSupported(QCamera::CaptureModes mode) const; + QCamera::CaptureModes captureMode() const override; + void setCaptureMode(QCamera::CaptureModes) override; + bool isCaptureModeSupported(QCamera::CaptureModes mode) const override; - bool canChangeProperty(PropertyChangeType changeType, QCamera::Status status) const; + bool canChangeProperty(PropertyChangeType changeType, QCamera::Status status) const override; private Q_SLOTS: void updateStatus(); diff --git a/src/plugins/avfoundation/camera/avfcameradevicecontrol.h b/src/plugins/avfoundation/camera/avfcameradevicecontrol.h index ac84b1983..0a16c0408 100644 --- a/src/plugins/avfoundation/camera/avfcameradevicecontrol.h +++ b/src/plugins/avfoundation/camera/avfcameradevicecontrol.h @@ -54,19 +54,19 @@ class AVFCameraDeviceControl : public QVideoDeviceSelectorControl { Q_OBJECT public: - AVFCameraDeviceControl(AVFCameraService *service, QObject *parent = 0); + AVFCameraDeviceControl(AVFCameraService *service, QObject *parent = nullptr); ~AVFCameraDeviceControl(); - int deviceCount() const; + int deviceCount() const override; - QString deviceName(int index) const; - QString deviceDescription(int index) const; + QString deviceName(int index) const override; + QString deviceDescription(int index) const override; - int defaultDevice() const; - int selectedDevice() const; + int defaultDevice() const override; + int selectedDevice() const override; public Q_SLOTS: - void setSelectedDevice(int index); + void setSelectedDevice(int index) override; public: //device changed since the last createCaptureDevice() diff --git a/src/plugins/avfoundation/camera/avfcameradevicecontrol.mm b/src/plugins/avfoundation/camera/avfcameradevicecontrol.mm index 87180859a..907373b61 100644 --- a/src/plugins/avfoundation/camera/avfcameradevicecontrol.mm +++ b/src/plugins/avfoundation/camera/avfcameradevicecontrol.mm @@ -105,7 +105,7 @@ void AVFCameraDeviceControl::setSelectedDevice(int index) AVCaptureDevice *AVFCameraDeviceControl::createCaptureDevice() { m_dirty = false; - AVCaptureDevice *device = 0; + AVCaptureDevice *device = nullptr; QString deviceId = deviceName(m_selectedDevice); if (!deviceId.isEmpty()) { diff --git a/src/plugins/avfoundation/camera/avfcameraflashcontrol.mm b/src/plugins/avfoundation/camera/avfcameraflashcontrol.mm index 134c88e68..42303ce17 100644 --- a/src/plugins/avfoundation/camera/avfcameraflashcontrol.mm +++ b/src/plugins/avfoundation/camera/avfcameraflashcontrol.mm @@ -50,7 +50,7 @@ AVFCameraFlashControl::AVFCameraFlashControl(AVFCameraService *service) : m_service(service) - , m_session(0) + , m_session(nullptr) , m_supportedModes(QCameraExposure::FlashOff) , m_flashMode(QCameraExposure::FlashOff) { diff --git a/src/plugins/avfoundation/camera/avfcamerainfocontrol.h b/src/plugins/avfoundation/camera/avfcamerainfocontrol.h index 806a51cbd..c3aa11918 100644 --- a/src/plugins/avfoundation/camera/avfcamerainfocontrol.h +++ b/src/plugins/avfoundation/camera/avfcamerainfocontrol.h @@ -48,10 +48,10 @@ class AVFCameraInfoControl : public QCameraInfoControl { Q_OBJECT public: - explicit AVFCameraInfoControl(QObject *parent = 0); + explicit AVFCameraInfoControl(QObject *parent = nullptr); - QCamera::Position cameraPosition(const QString &deviceName) const; - int cameraOrientation(const QString &deviceName) const; + QCamera::Position cameraPosition(const QString &deviceName) const override; + int cameraOrientation(const QString &deviceName) const override; }; QT_END_NAMESPACE diff --git a/src/plugins/avfoundation/camera/avfcamerametadatacontrol.h b/src/plugins/avfoundation/camera/avfcamerametadatacontrol.h index 1b00043d0..cba29c394 100644 --- a/src/plugins/avfoundation/camera/avfcamerametadatacontrol.h +++ b/src/plugins/avfoundation/camera/avfcamerametadatacontrol.h @@ -50,15 +50,15 @@ class AVFCameraMetaDataControl : public QMetaDataWriterControl { Q_OBJECT public: - AVFCameraMetaDataControl(AVFCameraService *service, QObject *parent=0); + AVFCameraMetaDataControl(AVFCameraService *service, QObject *parent = nullptr); virtual ~AVFCameraMetaDataControl(); - bool isMetaDataAvailable() const; - bool isWritable() const; + bool isMetaDataAvailable() const override; + bool isWritable() const override; - QVariant metaData(const QString &key) const; - void setMetaData(const QString &key, const QVariant &value); - QStringList availableMetaData() const; + QVariant metaData(const QString &key) const override; + void setMetaData(const QString &key, const QVariant &value) override; + QStringList availableMetaData() const override; private: QMap<QString, QVariant> m_tags; diff --git a/src/plugins/avfoundation/camera/avfcamerarenderercontrol.h b/src/plugins/avfoundation/camera/avfcamerarenderercontrol.h index e0966a027..3ef3d07d4 100644 --- a/src/plugins/avfoundation/camera/avfcamerarenderercontrol.h +++ b/src/plugins/avfoundation/camera/avfcamerarenderercontrol.h @@ -58,11 +58,11 @@ class AVFCameraRendererControl : public QVideoRendererControl { Q_OBJECT public: - AVFCameraRendererControl(QObject *parent = 0); + AVFCameraRendererControl(QObject *parent = nullptr); ~AVFCameraRendererControl(); - QAbstractVideoSurface *surface() const; - void setSurface(QAbstractVideoSurface *surface); + QAbstractVideoSurface *surface() const override; + void setSurface(QAbstractVideoSurface *surface) override; void configureAVCaptureSession(AVFCameraSession *cameraSession); void syncHandleViewfinderFrame(const QVideoFrame &frame); diff --git a/src/plugins/avfoundation/camera/avfcamerarenderercontrol.mm b/src/plugins/avfoundation/camera/avfcamerarenderercontrol.mm index e4f234b7e..0359f5d0a 100644 --- a/src/plugins/avfoundation/camera/avfcamerarenderercontrol.mm +++ b/src/plugins/avfoundation/camera/avfcamerarenderercontrol.mm @@ -65,7 +65,7 @@ public: : QAbstractPlanarVideoBuffer(renderer->supportsTextures() && CVPixelBufferGetPixelFormatType(buffer) == kCVPixelFormatType_32BGRA ? GLTextureHandle : NoHandle) - , m_texture(0) + , m_texture(nullptr) , m_renderer(renderer) #endif , m_buffer(buffer) @@ -117,8 +117,8 @@ public: } if (data) { - data[0] = (uchar *)CVPixelBufferGetBaseAddressOfPlane(m_buffer, 0); - data[1] = (uchar *)CVPixelBufferGetBaseAddressOfPlane(m_buffer, 1); + data[0] = static_cast<uchar*>(CVPixelBufferGetBaseAddressOfPlane(m_buffer, 0)); + data[1] = static_cast<uchar*>(CVPixelBufferGetBaseAddressOfPlane(m_buffer, 1)); } m_mode = mode; @@ -140,9 +140,9 @@ public: *bytesPerLine = CVPixelBufferGetBytesPerRow(m_buffer); m_mode = mode; - return (uchar*)CVPixelBufferGetBaseAddress(m_buffer); + return static_cast<uchar*>(CVPixelBufferGetBaseAddress(m_buffer)); } else { - return 0; + return nullptr; } } @@ -163,9 +163,9 @@ public: if (!m_renderer->m_textureCache) { CVReturn err = CVOpenGLESTextureCacheCreate(kCFAllocatorDefault, - NULL, + nullptr, [EAGLContext currentContext], - NULL, + nullptr, &m_renderer->m_textureCache); if (err != kCVReturnSuccess) @@ -178,7 +178,7 @@ public: CVReturn err = CVOpenGLESTextureCacheCreateTextureFromImage(kCFAllocatorDefault, m_renderer->m_textureCache, m_buffer, - NULL, + nullptr, GL_TEXTURE_2D, GL_RGBA, CVPixelBufferGetWidth(m_buffer), @@ -211,10 +211,6 @@ private: @interface AVFCaptureFramesDelegate : NSObject <AVCaptureVideoDataOutputSampleBufferDelegate> -{ -@private - AVFCameraRendererControl *m_renderer; -} - (AVFCaptureFramesDelegate *) initWithRenderer:(AVFCameraRendererControl*)renderer; @@ -225,6 +221,10 @@ private: @end @implementation AVFCaptureFramesDelegate +{ +@private + AVFCameraRendererControl *m_renderer; +} - (AVFCaptureFramesDelegate *) initWithRenderer:(AVFCameraRendererControl*)renderer { @@ -266,11 +266,11 @@ private: AVFCameraRendererControl::AVFCameraRendererControl(QObject *parent) : QVideoRendererControl(parent) - , m_surface(0) + , m_surface(nullptr) , m_supportsTextures(false) , m_needsHorizontalMirroring(false) #ifdef Q_OS_IOS - , m_textureCache(0) + , m_textureCache(nullptr) #endif { m_viewfinderFramesDelegate = [[AVFCaptureFramesDelegate alloc] initWithRenderer:this]; @@ -317,7 +317,7 @@ void AVFCameraRendererControl::configureAVCaptureSession(AVFCameraSession *camer m_videoDataOutput = [[[AVCaptureVideoDataOutput alloc] init] autorelease]; // Configure video output - m_delegateQueue = dispatch_queue_create("vf_queue", NULL); + m_delegateQueue = dispatch_queue_create("vf_queue", nullptr); [m_videoDataOutput setSampleBufferDelegate:m_viewfinderFramesDelegate queue:m_delegateQueue]; diff --git a/src/plugins/avfoundation/camera/avfcameraservice.h b/src/plugins/avfoundation/camera/avfcameraservice.h index 9ce637ee3..2969882b0 100644 --- a/src/plugins/avfoundation/camera/avfcameraservice.h +++ b/src/plugins/avfoundation/camera/avfcameraservice.h @@ -75,7 +75,7 @@ class AVFCameraService : public QMediaService { Q_OBJECT public: - AVFCameraService(QObject *parent = 0); + AVFCameraService(QObject *parent = nullptr); ~AVFCameraService(); QMediaControl* requestControl(const char *name); diff --git a/src/plugins/avfoundation/camera/avfcameraservice.mm b/src/plugins/avfoundation/camera/avfcameraservice.mm index 71ea31e5b..33b4b72aa 100644 --- a/src/plugins/avfoundation/camera/avfcameraservice.mm +++ b/src/plugins/avfoundation/camera/avfcameraservice.mm @@ -74,7 +74,7 @@ QT_USE_NAMESPACE AVFCameraService::AVFCameraService(QObject *parent): QMediaService(parent), - m_videoOutput(0) + m_videoOutput(nullptr) { m_session = new AVFCameraSession(this); m_cameraControl = new AVFCameraControl(this); @@ -93,12 +93,12 @@ AVFCameraService::AVFCameraService(QObject *parent): #endif m_imageCaptureControl = new AVFImageCaptureControl(this); m_cameraFocusControl = new AVFCameraFocusControl(this); - m_cameraExposureControl = 0; + m_cameraExposureControl = nullptr; #ifdef Q_OS_IOS m_cameraExposureControl = new AVFCameraExposureControl(this); #endif - m_cameraZoomControl = 0; + m_cameraZoomControl = nullptr; #ifdef Q_OS_IOS m_cameraZoomControl = new AVFCameraZoomControl(this); #endif @@ -120,9 +120,9 @@ AVFCameraService::~AVFCameraService() #endif if (m_videoOutput) { - m_session->setVideoOutput(0); + m_session->setVideoOutput(nullptr); delete m_videoOutput; - m_videoOutput = 0; + m_videoOutput = nullptr; } //delete controls before session, @@ -199,7 +199,7 @@ QMediaControl *AVFCameraService::requestControl(const char *name) return m_mediaContainerControl; if (qstrcmp(name,QMediaVideoProbeControl_iid) == 0) { - AVFMediaVideoProbeControl *videoProbe = 0; + AVFMediaVideoProbeControl *videoProbe = nullptr; videoProbe = new AVFMediaVideoProbeControl(this); m_session->addProbe(videoProbe); return videoProbe; @@ -220,7 +220,7 @@ QMediaControl *AVFCameraService::requestControl(const char *name) } } - return 0; + return nullptr; } void AVFCameraService::releaseControl(QMediaControl *control) @@ -230,9 +230,9 @@ void AVFCameraService::releaseControl(QMediaControl *control) m_session->removeProbe(videoProbe); delete videoProbe; } else if (m_videoOutput == control) { - m_session->setVideoOutput(0); + m_session->setVideoOutput(nullptr); delete m_videoOutput; - m_videoOutput = 0; + m_videoOutput = nullptr; } } diff --git a/src/plugins/avfoundation/camera/avfcameraserviceplugin.h b/src/plugins/avfoundation/camera/avfcameraserviceplugin.h index aec9767a7..bd5f83249 100644 --- a/src/plugins/avfoundation/camera/avfcameraserviceplugin.h +++ b/src/plugins/avfoundation/camera/avfcameraserviceplugin.h @@ -60,15 +60,15 @@ class AVFServicePlugin : public QMediaServiceProviderPlugin, public: AVFServicePlugin(); - QMediaService* create(QString const& key); - void release(QMediaService *service); + QMediaService* create(QString const &key) override; + void release(QMediaService *service) override; - QByteArray defaultDevice(const QByteArray &service) const; - QList<QByteArray> devices(const QByteArray &service) const; - QString deviceDescription(const QByteArray &service, const QByteArray &device); + QByteArray defaultDevice(const QByteArray &service) const override; + QList<QByteArray> devices(const QByteArray &service) const override; + QString deviceDescription(const QByteArray &service, const QByteArray &device) override; - QCamera::Position cameraPosition(const QByteArray &device) const; - int cameraOrientation(const QByteArray &device) const; + QCamera::Position cameraPosition(const QByteArray &device) const override; + int cameraOrientation(const QByteArray &device) const override; }; QT_END_NAMESPACE diff --git a/src/plugins/avfoundation/camera/avfcameraserviceplugin.mm b/src/plugins/avfoundation/camera/avfcameraserviceplugin.mm index 434d28683..08bd8c9bd 100644 --- a/src/plugins/avfoundation/camera/avfcameraserviceplugin.mm +++ b/src/plugins/avfoundation/camera/avfcameraserviceplugin.mm @@ -59,7 +59,7 @@ QMediaService* AVFServicePlugin::create(QString const& key) else qWarning() << "unsupported key:" << key; - return 0; + return nullptr; } void AVFServicePlugin::release(QMediaService *service) diff --git a/src/plugins/avfoundation/camera/avfcamerasession.h b/src/plugins/avfoundation/camera/avfcamerasession.h index 3f90f1f7f..103ec0e17 100644 --- a/src/plugins/avfoundation/camera/avfcamerasession.h +++ b/src/plugins/avfoundation/camera/avfcamerasession.h @@ -70,7 +70,7 @@ class AVFCameraSession : public QObject { Q_OBJECT public: - AVFCameraSession(AVFCameraService *service, QObject *parent = 0); + AVFCameraSession(AVFCameraService *service, QObject *parent = nullptr); ~AVFCameraSession(); static int defaultCameraIndex(); diff --git a/src/plugins/avfoundation/camera/avfcamerasession.mm b/src/plugins/avfoundation/camera/avfcamerasession.mm index 8e3436d39..8ed627774 100644 --- a/src/plugins/avfoundation/camera/avfcamerasession.mm +++ b/src/plugins/avfoundation/camera/avfcamerasession.mm @@ -64,11 +64,6 @@ int AVFCameraSession::m_defaultCameraIndex; QList<AVFCameraInfo> AVFCameraSession::m_cameraDevices; @interface AVFCameraSessionObserver : NSObject -{ -@private - AVFCameraSession *m_session; - AVCaptureSession *m_captureSession; -} - (AVFCameraSessionObserver *) initWithCameraSession:(AVFCameraSession*)session; - (void) processRuntimeError:(NSNotification *)notification; @@ -78,6 +73,11 @@ QList<AVFCameraInfo> AVFCameraSession::m_cameraDevices; @end @implementation AVFCameraSessionObserver +{ +@private + AVFCameraSession *m_session; + AVCaptureSession *m_captureSession; +} - (AVFCameraSessionObserver *) initWithCameraSession:(AVFCameraSession*)session { @@ -262,7 +262,7 @@ AVCaptureDevice *AVFCameraSession::videoCaptureDevice() const if (m_videoInput) return m_videoInput.device; - return 0; + return nullptr; } QCamera::State AVFCameraSession::state() const @@ -362,7 +362,7 @@ void AVFCameraSession::attachVideoInputDevice() if (m_videoInput) { [m_captureSession removeInput:m_videoInput]; [m_videoInput release]; - m_videoInput = 0; + m_videoInput = nullptr; m_activeCameraInfo = AVFCameraInfo(); } diff --git a/src/plugins/avfoundation/camera/avfcamerautility.h b/src/plugins/avfoundation/camera/avfcamerautility.h index ba1bd3861..370302b1c 100644 --- a/src/plugins/avfoundation/camera/avfcamerautility.h +++ b/src/plugins/avfoundation/camera/avfcamerautility.h @@ -118,7 +118,7 @@ template<> class AVFScopedPointer<dispatch_queue_t> { public: - AVFScopedPointer() : m_queue(0) {} + AVFScopedPointer() : m_queue(nullptr) {} explicit AVFScopedPointer(dispatch_queue_t q) : m_queue(q) {} ~AVFScopedPointer() @@ -138,7 +138,7 @@ public: return m_queue; } - void reset(dispatch_queue_t q = 0) + void reset(dispatch_queue_t q = nullptr) { if (m_queue) dispatch_release(m_queue); @@ -148,7 +148,7 @@ public: private: dispatch_queue_t m_queue; - Q_DISABLE_COPY(AVFScopedPointer); + Q_DISABLE_COPY(AVFScopedPointer) }; typedef QPair<qreal, qreal> AVFPSRange; diff --git a/src/plugins/avfoundation/camera/avfcamerautility.mm b/src/plugins/avfoundation/camera/avfcamerautility.mm index 8a2254c2e..e68fc703b 100644 --- a/src/plugins/avfoundation/camera/avfcamerautility.mm +++ b/src/plugins/avfoundation/camera/avfcamerautility.mm @@ -240,7 +240,7 @@ AVCaptureDeviceFormat *qt_find_best_resolution_match(AVCaptureDevice *captureDev Q_ASSERT(!request.isNull() && request.isValid()); if (!captureDevice.formats || !captureDevice.formats.count) - return 0; + return nullptr; QVector<AVCaptureDeviceFormat *> formats(qt_unique_device_formats(captureDevice, filter)); @@ -254,7 +254,7 @@ AVCaptureDeviceFormat *qt_find_best_resolution_match(AVCaptureDevice *captureDev } if (!qt_area_sane(request)) - return 0; + return nullptr; typedef QPair<QSize, AVCaptureDeviceFormat *> FormatPair; @@ -272,7 +272,7 @@ AVCaptureDeviceFormat *qt_find_best_resolution_match(AVCaptureDevice *captureDev } if (!pairs.size()) - return 0; + return nullptr; AVCaptureDeviceFormat *best = pairs[0].second; QSize next(pairs[0].first); diff --git a/src/plugins/avfoundation/camera/avfcameraviewfindersettingscontrol.mm b/src/plugins/avfoundation/camera/avfcameraviewfindersettingscontrol.mm index 0054a8d01..a77d7de03 100644 --- a/src/plugins/avfoundation/camera/avfcameraviewfindersettingscontrol.mm +++ b/src/plugins/avfoundation/camera/avfcameraviewfindersettingscontrol.mm @@ -167,7 +167,7 @@ QCameraViewfinderSettings AVFCameraViewfinderSettingsControl2::viewfinderSetting settings.setMinimumFrameRate(fps.first); settings.setMaximumFrameRate(fps.second); - AVCaptureVideoDataOutput *videoOutput = m_service->videoOutput() ? m_service->videoOutput()->videoDataOutput() : 0; + AVCaptureVideoDataOutput *videoOutput = m_service->videoOutput() ? m_service->videoOutput()->videoDataOutput() : nullptr; if (videoOutput) { NSObject *obj = [videoOutput.videoSettings objectForKey:(id)kCVPixelBufferPixelFormatTypeKey]; if (obj && [obj isKindOfClass:[NSNumber class]]) { @@ -291,7 +291,7 @@ QVector<QVideoFrame::PixelFormat> AVFCameraViewfinderSettingsControl2::viewfinde { QVector<QVideoFrame::PixelFormat> qtFormats; - AVCaptureVideoDataOutput *videoOutput = m_service->videoOutput() ? m_service->videoOutput()->videoDataOutput() : 0; + AVCaptureVideoDataOutput *videoOutput = m_service->videoOutput() ? m_service->videoOutput()->videoDataOutput() : nullptr; if (!videoOutput) { qDebugCamera() << Q_FUNC_INFO << "no video output found"; return qtFormats; @@ -318,7 +318,7 @@ QVector<QVideoFrame::PixelFormat> AVFCameraViewfinderSettingsControl2::viewfinde bool AVFCameraViewfinderSettingsControl2::convertPixelFormatIfSupported(QVideoFrame::PixelFormat qtFormat, unsigned &avfFormat)const { - AVCaptureVideoDataOutput *videoOutput = m_service->videoOutput() ? m_service->videoOutput()->videoDataOutput() : 0; + AVCaptureVideoDataOutput *videoOutput = m_service->videoOutput() ? m_service->videoOutput()->videoDataOutput() : nullptr; if (!videoOutput) return false; @@ -372,7 +372,7 @@ bool AVFCameraViewfinderSettingsControl2::applySettings(const QCameraViewfinderS // We still can update the pixel format at least. } - AVCaptureVideoDataOutput *videoOutput = m_service->videoOutput() ? m_service->videoOutput()->videoDataOutput() : 0; + AVCaptureVideoDataOutput *videoOutput = m_service->videoOutput() ? m_service->videoOutput()->videoDataOutput() : nullptr; if (videoOutput) { unsigned avfPixelFormat = 0; if (!convertPixelFormatIfSupported(settings.pixelFormat(), avfPixelFormat)) { diff --git a/src/plugins/avfoundation/camera/avfimagecapturecontrol.h b/src/plugins/avfoundation/camera/avfimagecapturecontrol.h index 2cdf0e5f3..314e867e7 100644 --- a/src/plugins/avfoundation/camera/avfimagecapturecontrol.h +++ b/src/plugins/avfoundation/camera/avfimagecapturecontrol.h @@ -60,17 +60,17 @@ public: QSharedPointer<QSemaphore> previewReady; }; - AVFImageCaptureControl(AVFCameraService *service, QObject *parent = 0); + AVFImageCaptureControl(AVFCameraService *service, QObject *parent = nullptr); ~AVFImageCaptureControl(); - bool isReadyForCapture() const; + bool isReadyForCapture() const override; - QCameraImageCapture::DriveMode driveMode() const { return QCameraImageCapture::SingleImageCapture; } - void setDriveMode(QCameraImageCapture::DriveMode ) {} + QCameraImageCapture::DriveMode driveMode() const override { return QCameraImageCapture::SingleImageCapture; } + void setDriveMode(QCameraImageCapture::DriveMode ) override {} AVCaptureStillImageOutput *stillImageOutput() const {return m_stillImageOutput;} - int capture(const QString &fileName); - void cancelCapture(); + int capture(const QString &fileName) override; + void cancelCapture() override; private Q_SLOTS: void updateCaptureConnection(); diff --git a/src/plugins/avfoundation/camera/avfmediaassetwriter.h b/src/plugins/avfoundation/camera/avfmediaassetwriter.h index 624906c85..9d61d5089 100644 --- a/src/plugins/avfoundation/camera/avfmediaassetwriter.h +++ b/src/plugins/avfoundation/camera/avfmediaassetwriter.h @@ -59,37 +59,8 @@ QT_END_NAMESPACE @interface QT_MANGLE_NAMESPACE(AVFMediaAssetWriter) : NSObject<AVCaptureVideoDataOutputSampleBufferDelegate, AVCaptureAudioDataOutputSampleBufferDelegate> { -@private - AVFCameraService *m_service; - - 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; - AVCaptureDevice *m_audioCaptureDevice; - - // Queue to write sample buffers: - QT_PREPEND_NAMESPACE(AVFScopedPointer)<dispatch_queue_t> m_writerQueue; - // High priority serial queue for video output: - QT_PREPEND_NAMESPACE(AVFScopedPointer)<dispatch_queue_t> m_videoQueue; - // Serial queue for audio output: - QT_PREPEND_NAMESPACE(AVFScopedPointer)<dispatch_queue_t> m_audioQueue; - - QT_PREPEND_NAMESPACE(AVFScopedPointer)<AVAssetWriter> m_assetWriter; - - QT_PREPEND_NAMESPACE(AVFMediaRecorderControlIOS) *m_delegate; - - bool m_setStartTime; - - QT_PREPEND_NAMESPACE(QAtomicInt) m_state; @public QT_PREPEND_NAMESPACE(AVFAtomicInt64) m_durationInMs; -@private - CMTime m_startTime; - CMTime m_lastTimeStamp; - - NSDictionary *m_audioSettings; - NSDictionary *m_videoSettings; } - (id)initWithDelegate:(QT_PREPEND_NAMESPACE(AVFMediaRecorderControlIOS) *)delegate; diff --git a/src/plugins/avfoundation/camera/avfmediaassetwriter.mm b/src/plugins/avfoundation/camera/avfmediaassetwriter.mm index 5a1257f6c..318d66117 100644 --- a/src/plugins/avfoundation/camera/avfmediaassetwriter.mm +++ b/src/plugins/avfoundation/camera/avfmediaassetwriter.mm @@ -89,6 +89,37 @@ enum WriterState @end @implementation QT_MANGLE_NAMESPACE(AVFMediaAssetWriter) +{ +@private + AVFCameraService *m_service; + + 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; + AVCaptureDevice *m_audioCaptureDevice; + + // Queue to write sample buffers: + QT_PREPEND_NAMESPACE(AVFScopedPointer)<dispatch_queue_t> m_writerQueue; + // High priority serial queue for video output: + QT_PREPEND_NAMESPACE(AVFScopedPointer)<dispatch_queue_t> m_videoQueue; + // Serial queue for audio output: + QT_PREPEND_NAMESPACE(AVFScopedPointer)<dispatch_queue_t> m_audioQueue; + + QT_PREPEND_NAMESPACE(AVFScopedPointer)<AVAssetWriter> m_assetWriter; + + QT_PREPEND_NAMESPACE(AVFMediaRecorderControlIOS) *m_delegate; + + bool m_setStartTime; + + QT_PREPEND_NAMESPACE(QAtomicInt) m_state; +@private + CMTime m_startTime; + CMTime m_lastTimeStamp; + + NSDictionary *m_audioSettings; + NSDictionary *m_videoSettings; +} - (id)initWithDelegate:(AVFMediaRecorderControlIOS *)delegate { diff --git a/src/plugins/avfoundation/camera/avfmediarecordercontrol.h b/src/plugins/avfoundation/camera/avfmediarecordercontrol.h index a4894b3da..fbba5eca4 100644 --- a/src/plugins/avfoundation/camera/avfmediarecordercontrol.h +++ b/src/plugins/avfoundation/camera/avfmediarecordercontrol.h @@ -60,27 +60,27 @@ class AVFMediaRecorderControl : public QMediaRecorderControl { Q_OBJECT public: - AVFMediaRecorderControl(AVFCameraService *service, QObject *parent = 0); + AVFMediaRecorderControl(AVFCameraService *service, QObject *parent = nullptr); ~AVFMediaRecorderControl(); - QUrl outputLocation() const; - bool setOutputLocation(const QUrl &location); + QUrl outputLocation() const override; + bool setOutputLocation(const QUrl &location) override; - QMediaRecorder::State state() const; - QMediaRecorder::Status status() const; + QMediaRecorder::State state() const override; + QMediaRecorder::Status status() const override; - qint64 duration() const; + qint64 duration() const override; - bool isMuted() const; - qreal volume() const; + bool isMuted() const override; + qreal volume() const override; - void applySettings(); + void applySettings() override; void unapplySettings(); public Q_SLOTS: - void setState(QMediaRecorder::State state); - void setMuted(bool muted); - void setVolume(qreal volume); + void setState(QMediaRecorder::State state) override; + void setMuted(bool muted) override; + void setVolume(qreal volume) override; void handleRecordingStarted(); void handleRecordingFinished(); diff --git a/src/plugins/avfoundation/camera/avfmediarecordercontrol.mm b/src/plugins/avfoundation/camera/avfmediarecordercontrol.mm index 546eabf89..9a6057e6b 100644 --- a/src/plugins/avfoundation/camera/avfmediarecordercontrol.mm +++ b/src/plugins/avfoundation/camera/avfmediarecordercontrol.mm @@ -394,7 +394,7 @@ void AVFMediaRecorderControl::setupSessionForCapture() qWarning() << "Failed to create audio device input"; } else if (![captureSession canAddInput:m_audioInput]) { qWarning() << "Could not connect the audio input"; - m_audioInput = 0; + m_audioInput = nullptr; } else { [m_audioInput retain]; [captureSession addInput:m_audioInput]; diff --git a/src/plugins/avfoundation/camera/avfmediarecordercontrol_ios.h b/src/plugins/avfoundation/camera/avfmediarecordercontrol_ios.h index 8e049a595..9afb1068d 100644 --- a/src/plugins/avfoundation/camera/avfmediarecordercontrol_ios.h +++ b/src/plugins/avfoundation/camera/avfmediarecordercontrol_ios.h @@ -62,8 +62,8 @@ class AVFMediaRecorderControlIOS : public QMediaRecorderControl { Q_OBJECT public: - AVFMediaRecorderControlIOS(AVFCameraService *service, QObject *parent = 0); - ~AVFMediaRecorderControlIOS(); + AVFMediaRecorderControlIOS(AVFCameraService *service, QObject *parent = nullptr); + ~AVFMediaRecorderControlIOS() override; QUrl outputLocation() const override; bool setOutputLocation(const QUrl &location) override; diff --git a/src/plugins/avfoundation/camera/avfmediavideoprobecontrol.h b/src/plugins/avfoundation/camera/avfmediavideoprobecontrol.h index ce9ef4dbe..69a452a97 100644 --- a/src/plugins/avfoundation/camera/avfmediavideoprobecontrol.h +++ b/src/plugins/avfoundation/camera/avfmediavideoprobecontrol.h @@ -48,7 +48,7 @@ class AVFMediaVideoProbeControl : public QMediaVideoProbeControl { Q_OBJECT public: - explicit AVFMediaVideoProbeControl(QObject *parent = 0); + explicit AVFMediaVideoProbeControl(QObject *parent = nullptr); ~AVFMediaVideoProbeControl(); void newFrameProbed(const QVideoFrame& frame); diff --git a/src/plugins/avfoundation/camera/avfvideoencodersettingscontrol.h b/src/plugins/avfoundation/camera/avfvideoencodersettingscontrol.h index 9bdf5a788..7c9574f3d 100644 --- a/src/plugins/avfoundation/camera/avfvideoencodersettingscontrol.h +++ b/src/plugins/avfoundation/camera/avfvideoencodersettingscontrol.h @@ -59,10 +59,10 @@ public: explicit AVFVideoEncoderSettingsControl(AVFCameraService *service); QList<QSize> supportedResolutions(const QVideoEncoderSettings &requestedVideoSettings, - bool *continuous = 0) const override; + bool *continuous = nullptr) const override; QList<qreal> supportedFrameRates(const QVideoEncoderSettings &requestedVideoSettings, - bool *continuous = 0) const override; + bool *continuous = nullptr) const override; QStringList supportedVideoCodecs() const override; QString videoCodecDescription(const QString &codecName) const override; diff --git a/src/plugins/avfoundation/mediaplayer/avfdisplaylink.h b/src/plugins/avfoundation/mediaplayer/avfdisplaylink.h index 45db7aef7..ba0803807 100644 --- a/src/plugins/avfoundation/mediaplayer/avfdisplaylink.h +++ b/src/plugins/avfoundation/mediaplayer/avfdisplaylink.h @@ -55,7 +55,7 @@ class AVFDisplayLink : public QObject { Q_OBJECT public: - explicit AVFDisplayLink(QObject *parent = 0); + explicit AVFDisplayLink(QObject *parent = nullptr); virtual ~AVFDisplayLink(); bool isValid() const; bool isActive() const; @@ -71,7 +71,7 @@ public: void displayLinkEvent(const CVTimeStamp *); protected: - virtual bool event(QEvent *); + virtual bool event(QEvent *) override; private: #if defined(Q_OS_IOS) || defined(Q_OS_TVOS) diff --git a/src/plugins/avfoundation/mediaplayer/avfdisplaylink.mm b/src/plugins/avfoundation/mediaplayer/avfdisplaylink.mm index 63747e486..bae18bc0a 100644 --- a/src/plugins/avfoundation/mediaplayer/avfdisplaylink.mm +++ b/src/plugins/avfoundation/mediaplayer/avfdisplaylink.mm @@ -55,10 +55,6 @@ QT_USE_NAMESPACE #if defined(Q_OS_IOS) || defined(Q_OS_TVOS) @interface DisplayLinkObserver : NSObject -{ - AVFDisplayLink *m_avfDisplayLink; - CADisplayLink *m_displayLink; -} - (void)start; - (void)stop; @@ -67,6 +63,10 @@ QT_USE_NAMESPACE @end @implementation DisplayLinkObserver +{ + AVFDisplayLink *m_avfDisplayLink; + CADisplayLink *m_displayLink; +} - (id)initWithAVFDisplayLink:(AVFDisplayLink *)link { @@ -84,7 +84,7 @@ QT_USE_NAMESPACE { if (m_displayLink) { [m_displayLink release]; - m_displayLink = NULL; + m_displayLink = nullptr; } [super dealloc]; @@ -129,7 +129,7 @@ static CVReturn CVDisplayLinkCallback(CVDisplayLinkRef displayLink, AVFDisplayLink::AVFDisplayLink(QObject *parent) : QObject(parent) - , m_displayLink(0) + , m_displayLink(nullptr) , m_pendingDisplayLinkEvent(false) , m_isActive(false) { @@ -161,13 +161,13 @@ AVFDisplayLink::~AVFDisplayLink() #else CVDisplayLinkRelease(m_displayLink); #endif - m_displayLink = NULL; + m_displayLink = nullptr; } } bool AVFDisplayLink::isValid() const { - return m_displayLink != 0; + return m_displayLink != nullptr; } bool AVFDisplayLink::isActive() const diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayercontrol.h b/src/plugins/avfoundation/mediaplayer/avfmediaplayercontrol.h index a65ee8529..ac0ba0ab2 100644 --- a/src/plugins/avfoundation/mediaplayer/avfmediaplayercontrol.h +++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayercontrol.h @@ -51,44 +51,44 @@ class AVFMediaPlayerControl : public QMediaPlayerControl { Q_OBJECT public: - explicit AVFMediaPlayerControl(QObject *parent = 0); + explicit AVFMediaPlayerControl(QObject *parent = nullptr); ~AVFMediaPlayerControl(); void setSession(AVFMediaPlayerSession *session); - QMediaPlayer::State state() const; - QMediaPlayer::MediaStatus mediaStatus() const; + QMediaPlayer::State state() const override; + QMediaPlayer::MediaStatus mediaStatus() const override; - QMediaContent media() const; - const QIODevice *mediaStream() const; - void setMedia(const QMediaContent &content, QIODevice *stream); + QMediaContent media() const override; + const QIODevice *mediaStream() const override; + void setMedia(const QMediaContent &content, QIODevice *stream) override; - qint64 position() const; - qint64 duration() const; + qint64 position() const override; + qint64 duration() const override; - int bufferStatus() const; + int bufferStatus() const override; - int volume() const; - bool isMuted() const; + int volume() const override; + bool isMuted() const override; - bool isAudioAvailable() const; - bool isVideoAvailable() const; + bool isAudioAvailable() const override; + bool isVideoAvailable() const override; - bool isSeekable() const; - QMediaTimeRange availablePlaybackRanges() const; + bool isSeekable() const override; + QMediaTimeRange availablePlaybackRanges() const override; - qreal playbackRate() const; - void setPlaybackRate(qreal rate); + qreal playbackRate() const override; + void setPlaybackRate(qreal rate) override; public Q_SLOTS: - void setPosition(qint64 pos); + void setPosition(qint64 pos) override; - void play(); - void pause(); - void stop(); + void play() override; + void pause() override; + void stop() override; - void setVolume(int volume); - void setMuted(bool muted); + void setVolume(int volume) override; + void setMuted(bool muted) override; private: AVFMediaPlayerSession *m_session; diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.h b/src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.h index 396550047..ae99c7eda 100644 --- a/src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.h +++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.h @@ -50,14 +50,14 @@ class AVFMediaPlayerMetaDataControl : public QMetaDataReaderControl { Q_OBJECT public: - explicit AVFMediaPlayerMetaDataControl(AVFMediaPlayerSession *session, QObject *parent = 0); + explicit AVFMediaPlayerMetaDataControl(AVFMediaPlayerSession *session, QObject *parent = nullptr); virtual ~AVFMediaPlayerMetaDataControl(); - bool isMetaDataAvailable() const; + bool isMetaDataAvailable() const override; bool isWritable() const; - QVariant metaData(const QString &key) const; - QStringList availableMetaData() const; + QVariant metaData(const QString &key) const override; + QStringList availableMetaData() const override; private Q_SLOTS: void updateTags(); diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.mm index 39783680b..b9ec38c0f 100644 --- a/src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.mm +++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.mm @@ -49,7 +49,7 @@ QT_USE_NAMESPACE AVFMediaPlayerMetaDataControl::AVFMediaPlayerMetaDataControl(AVFMediaPlayerSession *session, QObject *parent) : QMetaDataReaderControl(parent) , m_session(session) - , m_asset(0) + , m_asset(nullptr) { QObject::connect(m_session, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(updateTags())); } @@ -121,7 +121,7 @@ void AVFMediaPlayerMetaDataControl::updateTags() #ifdef QT_DEBUG_AVF qDebug() << Q_FUNC_INFO; #endif - AVAsset *currentAsset = (AVAsset*)m_session->currentAssetHandle(); + AVAsset *currentAsset = static_cast<AVAsset*>(m_session->currentAssetHandle()); //Don't read the tags from the same asset more than once if (currentAsset == m_asset) diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.h b/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.h index 4460a4867..6a4b915cf 100644 --- a/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.h +++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.h @@ -52,11 +52,11 @@ class AVFVideoOutput; class AVFMediaPlayerService : public QMediaService { public: - explicit AVFMediaPlayerService(QObject *parent = 0); + explicit AVFMediaPlayerService(QObject *parent = nullptr); ~AVFMediaPlayerService(); - QMediaControl* requestControl(const char *name); - void releaseControl(QMediaControl *control); + QMediaControl* requestControl(const char *name) override; + void releaseControl(QMediaControl *control) override; private: AVFMediaPlayerSession *m_session; diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.mm index 91def6b3b..bc59fa921 100644 --- a/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.mm +++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.mm @@ -56,7 +56,7 @@ QT_USE_NAMESPACE AVFMediaPlayerService::AVFMediaPlayerService(QObject *parent) : QMediaService(parent) - , m_videoOutput(0) + , m_videoOutput(nullptr) { m_session = new AVFMediaPlayerSession(this); m_control = new AVFMediaPlayerControl(this); @@ -111,7 +111,7 @@ QMediaControl *AVFMediaPlayerService::requestControl(const char *name) m_session->setVideoOutput(qobject_cast<AVFVideoOutput*>(m_videoOutput)); return m_videoOutput; } - return 0; + return nullptr; } void AVFMediaPlayerService::releaseControl(QMediaControl *control) @@ -124,10 +124,10 @@ void AVFMediaPlayerService::releaseControl(QMediaControl *control) AVFVideoRendererControl *renderControl = qobject_cast<AVFVideoRendererControl*>(m_videoOutput); if (renderControl) - renderControl->setSurface(0); + renderControl->setSurface(nullptr); #endif - m_videoOutput = 0; - m_session->setVideoOutput(0); + m_videoOutput = nullptr; + m_session->setVideoOutput(nullptr); delete control; } diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayerserviceplugin.h b/src/plugins/avfoundation/mediaplayer/avfmediaplayerserviceplugin.h index eae9b9a05..e08f0f46e 100644 --- a/src/plugins/avfoundation/mediaplayer/avfmediaplayerserviceplugin.h +++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayerserviceplugin.h @@ -59,12 +59,12 @@ class AVFMediaPlayerServicePlugin public: explicit AVFMediaPlayerServicePlugin(); - QMediaService* create(QString const& key); - void release(QMediaService *service); + QMediaService* create(QString const& key) override; + void release(QMediaService *service) override; - QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const; - QMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const; - QStringList supportedMimeTypes() const; + QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const override; + QMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const override; + QStringList supportedMimeTypes() const override; private: void buildSupportedTypes(); diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayerserviceplugin.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayerserviceplugin.mm index dcdd9efed..59b29a3d2 100644 --- a/src/plugins/avfoundation/mediaplayer/avfmediaplayerserviceplugin.mm +++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayerserviceplugin.mm @@ -60,7 +60,7 @@ QMediaService *AVFMediaPlayerServicePlugin::create(const QString &key) return new AVFMediaPlayerService; qWarning() << "unsupported key: " << key; - return 0; + return nullptr; } void AVFMediaPlayerServicePlugin::release(QMediaService *service) diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h index e20f4a1ec..f6e0ef3bf 100644 --- a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h +++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h @@ -57,7 +57,7 @@ class AVFMediaPlayerSession : public QObject { Q_OBJECT public: - AVFMediaPlayerSession(AVFMediaPlayerService *service, QObject *parent = 0); + AVFMediaPlayerSession(AVFMediaPlayerService *service, QObject *parent = nullptr); virtual ~AVFMediaPlayerSession(); void setVideoOutput(AVFVideoOutput *output); @@ -127,7 +127,7 @@ Q_SIGNALS: private: class ResourceHandler { public: - ResourceHandler():resource(0) {} + ResourceHandler() : resource(nullptr) {} ~ResourceHandler() { clear(); } void setResourceFile(const QString &file) { if (resource) { @@ -138,10 +138,10 @@ private: } resource = new QResource(file); } - bool isValid() const { return resource && resource->isValid() && resource->data() != 0; } + bool isValid() const { return resource && resource->isValid() && resource->data() != nullptr; } const uchar *data() { if (!isValid()) - return 0; + return nullptr; if (resource->isCompressed()) { if (rawData.size() == 0) rawData = qUncompress(resource->data(), resource->size()); @@ -150,7 +150,7 @@ private: return resource->data(); } qint64 size() { - if (data() == 0) + if (data() == nullptr) return 0; return resource->isCompressed() ? rawData.size() : resource->size(); } diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm index 06fb71ef8..2309221c2 100644 --- a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm +++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm @@ -67,15 +67,6 @@ static void *AVFMediaPlayerSessionObserverCurrentItemObservationContext = &AVFMe static void *AVFMediaPlayerSessionObserverCurrentItemDurationObservationContext = &AVFMediaPlayerSessionObserverCurrentItemDurationObservationContext; @interface AVFMediaPlayerSessionObserver : NSObject -{ -@private - AVFMediaPlayerSession *m_session; - AVPlayer *m_player; - AVPlayerItem *m_playerItem; - AVPlayerLayer *m_playerLayer; - NSURL *m_URL; - BOOL m_bufferIsLikelyToKeepUp; -} @property (readonly, getter=player) AVPlayer* m_player; @property (readonly, getter=playerItem) AVPlayerItem* m_playerItem; @@ -96,6 +87,15 @@ static void *AVFMediaPlayerSessionObserverCurrentItemDurationObservationContext @end @implementation AVFMediaPlayerSessionObserver +{ +@private + AVFMediaPlayerSession *m_session; + AVPlayer *m_player; + AVPlayerItem *m_playerItem; + AVPlayerLayer *m_playerLayer; + NSURL *m_URL; + BOOL m_bufferIsLikelyToKeepUp; +} @synthesize m_player, m_playerItem, m_playerLayer, m_session; @@ -339,7 +339,7 @@ static void *AVFMediaPlayerSessionObserverCurrentItemDurationObservationContext case AVPlayerStatusFailed: { - AVPlayerItem *playerItem = (AVPlayerItem *)object; + AVPlayerItem *playerItem = static_cast<AVPlayerItem*>(object); [self assetFailedToPrepareForPlayback:playerItem.error]; if (self.session) @@ -411,10 +411,10 @@ static void *AVFMediaPlayerSessionObserverCurrentItemDurationObservationContext AVFMediaPlayerSession::AVFMediaPlayerSession(AVFMediaPlayerService *service, QObject *parent) : QObject(parent) , m_service(service) - , m_videoOutput(0) + , m_videoOutput(nullptr) , m_state(QMediaPlayer::StoppedState) , m_mediaStatus(QMediaPlayer::NoMedia) - , m_mediaStream(0) + , m_mediaStream(nullptr) , m_muted(false) , m_tryingAsync(false) , m_volume(100) @@ -435,8 +435,8 @@ AVFMediaPlayerSession::~AVFMediaPlayerSession() qDebug() << Q_FUNC_INFO; #endif //Detatch the session from the sessionObserver (which could still be alive trying to communicate with this session). - [(AVFMediaPlayerSessionObserver*)m_observer detatchSession]; - [(AVFMediaPlayerSessionObserver*)m_observer release]; + [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) detatchSession]; + [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) release]; } void AVFMediaPlayerSession::setVideoOutput(AVFVideoOutput *output) @@ -450,13 +450,13 @@ void AVFMediaPlayerSession::setVideoOutput(AVFVideoOutput *output) //Set the current output layer to null to stop rendering if (m_videoOutput) { - m_videoOutput->setLayer(0); + m_videoOutput->setLayer(nullptr); } m_videoOutput = output; if (m_videoOutput && m_state != QMediaPlayer::StoppedState) - m_videoOutput->setLayer([(AVFMediaPlayerSessionObserver*)m_observer playerLayer]); + m_videoOutput->setLayer([static_cast<AVFMediaPlayerSessionObserver*>(m_observer) playerLayer]); } void *AVFMediaPlayerSession::currentAssetHandle() @@ -464,7 +464,7 @@ void *AVFMediaPlayerSession::currentAssetHandle() #ifdef QT_DEBUG_AVF qDebug() << Q_FUNC_INFO; #endif - AVAsset *currentAsset = [[(AVFMediaPlayerSessionObserver*)m_observer playerItem] asset]; + AVAsset *currentAsset = [[static_cast<AVFMediaPlayerSessionObserver*>(m_observer) playerItem] asset]; return currentAsset; } @@ -494,7 +494,7 @@ void AVFMediaPlayerSession::setMedia(const QMediaContent &content, QIODevice *st qDebug() << Q_FUNC_INFO << content.canonicalUrl(); #endif - [(AVFMediaPlayerSessionObserver*)m_observer unloadMedia]; + [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) unloadMedia]; m_resources = content; m_mediaStream = stream; @@ -528,7 +528,7 @@ void AVFMediaPlayerSession::setMedia(const QMediaContent &content, QIODevice *st //initialize asset using content's URL NSString *urlString = [NSString stringWithUTF8String:content.canonicalUrl().toEncoded().constData()]; NSURL *url = [NSURL URLWithString:urlString]; - [(AVFMediaPlayerSessionObserver*)m_observer setURL:url]; + [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) setURL:url]; m_state = QMediaPlayer::StoppedState; if (m_state != oldState) @@ -537,7 +537,7 @@ void AVFMediaPlayerSession::setMedia(const QMediaContent &content, QIODevice *st qint64 AVFMediaPlayerSession::position() const { - AVPlayerItem *playerItem = [(AVFMediaPlayerSessionObserver*)m_observer playerItem]; + AVPlayerItem *playerItem = [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) playerItem]; if (!playerItem) return m_requestedPosition != -1 ? m_requestedPosition : 0; @@ -616,7 +616,7 @@ void AVFMediaPlayerSession::setSeekable(bool seekable) QMediaTimeRange AVFMediaPlayerSession::availablePlaybackRanges() const { - AVPlayerItem *playerItem = [(AVFMediaPlayerSessionObserver*)m_observer playerItem]; + AVPlayerItem *playerItem = [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) playerItem]; if (playerItem) { QMediaTimeRange timeRanges; @@ -649,7 +649,7 @@ void AVFMediaPlayerSession::setPlaybackRate(qreal rate) m_rate = rate; - AVPlayer *player = [(AVFMediaPlayerSessionObserver*)m_observer player]; + AVPlayer *player = [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) player]; if (player && m_state == QMediaPlayer::PlayingState) [player setRate:m_rate]; @@ -665,7 +665,7 @@ void AVFMediaPlayerSession::setPosition(qint64 pos) if (pos == position()) return; - AVPlayerItem *playerItem = [(AVFMediaPlayerSessionObserver*)m_observer playerItem]; + AVPlayerItem *playerItem = [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) playerItem]; if (!playerItem) { m_requestedPosition = pos; Q_EMIT positionChanged(m_requestedPosition); @@ -711,7 +711,7 @@ void AVFMediaPlayerSession::play() return; if (m_videoOutput) { - m_videoOutput->setLayer([(AVFMediaPlayerSessionObserver*)m_observer playerLayer]); + m_videoOutput->setLayer([static_cast<AVFMediaPlayerSessionObserver*>(m_observer) playerLayer]); } // Reset media status if the current status is EndOfMedia @@ -720,7 +720,7 @@ void AVFMediaPlayerSession::play() if (m_mediaStatus == QMediaPlayer::LoadedMedia || m_mediaStatus == QMediaPlayer::BufferedMedia) { // Setting the rate starts playback - [[(AVFMediaPlayerSessionObserver*)m_observer player] setRate:m_rate]; + [[static_cast<AVFMediaPlayerSessionObserver*>(m_observer) player] setRate:m_rate]; } m_state = QMediaPlayer::PlayingState; @@ -744,10 +744,10 @@ void AVFMediaPlayerSession::pause() m_state = QMediaPlayer::PausedState; if (m_videoOutput) { - m_videoOutput->setLayer([(AVFMediaPlayerSessionObserver*)m_observer playerLayer]); + m_videoOutput->setLayer([static_cast<AVFMediaPlayerSessionObserver*>(m_observer) playerLayer]); } - [[(AVFMediaPlayerSessionObserver*)m_observer player] pause]; + [[static_cast<AVFMediaPlayerSessionObserver*>(m_observer) player] pause]; // Reset media status if the current status is EndOfMedia if (m_mediaStatus == QMediaPlayer::EndOfMedia) @@ -767,11 +767,11 @@ void AVFMediaPlayerSession::stop() return; // AVPlayer doesn't have stop(), only pause() and play(). - [[(AVFMediaPlayerSessionObserver*)m_observer player] pause]; + [[static_cast<AVFMediaPlayerSessionObserver*>(m_observer) player] pause]; setPosition(0); if (m_videoOutput) { - m_videoOutput->setLayer(0); + m_videoOutput->setLayer(nullptr); } if (m_mediaStatus == QMediaPlayer::BufferedMedia) @@ -792,7 +792,7 @@ void AVFMediaPlayerSession::setVolume(int volume) m_volume = volume; - AVPlayer *player = [(AVFMediaPlayerSessionObserver*)m_observer player]; + AVPlayer *player = [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) player]; if (player) [player setVolume:volume / 100.0f]; @@ -810,7 +810,7 @@ void AVFMediaPlayerSession::setMuted(bool muted) m_muted = muted; - AVPlayer *player = [(AVFMediaPlayerSessionObserver*)m_observer player]; + AVPlayer *player = [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) player]; if (player) [player setMuted:muted]; @@ -832,14 +832,14 @@ void AVFMediaPlayerSession::processEOS() // At this point, frames should not be rendered anymore. // Clear the output layer to make sure of that. if (m_videoOutput) - m_videoOutput->setLayer(0); + m_videoOutput->setLayer(nullptr); Q_EMIT stateChanged(m_state); } void AVFMediaPlayerSession::processLoadStateChange(QMediaPlayer::State newState) { - AVPlayerStatus currentStatus = [[(AVFMediaPlayerSessionObserver*)m_observer player] status]; + AVPlayerStatus currentStatus = [[static_cast<AVFMediaPlayerSessionObserver*>(m_observer) player] status]; #ifdef QT_DEBUG_AVF qDebug() << Q_FUNC_INFO << currentStatus << ", " << m_mediaStatus << ", " << newState; @@ -852,7 +852,7 @@ void AVFMediaPlayerSession::processLoadStateChange(QMediaPlayer::State newState) QMediaPlayer::MediaStatus newStatus = m_mediaStatus; - AVPlayerItem *playerItem = [(AVFMediaPlayerSessionObserver*)m_observer playerItem]; + AVPlayerItem *playerItem = [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) playerItem]; if (playerItem) { // Check each track for audio and video content @@ -874,7 +874,7 @@ void AVFMediaPlayerSession::processLoadStateChange(QMediaPlayer::State newState) setSeekable([[playerItem seekableTimeRanges] count] > 0); // Get the native size of the video, and reset the bounds of the player layer - AVPlayerLayer *playerLayer = [(AVFMediaPlayerSessionObserver*)m_observer playerLayer]; + AVPlayerLayer *playerLayer = [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) playerLayer]; if (videoTrack && playerLayer) { playerLayer.bounds = CGRectMake(0.0f, 0.0f, videoTrack.naturalSize.width, @@ -899,9 +899,9 @@ void AVFMediaPlayerSession::processLoadStateChange(QMediaPlayer::State newState) } - if (newState == QMediaPlayer::PlayingState && [(AVFMediaPlayerSessionObserver*)m_observer player]) { + if (newState == QMediaPlayer::PlayingState && [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) player]) { // Setting the rate is enough to start playback, no need to call play() - [[(AVFMediaPlayerSessionObserver*)m_observer player] setRate:m_rate]; + [[static_cast<AVFMediaPlayerSessionObserver*>(m_observer) player] setRate:m_rate]; } } diff --git a/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.h b/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.h index 054bce166..99b6bb0b5 100644 --- a/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.h +++ b/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.h @@ -58,7 +58,7 @@ class QAbstractVideoSurface; class AVFVideoFrameRenderer : public QObject { public: - AVFVideoFrameRenderer(QAbstractVideoSurface *surface, QObject *parent = 0); + AVFVideoFrameRenderer(QAbstractVideoSurface *surface, QObject *parent = nullptr); virtual ~AVFVideoFrameRenderer(); diff --git a/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm b/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm index 0759702e8..b2c6638cc 100644 --- a/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm +++ b/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm @@ -54,15 +54,15 @@ QT_USE_NAMESPACE AVFVideoFrameRenderer::AVFVideoFrameRenderer(QAbstractVideoSurface *surface, QObject *parent) : QObject(parent) - , m_videoLayerRenderer(0) + , m_videoLayerRenderer(nullptr) , m_surface(surface) - , m_offscreenSurface(0) - , m_glContext(0) + , m_offscreenSurface(nullptr) + , m_glContext(nullptr) , m_currentBuffer(1) , m_isContextShared(true) { - m_fbo[0] = 0; - m_fbo[1] = 0; + m_fbo[0] = nullptr; + m_fbo[1] = nullptr; } AVFVideoFrameRenderer::~AVFVideoFrameRenderer() @@ -155,7 +155,7 @@ QOpenGLFramebufferObject *AVFVideoFrameRenderer::initRenderer(AVPlayerLayer *lay } if (!m_glContext->create()) { qWarning("failed to create QOpenGLContext"); - return 0; + return nullptr; } } diff --git a/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer_ios.h b/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer_ios.h index 3def186ef..d9f6baa7e 100644 --- a/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer_ios.h +++ b/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer_ios.h @@ -86,7 +86,7 @@ typedef CVOpenGLTextureRef CVOGLTextureRef; class AVFVideoFrameRenderer : public QObject { public: - AVFVideoFrameRenderer(QAbstractVideoSurface *surface, QObject *parent = 0); + AVFVideoFrameRenderer(QAbstractVideoSurface *surface, QObject *parent = nullptr); virtual ~AVFVideoFrameRenderer(); diff --git a/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer_ios.mm b/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer_ios.mm index f84718c55..70e402e6c 100644 --- a/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer_ios.mm +++ b/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer_ios.mm @@ -54,11 +54,11 @@ QT_USE_NAMESPACE AVFVideoFrameRenderer::AVFVideoFrameRenderer(QAbstractVideoSurface *surface, QObject *parent) : QObject(parent) - , m_glContext(0) - , m_offscreenSurface(0) + , m_glContext(nullptr) + , m_offscreenSurface(nullptr) , m_surface(surface) - , m_textureCache(0) - , m_videoOutput(0) + , m_textureCache(nullptr) + , m_videoOutput(nullptr) , m_isContextShared(true) { } @@ -81,7 +81,7 @@ void AVFVideoFrameRenderer::setPlayerLayer(AVPlayerLayer *layer) Q_UNUSED(layer) if (m_videoOutput) { [m_videoOutput release]; - m_videoOutput = 0; + m_videoOutput = nullptr; // will be re-created in first call to copyPixelBufferFromLayer } } @@ -92,7 +92,7 @@ CVOGLTextureRef AVFVideoFrameRenderer::renderLayerToTexture(AVPlayerLayer *layer // If the glContext isn't shared, it doesn't make sense to return a texture for us if (!m_isContextShared) - return 0; + return nullptr; size_t dummyWidth = 0, dummyHeight = 0; return createCacheTextureFromLayer(layer, dummyWidth, dummyHeight); @@ -111,7 +111,7 @@ CVPixelBufferRef AVFVideoFrameRenderer::copyPixelBufferFromLayer(AVPlayerLayer * #ifdef QT_DEBUG_AVF qWarning("copyPixelBufferFromLayer: invalid layer"); #endif - return 0; + return nullptr; } if (!m_videoOutput) { @@ -125,7 +125,7 @@ CVPixelBufferRef AVFVideoFrameRenderer::copyPixelBufferFromLayer(AVPlayerLayer * CMTime currentCMFrameTime = [m_videoOutput itemTimeForHostTime:currentCAFrameTime]; // happens when buffering / loading if (CMTimeCompare(currentCMFrameTime, kCMTimeZero) < 0) { - return 0; + return nullptr; } CVPixelBufferRef pixelBuffer = [m_videoOutput copyPixelBufferForItemTime:currentCMFrameTime @@ -135,7 +135,7 @@ CVPixelBufferRef AVFVideoFrameRenderer::copyPixelBufferFromLayer(AVPlayerLayer * qWarning("copyPixelBufferForItemTime returned nil"); CMTimeShow(currentCMFrameTime); #endif - return 0; + return nullptr; } width = CVPixelBufferGetWidth(pixelBuffer); @@ -149,12 +149,12 @@ CVOGLTextureRef AVFVideoFrameRenderer::createCacheTextureFromLayer(AVPlayerLayer CVPixelBufferRef pixelBuffer = copyPixelBufferFromLayer(layer, width, height); if (!pixelBuffer) - return 0; + return nullptr; CVOGLTextureCacheFlush(m_textureCache, 0); - CVOGLTextureRef texture = 0; - CVReturn err = CVOGLTextureCacheCreateTextureFromImage(kCFAllocatorDefault, m_textureCache, pixelBuffer, NULL, + CVOGLTextureRef texture = nullptr; + CVReturn err = CVOGLTextureCacheCreateTextureFromImage(kCFAllocatorDefault, m_textureCache, pixelBuffer, nullptr, GL_TEXTURE_2D, GL_RGBA, (GLsizei) width, (GLsizei) height, GL_BGRA, GL_UNSIGNED_BYTE, 0, @@ -214,7 +214,7 @@ void AVFVideoFrameRenderer::initRenderer() //Make sure we have an OpenGL context to make current if (!m_glContext) { //Create OpenGL context and set share context from surface - QOpenGLContext *shareContext = 0; + QOpenGLContext *shareContext = nullptr; if (m_surface) { shareContext = qobject_cast<QOpenGLContext*>(m_surface->property("GLContext").value<QObject*>()); } @@ -248,9 +248,9 @@ void AVFVideoFrameRenderer::initRenderer() if (!m_textureCache) { // Create a new open gl texture cache - CVReturn err = CVOGLTextureCacheCreate(kCFAllocatorDefault, NULL, + CVReturn err = CVOGLTextureCacheCreate(kCFAllocatorDefault, nullptr, [EAGLContext currentContext], - NULL, &m_textureCache); + nullptr, &m_textureCache); if (err) { #ifdef QT_DEBUG_AVF qWarning("Error at CVOGLTextureCacheCreate %d", err); diff --git a/src/plugins/avfoundation/mediaplayer/avfvideorenderercontrol.h b/src/plugins/avfoundation/mediaplayer/avfvideorenderercontrol.h index 26032f0be..85dc19d31 100644 --- a/src/plugins/avfoundation/mediaplayer/avfvideorenderercontrol.h +++ b/src/plugins/avfoundation/mediaplayer/avfvideorenderercontrol.h @@ -58,13 +58,13 @@ class AVFVideoRendererControl : public QVideoRendererControl, public AVFVideoOut Q_OBJECT Q_INTERFACES(AVFVideoOutput) public: - explicit AVFVideoRendererControl(QObject *parent = 0); + explicit AVFVideoRendererControl(QObject *parent = nullptr); virtual ~AVFVideoRendererControl(); - QAbstractVideoSurface *surface() const; - void setSurface(QAbstractVideoSurface *surface); + QAbstractVideoSurface *surface() const override; + void setSurface(QAbstractVideoSurface *surface) override; - void setLayer(void *playerLayer); + void setLayer(void *playerLayer) override; private Q_SLOTS: void updateVideoFrame(const CVTimeStamp &ts); diff --git a/src/plugins/avfoundation/mediaplayer/avfvideorenderercontrol.mm b/src/plugins/avfoundation/mediaplayer/avfvideorenderercontrol.mm index e40b7eb17..5f468e532 100644 --- a/src/plugins/avfoundation/mediaplayer/avfvideorenderercontrol.mm +++ b/src/plugins/avfoundation/mediaplayer/avfvideorenderercontrol.mm @@ -75,7 +75,7 @@ public: } MapMode mapMode() const { return NotMapped; } - uchar *map(MapMode, int*, int*) { return 0; } + uchar *map(MapMode, int*, int*) { return nullptr; } void unmap() {} QVariant handle() const @@ -116,9 +116,9 @@ private: AVFVideoRendererControl::AVFVideoRendererControl(QObject *parent) : QVideoRendererControl(parent) - , m_surface(0) - , m_playerLayer(0) - , m_frameRenderer(0) + , m_surface(nullptr) + , m_playerLayer(nullptr) + , m_frameRenderer(nullptr) , m_enableOpenGL(false) { @@ -132,7 +132,7 @@ AVFVideoRendererControl::~AVFVideoRendererControl() qDebug() << Q_FUNC_INFO; #endif m_displayLink->stop(); - [(AVPlayerLayer*)m_playerLayer release]; + [static_cast<AVPlayerLayer*>(m_playerLayer) release]; } QAbstractVideoSurface *AVFVideoRendererControl::surface() const @@ -160,10 +160,10 @@ void AVFVideoRendererControl::setSurface(QAbstractVideoSurface *surface) //If the surface changed, then the current frame renderer is no longer valid delete m_frameRenderer; - m_frameRenderer = 0; + m_frameRenderer = nullptr; //If there is now no surface to render too - if (m_surface == 0) { + if (m_surface == nullptr) { m_displayLink->stop(); return; } @@ -191,8 +191,8 @@ void AVFVideoRendererControl::setLayer(void *playerLayer) if (m_playerLayer == playerLayer) return; - [(AVPlayerLayer*)playerLayer retain]; - [(AVPlayerLayer*)m_playerLayer release]; + [static_cast<AVPlayerLayer*>(playerLayer) retain]; + [static_cast<AVPlayerLayer*>(playerLayer) release]; m_playerLayer = playerLayer; @@ -208,7 +208,7 @@ void AVFVideoRendererControl::setLayer(void *playerLayer) #endif //If there is no layer to render, stop scheduling updates - if (m_playerLayer == 0) { + if (m_playerLayer == nullptr) { m_displayLink->stop(); return; } @@ -225,7 +225,7 @@ void AVFVideoRendererControl::updateVideoFrame(const CVTimeStamp &ts) { Q_UNUSED(ts) - AVPlayerLayer *playerLayer = (AVPlayerLayer*)m_playerLayer; + AVPlayerLayer *playerLayer = static_cast<AVPlayerLayer*>(playerLayer); if (!playerLayer) { qWarning("updateVideoFrame called without AVPlayerLayer (which shouldn't happen"); @@ -240,7 +240,7 @@ void AVFVideoRendererControl::updateVideoFrame(const CVTimeStamp &ts) CVOGLTextureRef tex = m_frameRenderer->renderLayerToTexture(playerLayer); //Make sure we got a valid texture - if (tex == 0) + if (tex == nullptr) return; QAbstractVideoBuffer *buffer = new TextureCacheVideoBuffer(tex); @@ -305,7 +305,7 @@ void AVFVideoRendererControl::updateVideoFrame(const CVTimeStamp &ts) void AVFVideoRendererControl::setupVideoOutput() { - AVPlayerLayer *playerLayer = (AVPlayerLayer*)m_playerLayer; + AVPlayerLayer *playerLayer = static_cast<AVPlayerLayer*>(playerLayer); if (playerLayer) m_nativeSize = QSize(playerLayer.bounds.size.width, playerLayer.bounds.size.height); } diff --git a/src/plugins/avfoundation/mediaplayer/avfvideowidget.h b/src/plugins/avfoundation/mediaplayer/avfvideowidget.h index be6f16e64..faf71f1a4 100644 --- a/src/plugins/avfoundation/mediaplayer/avfvideowidget.h +++ b/src/plugins/avfoundation/mediaplayer/avfvideowidget.h @@ -57,14 +57,14 @@ public: AVFVideoWidget(QWidget *parent); virtual ~AVFVideoWidget(); - QSize sizeHint() const; + QSize sizeHint() const override; Qt::AspectRatioMode aspectRatioMode() const; void setAspectRatioMode(Qt::AspectRatioMode mode); void setPlayerLayer(AVPlayerLayer *layer); protected: - void resizeEvent(QResizeEvent *); - void paintEvent(QPaintEvent *); + void resizeEvent(QResizeEvent *) override; + void paintEvent(QPaintEvent *) override; private: void updateAspectRatio(); diff --git a/src/plugins/avfoundation/mediaplayer/avfvideowidget.mm b/src/plugins/avfoundation/mediaplayer/avfvideowidget.mm index 7eb5a71cf..be349710c 100644 --- a/src/plugins/avfoundation/mediaplayer/avfvideowidget.mm +++ b/src/plugins/avfoundation/mediaplayer/avfvideowidget.mm @@ -56,8 +56,8 @@ QT_USE_NAMESPACE AVFVideoWidget::AVFVideoWidget(QWidget *parent) : QWidget(parent) , m_aspectRatioMode(Qt::KeepAspectRatio) - , m_playerLayer(0) - , m_nativeView(0) + , m_playerLayer(nullptr) + , m_nativeView(nullptr) { setAutoFillBackground(false); } diff --git a/src/plugins/avfoundation/mediaplayer/avfvideowidgetcontrol.h b/src/plugins/avfoundation/mediaplayer/avfvideowidgetcontrol.h index f442d666a..22379d273 100644 --- a/src/plugins/avfoundation/mediaplayer/avfvideowidgetcontrol.h +++ b/src/plugins/avfoundation/mediaplayer/avfvideowidgetcontrol.h @@ -54,30 +54,30 @@ class AVFVideoWidgetControl : public QVideoWidgetControl, public AVFVideoOutput Q_OBJECT Q_INTERFACES(AVFVideoOutput) public: - AVFVideoWidgetControl(QObject *parent = 0); + AVFVideoWidgetControl(QObject *parent = nullptr); virtual ~AVFVideoWidgetControl(); - void setLayer(void *playerLayer); + void setLayer(void *playerLayer) override; - QWidget *videoWidget(); + QWidget *videoWidget() override; - bool isFullScreen() const; - void setFullScreen(bool fullScreen); + bool isFullScreen() const override; + void setFullScreen(bool fullScreen) override; - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode mode); + Qt::AspectRatioMode aspectRatioMode() const override; + void setAspectRatioMode(Qt::AspectRatioMode mode) override; - int brightness() const; - void setBrightness(int brightness); + int brightness() const override; + void setBrightness(int brightness) override; - int contrast() const; - void setContrast(int contrast); + int contrast() const override; + void setContrast(int contrast) override; - int hue() const; - void setHue(int hue); + int hue() const override; + void setHue(int hue) override; - int saturation() const; - void setSaturation(int saturation); + int saturation() const override; + void setSaturation(int saturation) override; private: AVFVideoWidget *m_videoWidget; diff --git a/src/plugins/avfoundation/mediaplayer/avfvideowidgetcontrol.mm b/src/plugins/avfoundation/mediaplayer/avfvideowidgetcontrol.mm index 287dd3add..91ece817e 100644 --- a/src/plugins/avfoundation/mediaplayer/avfvideowidgetcontrol.mm +++ b/src/plugins/avfoundation/mediaplayer/avfvideowidgetcontrol.mm @@ -56,7 +56,7 @@ AVFVideoWidgetControl::AVFVideoWidgetControl(QObject *parent) , m_hue(0) , m_saturation(0) { - m_videoWidget = new AVFVideoWidget(0); + m_videoWidget = new AVFVideoWidget(nullptr); } AVFVideoWidgetControl::~AVFVideoWidgetControl() @@ -73,7 +73,7 @@ void AVFVideoWidgetControl::setLayer(void *playerLayer) qDebug() << Q_FUNC_INFO << playerLayer; #endif - m_videoWidget->setPlayerLayer((AVPlayerLayer*)playerLayer); + m_videoWidget->setPlayerLayer(static_cast<AVPlayerLayer*>(playerLayer)); } diff --git a/src/plugins/avfoundation/mediaplayer/avfvideowindowcontrol.h b/src/plugins/avfoundation/mediaplayer/avfvideowindowcontrol.h index 18bf3fa71..763656c6c 100644 --- a/src/plugins/avfoundation/mediaplayer/avfvideowindowcontrol.h +++ b/src/plugins/avfoundation/mediaplayer/avfvideowindowcontrol.h @@ -61,40 +61,40 @@ class AVFVideoWindowControl : public QVideoWindowControl, public AVFVideoOutput Q_INTERFACES(AVFVideoOutput) public: - AVFVideoWindowControl(QObject *parent = 0); + AVFVideoWindowControl(QObject *parent = nullptr); virtual ~AVFVideoWindowControl(); // QVideoWindowControl interface public: - WId winId() const; - void setWinId(WId id); + WId winId() const override; + void setWinId(WId id) override; - QRect displayRect() const; - void setDisplayRect(const QRect &rect); + QRect displayRect() const override; + void setDisplayRect(const QRect &rect) override; - bool isFullScreen() const; - void setFullScreen(bool fullScreen); + bool isFullScreen() const override; + void setFullScreen(bool fullScreen) override; - void repaint(); - QSize nativeSize() const; + void repaint() override; + QSize nativeSize() const override; - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode mode); + Qt::AspectRatioMode aspectRatioMode() const override; + void setAspectRatioMode(Qt::AspectRatioMode mode) override; - int brightness() const; - void setBrightness(int brightness); + int brightness() const override; + void setBrightness(int brightness) override; - int contrast() const; - void setContrast(int contrast); + int contrast() const override; + void setContrast(int contrast) override; - int hue() const; - void setHue(int hue); + int hue() const override; + void setHue(int hue) override; - int saturation() const; - void setSaturation(int saturation); + int saturation() const override; + void setSaturation(int saturation) override; // AVFVideoOutput interface - void setLayer(void *playerLayer); + void setLayer(void *playerLayer) override; private: void updateAspectRatio(); diff --git a/src/plugins/avfoundation/mediaplayer/avfvideowindowcontrol.mm b/src/plugins/avfoundation/mediaplayer/avfvideowindowcontrol.mm index 5727cb0f4..7fa41fdc2 100644 --- a/src/plugins/avfoundation/mediaplayer/avfvideowindowcontrol.mm +++ b/src/plugins/avfoundation/mediaplayer/avfvideowindowcontrol.mm @@ -60,8 +60,8 @@ AVFVideoWindowControl::AVFVideoWindowControl(QObject *parent) , m_hue(0) , m_saturation(0) , m_aspectRatioMode(Qt::IgnoreAspectRatio) - , m_playerLayer(0) - , m_nativeView(0) + , m_playerLayer(nullptr) + , m_nativeView(nullptr) { } @@ -188,7 +188,7 @@ void AVFVideoWindowControl::setSaturation(int saturation) void AVFVideoWindowControl::setLayer(void *playerLayer) { - AVPlayerLayer *layer = (AVPlayerLayer*)playerLayer; + AVPlayerLayer *layer = static_cast<AVPlayerLayer*>(playerLayer); if (m_playerLayer == layer) return; diff --git a/src/plugins/common/evr/evrcustompresenter.cpp b/src/plugins/common/evr/evrcustompresenter.cpp index 872b97bcc..fdaedea7a 100644 --- a/src/plugins/common/evr/evrcustompresenter.cpp +++ b/src/plugins/common/evr/evrcustompresenter.cpp @@ -1208,6 +1208,8 @@ HRESULT EVRCustomPresenter::checkEndOfStream() // Everything is complete. Now we can tell the EVR that we are done. notifyEvent(EC_COMPLETE, (LONG_PTR)S_OK, 0); m_endStreaming = false; + + stopSurface(); return S_OK; } diff --git a/src/plugins/directshow/common/directshowutils.cpp b/src/plugins/directshow/common/directshowutils.cpp index 8f3f321e7..d1c1d42ab 100644 --- a/src/plugins/directshow/common/directshowutils.cpp +++ b/src/plugins/directshow/common/directshowutils.cpp @@ -56,8 +56,10 @@ bool DirectShowUtils::isPinConnected(IPin *pin, HRESULT *hrOut) hrOut = &hr; *hrOut = pin->ConnectedTo(&connectedPin); - if (*hrOut == VFW_E_NOT_CONNECTED) // Not an error in this case + if (*hrOut == VFW_E_NOT_CONNECTED) { // Not an error in this case *hrOut = S_OK; + return false; + } if (FAILED(*hrOut)) { qCDebug(qtDirectShowPlugin, "Querying pin connection failed!"); @@ -282,7 +284,7 @@ bool DirectShowUtils::connectFilters(IGraphBuilder *graph, // Try to connect to the upstream filter first. if (findAndConnect(upstreamFilter)) - return false; + return true; const auto getFilters = [graph, hrOut]() -> IEnumFilters * { IEnumFilters *f = nullptr; diff --git a/src/plugins/directshow/directshow.pro b/src/plugins/directshow/directshow.pro index 54d617166..e531efc53 100644 --- a/src/plugins/directshow/directshow.pro +++ b/src/plugins/directshow/directshow.pro @@ -17,12 +17,11 @@ mingw { } include(common/common.pri) -qtConfig(directshow-player): include(player/player.pri) +include(player/player.pri) include(camera/camera.pri) OTHER_FILES += \ - directshow.json \ - directshow_camera.json + directshow.json PLUGIN_TYPE = mediaservice PLUGIN_CLASS_NAME = DSServicePlugin diff --git a/src/plugins/directshow/directshow_camera.json b/src/plugins/directshow/directshow_camera.json deleted file mode 100644 index c37ce2c9a..000000000 --- a/src/plugins/directshow/directshow_camera.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "Keys": ["directshow"], - "Services": ["org.qt-project.qt.camera"] -} diff --git a/src/plugins/directshow/dsserviceplugin.cpp b/src/plugins/directshow/dsserviceplugin.cpp index 64b30f561..727a11b55 100644 --- a/src/plugins/directshow/dsserviceplugin.cpp +++ b/src/plugins/directshow/dsserviceplugin.cpp @@ -51,9 +51,7 @@ #include <dshow.h> #include "dscameraservice.h" -#if QT_CONFIG(directshow_player) #include "directshowplayerservice.h" -#endif #include <qmediaserviceproviderplugin.h> @@ -95,12 +93,11 @@ QMediaService* DSServicePlugin::create(QString const& key) addRefCount(); return new DSCameraService; } -#if QT_CONFIG(directshow_player) + if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER)) { addRefCount(); return new DirectShowPlayerService; } -#endif return 0; } diff --git a/src/plugins/directshow/dsserviceplugin.h b/src/plugins/directshow/dsserviceplugin.h index 2e87058c3..55db9310c 100644 --- a/src/plugins/directshow/dsserviceplugin.h +++ b/src/plugins/directshow/dsserviceplugin.h @@ -55,13 +55,7 @@ class DSServicePlugin Q_INTERFACES(QMediaServiceSupportedDevicesInterface) Q_INTERFACES(QMediaServiceDefaultDeviceInterface) Q_INTERFACES(QMediaServiceFeaturesInterface) - // The player service provided by the WMF-plugin should preferably be used. - // DirectShow should then only provide the camera (see QTBUG-29172, QTBUG-29175). -#if QT_CONFIG(directshow_player) Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "directshow.json") -#else - Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "directshow_camera.json") -#endif public: QMediaService* create(QString const& key) override; diff --git a/src/plugins/directshow/player/directshowmetadatacontrol.cpp b/src/plugins/directshow/player/directshowmetadatacontrol.cpp index 90d2b3e7d..52b73a7df 100644 --- a/src/plugins/directshow/player/directshowmetadatacontrol.cpp +++ b/src/plugins/directshow/player/directshowmetadatacontrol.cpp @@ -477,21 +477,14 @@ static QString convertBSTR(BSTR *string) return value; } -void DirectShowMetaDataControl::reset() +void DirectShowMetaDataControl::setMetadata(const QVariantMap &metadata) { - bool hadMetadata = !m_metadata.isEmpty(); - m_metadata.clear(); - - setMetadataAvailable(false); - - if (hadMetadata) - emit metaDataChanged(); + m_metadata = metadata; + setMetadataAvailable(!m_metadata.isEmpty()); } -void DirectShowMetaDataControl::updateMetadata(IFilterGraph2 *graph, IBaseFilter *source, const QString &fileSrc) +void DirectShowMetaDataControl::updateMetadata(const QString &fileSrc, QVariantMap &metadata) { - m_metadata.clear(); - #if QT_CONFIG(wshellitem) if (!sHCreateItemFromParsingName) { QSystemLibrary lib(QStringLiteral("shell32")); @@ -518,90 +511,90 @@ void DirectShowMetaDataControl::updateMetadata(IFilterGraph2 *graph, IBaseFilter continue; if (IsEqualPropertyKey(key, PKEY_Author)) { - m_metadata.insert(QMediaMetaData::Author, convertValue(var)); + metadata.insert(QMediaMetaData::Author, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Title)) { - m_metadata.insert(QMediaMetaData::Title, convertValue(var)); + metadata.insert(QMediaMetaData::Title, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Media_SubTitle)) { - m_metadata.insert(QMediaMetaData::SubTitle, convertValue(var)); + metadata.insert(QMediaMetaData::SubTitle, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_ParentalRating)) { - m_metadata.insert(QMediaMetaData::ParentalRating, convertValue(var)); + metadata.insert(QMediaMetaData::ParentalRating, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Comment)) { - m_metadata.insert(QMediaMetaData::Description, convertValue(var)); + metadata.insert(QMediaMetaData::Description, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Copyright)) { - m_metadata.insert(QMediaMetaData::Copyright, convertValue(var)); + metadata.insert(QMediaMetaData::Copyright, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Media_ProviderStyle)) { - m_metadata.insert(QMediaMetaData::Genre, convertValue(var)); + metadata.insert(QMediaMetaData::Genre, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Media_Year)) { - m_metadata.insert(QMediaMetaData::Year, convertValue(var)); + metadata.insert(QMediaMetaData::Year, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Media_DateEncoded)) { - m_metadata.insert(QMediaMetaData::Date, convertValue(var)); + metadata.insert(QMediaMetaData::Date, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Rating)) { - m_metadata.insert(QMediaMetaData::UserRating, + metadata.insert(QMediaMetaData::UserRating, int((convertValue(var).toUInt() - 1) / qreal(98) * 100)); } else if (IsEqualPropertyKey(key, PKEY_Keywords)) { - m_metadata.insert(QMediaMetaData::Keywords, convertValue(var)); + metadata.insert(QMediaMetaData::Keywords, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Language)) { - m_metadata.insert(QMediaMetaData::Language, convertValue(var)); + metadata.insert(QMediaMetaData::Language, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Media_Publisher)) { - m_metadata.insert(QMediaMetaData::Publisher, convertValue(var)); + metadata.insert(QMediaMetaData::Publisher, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Media_Duration)) { - m_metadata.insert(QMediaMetaData::Duration, + metadata.insert(QMediaMetaData::Duration, (convertValue(var).toLongLong() + 10000) / 10000); } else if (IsEqualPropertyKey(key, PKEY_Audio_EncodingBitrate)) { - m_metadata.insert(QMediaMetaData::AudioBitRate, convertValue(var)); + metadata.insert(QMediaMetaData::AudioBitRate, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Media_AverageLevel)) { - m_metadata.insert(QMediaMetaData::AverageLevel, convertValue(var)); + metadata.insert(QMediaMetaData::AverageLevel, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Audio_ChannelCount)) { - m_metadata.insert(QMediaMetaData::ChannelCount, convertValue(var)); + metadata.insert(QMediaMetaData::ChannelCount, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Audio_PeakValue)) { - m_metadata.insert(QMediaMetaData::PeakValue, convertValue(var)); + metadata.insert(QMediaMetaData::PeakValue, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Audio_SampleRate)) { - m_metadata.insert(QMediaMetaData::SampleRate, convertValue(var)); + metadata.insert(QMediaMetaData::SampleRate, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Music_AlbumTitle)) { - m_metadata.insert(QMediaMetaData::AlbumTitle, convertValue(var)); + metadata.insert(QMediaMetaData::AlbumTitle, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Music_AlbumArtist)) { - m_metadata.insert(QMediaMetaData::AlbumArtist, convertValue(var)); + metadata.insert(QMediaMetaData::AlbumArtist, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Music_Artist)) { - m_metadata.insert(QMediaMetaData::ContributingArtist, convertValue(var)); + metadata.insert(QMediaMetaData::ContributingArtist, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Music_Composer)) { - m_metadata.insert(QMediaMetaData::Composer, convertValue(var)); + metadata.insert(QMediaMetaData::Composer, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Music_Conductor)) { - m_metadata.insert(QMediaMetaData::Conductor, convertValue(var)); + metadata.insert(QMediaMetaData::Conductor, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Music_Lyrics)) { - m_metadata.insert(QMediaMetaData::Lyrics, convertValue(var)); + metadata.insert(QMediaMetaData::Lyrics, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Music_Mood)) { - m_metadata.insert(QMediaMetaData::Mood, convertValue(var)); + metadata.insert(QMediaMetaData::Mood, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Music_TrackNumber)) { - m_metadata.insert(QMediaMetaData::TrackNumber, convertValue(var)); + metadata.insert(QMediaMetaData::TrackNumber, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Music_Genre)) { - m_metadata.insert(QMediaMetaData::Genre, convertValue(var)); + metadata.insert(QMediaMetaData::Genre, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_ThumbnailStream)) { - m_metadata.insert(QMediaMetaData::ThumbnailImage, convertValue(var)); + metadata.insert(QMediaMetaData::ThumbnailImage, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Video_FrameHeight)) { QSize res; res.setHeight(convertValue(var).toUInt()); if (SUCCEEDED(pStore->GetValue(PKEY_Video_FrameWidth, &var))) res.setWidth(convertValue(var).toUInt()); - m_metadata.insert(QMediaMetaData::Resolution, res); + metadata.insert(QMediaMetaData::Resolution, res); } else if (IsEqualPropertyKey(key, PKEY_Video_HorizontalAspectRatio)) { QSize aspectRatio; aspectRatio.setWidth(convertValue(var).toUInt()); if (SUCCEEDED(pStore->GetValue(PKEY_Video_VerticalAspectRatio, &var))) aspectRatio.setHeight(convertValue(var).toUInt()); - m_metadata.insert(QMediaMetaData::PixelAspectRatio, aspectRatio); + metadata.insert(QMediaMetaData::PixelAspectRatio, aspectRatio); } else if (IsEqualPropertyKey(key, PKEY_Video_FrameRate)) { - m_metadata.insert(QMediaMetaData::VideoFrameRate, + metadata.insert(QMediaMetaData::VideoFrameRate, convertValue(var).toReal() / 1000); } else if (IsEqualPropertyKey(key, PKEY_Video_EncodingBitrate)) { - m_metadata.insert(QMediaMetaData::VideoBitRate, convertValue(var)); + metadata.insert(QMediaMetaData::VideoBitRate, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Video_Director)) { - m_metadata.insert(QMediaMetaData::Director, convertValue(var)); + metadata.insert(QMediaMetaData::Director, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Media_Writer)) { - m_metadata.insert(QMediaMetaData::Writer, convertValue(var)); + metadata.insert(QMediaMetaData::Writer, convertValue(var)); } else if (IsEqualPropertyKey(key, PKEY_Video_Compression)) { - m_metadata.insert(QMediaMetaData::VideoCodec, nameForGUIDString(convertValue(var).toString())); + metadata.insert(QMediaMetaData::VideoCodec, nameForGUIDString(convertValue(var).toString())); } else if (IsEqualPropertyKey(key, PKEY_Audio_Format)) { - m_metadata.insert(QMediaMetaData::AudioCodec, nameForGUIDString(convertValue(var).toString())); + metadata.insert(QMediaMetaData::AudioCodec, nameForGUIDString(convertValue(var).toString())); } PropVariantClear(&var); @@ -614,11 +607,14 @@ void DirectShowMetaDataControl::updateMetadata(IFilterGraph2 *graph, IBaseFilter shellItem->Release(); } } - - if (!m_metadata.isEmpty()) - goto send_event; +#else + Q_UNUSED(fileSrc); + Q_UNUSED(metadata); #endif +} +void DirectShowMetaDataControl::updateMetadata(IFilterGraph2 *graph, IBaseFilter *source, QVariantMap &metadata) +{ #if QT_CONFIG(wmsdk) if (IWMHeaderInfo *info = com_cast<IWMHeaderInfo>(source, IID_IWMHeaderInfo)) { const auto keys = *qt_wmMetaDataKeys(); @@ -644,15 +640,15 @@ void DirectShowMetaDataControl::updateMetadata(IFilterGraph2 *graph, IBaseFilter var = (var.toUInt() - 1) / qreal(98) * 100; } - m_metadata.insert(key.qtName, var); + metadata.insert(key.qtName, var); } } info->Release(); } - if (!m_metadata.isEmpty()) - goto send_event; + if (!metadata.isEmpty()) + return; #endif { IAMMediaContent *content = 0; @@ -668,41 +664,23 @@ void DirectShowMetaDataControl::updateMetadata(IFilterGraph2 *graph, IBaseFilter BSTR string = 0; if (content->get_AuthorName(&string) == S_OK) - m_metadata.insert(QMediaMetaData::Author, convertBSTR(&string)); + metadata.insert(QMediaMetaData::Author, convertBSTR(&string)); if (content->get_Title(&string) == S_OK) - m_metadata.insert(QMediaMetaData::Title, convertBSTR(&string)); + metadata.insert(QMediaMetaData::Title, convertBSTR(&string)); if (content->get_Description(&string) == S_OK) - m_metadata.insert(QMediaMetaData::Description, convertBSTR(&string)); + metadata.insert(QMediaMetaData::Description, convertBSTR(&string)); if (content->get_Rating(&string) == S_OK) - m_metadata.insert(QMediaMetaData::UserRating, convertBSTR(&string)); + metadata.insert(QMediaMetaData::UserRating, convertBSTR(&string)); if (content->get_Copyright(&string) == S_OK) - m_metadata.insert(QMediaMetaData::Copyright, convertBSTR(&string)); + metadata.insert(QMediaMetaData::Copyright, convertBSTR(&string)); content->Release(); } } - -send_event: - // DirectShowMediaPlayerService holds a lock at this point so defer emitting signals to a later - // time. - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(MetaDataChanged))); -} - -void DirectShowMetaDataControl::customEvent(QEvent *event) -{ - if (event->type() == QEvent::Type(MetaDataChanged)) { - event->accept(); - - setMetadataAvailable(!m_metadata.isEmpty()); - - emit metaDataChanged(); - } else { - QMetaDataReaderControl::customEvent(event); - } } void DirectShowMetaDataControl::setMetadataAvailable(bool available) @@ -711,5 +689,10 @@ void DirectShowMetaDataControl::setMetadataAvailable(bool available) return; m_available = available; - emit metaDataAvailableChanged(m_available); + + // If the metadata is not available, notify about it immediately. + Qt::ConnectionType type = m_available ? Qt::QueuedConnection : Qt::AutoConnection; + QMetaObject::invokeMethod(this, "metaDataAvailableChanged", type, Q_ARG(bool, m_available)); + // Currently the metadata is changed only with its availability. + QMetaObject::invokeMethod(this, "metaDataChanged", type); } diff --git a/src/plugins/directshow/player/directshowmetadatacontrol.h b/src/plugins/directshow/player/directshowmetadatacontrol.h index ea20bf0c5..4196a7950 100644 --- a/src/plugins/directshow/player/directshowmetadatacontrol.h +++ b/src/plugins/directshow/player/directshowmetadatacontrol.h @@ -62,12 +62,10 @@ public: QVariant metaData(const QString &key) const override; QStringList availableMetaData() const override; - void reset(); - void updateMetadata(IFilterGraph2 *graph, IBaseFilter *source, - const QString &fileSrc = QString()); + void setMetadata(const QVariantMap &metadata); -protected: - void customEvent(QEvent *event) override; + static void updateMetadata(const QString &fileSrc, QVariantMap &metadata); + static void updateMetadata(IFilterGraph2 *graph, IBaseFilter *source, QVariantMap &metadata); private: void setMetadataAvailable(bool available); diff --git a/src/plugins/directshow/player/directshowplayerservice.cpp b/src/plugins/directshow/player/directshowplayerservice.cpp index 08d99d735..d48350fa2 100644 --- a/src/plugins/directshow/player/directshowplayerservice.cpp +++ b/src/plugins/directshow/player/directshowplayerservice.cpp @@ -142,6 +142,7 @@ DirectShowPlayerService::DirectShowPlayerService(QObject *parent) , m_graphStatus(NoMedia) , m_stream(0) , m_graph(0) + , m_graphBuilder(nullptr) , m_source(0) , m_audioOutput(0) , m_videoOutput(0) @@ -297,7 +298,7 @@ void DirectShowPlayerService::load(const QMediaContent &media, QIODevice *stream if (m_graph) releaseGraph(); - m_resources = media.resources(); + m_url = media.canonicalUrl(); m_stream = stream; m_error = QMediaPlayer::NoError; m_errorString = QString(); @@ -310,13 +311,11 @@ void DirectShowPlayerService::load(const QMediaContent &media, QIODevice *stream m_seekable = false; m_atEnd = false; m_dontCacheNextSeekResult = false; - m_metaDataControl->reset(); + m_metaDataControl->setMetadata(QVariantMap()); - if (m_resources.isEmpty() && !stream) { + if (m_url.isEmpty() && !stream) { m_pendingTasks = 0; m_graphStatus = NoMedia; - - m_url.clear(); } else if (stream && (!stream->isReadable() || stream->isSequential())) { m_pendingTasks = 0; m_graphStatus = InvalidMedia; @@ -328,6 +327,15 @@ void DirectShowPlayerService::load(const QMediaContent &media, QIODevice *stream m_graphStatus = Loading; m_graph = com_new<IFilterGraph2>(CLSID_FilterGraph, iid_IFilterGraph2); + m_graphBuilder = com_new<ICaptureGraphBuilder2>(CLSID_CaptureGraphBuilder2, IID_ICaptureGraphBuilder2); + + // Attach the filter graph to the capture graph. + HRESULT hr = m_graphBuilder->SetFiltergraph(m_graph); + if (FAILED(hr)) { + qCWarning(qtDirectShowPlugin, "[0x%x] Failed to attach filter to capture graph", hr); + m_graphBuilder->Release(); + m_graphBuilder = nullptr; + } if (stream) m_pendingTasks = SetStreamSource; @@ -348,9 +356,6 @@ void DirectShowPlayerService::doSetUrlSource(QMutexLocker *locker) { IBaseFilter *source = 0; - QMediaResource resource = m_resources.takeFirst(); - m_url = resource.url(); - HRESULT hr = E_FAIL; if (m_url.scheme() == QLatin1String("http") || m_url.scheme() == QLatin1String("https")) { static const GUID clsid_WMAsfReader = { @@ -403,7 +408,7 @@ void DirectShowPlayerService::doSetUrlSource(QMutexLocker *locker) m_pendingTasks |= SetRate; m_source = source; - } else if (!m_resources.isEmpty()) { + } else if (!m_url.isEmpty()) { m_pendingTasks |= SetUrlSource; } else { m_graphStatus = InvalidMedia; @@ -596,7 +601,6 @@ void DirectShowPlayerService::doRender(QMutexLocker *locker) void DirectShowPlayerService::doFinalizeLoad(QMutexLocker *locker) { - Q_UNUSED(locker) if (m_graphStatus != Loaded) { if (IMediaEvent *event = com_cast<IMediaEvent>(m_graph, IID_IMediaEvent)) { event->GetEventHandle(reinterpret_cast<OAEVENT *>(&m_eventHandle)); @@ -625,6 +629,11 @@ void DirectShowPlayerService::doFinalizeLoad(QMutexLocker *locker) m_graphStatus = Loaded; + // Do not block gui thread while updating metadata from file. + locker->unlock(); + DirectShowMetaDataControl::updateMetadata(m_url.toString(), m_metadata); + locker->relock(); + QCoreApplication::postEvent(this, new QEvent(QEvent::Type(FinalizedLoad))); } @@ -674,6 +683,11 @@ void DirectShowPlayerService::doReleaseGraph(QMutexLocker *locker) m_graph->Release(); m_graph = 0; + if (m_graphBuilder) { + m_graphBuilder->Release(); + m_graphBuilder = nullptr; + } + m_loop->wake(); } @@ -684,7 +698,7 @@ void DirectShowPlayerService::doSetVideoProbe(QMutexLocker *locker) { Q_UNUSED(locker); - if (!m_graph) { + if (!m_graph || !m_graphBuilder) { qCWarning(qtDirectShowPlugin, "Attempting to set a video probe without a valid graph!"); return; } @@ -700,41 +714,14 @@ void DirectShowPlayerService::doSetVideoProbe(QMutexLocker *locker) return; } - // TODO: Make util function for getting this, so it's easy to keep it in sync. - static const GUID subtypes[] = { MEDIASUBTYPE_ARGB32, - MEDIASUBTYPE_RGB32, - MEDIASUBTYPE_RGB24, - MEDIASUBTYPE_RGB565, - MEDIASUBTYPE_RGB555, - MEDIASUBTYPE_AYUV, - MEDIASUBTYPE_I420, - MEDIASUBTYPE_IYUV, - MEDIASUBTYPE_YV12, - MEDIASUBTYPE_UYVY, - MEDIASUBTYPE_YUYV, - MEDIASUBTYPE_YUY2, - MEDIASUBTYPE_NV12, - MEDIASUBTYPE_MJPG, - MEDIASUBTYPE_IMC1, - MEDIASUBTYPE_IMC2, - MEDIASUBTYPE_IMC3, - MEDIASUBTYPE_IMC4 }; - - // Negotiate the subtype - DirectShowMediaType mediaType(AM_MEDIA_TYPE { MEDIATYPE_Video }); - const int items = (sizeof subtypes / sizeof(GUID)); - bool connected = false; - for (int i = 0; i != items; ++i) { - mediaType->subtype = subtypes[i]; - m_videoSampleGrabber->setMediaType(&mediaType); - if (DirectShowUtils::connectFilters(m_graph, m_source, m_videoSampleGrabber->filter(), true)) { - connected = true; - break; - } - } + DirectShowMediaType mediaType({ MEDIATYPE_Video, MEDIASUBTYPE_ARGB32 }); + m_videoSampleGrabber->setMediaType(&mediaType); - if (!connected) { - qCWarning(qtDirectShowPlugin, "Unable to connect the video probe!"); + // Connect source filter to sample grabber filter. + HRESULT hr = m_graphBuilder->RenderStream(nullptr, &MEDIATYPE_Video, + m_source, nullptr, m_videoSampleGrabber->filter()); + if (FAILED(hr)) { + qCWarning(qtDirectShowPlugin, "[0x%x] Failed to connect the video sample grabber", hr); return; } @@ -765,8 +752,15 @@ void DirectShowPlayerService::doSetAudioProbe(QMutexLocker *locker) } if (!DirectShowUtils::connectFilters(m_graph, m_source, m_audioSampleGrabber->filter(), true)) { - qCWarning(qtDirectShowPlugin, "Failed to connect the audio sample grabber"); - return; + // Connect source filter to sample grabber filter. + HRESULT hr = m_graphBuilder + ? m_graphBuilder->RenderStream(nullptr, &MEDIATYPE_Audio, + m_source, nullptr, m_audioSampleGrabber->filter()) + : E_FAIL; + if (FAILED(hr)) { + qCWarning(qtDirectShowPlugin, "[0x%x] Failed to connect the audio sample grabber", hr); + return; + } } m_audioSampleGrabber->start(DirectShowSampleGrabber::CallbackMethod::BufferCB); @@ -1406,7 +1400,11 @@ void DirectShowPlayerService::customEvent(QEvent *event) QMutexLocker locker(&m_mutex); m_playerControl->updateMediaInfo(m_duration, m_streamTypes, m_seekable); - m_metaDataControl->updateMetadata(m_graph, m_source, m_url.toString()); + if (m_metadata.isEmpty()) + DirectShowMetaDataControl::updateMetadata(m_graph, m_source, m_metadata); + + m_metaDataControl->setMetadata(m_metadata); + m_metadata.clear(); updateStatus(); } else if (event->type() == QEvent::Type(Error)) { diff --git a/src/plugins/directshow/player/directshowplayerservice.h b/src/plugins/directshow/player/directshowplayerservice.h index 4a9e25678..a6eeb8a77 100644 --- a/src/plugins/directshow/player/directshowplayerservice.h +++ b/src/plugins/directshow/player/directshowplayerservice.h @@ -215,6 +215,7 @@ private: QMediaPlayer::Error m_error; QIODevice *m_stream; IFilterGraph2 *m_graph; + ICaptureGraphBuilder2 *m_graphBuilder; IBaseFilter *m_source; IBaseFilter *m_audioOutput; IBaseFilter *m_videoOutput; @@ -224,13 +225,13 @@ private: qint64 m_duration; QMediaTimeRange m_playbackRange; QUrl m_url; - QMediaResourceList m_resources; QString m_errorString; QMutex m_mutex; bool m_buffering; bool m_seekable; bool m_atEnd; bool m_dontCacheNextSeekResult; + QVariantMap m_metadata; friend class DirectShowPlayerServiceThread; }; diff --git a/src/plugins/directshow/player/videosurfacefilter.cpp b/src/plugins/directshow/player/videosurfacefilter.cpp index 826d26bdb..74d59231c 100644 --- a/src/plugins/directshow/player/videosurfacefilter.cpp +++ b/src/plugins/directshow/player/videosurfacefilter.cpp @@ -462,6 +462,7 @@ HRESULT VideoSurfaceFilter::EndOfStream() if (!m_pendingSample && m_running) checkEOS(); + stopSurface(); return S_OK; } diff --git a/src/plugins/gstreamer/camerabin/camerabinmetadata.cpp b/src/plugins/gstreamer/camerabin/camerabinmetadata.cpp index 6ae41de0e..afda2346d 100644 --- a/src/plugins/gstreamer/camerabin/camerabinmetadata.cpp +++ b/src/plugins/gstreamer/camerabin/camerabinmetadata.cpp @@ -43,45 +43,12 @@ #include <gst/gst.h> #include <gst/gstversion.h> +#include <private/qgstutils_p.h> #include <QDebug> QT_BEGIN_NAMESPACE -#if GST_CHECK_VERSION(0,10,30) - -static QVariant fromGStreamerOrientation(const QVariant &value) -{ - // Note gstreamer tokens either describe the counter clockwise rotation of the - // image or the clockwise transform to apply to correct the image. The orientation - // value returned is the clockwise rotation of the image. - const QString token = value.toString(); - if (token == QStringLiteral("rotate-90")) - return 270; - else if (token == QStringLiteral("rotate-180")) - return 180; - else if (token == QStringLiteral("rotate-270")) - return 90; - else - return 0; -} - -#endif - -static QVariant toGStreamerOrientation(const QVariant &value) -{ - switch (value.toInt()) { - case 90: - return QStringLiteral("rotate-270"); - case 180: - return QStringLiteral("rotate-180"); - case 270: - return QStringLiteral("rotate-90"); - default: - return QStringLiteral("rotate-0"); - } -} - namespace { struct QGStreamerMetaDataKey { @@ -196,7 +163,7 @@ QVariant CameraBinMetaData::metaData(const QString &key) const { #if GST_CHECK_VERSION(0,10,30) if (key == QMediaMetaData::Orientation) { - return fromGStreamerOrientation(m_values.value(QByteArray(GST_TAG_IMAGE_ORIENTATION))); + return QGstUtils::fromGStreamerOrientation(m_values.value(QByteArray(GST_TAG_IMAGE_ORIENTATION))); } else if (key == QMediaMetaData::GPSSpeed) { const double metersPerSec = m_values.value(QByteArray(GST_TAG_GEO_LOCATION_MOVEMENT_SPEED)).toDouble(); return (metersPerSec * 3600) / 1000; @@ -214,14 +181,16 @@ QVariant CameraBinMetaData::metaData(const QString &key) const void CameraBinMetaData::setMetaData(const QString &key, const QVariant &value) { QVariant correctedValue = value; +#if GST_CHECK_VERSION(0,10,30) if (value.isValid()) { if (key == QMediaMetaData::Orientation) { - correctedValue = toGStreamerOrientation(value); + correctedValue = QGstUtils::toGStreamerOrientation(value); } else if (key == QMediaMetaData::GPSSpeed) { // kilometers per hour to meters per second. correctedValue = (value.toDouble() * 1000) / 3600; } } +#endif const auto keys = *qt_gstreamerMetaDataKeys(); for (const QGStreamerMetaDataKey &metadataKey : keys) { diff --git a/src/plugins/gstreamer/camerabin/camerabinsession.cpp b/src/plugins/gstreamer/camerabin/camerabinsession.cpp index 23cbd6082..f064c7c92 100644 --- a/src/plugins/gstreamer/camerabin/camerabinsession.cpp +++ b/src/plugins/gstreamer/camerabin/camerabinsession.cpp @@ -541,13 +541,26 @@ GstElement *CameraBinSession::buildCameraSource() if (!m_videoSrc) m_videoSrc = gst_element_factory_make("v4l2src", "camera_source"); + if (!m_videoSrc) + m_videoSrc = gst_element_factory_make("ksvideosrc", "camera_source"); + + if (!m_videoSrc) + m_videoSrc = gst_element_factory_make("avfvideosrc", "camera_source"); + if (m_videoSrc) g_object_set(G_OBJECT(m_cameraSrc), "video-source", m_videoSrc, NULL); } - if (m_videoSrc) - g_object_set(G_OBJECT(m_videoSrc), "device", m_inputDevice.toUtf8().constData(), NULL); + if (m_videoSrc) { + if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSrc), "device")) + g_object_set(G_OBJECT(m_videoSrc), "device", m_inputDevice.toUtf8().constData(), NULL); + if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSrc), "device-path")) + g_object_set(G_OBJECT(m_videoSrc), "device-path", m_inputDevice.toUtf8().constData(), NULL); + + if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSrc), "device-index")) + g_object_set(G_OBJECT(m_videoSrc), "device-index", m_inputDevice.toInt(), NULL); + } } else if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_cameraSrc), "camera-device")) { if (m_inputDevice == QLatin1String("secondary")) { g_object_set(G_OBJECT(m_cameraSrc), "camera-device", 1, NULL); @@ -1177,11 +1190,16 @@ void CameraBinSession::recordVideo() if (format.isEmpty()) format = m_mediaContainerControl->actualContainerFormat(); - const QString actualFileName = m_mediaStorageLocation.generateFileName(m_sink.isLocalFile() ? m_sink.toLocalFile() - : m_sink.toString(), + const QString fileName = m_sink.isLocalFile() ? m_sink.toLocalFile() : m_sink.toString(); + const QFileInfo fileInfo(fileName); + const QString extension = fileInfo.suffix().isEmpty() + ? QGstUtils::fileExtensionForMimeType(format) + : fileInfo.suffix(); + + const QString actualFileName = m_mediaStorageLocation.generateFileName(fileName, QMediaStorageLocation::Movies, QLatin1String("clip_"), - QGstUtils::fileExtensionForMimeType(format)); + extension); m_recordingActive = true; m_actualSink = QUrl::fromLocalFile(actualFileName); diff --git a/src/plugins/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp b/src/plugins/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp index 50ab0256b..8f2f6643c 100644 --- a/src/plugins/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp +++ b/src/plugins/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp @@ -43,6 +43,7 @@ #include <QtMultimedia/qmediametadata.h> #include <gst/gstversion.h> +#include <private/qgstutils_p.h> QT_BEGIN_NAMESPACE @@ -99,6 +100,9 @@ static const QGstreamerMetaDataKeyLookup *qt_gstreamerMetaDataKeys() // Image/Video metadataKeys->insert("resolution", QMediaMetaData::Resolution); metadataKeys->insert("pixel-aspect-ratio", QMediaMetaData::PixelAspectRatio); +#if GST_CHECK_VERSION(0,10,30) + metadataKeys->insert(GST_TAG_IMAGE_ORIENTATION, QMediaMetaData::Orientation); +#endif // Video //metadataKeys->insert(0, QMediaMetaData::VideoFrameRate); @@ -145,6 +149,10 @@ bool QGstreamerMetaDataProvider::isWritable() const QVariant QGstreamerMetaDataProvider::metaData(const QString &key) const { +#if GST_CHECK_VERSION(0,10,30) + if (key == QMediaMetaData::Orientation) + return QGstUtils::fromGStreamerOrientation(m_tags.value(key)); +#endif return m_tags.value(key); } diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index 71b9ec6e1..95c004125 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -44,12 +44,10 @@ winrt { audiocapture } +qtConfig(gstreamer): SUBDIRS += gstreamer + unix:!mac:!android { - qtConfig(gstreamer) { - SUBDIRS += gstreamer - } else { - SUBDIRS += audiocapture - } + !qtConfig(gstreamer): SUBDIRS += audiocapture qtConfig(pulseaudio): SUBDIRS += pulseaudio qtConfig(alsa): SUBDIRS += alsa diff --git a/src/plugins/pulseaudio/qaudiooutput_pulse.cpp b/src/plugins/pulseaudio/qaudiooutput_pulse.cpp index ea7a2be0c..19ddac1e5 100644 --- a/src/plugins/pulseaudio/qaudiooutput_pulse.cpp +++ b/src/plugins/pulseaudio/qaudiooutput_pulse.cpp @@ -310,7 +310,34 @@ bool QPulseAudioOutput::open() if (!m_category.isNull()) pa_proplist_sets(propList, PA_PROP_MEDIA_ROLE, m_category.toLatin1().constData()); - m_stream = pa_stream_new_with_proplist(pulseEngine->context(), m_streamName.constData(), &m_spec, 0, propList); + static const auto mapName = qEnvironmentVariable("QT_PA_CHANNEL_MAP"); + pa_channel_map_def_t mapDef = PA_CHANNEL_MAP_DEFAULT; + if (mapName == QLatin1String("ALSA")) + mapDef = PA_CHANNEL_MAP_ALSA; + else if (mapName == QLatin1String("AUX")) + mapDef = PA_CHANNEL_MAP_AUX; + else if (mapName == QLatin1String("WAVEEX")) + mapDef = PA_CHANNEL_MAP_WAVEEX; + else if (mapName == QLatin1String("OSS")) + mapDef = PA_CHANNEL_MAP_OSS; + else if (!mapName.isEmpty()) + qWarning() << "Unknown pulse audio channel mapping definition:" << mapName; + + pa_channel_map m; + auto channelMap = pa_channel_map_init_extend(&m, m_spec.channels, mapDef); + if (!channelMap) + qWarning() << "QAudioOutput: pa_channel_map_init_extend() Could not initialize channel map"; + + m_stream = pa_stream_new_with_proplist(pulseEngine->context(), m_streamName.constData(), &m_spec, channelMap, propList); + if (!m_stream) { + qWarning() << "QAudioOutput: pa_stream_new_with_proplist() failed!"; + pulseEngine->unlock(); + setError(QAudio::OpenError); + setState(QAudio::StoppedState); + emit stateChanged(m_deviceState); + return false; + } + pa_proplist_free(propList); pa_stream_set_state_callback(m_stream, outputStreamStateCallback, this); @@ -469,8 +496,7 @@ void QPulseAudioOutput::userFeed() if (m_notifyInterval && (m_timeStamp.elapsed() + m_elapsedTimeOffset) > m_notifyInterval) { emit notify(); - m_elapsedTimeOffset = m_timeStamp.elapsed() + m_elapsedTimeOffset - m_notifyInterval; - m_timeStamp.restart(); + m_elapsedTimeOffset = m_timeStamp.restart() + m_elapsedTimeOffset - m_notifyInterval; } } diff --git a/src/plugins/pulseaudio/qaudiooutput_pulse.h b/src/plugins/pulseaudio/qaudiooutput_pulse.h index 58f175e18..40d052681 100644 --- a/src/plugins/pulseaudio/qaudiooutput_pulse.h +++ b/src/plugins/pulseaudio/qaudiooutput_pulse.h @@ -55,7 +55,7 @@ #include <QtCore/qtimer.h> #include <QtCore/qstring.h> #include <QtCore/qstringlist.h> -#include <QtCore/qdatetime.h> +#include <QtCore/qelapsedtimer.h> #include <QtCore/qiodevice.h> #include "qaudio.h" @@ -131,11 +131,11 @@ private: int m_periodSize; int m_bufferSize; int m_maxBufferSize; - QTime m_clockStamp; + QElapsedTimer m_clockStamp; qint64 m_totalTimeValue; QTimer *m_tickTimer; char *m_audioBuffer; - QTime m_timeStamp; + QElapsedTimer m_timeStamp; qint64 m_elapsedTimeOffset; bool m_resuming; QString m_category; diff --git a/src/plugins/wmf/decoder/mfaudiodecodercontrol.cpp b/src/plugins/wmf/decoder/mfaudiodecodercontrol.cpp index 438c2aae0..c0eada324 100644 --- a/src/plugins/wmf/decoder/mfaudiodecodercontrol.cpp +++ b/src/plugins/wmf/decoder/mfaudiodecodercontrol.cpp @@ -124,14 +124,12 @@ void MFAudioDecoderControl::setSourceFilename(const QString &fileName) m_sourceFilename = fileName; if (!m_sourceFilename.isEmpty()) { m_sourceResolver->shutdown(); - QMediaResourceList rl; QUrl url; if (m_sourceFilename.startsWith(':')) url = QUrl(QStringLiteral("qrc%1").arg(m_sourceFilename)); else url = QUrl::fromLocalFile(m_sourceFilename); - rl.push_back(QMediaResource(url)); - m_sourceResolver->load(rl, 0); + m_sourceResolver->load(url, 0); m_loadingSource = true; } else { onSourceCleared(); @@ -155,7 +153,7 @@ void MFAudioDecoderControl::setSourceDevice(QIODevice *device) m_device = device; if (m_device) { m_sourceResolver->shutdown(); - m_sourceResolver->load(QMediaResourceList(), m_device); + m_sourceResolver->load(QUrl(), m_device); m_loadingSource = true; } else { onSourceCleared(); diff --git a/src/plugins/wmf/player/mfplayersession.cpp b/src/plugins/wmf/player/mfplayersession.cpp index 3219936a7..9f909252d 100644 --- a/src/plugins/wmf/player/mfplayersession.cpp +++ b/src/plugins/wmf/player/mfplayersession.cpp @@ -197,12 +197,12 @@ void MFPlayerSession::load(const QMediaContent &media, QIODevice *stream) qDebug() << "load"; #endif clear(); - QMediaResourceList resources = media.resources(); + QUrl url = media.canonicalUrl(); if (m_status == QMediaPlayer::LoadingMedia && m_sourceResolver) m_sourceResolver->cancel(); - if (resources.isEmpty() && !stream) { + if (url.isEmpty() && !stream) { changeStatus(QMediaPlayer::NoMedia); } else if (stream && (!stream->isReadable())) { changeStatus(QMediaPlayer::InvalidMedia); @@ -210,7 +210,7 @@ void MFPlayerSession::load(const QMediaContent &media, QIODevice *stream) } else { createSession(); changeStatus(QMediaPlayer::LoadingMedia); - m_sourceResolver->load(resources, stream); + m_sourceResolver->load(url, stream); } emit positionChanged(position()); } diff --git a/src/plugins/wmf/player/mfplayersession.h b/src/plugins/wmf/player/mfplayersession.h index 72dc99d02..21fabbd92 100644 --- a/src/plugins/wmf/player/mfplayersession.h +++ b/src/plugins/wmf/player/mfplayersession.h @@ -62,9 +62,6 @@ QT_END_NAMESPACE QT_USE_NAMESPACE class SourceResolver; -#ifndef Q_WS_SIMULATOR -class EvrVideoWindowControl; -#endif class MFAudioEndpointControl; class MFVideoRendererControl; class MFPlayerControl; diff --git a/src/plugins/wmf/sourceresolver.cpp b/src/plugins/wmf/sourceresolver.cpp index 83949c976..c6f4e8566 100644 --- a/src/plugins/wmf/sourceresolver.cpp +++ b/src/plugins/wmf/sourceresolver.cpp @@ -158,7 +158,7 @@ HRESULT STDMETHODCALLTYPE SourceResolver::GetParameters(DWORD*, DWORD*) return E_NOTIMPL; } -void SourceResolver::load(const QMediaResourceList &resources, QIODevice* stream) +void SourceResolver::load(const QUrl &url, QIODevice* stream) { QMutexLocker locker(&m_mutex); HRESULT hr = S_OK; @@ -174,12 +174,10 @@ void SourceResolver::load(const QMediaResourceList &resources, QIODevice* stream qWarning() << "Failed to create Source Resolver!"; emit error(hr); } else if (stream) { - QString url; - if (!resources.isEmpty()) - url = resources.constFirst().url().toString(); + QString urlString = url.toString(); m_stream = new MFStream(stream, false); hr = m_sourceResolver->BeginCreateObjectFromByteStream( - m_stream, url.isEmpty() ? 0 : reinterpret_cast<LPCWSTR>(url.utf16()), + m_stream, urlString.isEmpty() ? 0 : reinterpret_cast<LPCWSTR>(urlString.utf16()), MF_RESOLUTION_MEDIASOURCE | MF_RESOLUTION_CONTENT_DOES_NOT_HAVE_TO_MATCH_EXTENSION_OR_MIME_TYPE , NULL, &m_cancelCookie, this, new State(m_sourceResolver, true)); if (FAILED(hr)) { @@ -187,8 +185,6 @@ void SourceResolver::load(const QMediaResourceList &resources, QIODevice* stream emit error(hr); } } else { - QMediaResource resource = resources.constFirst(); - QUrl url = resource.url(); #ifdef DEBUG_MEDIAFOUNDATION qDebug() << "loading :" << url; qDebug() << "url path =" << url.path().mid(1); diff --git a/src/plugins/wmf/sourceresolver.h b/src/plugins/wmf/sourceresolver.h index 387f59739..aa104a60e 100644 --- a/src/plugins/wmf/sourceresolver.h +++ b/src/plugins/wmf/sourceresolver.h @@ -59,7 +59,7 @@ public: HRESULT STDMETHODCALLTYPE GetParameters(DWORD*, DWORD*); - void load(const QMediaResourceList &resources, QIODevice* stream); + void load(const QUrl &url, QIODevice* stream); void cancel(); diff --git a/src/plugins/wmf/wmf.pro b/src/plugins/wmf/wmf.pro index b202ff2a1..7c712233d 100644 --- a/src/plugins/wmf/wmf.pro +++ b/src/plugins/wmf/wmf.pro @@ -17,12 +17,11 @@ SOURCES += \ mfstream.cpp \ sourceresolver.cpp -qtConfig(wmf-player): include (player/player.pri) +include (player/player.pri) include (decoder/decoder.pri) OTHER_FILES += \ - wmf.json \ - wmf_audiodecode.json + wmf.json PLUGIN_TYPE = mediaservice PLUGIN_CLASS_NAME = WMFServicePlugin diff --git a/src/plugins/wmf/wmf_audiodecode.json b/src/plugins/wmf/wmf_audiodecode.json deleted file mode 100644 index 2a65dd758..000000000 --- a/src/plugins/wmf/wmf_audiodecode.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "Keys": ["windowsmediafoundation"], - "Services": ["org.qt-project.qt.audiodecode"] -} diff --git a/src/plugins/wmf/wmfserviceplugin.cpp b/src/plugins/wmf/wmfserviceplugin.cpp index 1eeb22428..740067600 100644 --- a/src/plugins/wmf/wmfserviceplugin.cpp +++ b/src/plugins/wmf/wmfserviceplugin.cpp @@ -42,9 +42,7 @@ #include <QtCore/QFile> #include "wmfserviceplugin.h" -#if QT_CONFIG(wmf_player) #include "mfplayerservice.h" -#endif #include "mfdecoderservice.h" #include <mfapi.h> @@ -74,12 +72,11 @@ void releaseRefCount() QMediaService* WMFServicePlugin::create(QString const& key) { -#if QT_CONFIG(wmf_player) if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER)) { addRefCount(); return new MFPlayerService; } -#endif + if (key == QLatin1String(Q_MEDIASERVICE_AUDIODECODER)) { addRefCount(); return new MFAudioDecoderService; @@ -97,13 +94,9 @@ void WMFServicePlugin::release(QMediaService *service) QMediaServiceProviderHint::Features WMFServicePlugin::supportedFeatures( const QByteArray &service) const { -#if QT_CONFIG(wmf_player) if (service == Q_MEDIASERVICE_MEDIAPLAYER) return QMediaServiceProviderHint::StreamPlayback; else -#else - Q_UNUSED(service); -#endif return QMediaServiceProviderHint::Features(); } diff --git a/src/plugins/wmf/wmfserviceplugin.h b/src/plugins/wmf/wmfserviceplugin.h index 826ca1d26..493a0b08c 100644 --- a/src/plugins/wmf/wmfserviceplugin.h +++ b/src/plugins/wmf/wmfserviceplugin.h @@ -55,11 +55,8 @@ class WMFServicePlugin Q_INTERFACES(QMediaServiceSupportedDevicesInterface) Q_INTERFACES(QMediaServiceDefaultDeviceInterface) Q_INTERFACES(QMediaServiceFeaturesInterface) -#if QT_CONFIG(wmf_player) Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "wmf.json") -#else - Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "wmf_audiodecode.json") -#endif + public: QMediaService* create(QString const& key); void release(QMediaService *service); diff --git a/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp b/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp index 3c6a6f9c5..fccab54ab 100644 --- a/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp +++ b/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp @@ -878,4 +878,28 @@ void QDeclarativeVideoOutput::_q_invalidateSceneGraph() m_backend->invalidateSceneGraph(); } +/*! + \qmlproperty enumeration QtMultimedia::VideoOutput::flushMode + + Set this property to define what \c VideoOutput should show + when playback is finished or stopped. + + \list + \li EmptyFrame - clears video output. + \li FirstFrame - shows the first valid frame. + \li LastFrame - shows the last valid frame. + \endlist + + The default flush mode is EmptyFrame. +*/ + +void QDeclarativeVideoOutput::setFlushMode(FlushMode mode) +{ + if (m_flushMode == mode) + return; + + m_flushMode = mode; + emit flushModeChanged(); +} + QT_END_NAMESPACE diff --git a/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp b/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp index c51aec088..5cb4689cc 100644 --- a/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp +++ b/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp @@ -46,6 +46,7 @@ #include <QtCore/qloggingcategory.h> #include <private/qmediapluginloader_p.h> #include <private/qsgvideonode_p.h> +#include <private/qvideoframe_p.h> #include <QtGui/QOpenGLContext> #include <QtQuick/QQuickWindow> @@ -210,13 +211,13 @@ void QDeclarativeVideoRendererBackend::releaseControl() QSize QDeclarativeVideoRendererBackend::nativeSize() const { - return m_surface->surfaceFormat().sizeHint(); + return m_surfaceFormat.sizeHint(); } void QDeclarativeVideoRendererBackend::updateGeometry() { - const QRectF viewport = videoSurface()->surfaceFormat().viewport(); - const QSizeF frameSize = videoSurface()->surfaceFormat().frameSize(); + const QRectF viewport = m_surfaceFormat.viewport(); + const QSizeF frameSize = m_surfaceFormat.frameSize(); const QRectF normalizedViewport(viewport.x() / frameSize.width(), viewport.y() / frameSize.height(), viewport.width() / frameSize.width(), @@ -257,13 +258,13 @@ void QDeclarativeVideoRendererBackend::updateGeometry() } } - if (videoSurface()->surfaceFormat().scanLineDirection() == QVideoSurfaceFormat::BottomToTop) { + if (m_surfaceFormat.scanLineDirection() == QVideoSurfaceFormat::BottomToTop) { qreal top = m_sourceTextureRect.top(); m_sourceTextureRect.setTop(m_sourceTextureRect.bottom()); m_sourceTextureRect.setBottom(top); } - if (videoSurface()->surfaceFormat().property("mirrored").toBool()) { + if (m_surfaceFormat.property("mirrored").toBool()) { qreal left = m_sourceTextureRect.left(); m_sourceTextureRect.setLeft(m_sourceTextureRect.right()); m_sourceTextureRect.setRight(left); @@ -294,7 +295,6 @@ QSGNode *QDeclarativeVideoRendererBackend::updatePaintNode(QSGNode *oldNode, if (m_frameChanged) { // Run the VideoFilter if there is one. This must be done before potentially changing the videonode below. if (m_frame.isValid() && !m_filters.isEmpty()) { - const QVideoSurfaceFormat surfaceFormat = videoSurface()->surfaceFormat(); for (int i = 0; i < m_filters.count(); ++i) { QAbstractVideoFilter *filter = m_filters[i].filter; QVideoFilterRunnable *&runnable = m_filters[i].runnable; @@ -309,7 +309,7 @@ QSGNode *QDeclarativeVideoRendererBackend::updatePaintNode(QSGNode *oldNode, if (i == m_filters.count() - 1) flags |= QVideoFilterRunnable::LastInChain; - QVideoFrame newFrame = runnable->run(&m_frame, surfaceFormat, flags); + QVideoFrame newFrame = runnable->run(&m_frame, m_surfaceFormat, flags); if (newFrame.isValid() && newFrame != m_frame) { isFrameModified = true; @@ -336,12 +336,13 @@ QSGNode *QDeclarativeVideoRendererBackend::updatePaintNode(QSGNode *oldNode, // Get a node that supports our frame. The surface is irrelevant, our // QSGVideoItemSurface supports (logically) anything. QVideoSurfaceFormat nodeFormat(m_frame.size(), m_frame.pixelFormat(), m_frame.handleType()); - const QVideoSurfaceFormat surfaceFormat = m_surface->surfaceFormat(); - nodeFormat.setYCbCrColorSpace(surfaceFormat.yCbCrColorSpace()); - nodeFormat.setPixelAspectRatio(surfaceFormat.pixelAspectRatio()); - nodeFormat.setScanLineDirection(surfaceFormat.scanLineDirection()); - nodeFormat.setViewport(surfaceFormat.viewport()); - nodeFormat.setFrameRate(surfaceFormat.frameRate()); + nodeFormat.setYCbCrColorSpace(m_surfaceFormat.yCbCrColorSpace()); + nodeFormat.setPixelAspectRatio(m_surfaceFormat.pixelAspectRatio()); + nodeFormat.setScanLineDirection(m_surfaceFormat.scanLineDirection()); + nodeFormat.setViewport(m_surfaceFormat.viewport()); + nodeFormat.setFrameRate(m_surfaceFormat.frameRate()); + // Update current surface format if something has changed. + m_surfaceFormat = nodeFormat; videoNode = factory->createNode(nodeFormat); if (videoNode) { qCDebug(qLcVideo) << "updatePaintNode: Video node created. Handle type:" << m_frame.handleType() @@ -367,6 +368,14 @@ QSGNode *QDeclarativeVideoRendererBackend::updatePaintNode(QSGNode *oldNode, if (isFrameModified) flags |= QSGVideoNode::FrameFiltered; videoNode->setCurrentFrame(m_frame, flags); + + if ((q->flushMode() == QDeclarativeVideoOutput::FirstFrame && !m_frameOnFlush.isValid()) + || q->flushMode() == QDeclarativeVideoOutput::LastFrame) { + m_frameOnFlush = m_surfaceFormat.handleType() == QAbstractVideoBuffer::NoHandle + ? m_frame + : qt_imageFromVideoFrame(m_frame); + } + //don't keep the frame for more than really necessary m_frameChanged = false; m_frame = QVideoFrame(); @@ -403,7 +412,7 @@ QOpenGLContext *QDeclarativeVideoRendererBackend::glContext() const void QDeclarativeVideoRendererBackend::present(const QVideoFrame &frame) { m_frameMutex.lock(); - m_frame = frame; + m_frame = frame.isValid() ? frame : m_frameOnFlush; m_frameChanged = true; m_frameMutex.unlock(); @@ -450,10 +459,12 @@ QList<QVideoFrame::PixelFormat> QSGVideoItemSurface::supportedPixelFormats( bool QSGVideoItemSurface::start(const QVideoSurfaceFormat &format) { qCDebug(qLcVideo) << "Video surface format:" << format << "all supported formats:" << supportedPixelFormats(format.handleType()); + m_backend->m_frameOnFlush = QVideoFrame(); if (!supportedPixelFormats(format.handleType()).contains(format.pixelFormat())) return false; + m_backend->m_surfaceFormat = format; return QAbstractVideoSurface::start(format); } diff --git a/src/qtmultimediaquicktools/qdeclarativevideooutput_render_p.h b/src/qtmultimediaquicktools/qdeclarativevideooutput_render_p.h index 4f1a90c8b..c69e74150 100644 --- a/src/qtmultimediaquicktools/qdeclarativevideooutput_render_p.h +++ b/src/qtmultimediaquicktools/qdeclarativevideooutput_render_p.h @@ -100,8 +100,10 @@ private: QPointer<QVideoRendererControl> m_rendererControl; QList<QSGVideoNodeFactoryInterface*> m_videoNodeFactories; QSGVideoItemSurface *m_surface; + QVideoSurfaceFormat m_surfaceFormat; QOpenGLContext *m_glContext; QVideoFrame m_frame; + QVideoFrame m_frameOnFlush; bool m_frameChanged; QSGVideoNodeFactory_YUV m_i420Factory; QSGVideoNodeFactory_RGB m_rgbFactory; |