summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-05-10 11:35:18 +0200
committerLars Knoll <lars.knoll@qt.io>2021-05-18 08:41:33 +0000
commitf6b68bb6834214dd3a05f95421b0ae5aa2404b03 (patch)
tree789a645137a9e2aa63f1f4cf09142a1a3dda6d25
parent4a2d272886eeb4f61c4830dbe1f3a0421d167fda (diff)
Doc improvements
Try to add at least a short class overview to every C++ class and document most properties there. Some API cleanups in QMediaRecorder. Some rough cleanups in the overview documentation, removing mentions of features and APIs that do not exist anymore and adjust the ones that have changed. Updated the changes.qdoc file to now reflect the changes from Qt 5 to Qt 6, not from Qt 4 to Qt 5 anymore. Change-Id: I42f4994d3af4d35ab5e51afe351afa653964bea8 Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r--src/multimedia/doc/snippets/multimedia-snippets/audiorecorder.cpp210
-rw-r--r--src/multimedia/doc/snippets/multimedia-snippets/camera.cpp2
-rw-r--r--src/multimedia/doc/snippets/multimedia-snippets/media.cpp24
-rw-r--r--src/multimedia/doc/src/audiooverview.qdoc22
-rw-r--r--src/multimedia/doc/src/cameraoverview.qdoc74
-rw-r--r--src/multimedia/doc/src/changes.qdoc142
-rw-r--r--src/multimedia/doc/src/multimedia.qdoc19
-rw-r--r--src/multimedia/doc/src/multimediabackend.qdoc46
-rw-r--r--src/multimedia/doc/src/platform-notes-apple.qdoc (renamed from src/multimedia/doc/src/platform-notes-ios.qdoc)8
-rw-r--r--src/multimedia/doc/src/platform-notes-gstreamer-on-android.qdoc59
-rw-r--r--src/multimedia/doc/src/platform-notes-windows.qdoc59
-rw-r--r--src/multimedia/doc/src/qtaudioengine.qdoc59
-rw-r--r--src/multimedia/doc/src/qtmultimedia-index.qdoc10
-rw-r--r--src/multimedia/doc/src/qtmultimedia5.qdoc16
-rw-r--r--src/multimedia/doc/src/videooverview.qdoc32
-rw-r--r--src/multimedia/qmediadevices.cpp32
-rw-r--r--src/multimedia/qmediametadata.cpp78
-rw-r--r--src/multimedia/qmediametadata.h6
-rw-r--r--src/multimedia/recording/qmediacapturesession.cpp60
-rw-r--r--src/multimedia/recording/qmediaencoder.cpp7
-rw-r--r--src/multimedia/recording/qmediarecorder.cpp50
-rw-r--r--src/multimedia/recording/qmediarecorder.h17
-rw-r--r--src/multimedia/video/qvideoframe.cpp117
-rw-r--r--src/multimedia/video/qvideoframeformat.cpp144
-rw-r--r--src/multimedia/video/qvideosink.cpp3
-rw-r--r--tests/auto/unit/multimedia/qaudiorecorder/tst_qaudiorecorder.cpp7
26 files changed, 444 insertions, 859 deletions
diff --git a/src/multimedia/doc/snippets/multimedia-snippets/audiorecorder.cpp b/src/multimedia/doc/snippets/multimedia-snippets/audiorecorder.cpp
deleted file mode 100644
index bf4a321ea..000000000
--- a/src/multimedia/doc/snippets/multimedia-snippets/audiorecorder.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $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 <QtWidgets>
-
-#include <qaudiorecorder.h>
-
-#include <QtMultimedia/qaudioformat.h>
-
-#include "audiorecorder.h"
-
-AudioRecorder::AudioRecorder()
-{
-//! [create-objs-1]
- capture = new QAudioRecorder();
-//! [create-objs-1]
-
- // set a default file
- capture->setOutputLocation(QUrl("test.raw"));
-
- QWidget *window = new QWidget;
- QGridLayout* layout = new QGridLayout;
-
- QLabel* deviceLabel = new QLabel;
- deviceLabel->setText("Devices");
- deviceBox = new QComboBox(this);
- deviceBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
-
- QLabel* codecLabel = new QLabel;
- codecLabel->setText("Codecs");
- codecsBox = new QComboBox(this);
- codecsBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
-
- QLabel* qualityLabel = new QLabel;
- qualityLabel->setText("Quality");
- qualityBox = new QComboBox(this);
- qualityBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
-
-//! [device-list]
- for(int i = 0; i < audiosource->deviceCount(); i++)
- deviceBox->addItem(audiosource->name(i));
-//! [device-list]
-
-//! [codec-list]
- QStringList codecs = capture->supportedAudioCodecs();
- for(int i = 0; i < codecs.count(); i++)
- codecsBox->addItem(codecs.at(i));
-//! [codec-list]
-
- qualityBox->addItem("Low");
- qualityBox->addItem("Medium");
- qualityBox->addItem("High");
-
- connect(capture, SIGNAL(durationChanged(qint64)), this, SLOT(updateProgress(qint64)));
- connect(capture, SIGNAL(stateChanged(QMediaRecorder::State)), this, SLOT(stateChanged(QMediaRecorder::State)));
-
- layout->addWidget(deviceLabel,0,0,Qt::AlignHCenter);
- connect(deviceBox,SIGNAL(activated(int)),SLOT(deviceChanged(int)));
- layout->addWidget(deviceBox,0,1,1,3,Qt::AlignLeft);
-
- layout->addWidget(codecLabel,1,0,Qt::AlignHCenter);
- connect(codecsBox,SIGNAL(activated(int)),SLOT(codecChanged(int)));
- layout->addWidget(codecsBox,1,1,Qt::AlignLeft);
-
- layout->addWidget(qualityLabel,1,2,Qt::AlignHCenter);
- connect(qualityBox,SIGNAL(activated(int)),SLOT(qualityChanged(int)));
- layout->addWidget(qualityBox,1,3,Qt::AlignLeft);
-
- fileButton = new QPushButton(this);
- fileButton->setText(tr("Output File"));
- connect(fileButton,SIGNAL(clicked()),SLOT(selectOutputFile()));
- layout->addWidget(fileButton,3,0,Qt::AlignHCenter);
-
- button = new QPushButton(this);
- button->setText(tr("Record"));
- connect(button,SIGNAL(clicked()),SLOT(toggleRecord()));
- layout->addWidget(button,3,3,Qt::AlignHCenter);
-
- recTime = new QLabel;
- recTime->setText("0 sec");
- layout->addWidget(recTime,4,0,Qt::AlignHCenter);
-
- window->setLayout(layout);
- setCentralWidget(window);
- window->show();
-
- active = false;
-}
-
-AudioRecorder::~AudioRecorder()
-{
- delete capture;
- delete audiosource;
-}
-
-void AudioRecorder::updateProgress(qint64 pos)
-{
- currentTime = pos;
- if(currentTime == 0) currentTime = 1;
- QString text = QString("%1 secs").arg(currentTime/1000);
- recTime->setText(text);
-}
-
-void AudioRecorder::stateChanged(QMediaRecorder::State state)
-{
- qWarning()<<"stateChanged() "<<state;
-}
-
-void AudioRecorder::deviceChanged(int idx)
-{
-//! [get-device]
- for(int i = 0; i < audiosource->deviceCount(); i++) {
- if(deviceBox->itemText(idx).compare(audiosource->name(i)) == 0)
- audiosource->setSelectedDevice(i);
- }
-//! [get-device]
-}
-
-void AudioRecorder::codecChanged(int idx)
-{
- Q_UNUSED(idx);
- //capture->setAudioCodec(codecsBox->itemText(idx));
-}
-
-void AudioRecorder::qualityChanged(int idx)
-{
- Q_UNUSED(idx);
- /*
- if(capture->audioCodec().compare("audio/x-raw") == 0) {
- if(qualityBox->itemText(idx).compare("Low") == 0) {
- // 8000Hz mono is 8kbps
- capture->setAudioBitrate(8);
- } else if(qualityBox->itemText(idx).compare("Medium") == 0) {
- // 22050Hz mono is 44.1kbps
- capture->setAudioBitrate(44);
- } else if(qualityBox->itemText(idx).compare("High") == 0) {
- // 44100Hz mono is 88.2kbps
- capture->setAudioBitrate(88);
- }
- }
- */
-}
-
-//! [toggle-record]
-void AudioRecorder::toggleRecord()
-{
- if(!active) {
- recTime->setText("0 sec");
- currentTime = 0;
- capture->record();
-
- button->setText(tr("Stop"));
- active = true;
- } else {
- capture->stop();
- button->setText(tr("Record"));
- active = false;
- }
-}
-//! [toggle-record]
-
-void AudioRecorder::selectOutputFile()
-{
- QStringList fileNames;
-
- QFileDialog dialog(this);
-
- dialog.setFileMode(QFileDialog::AnyFile);
- if (dialog.exec())
- fileNames = dialog.selectedFiles();
-
- if(fileNames.size() > 0)
- capture->setOutputLocation(QUrl(fileNames.first()));
-}
diff --git a/src/multimedia/doc/snippets/multimedia-snippets/camera.cpp b/src/multimedia/doc/snippets/multimedia-snippets/camera.cpp
index 48f63e797..80d4853f7 100644
--- a/src/multimedia/doc/snippets/multimedia-snippets/camera.cpp
+++ b/src/multimedia/doc/snippets/multimedia-snippets/camera.cpp
@@ -100,7 +100,7 @@ void overview_surface()
camera->setVideoOutput(mySink);
camera->start();
- // MyVideoSurface::newVideoFrame(..) will be called with video frames
+ // MyVideoSink::newVideoFrame(..) will be called with video frames
//! [Camera overview surface]
}
diff --git a/src/multimedia/doc/snippets/multimedia-snippets/media.cpp b/src/multimedia/doc/snippets/multimedia-snippets/media.cpp
index 87eb5999c..fcd1a6b17 100644
--- a/src/multimedia/doc/snippets/multimedia-snippets/media.cpp
+++ b/src/multimedia/doc/snippets/multimedia-snippets/media.cpp
@@ -51,6 +51,7 @@
#include "qcamera.h"
#include "qcameraviewfinder.h"
#include "qaudiorecorder.h"
+#include "qurl.h"
#include <QVideoSink>
class MediaExample : public QObject {
@@ -75,7 +76,6 @@ private:
QCameraViewfinder *viewfinder;
QCameraImageCapture *imageCapture;
QString fileName;
- QAudioRecorder *audioRecorder;
QMediaContent image1;
QMediaContent image2;
@@ -147,29 +147,17 @@ void MediaExample::MediaRecorder()
void MediaExample::AudioRecorder()
{
//! [Audio recorder]
- audioRecorder = new QAudioRecorder;
+ QMediaRecorder recorder;
+ recorder.setCaptureMode(QMediaRecorder::AudioOnly);
QMediaEncoderSettings audioSettings;
audioSettings.setFormat(QMediaEncoderSettings::MP3);
audioSettings.setQuality(QMediaEncoderSettings::HighQuality);
- audioRecorder->setEncodingSettings(audioSettings);
+ recorder.setEncoderSettings(audioSettings);
- audioRecorder->setOutputLocation(QUrl::fromLocalFile("test.amr"));
- audioRecorder->record();
+ recorder.setOutputLocation(QUrl::fromLocalFile("test.amr"));
+ recorder.record();
//! [Audio recorder]
-
- //! [Audio recorder inputs]
- const QStringList inputs = audioRecorder->audioInputs();
- QString selectedInput = audioRecorder->defaultAudioInput();
-
- for (const QString &input : inputs) {
- QString description = audioRecorder->audioInputDescription(input);
- // show descriptions to user and allow selection
- selectedInput = input;
- }
-
- audioRecorder->setAudioInput(selectedInput);
- //! [Audio recorder inputs]
}
diff --git a/src/multimedia/doc/src/audiooverview.qdoc b/src/multimedia/doc/src/audiooverview.qdoc
index 30f94d548..e74b285c7 100644
--- a/src/multimedia/doc/src/audiooverview.qdoc
+++ b/src/multimedia/doc/src/audiooverview.qdoc
@@ -33,19 +33,16 @@
\section1 Audio Features
Qt Multimedia offers a range of audio classes, covering both low and
-high level approaches to audio input, output and processing. In
-addition to traditional audio usage, the \l{Qt Audio Engine QML Types}{Qt Audio Engine}
-QML types offer high level 3D positional audio for QML applications.
-See that documentation for more information.
+high level approaches to audio input, output and processing.
\section1 Audio Implementation Details
\section2 Playing Compressed Audio
For playing media or audio files that are not simple, uncompressed audio, you can
-use the \l QMediaPlayer C++ class, or the \l {Audio} and \l {MediaPlayer} QML types.
+use the \l QMediaPlayer C++ class, or the \l {MediaPlayer} QML type.
The QMediaPlayer class and associated QML types are also capable of playing
\l{multimedia-playing-video}{video}, if required. The compressed audio formats supported does depend
-on the operating system environment, and also what media plugins the user
+on the operating system environment, and also what decoder plugins the user
may have installed.
Here is how you play a local file using C++:
@@ -56,18 +53,19 @@ You can also put files (even remote URLs) into a playlist:
\snippet multimedia-snippets/media.cpp Audio playlist
\section2 Recording Audio to a File
-For recording audio to a file, the \l {QAudioRecorder} class allows you
+For recording audio to a file, the \l {QMediaRecorder} class allows you
to compress audio data from an input device and record it.
\snippet multimedia-snippets/media.cpp Audio recorder
+\l {QMediaCaptureSession} provides support for more complex capturing and recording use cases.
+
\section2 Low Latency Sound Effects
In addition to the raw access to sound devices described above, the QSoundEffect class (and
\l {SoundEffect} QML type) offers a slightly higher level way to play
-sounds. These classes allow you to specify a WAV format file which can
-then be played with low latency when necessary. Both QSoundEffect and
-SoundEffect have essentially the same API.
+sounds. This class allows you to specify a WAV format file which can
+then be played with low latency when necessary.
You can adjust the number of \l {QSoundEffect::loopCount()}{loops} a sound effect is played, as well as
the \l {QSoundEffect::setVolume()}{volume} (or \l {QSoundEffect::setMuted()}{muting}) of the effect.
@@ -80,9 +78,7 @@ these classes do not do any audio decoding, or other processing, but they
can support different types of raw audio data.
The QAudioOutput class offers raw audio data output, while QAudioInput
-offers raw audio data input. Both classes have adjustable buffers and
-latency, so they are suitable for both low latency use cases (like games
-or VOIP) and high latency (like music playback). The available hardware
+offers raw audio data input. The available hardware
determines what audio outputs and inputs are available.
\section3 Push and Pull
diff --git a/src/multimedia/doc/src/cameraoverview.qdoc b/src/multimedia/doc/src/cameraoverview.qdoc
index 6ae14c015..f832bc6bb 100644
--- a/src/multimedia/doc/src/cameraoverview.qdoc
+++ b/src/multimedia/doc/src/cameraoverview.qdoc
@@ -98,12 +98,12 @@ check in C++, use the \l QCameraInfo::availableCameras() function, as shown in t
\snippet multimedia-snippets/camera.cpp Camera overview check
-In QML, use the \l{QtMultimedia::QtMultimedia::availableCameras}{QtMultimedia.availableCameras}
+In QML, use the \l{QtMultimedia::MediaDevices::availableCameras}{MediaDevices.availableCameras}
property:
\qml
Item {
- property bool isCameraAvailable: QtMultimedia.availableCameras.length > 0
+ property bool isCameraAvailable: MediaDevices.availableCameras.length > 0
}
\endqml
@@ -116,16 +116,16 @@ In C++:
\snippet multimedia-snippets/camera.cpp Camera selection
-In QML, you can set the \c Camera \l{Camera::deviceId}{deviceId} property. All available IDs can
-be retrieved from \l{QtMultimedia::QtMultimedia::availableCameras}{QtMultimedia.availableCameras}:
+In QML, you can set the \c Camera \l{Camera::cameraInfo}{cameraInfo} property. All available cameras can
+be retrieved from \l{QtMultimedia::MediaDevices::availableCameras}{MediaDevices.availableCameras}:
\qml
Camera {
- deviceId: QtMultimedia.availableCameras[0].deviceId
+ cameraInfo: QtMultimedia.availableCameras[0]
}
\endqml
-You can also select the camera by its physical position on the system rather than its device ID.
+You can also select the camera by its physical position on the system rather than by camera info.
This is useful on mobile devices, which often have a front-facing and a back-facing camera.
In C++:
@@ -140,50 +140,51 @@ Camera {
}
\endqml
-If neither device ID nor position is specified, the default camera will be used. On desktop
+If neither cameraInfo nor position is specified, the default camera will be used. On desktop
platforms, the default camera is set by the user in the system settings. On a mobile device, the
back-facing camera is usually the default camera. You can get information about the default camera
using \l QCameraInfo::defaultCamera() in C++ or
-\l{QtMultimedia::QtMultimedia::defaultCamera}{QtMultimedia.defaultCamera} in QML.
+\l{QtMultimedia::MediaDevices::defaultCamera}{MediaDevices.defaultCamera} in QML.
-\section2 Viewfinder
+\section2 Preview
While not strictly necessary, it's often useful to be able to see
-what the camera is pointing at. Most digital cameras allow an image
-feed from the camera sensor at a lower resolution (usually up to
-the size of the display of the camera) so you can compose
-a photo or video, and then switch to a slower but higher resolution
-mode for capturing the image.
+what the camera is pointing at.
Depending on whether you're using QML or C++, you can do this in multiple ways.
-In QML, you can use \l Camera and \l VideoOutput together to show a
+In QML, you can use \l Camera and \l VideoOutput together in a CaptureSession to show a
simple viewfinder:
\qml
-VideoOutput {
- source: camera
+Item {
+ VideoOutput {
+ id: output
+ anchors.fill: parent
+ }
+ CaptureSession {
+ videoOutput: output
- Camera {
- id: camera
- // You can adjust various settings in here
+ Camera {
+ // You can adjust various settings in here
+ }
}
}
\endqml
In C++, your choice depends on whether you are using widgets, or QGraphicsView.
-The \l QCameraViewfinder class is used in the widgets case, and \l QGraphicsVideoItem
+The \l QVideoWidget class is used in the widgets case, and \l QGraphicsVideoItem
is useful for QGraphicsView.
\snippet multimedia-snippets/camera.cpp Camera overview viewfinder
-For advanced usage (like processing viewfinder frames as they come, to detect
-objects or patterns), you can also use your own QVideoSink and set that as the viewfinder
+For advanced usage (like processing preview frames as they come, to detect
+objects or patterns), you can also use your own QVideoSink and set that as the videoOutput
for the QCamera object. In this case you will need to render the viewfinder image yourself
by processing the data received from the newVideoFrame() signal.
\snippet multimedia-snippets/camera.cpp Camera overview surface
-On mobile devices, the viewfinder image might not always be in the orientation you would expect.
+On mobile devices, the preview image might not always be in the orientation you would expect.
The camera sensors on these devices are often mounted in landscape while the natural
orientation of the screen is portrait. This results in the image appearing sideways or inverted
depending on the device orientation. In order to reflect on screen what the user actually sees, you
@@ -196,31 +197,30 @@ account the camera sensor orientation and the current display orientation.
After setting up a viewfinder and finding something photogenic,
to capture an image we need to initialize a new QCameraImageCapture
-object. All that is then needed is to start the camera, lock it so
-that things are in focus and the settings are not different from the
-viewfinder while the image capture occurs, capture the image, and
-finally unlock the camera ready for the next photo.
+object. All that is then needed is to start the camera and capture the image.
\snippet multimedia-snippets/camera.cpp Camera overview capture
\section2 Movies
Previously we saw code that allowed the capture of a still image. Recording
-video requires the use of a \l QMediaRecorder object.
+video requires the use of a \l QMediaEncoder object.
To record video we need to create a camera object as before but this time as
well as creating a viewfinder, we will also initialize a media recorder object.
\snippet multimedia-snippets/camera.cpp Camera overview movie
-Signals from the \e mediaRecorder can be connected to slots to react to
-changes in the state of the recorder or error events. Recording itself
-starts with the \l {QMediaRecorder::record()}{record()} function of
-mediaRecorder being called, this causes the signal \l
-{QMediaRecorder::stateChanged()}{stateChanged()} to be emitted. The
-recording process can be changed with the \l {QMediaRecorder::record()}{record()},
-\l {QMediaRecorder::stop()}{stop()} and \l {QMediaRecorder::setMuted()}{setMuted()}
-slots in \l QMediaRecorder.
+Signals from the \e mediaEncoder can be connected to slots to react to
+changes in the state of the encoding process or error events. Recording itself
+starts with the \l {QMediaEncoder::record()}{record()} function of
+mediaEncoder being called, this causes the signal \l
+{QMediaEncoder::stateChanged()}{stateChanged()} to be emitted. The
+recording process can be changed with the \l {QMediaEncoder::record()}{record()},
+\l {QMediaEncoder::stop()}{stop()} slots in \l QMediaEncoder.
+
+On top of the above, QMediaRecorder provides a simple to use, but more limited all-in-one class
+for recording audio and video content.
\section2 Controlling the Imaging Pipeline
diff --git a/src/multimedia/doc/src/changes.qdoc b/src/multimedia/doc/src/changes.qdoc
index fd7188fa3..871dc92b5 100644
--- a/src/multimedia/doc/src/changes.qdoc
+++ b/src/multimedia/doc/src/changes.qdoc
@@ -32,44 +32,74 @@
\brief A description of changes in this version of Qt Multimedia
-The Qt Multimedia module in Qt 5 combines (and replaces) two older modules, namely the
-Qt Multimedia module from Qt 4.x, and Qt Multimedia Kit module from Qt Mobility.
-Existing code that uses Qt Multimedia from Qt 4 can be ported with minimal effort, but
-porting code that uses Qt Multimedia Kit may be a more involved process. The
+The Qt Multimedia module in Qt 6 replaces the Qt Multimedia module from Qt 5.x.
+Existing code that uses Qt Multimedia from Qt 5 can be ported with limited effort. The
\l {changed features} section highlights changes relevant to porting.
-Also, note that widget-based classes, such as \l QVideoWidget, are now in a separate
-module called Qt Multimedia Widgets.
-
-\section1 New features in Qt 5.0
+\section1 New features in Qt 6.0
There are a number of new features in Qt Multimedia:
\list
-\li Expanded QML API
-\li In addition to the \l Video QML type, there is now the option of using \l MediaPlayer and \l VideoOutput together
-\li QML \l Torch class
-\li New \l QAudioRecorder class
-\li Volume support for QAudioOutput and QAudioInput
-\li More examples and documentation
-\li QSound moved from Qt GUI to Qt Multimedia
-\li QSoundEffect available to C++ now, as well as QML
-\li Various other API improvements and bugfixes
+\li QMediaCaptureSession class as the central object for media capture
+\li Changed QMediaRecorder class to be a high level class for audio/video recording
+\li new QMediaEncoder class to handle encoding of data produced in a capture session
+\li Setting up the desired encodings when recording has changed significantly, see
+QMediaEncoderSettings for details
+\li Support for selection of audio, video and subtitle tracks when playing back media files
+\li QAudioDecoder is now supported on all platforms
\endlist
\section1 Removed features
-A number of classes or features previously offered in Qt Multimedia or Qt Multimedia Kit have
-been removed.
-
\table 70%
\header
\li Removed feature
\li Notes
\row
- \li QMediaImageViewer
- \li This class (and related controls and services) were removed since
- their functionality was not suitable for many applications
+ \li Playlist in QMediaPlayer
+ \li QMediaPlayer does not do any playlist handling anymore in Qt 6. The QMediaPlayList class
+ does however still exist and provides this functionality. Users will need to connect the
+ playlist to the mediaplayer themselves to handle playlists.
+ \row
+ \li QAudioProbe and QVideoProbe
+ \li The audio and video probing API has been removed. A replacement API using custom audio
+ and video outputs may be added in a future release.
+ \row
+ \li QAudioRecorder and the Audio QML type
+ \li QMediaRecorder and the MediaRecorder QML type provide the same functionality
+ \row
+ \li QMediaObject and QMediaBindableInterface
+ \li These classes have been removed in favor of a more direct API for setting up connections
+ between objects using e.g. setVideoOutput and QMediaCaptureSession.
+ \row
+ \li QCameraViewFinderSettings
+ \li This class has been removed. Use QCameraFormat to define the resolution and framerate the
+ camera should be using.
+ \row
+ \li QMediaContent
+ \li The class has been removed. Use QMediaPlayList for play lists and QUrl for individual
+ media files instead.
+ \row
+ \li QSound
+ \li Use QSoundEffect instead.
+ \row
+ \li QVideoFilterRunnable
+ \li Use shader effects in QML instead or access the QVideoFrame's content in C++.
+ \row
+ \li Backend API
+ \li The backend API of Qt Multimedia is private in Qt 6. Having a public backend API was one
+ the main things that made supporting and enhancing Qt Multimedia in Qt 5 very difficult.
+ By making the backend API private, we expect to be able to better support new multimedia
+ use cases in the future. This includes all classes the contain "Control" or "Abstract"
+ in the class name in Qt 5.
+ \row
+ \li Pluggable backends
+ \li Qt Multimedia in Qt 6 does not use a plugin infrastructure for its backends anymore.
+ This means that users do not need to ship those backends with their application anymore
+ neither. Instead the backend being used is determined at compile time based on the
+ underlying operating system. Qt uses gstreamer on Linux, WMF on Windows, AVFoundation
+ on macOS and iOS and the Android multimedia APIs on Android.
\endtable
\section1 Changed features
@@ -82,59 +112,27 @@ changed in ways that may affect previously written code. This table highlights s
\li Changed feature
\li Notes
\row
- \li \c qmake project file changes
- \li Previously, to use Qt Multimedia Kit, the \c qmake project file must contain
- \code
- CONFIG += mobility
- MOBILITY += multimedia
- \endcode
- Now, you only need to write
- \code
- QT += multimedia
- \endcode
- Or, if you want to use the widget classes,
- \code
- QT += multimedia multimediawidgets
- \endcode
+ \li Handling of Camera resolutions and frame rates
+ \li Handling of those has been simplified and a new QCameraFormat class helps selecting
+ the correct resolution and frame rate on the camera.
\row
- \li Namespaces
- \li The \c QtMultimediaKit namespace has been renamed to QMultimedia. This
- affects a few enumerations, namely \c SupportEstimate, \c EncodingQuality,
- \c EncodingMode and \c AvailabilityStatus. Searching and replacing
- \c QtMultimediaKit with \c QMultimedia will greatly aid porting efforts. Metadata
- have been split off into their own namespace, QMediaMetaData.
+ \li Video output handling on the C++ side has changed significantly.
+ \li QAbstractVideoSurface has been replaced by the QVideoSink class, and generic rendering
+ support has been enhanced to cover all pixel formats supported by Qt Multimedia
\row
\li Metadata types
- \li In Qt Multimedia Kit, pre-defined metadata keys were enumerations in the
- \c QtMultimediaKit namespace. These pre-defined keys have been changed to
- string literals in the \c QMediaMetaData namespace, for consistency with
- extended keys.
- \row
- \li Metadata accessor methods
- \li In Qt Multimedia Kit, there were two different families of methods to access
- metadata. Functions such as \c QMediaObject::metaData() operated on pre-defined
- metadata using enumerated keys, while functions such as
- \c QMediaObject::extendedMetaData() operated on extended metadata using
- string keys. Qt 5 combines both families into one (e.g. QMediaObject::metaData()),
- which can operate on both pre-defined and extended metadata, using string keys.
+ \li QMediaMetaData has changed significantly, mainly moving from string based
+ to enum based keys, and reducing the set of supported keys to the ones that
+ can be supported on most platforms.
\row
- \li Qt Metatype registration
- \li Qt 5 registers many more classes and types with the meta-object system than before.
- If you have previously applied Q_DECLARE_METATYPE macros to any Qt Multimedia class,
- you will probably need to remove them.
- \row
- \li QSoundEffect availability
- \li The SoundEffect QML type was publicly accessible in Qt Multimeda Kit,
- and now the C++ version is officially public too. If your code contains the
- previously undocumented QSoundEffect, you may need to update it.
- \row
- \li Camera controls
- \li A large number of the camera controls (QCameraImageProcessingControl,
- QCameraFocusControl, etc.) have been updated to address a number of
- design flaws. In particular, a number of discrete
- accessor methods have been collapsed into parametrized methods, and
- the ranges or data types of some parameters have been adjusted.
-
+ \li QMediaFormat and QMediaEncoderSettings
+ \li Handling of formats for encoded media and the settings for the media encoder have
+ changed significantly. While Qt 5 provided a string based API and separated file format,
+ audio and video codecs into 3 classes, Qt 6 does unify the formats in the QMediaFormat class,
+ and encoder settings in QMediaEncoderSettings. Setting up of file formats and codecs is now
+ enum based and doesn't use strings anymore. This puts some limitations on the set of codecs
+ that can be used, but helps provide a consistent cross-platform API and reduces the changes
+ for inconsistencies.
\endtable
*/
diff --git a/src/multimedia/doc/src/multimedia.qdoc b/src/multimedia/doc/src/multimedia.qdoc
index f0272c4b1..804333db3 100644
--- a/src/multimedia/doc/src/multimedia.qdoc
+++ b/src/multimedia/doc/src/multimedia.qdoc
@@ -153,31 +153,18 @@ The Qt Multimedia APIs build upon the multimedia framework of the underlying
platform. This can mean that support for various codecs or containers can vary
between machines, depending on what the end user has installed.
-\section1 Advanced Usage
-
-For developers wishing to access some platform specific settings, or to port the
-Qt Multimedia APIs to a new platform or technology, see \l{Multimedia Backend
-Development}.
-
\section1 Changes from Previous Versions
-If you previously used Qt Multimedia in Qt 4, or used Qt Multimedia Kit in
-Qt Mobility, please see \l {Changes in Qt Multimedia} for more information on
-what changed, and what you might need to change when porting code.
+If you previously used Qt Multimedia in Qt 5, please see \l {Changes in Qt Multimedia}
+for more information on what changed, and what you might need to change when porting code.
\section1 Reference Documentation
\section2 QML Types
The QML types are accessed by using:
\code
-import QtMultimedia 5.8
+import QtMultimedia
\endcode
-\annotatedlist multimedia_qml
-The following types are accessed by using \l{Qt Audio Engine QML Types}{Qt Audio Engine}:
-\qml \QtMinorVersion
-import QtAudioEngine 1.\1
-\endqml
-\annotatedlist multimedia_audioengine
\section2 Multimedia Classes
diff --git a/src/multimedia/doc/src/multimediabackend.qdoc b/src/multimedia/doc/src/multimediabackend.qdoc
deleted file mode 100644
index 39b2841a2..000000000
--- a/src/multimedia/doc/src/multimediabackend.qdoc
+++ /dev/null
@@ -1,46 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-/*!
-
-\title Multimedia Backend Development
-\page multimediabackend.html
-\brief Information for implementing a new multimedia backend.
-\ingroup mobility
-
-\tableofcontents
-
-\section1 Overview
-
-A multimedia backend provides the glue between platform-specific libraries, and
-Qt Multimedia. In some cases the available cross-platform Multimedia APIs or
-implementations are not sufficient, or not immediately available on a certain
-platform.
-*/
-
-
diff --git a/src/multimedia/doc/src/platform-notes-ios.qdoc b/src/multimedia/doc/src/platform-notes-apple.qdoc
index db5cd6d5a..ac0655c5b 100644
--- a/src/multimedia/doc/src/platform-notes-ios.qdoc
+++ b/src/multimedia/doc/src/platform-notes-apple.qdoc
@@ -26,17 +26,17 @@
****************************************************************************/
/*!
-\page qtmultimedia-ios.html
+\page qtmultimedia-apple.html
\title Qt Multimedia on iOS
\brief Platform notes for iOS
-This page covers the availability of Qt Multimedia features on iOS.
+This page covers the availability of Qt Multimedia features on iOS and macOS.
\section1 Limitations
-Since Qt Multimedia for iOS uses the camera, the \c Info.plist assigned to
+Since Qt Multimedia for iOS uses the camera and microphone, the \c Info.plist assigned to
QMAKE_INFO_PLIST in the project file must contain the key
-\c NSCameraUsageDescription. Otherwise the application will
+\c NSCameraUsageDescription and NSMicrophoneUsageDescription. Otherwise the application will
abort on startup. See Info.plist documentation from Apple for more information
regarding this key.
diff --git a/src/multimedia/doc/src/platform-notes-gstreamer-on-android.qdoc b/src/multimedia/doc/src/platform-notes-gstreamer-on-android.qdoc
deleted file mode 100644
index 51836d99a..000000000
--- a/src/multimedia/doc/src/platform-notes-gstreamer-on-android.qdoc
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page platform-notes-gstreamer-on-android.html
-\title Qt Multimedia GStreamer on Android
-\brief Platform notes for GStreamer on Android
-\since 5.14
-
-This page covers the availability of GStreamer on Android.
-
-\section1 Limitations
-
-Since GStreamer is licensed under LGPL and distributed in archives (and should be statically linked),
-Qt Multimedia does not provide support of GStreamer on Android by default.
-
-Therefore GStreamer support must be explicitly enabled by configuring Qt with the \c -gstreamer option.
-
-\section1 Setup
-
-The GStreamer project provides prebuilt binaries which you can download and unzip into any location of your choice.
-
-The environment variable \c GSTREAMER_ROOT_ANDROID should be set to the location where you unzipped the downloaded package.
-
-\section1 Application
-
-Qt Multimedia does not contain any plugins and all needed plugins must be included
-and registered in applications manually by \c GST_PLUGIN_STATIC_DECLARE and \c GST_PLUGIN_STATIC_REGISTER
-after \c gst_init().
-
-Please refer to the official manual on how to statically link plugins to an application.
-
-https://gstreamer.freedesktop.org/documentation/gstreamer/gstplugin.html?gi-language=c#GST_PLUGIN_STATIC_REGISTER
-
-*/
diff --git a/src/multimedia/doc/src/platform-notes-windows.qdoc b/src/multimedia/doc/src/platform-notes-windows.qdoc
deleted file mode 100644
index 3b8d6aa18..000000000
--- a/src/multimedia/doc/src/platform-notes-windows.qdoc
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page qtmultimedia-windows.html
-\title Qt Multimedia on Windows
-\brief Platform notes for Windows
-
-This page covers the availability of Qt Multimedia features on Windows.
-
-\section1 Implementation
-
-Qt Multimedia features for Windows are implemented in two plugins; one
-using the Microsoft DirectShow API, and another using WMF (Windows Media
-Foundation) framework. DirectShow API was introduced in Windows 98, and
-gradually deprecated from Windows XP onwards. Media Foundation framework
-was introduced in Windows Vista as a replacement for DirectShow and other
-multimedia APIs. Consequently, WMF plugin in Qt is supported only for
-Windows Vista and later versions of the operating system.
-
-The environment variable \c QT_MULTIMEDIA_PREFERRED_PLUGINS can be used to
-control the priority of the plugins. For example, setting it to
-"windowsmediafoundation" or "directshow" will cause the corresponding plugin
-to be the preferred one.
-
-\section1 Limitations
-
-The WMF plugin in Qt does not currently provide a camera backend. Instead,
-limited support for camera features is provided by the DirectShow
-plugin. Basic features such as displaying a viewfinder and capturing a
-still image are supported, however, majority of camera controls are not
-implemented.
-
-Video recording is currently not supported.
-*/
diff --git a/src/multimedia/doc/src/qtaudioengine.qdoc b/src/multimedia/doc/src/qtaudioengine.qdoc
deleted file mode 100644
index c45d4e8af..000000000
--- a/src/multimedia/doc/src/qtaudioengine.qdoc
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\qmlmodule QtAudioEngine 1.\QtMinorVersion
-\title Qt Audio Engine QML Types
-\ingroup qmlmodules
-\brief Provides QML types for 3D positional audio playback and content management.
-
-Qt Audio Engine is part of the \l{Qt Multimedia} module. Qt Audio
-Engine provides types for 3D positional audio playback and content management.
-
-The QML types can be imported into your application using the following import
-statement in your .qml file:
-\qml \QtMinorVersion
-import QtAudioEngine 1.\1
-\endqml
-
-\section1 Qt Audio Engine Features
-
-Qt Audio Engine enables developers to organize wave files into discrete \l Sound
-with different \l {PlayVariation}{play variations}, group sound controls by \l
-{AudioCategory} categories and define \l {AttenuationModelLinear}{attenuation
-models} and various 3D audio settings all in one place. Playback of \l
-{SoundInstance}{sound instances} can be conveniently activated by in-app events
-and managed by QtAudioEngine or controlled by explicitly defining \l
-SoundInstance for easier QML bindings.
-
-\section1 Examples
-\list
- \li \l {AudioEngine Example}{Audio Engine}
-\endlist
-
-\section1 QML Types
-*/
diff --git a/src/multimedia/doc/src/qtmultimedia-index.qdoc b/src/multimedia/doc/src/qtmultimedia-index.qdoc
index d2d39a5aa..607215d3b 100644
--- a/src/multimedia/doc/src/qtmultimedia-index.qdoc
+++ b/src/multimedia/doc/src/qtmultimedia-index.qdoc
@@ -159,8 +159,7 @@
following topics provide more platform-specific information.
\list
- \li \l{Qt Multimedia on Windows}{Windows}
- \li \l{Qt Multimedia on iOS}{iOS}
+ \li \l{Qt Multimedia on macOS and iOS}{iOS}
\endlist
\section2 Reference
@@ -172,13 +171,6 @@
\endlist
\endlist
- \list
- \li Qt Audio Engine
- \list
- \li \l{Qt Audio Engine QML Types}{QML Types}
- \endlist
- \endlist
-
\section2 Examples
\list
\li \l{Qt Multimedia Examples}
diff --git a/src/multimedia/doc/src/qtmultimedia5.qdoc b/src/multimedia/doc/src/qtmultimedia5.qdoc
index 461cc716f..16e0e581b 100644
--- a/src/multimedia/doc/src/qtmultimedia5.qdoc
+++ b/src/multimedia/doc/src/qtmultimedia5.qdoc
@@ -26,7 +26,7 @@
****************************************************************************/
/*!
-\qmlmodule QtMultimedia 5.\QtMinorVersion
+\qmlmodule QtMultimedia
\title Qt Multimedia QML Types
\ingroup qmlmodules
\brief Provides QML types for multimedia support.
@@ -45,22 +45,10 @@ Qt Multimedia QML types can be imported into your application using the
following import statement in your .qml file:
\qml \QtMinorVersion
-import QtMultimedia 5.\1
+import QtMultimedia
\endqml
\generatelist qmltypesbymodule QtMultimedia
-\section2 Qt Audio Engine
-
-\l {QtAudioEngine}{Qt Audio Engine} provides types for 3D positional audio
-playback and content management. These types can be imported into your
-application using the following import statement in your .qml file:
-
-\qml \QtMinorVersion
-import QtAudioEngine 1.\1
-\endqml
-
-\generatelist qmltypesbymodule QtAudioEngine
-
\noautolist
*/
diff --git a/src/multimedia/doc/src/videooverview.qdoc b/src/multimedia/doc/src/videooverview.qdoc
index 725c8873f..e3fe0175e 100644
--- a/src/multimedia/doc/src/videooverview.qdoc
+++ b/src/multimedia/doc/src/videooverview.qdoc
@@ -58,10 +58,7 @@ You can use \l VideoOutput to render content that is
provided by either a \l MediaPlayer or a \l Camera.
The VideoOutput is a visual component that can be transformed
or acted upon by shaders (as the \l {QML Video Shader Effects Example} shows), while
-all media decoding and playback control is handled by the \l MediaPlayer.
-
-Alternatively there is also a higher level \l Video type that
-acts as a single, visual element to play video and control playback.
+all media decoding and playback control is handled by the \l MediaPlayer or \l CaptureSession.
\section2 Working with Low Level Video Frames
@@ -77,32 +74,9 @@ processing. Using your own QVideoSink
allows you to receive these frames from \l QMediaPlayer and
\l QCamera.
-\snippet multimedia-snippets/video.cpp Derived Surface
-
-and with an instance of this surface, \c myVideoSurface, you can set
-the surface as the \l {QMediaPlayer::setVideoOutput()}{video output} for QMediaPlayer.
-
-\snippet multimedia-snippets/video.cpp Setting surface in player
-
-Several of the built-in Qt classes offer this functionality
-as well, so if you decode video in your application, you can present
-it to classes that offer a \l QVideoRendererControl class, and in QML
-you can set a custom object for the source of a \l VideoOutput
-with either a writable \c videoSurface property (that the instance will
-set it's internal video surface to) or a readable \c mediaObject property
-with a QMediaObject derived class that implements the \l QVideoRendererControl
-interface.
-
-The following snippet shows a class that has a writable \c videoSurface property
-and receives frames through a public slot \c onNewVideoContentReceived(). These
-frames are then presented on the surface set in \c setVideoSurface().
-
-\snippet multimedia-snippets/video.cpp Video producer
-
\section2 Recording Video
-You can use the \l QMediaRecorder class in conjunction with other
-classes to record video to disk. Primarily this is used with
-the camera, so consult the \l {Camera Overview} for more information.
+You can use the \l QMediaRecorder class as a simple way to record video to disk.
+For more advances use cases \l QMediaCaptureSession provides a more flexible API.
\section1 Examples
diff --git a/src/multimedia/qmediadevices.cpp b/src/multimedia/qmediadevices.cpp
index 36278e5e0..52ea22c99 100644
--- a/src/multimedia/qmediadevices.cpp
+++ b/src/multimedia/qmediadevices.cpp
@@ -88,27 +88,42 @@ private:
QMediaDevices is a singleton object and all getters are thread-safe.
*/
+/*!
+ Returns a list of available audio input devices on the system.
+
+ Those devices are usually microphones, either built-in, or connected to
+ the device through e.g. USB or Bluetooth.
+*/
QList<QAudioDeviceInfo> QMediaDevices::audioInputs()
{
return priv.platformDevices()->audioInputs();
}
+/*!
+ Returns a list of available audio input devices on the system.
+
+ Those devices are usually loudspeakers or head sets, either built-in,
+ or connected to the device through e.g. USB or Bluetooth.
+*/
QList<QAudioDeviceInfo> QMediaDevices::audioOutputs()
{
return priv.platformDevices()->audioOutputs();
}
/*!
- Returns a list of available cameras on the system which are located at \a position.
-
- If \a position is not specified or if the value is QCameraInfo::UnspecifiedPosition, a list of
- all available cameras will be returned.
+ Returns a list of available cameras on the system.
*/
QList<QCameraInfo> QMediaDevices::videoInputs()
{
return priv.platformDevices()->videoInputs();
}
+/*!
+ Returns the default audio input device.
+
+ The default device can change during the runtime of the application. The audioInputsChanged()
+ signal will get emitted in that case.
+*/
QAudioDeviceInfo QMediaDevices::defaultAudioInput()
{
const auto inputs = audioInputs();
@@ -118,6 +133,12 @@ QAudioDeviceInfo QMediaDevices::defaultAudioInput()
return inputs.value(0);
}
+/*!
+ Returns the default audio output device.
+
+ The default device can change during the runtime of the application. The audioOutputsChanged()
+ signal will get emitted in that case.
+*/
QAudioDeviceInfo QMediaDevices::defaultAudioOutput()
{
const auto outputs = audioOutputs();
@@ -133,6 +154,9 @@ QAudioDeviceInfo QMediaDevices::defaultAudioOutput()
The returned object should be checked using isNull() before being used, in case there is no
default camera or no cameras at all.
+ The default device can change during the runtime of the application. The videoInputsChanged()
+ signal will get emitted in that case.
+
\sa availableCameras()
*/
QCameraInfo QMediaDevices::defaultVideoInput()
diff --git a/src/multimedia/qmediametadata.cpp b/src/multimedia/qmediametadata.cpp
index 24ff74aaf..cd7c41c11 100644
--- a/src/multimedia/qmediametadata.cpp
+++ b/src/multimedia/qmediametadata.cpp
@@ -59,26 +59,19 @@ QT_BEGIN_NAMESPACE
Common attributes
\header \li Value \li Description \li Type
\row \li Title \li The title of the media. \li QString
- \row \li SubTitle \li The sub-title of the media. \li QString
\row \li Author \li The authors of the media. \li QStringList
\row \li Comment \li A user comment about the media. \li QString
\row \li Description \li A description of the media. \li QString
- \row \li Category \li The category of the media. \li QStringList
\row \li Genre \li The genre of the media. \li QStringList
\row \li Date \li The date of the media. \li QDate.
- \row \li UserRating \li A user rating of the media. \li int [0..100]
- \row \li Keywords \li A list of keywords describing the media. \li QStringList
\row \li Language \li The language of media, as an ISO 639-2 code. \li QString
\row \li Publisher \li The publisher of the media. \li QString
\row \li Copyright \li The media's copyright notice. \li QString
- \row \li ParentalRating \li The parental rating of the media. \li QString
- \row \li RatingOrganization \li The organization responsible for the parental rating of the media.
- \li QString
+ \row \li Url \li A Url pointing to the origin of the media. \li QUrl
\header \li {3,1}
Media attributes
- \row \li Size \li The size in bytes of the media. \li qint64
\row \li MediaType \li The type of the media (audio, video, etc). \li QString
\row \li FileFormat \li The file format of the media. \li QMediaFormat::FileFormat
\row \li Duration \li The duration in millseconds of the media. \li qint64
@@ -87,47 +80,35 @@ QT_BEGIN_NAMESPACE
Audio attributes
\row \li AudioBitRate \li The bit rate of the media's audio stream in bits per second. \li int
\row \li AudioCodec \li The codec of the media's audio stream. \li QMediaForma::AudioCodec
- \row \li AverageLevel \li The average volume level of the media. \li int
- \row \li ChannelCount \li The number of channels in the media's audio stream. \li int
- \row \li PeakValue \li The peak volume of the media's audio stream. \li int
- \row \li SampleRate \li The sample rate of the media's audio stream in hertz. \li int
+
+ \header \li {3,1}
+ Video attributes
+ \row \li VideoFrameRate \li The frame rate of the media's video stream. \li qreal
+ \row \li VideoBitRate \li The bit rate of the media's video stream in bits per second. \li int
+ \row \li VideoCodec \li The codec of the media's video stream. \li QMediaFormat::VideoCodec
\header \li {3,1}
Music attributes
\row \li AlbumTitle \li The title of the album the media belongs to. \li QString
\row \li AlbumArtist \li The principal artist of the album the media belongs to. \li QString
\row \li ContributingArtist \li The artists contributing to the media. \li QStringList
- \row \li Composer \li The composer of the media. \li QStringList
- \row \li Conductor \li The conductor of the media. \li QString
- \row \li Lyrics \li The lyrics to the media. \li QString
- \row \li Mood \li The mood of the media. \li QString
\row \li TrackNumber \li The track number of the media. \li int
- \row \li TrackCount \li The number of tracks on the album containing the media. \li int
+ \row \li Composer \li The composer of the media. \li QStringList
+ \row \li LeadPerformer \li The lead performer in the media. \li QStringList
- \row \li CoverArtUrlSmall \li The URL of a small cover art image. \li QUrl
- \row \li CoverArtUrlLarge \li The URL of a large cover art image. \li QUrl
+ \row \li ThumbnailImage \li An embedded thumbnail image. \li QImage
\row \li CoverArtImage \li An embedded cover art image. \li QImage
\header \li {3,1}
Image and video attributes
\row \li Resolution \li The dimensions 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
- \row \li VideoFrameRate \li The frame rate of the media's video stream. \li qreal
- \row \li VideoBitRate \li The bit rate of the media's video stream in bits per second. \li int
- \row \li VideoCodec \li The codec of the media's video stream. \li QMediaFormat::VideoCodec
+ \endtable
+*/
- \row \li PosterUrl \li The URL of a poster image. \li QUrl
- \row \li PosterImage \li An embedded poster image. \li QImage
-
- \header \li {3,1}
- Movie attributes
- \row \li ChapterNumber \li The chapter number of the media. \li int
- \row \li Director \li The director of the media. \li QString
- \row \li LeadPerformer \li The lead performer in the media. \li QStringList
- \row \li Writer \li The writer of the media. \li QStringList
+/*
+ Some potential attributes to add if we can properly support them.
+ Might require that we add EXIF support to Qt Multimedia
\header \li {3,1}
Photo attributes.
@@ -216,30 +197,32 @@ QT_BEGIN_NAMESPACE
\row \li GPSAreaInformation
\li The name of the GPS area. \li QString
- \row \li ThumbnailImage \li An embedded thumbnail image. \li QImage
\endtable
*/
-//QMetaType QMediaMetaData::typeForKey(QMediaMetaData::Key k)
-//{
-
-//}
-
/*!
- \fn QVariant QMediaMetaData::value(QMediaMetaData::Key k) const
+ \fn QVariant QMediaMetaData::value(QMediaMetaData::Key key) const
+
+ Returns the meta data value for Key \a key, or a null QVariant is not
+ meta data for the key is available.
*/
/*!
\fn void QMediaMetaData::insert(QMediaMetaData::Key k, const QVariant &value)
*/
-QString QMediaMetaData::stringValue(QMediaMetaData::Key k) const
+/*!
+ Returns the meta data for key \a key as a QString.
+
+ This is mainly meant to simplify presenting the meta data to a user.
+*/
+QString QMediaMetaData::stringValue(QMediaMetaData::Key key) const
{
- QVariant value = data.value(k);
+ QVariant value = data.value(key);
if (value.isNull())
return QString();
- switch (k) {
+ switch (key) {
// string based or convertible to string
case Title:
case Author:
@@ -284,9 +267,12 @@ QString QMediaMetaData::stringValue(QMediaMetaData::Key k) const
return QString();
}
-QString QMediaMetaData::metaDataKeyToString(QMediaMetaData::Key k)
+/*!
+ returns a string representation of \a key that can be used when presenting meta data to users.
+*/
+QString QMediaMetaData::metaDataKeyToString(QMediaMetaData::Key key)
{
- switch (k) {
+ switch (key) {
case QMediaMetaData::Title:
return (QObject::tr("Title"));
case QMediaMetaData::Author:
diff --git a/src/multimedia/qmediametadata.h b/src/multimedia/qmediametadata.h
index 87de56fdb..f8fa23098 100644
--- a/src/multimedia/qmediametadata.h
+++ b/src/multimedia/qmediametadata.h
@@ -69,9 +69,9 @@ public:
Url,
Duration,
-
MediaType,
FileFormat,
+
AudioBitRate,
AudioCodec,
VideoBitRate,
@@ -83,13 +83,13 @@ public:
ContributingArtist,
TrackNumber,
Composer,
+ LeadPerformer,
ThumbnailImage,
CoverArtImage,
Orientation,
- Resolution,
- LeadPerformer
+ Resolution
};
Q_ENUM(Key)
diff --git a/src/multimedia/recording/qmediacapturesession.cpp b/src/multimedia/recording/qmediacapturesession.cpp
index c6145523d..727f5bac6 100644
--- a/src/multimedia/recording/qmediacapturesession.cpp
+++ b/src/multimedia/recording/qmediacapturesession.cpp
@@ -85,6 +85,27 @@ public:
}
};
+/*!
+ \class QMediaCaptureSession
+
+ \brief The QMediaCaptureSession class allows capturing of audio and video content.
+ \inmodule QtMultimedia
+ \ingroup multimedia
+
+ The QMediaCaptureSession is the central class that manages capturing of media on the local device.
+
+ You can connect a camera and a microphone to QMediaCaptureSession using setCamera() and setAudioInput().
+ A preview of the captured media can be seen by setting a QVideoSink of QVideoWidget using setVideoOutput()
+ and heard by routing the audio to an output device using setAudioOutput().
+
+ You can capture still images from a camera by setting a QCameraImageCapture object on the capture session,
+ and record audio/video using a QMediaEncoder.
+
+ If you need a simple class that records media from the default camera and microphone, you can use QMediaRecorder.
+ That class uses a QMediaCaptureSession behind the scene to support audio and video capture.
+
+ \sa QCamera, QAudioDeviceInfo, QMediaEncoder, QCameraImageCapture, QMediaRecorder
+*/
/*!
Creates a session for media capture.
@@ -124,13 +145,22 @@ bool QMediaCaptureSession::isAvailable() const
}
/*!
- Creates a session for media capture.
- */
+ Returns the device that is being used to capture audio.
+*/
QAudioDeviceInfo QMediaCaptureSession::audioInput() const
{
return d_ptr->audioInput;
}
+/*!
+ Sets the audio input device to \a device. If setting it to an empty
+ QAudioDeviceInfo the capture session will use the default input as
+ defined by the operating system.
+
+ Use setMuted(), if you want to disable audio input.
+
+ \sa muted(), setMuted()
+*/
void QMediaCaptureSession::setAudioInput(const QAudioDeviceInfo &device)
{
d_ptr->audioInput = device;
@@ -178,7 +208,13 @@ void QMediaCaptureSession::setVolume(qreal volume)
d_ptr->captureSession->setVolume(volume);
}
+/*!
+ \property QMediaCaptureSession::camera
+
+ \brief the camera used to capture video.
+ Record the camera or take images by adding a camera t the capture session using this property,
+*/
QCamera *QMediaCaptureSession::camera() const
{
return d_ptr->camera;
@@ -197,6 +233,14 @@ void QMediaCaptureSession::setCamera(QCamera *camera)
emit cameraChanged();
}
+/*!
+ \property QMediaCaptureSession::imageCapture
+
+ \brief the object used to capture still images.
+
+ Add a QCameraImageCapture object to the capture session to enable
+ capturing of still images from the camera.
+*/
QCameraImageCapture *QMediaCaptureSession::imageCapture()
{
return d_ptr->imageCapture;
@@ -215,6 +259,15 @@ void QMediaCaptureSession::setImageCapture(QCameraImageCapture *imageCapture)
emit imageCaptureChanged();
}
+/*!
+ \property QMediaCaptureSession::encoder
+
+ \brief the encoder object used to capture audio/video.
+
+ Add a QMediaEncoder object to the capture session to enable
+ recording of audio and/or video from the capture session.
+*/
+
QMediaEncoder *QMediaCaptureSession::encoder()
{
return d_ptr->encoder;
@@ -292,6 +345,9 @@ void QMediaCaptureSession::setVideoOutput(QVideoSink *sink)
d->setVideoSink(sink);
}
+/*!
+ \internal
+*/
QPlatformMediaCaptureSession *QMediaCaptureSession::platformSession() const
{
return d_ptr->captureSession;
diff --git a/src/multimedia/recording/qmediaencoder.cpp b/src/multimedia/recording/qmediaencoder.cpp
index f74ee3bbc..7f48b03b1 100644
--- a/src/multimedia/recording/qmediaencoder.cpp
+++ b/src/multimedia/recording/qmediaencoder.cpp
@@ -63,11 +63,10 @@ QT_BEGIN_NAMESPACE
\ingroup multimedia
\ingroup multimedia_recording
- \brief The QMediaEncoder class is used for the recording of media content.
+ \brief The QMediaEncoder class is used for the encoding and recording a capture session.
- The QMediaEncoder class is a high level media recording class. It's not
- intended to be used alone but for accessing the media recording functions
- of other media objects, like QCamera.
+ The QMediaEncoder class is a class for encoding and recording media generated in a
+ QMediaCaptureSession.
\snippet multimedia-snippets/media.cpp Media encoder
*/
diff --git a/src/multimedia/recording/qmediarecorder.cpp b/src/multimedia/recording/qmediarecorder.cpp
index 71365a501..3a2fe5315 100644
--- a/src/multimedia/recording/qmediarecorder.cpp
+++ b/src/multimedia/recording/qmediarecorder.cpp
@@ -71,15 +71,23 @@ public:
\brief The QMediaRecorder class is used for the recording of media content.
- The QMediaRecorder class is a high level media recording class. It's not
- intended to be used alone but for accessing the media recording functions
- of other media objects, like QCamera.
+ The QMediaRecorder class is a high level media recording class. It's
+ intended to be used as a simple standalone class to record from the default
+ camera and microphone.
\snippet multimedia-snippets/media.cpp Media recorder
+
+ If you need a more flexible setup, use QMediaCaptureSession.
+
+ \sa QMediaCaptureSession
*/
/*!
- Constructs a media recorder which records the media produced by a microphone and camera.
+ Constructs a media recorder with \a parent and \a mode.
+
+ QMediaRecorder will always use the default microphone and camera of the system.
+ The CaptureMode \a mode parameter can be used to determine whether the recorder
+ should only record audio or also use the camera.
*/
QMediaRecorder::QMediaRecorder(QObject *parent, CaptureMode mode)
@@ -98,7 +106,7 @@ QMediaRecorder::QMediaRecorder(QObject *parent, CaptureMode mode)
connect(d->encoder, &QMediaEncoder::statusChanged, this, &QMediaRecorder::statusChanged);
connect(d->captureSession, &QMediaCaptureSession::mutedChanged, this, &QMediaRecorder::mutedChanged);
connect(d->captureSession, &QMediaCaptureSession::volumeChanged, this, &QMediaRecorder::volumeChanged);
- connect(d->captureSession, &QMediaCaptureSession::audioInputChanged, this, &QMediaRecorder::audioInputChanged);
+ connect(d->captureSession, &QMediaCaptureSession::videoOutputChanged, this, &QMediaRecorder::videoOutputChanged);
}
/*!
@@ -446,34 +454,36 @@ void QMediaRecorder::addMetaData(const QMediaMetaData &metaData)
*/
-/*!
- Returns the active audio input.
-*/
+QMediaCaptureSession *QMediaRecorder::captureSession() const
+{
+ Q_D(const QMediaRecorder);
+ return d->captureSession;
+}
-QAudioDeviceInfo QMediaRecorder::audioInput() const
+void QMediaRecorder::setVideoOutput(const QVariant &output)
{
- return d_ptr->captureSession->audioInput();
+ d_ptr->captureSession->setVideoOutput(output);
}
-QMediaCaptureSession *QMediaRecorder::captureSession() const
+QVariant QMediaRecorder::videoOutput() const
{
- Q_D(const QMediaRecorder);
- return d->captureSession;
+ return d_ptr->captureSession->videoOutput();
}
-/*!
- Set the active audio input to \a device.
-*/
+void QMediaRecorder::setVideoOutput(QObject *output)
+{
+ d_ptr->captureSession->setVideoOutput(output);
+}
-void QMediaRecorder::setAudioInput(const QAudioDeviceInfo &device)
+void QMediaRecorder::setVideoOutput(QVideoSink *output)
{
- d_ptr->captureSession->setAudioInput(device);
+ d_ptr->captureSession->setVideoOutput(output);
}
/*!
- \fn QMediaRecorder::audioInputChanged(const QString& name)
+ \fn QMediaRecorder::videoOutputChanged()
- Signal emitted when active audio input changes to \a name.
+ This signal is emitted when the active video output changed.
*/
QT_END_NAMESPACE
diff --git a/src/multimedia/recording/qmediarecorder.h b/src/multimedia/recording/qmediarecorder.h
index d2420b4f0..b6ea41c36 100644
--- a/src/multimedia/recording/qmediarecorder.h
+++ b/src/multimedia/recording/qmediarecorder.h
@@ -44,6 +44,8 @@
QT_BEGIN_NAMESPACE
+class QVideoSink;
+
class QMediaRecorderPrivate;
class Q_MULTIMEDIA_EXPORT QMediaRecorder : public QMediaEncoderBase
{
@@ -55,8 +57,9 @@ class Q_MULTIMEDIA_EXPORT QMediaRecorder : public QMediaEncoderBase
Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged)
Q_PROPERTY(QMediaMetaData metaData READ metaData WRITE setMetaData NOTIFY metaDataChanged)
- Q_PROPERTY(QAudioDeviceInfo audioInput READ audioInput WRITE setAudioInput NOTIFY audioInputChanged)
Q_PROPERTY(CaptureMode captureMode READ captureMode WRITE setCaptureMode NOTIFY captureModeChanged)
+ Q_PROPERTY(QVariant videoOutput READ videoOutput WRITE setVideoOutput NOTIFY videoOutputChanged)
+ Q_PROPERTY(QCamera camera READ camera)
public:
enum CaptureMode {
@@ -72,6 +75,7 @@ public:
CaptureMode captureMode() const;
void setCaptureMode(CaptureMode mode);
+ // ### Should we expose this, or restrict it to cameraFormat?
QCamera *camera() const;
QUrl outputLocation() const;
@@ -95,17 +99,20 @@ public:
void setMetaData(const QMediaMetaData &metaData);
void addMetaData(const QMediaMetaData &metaData);
- QAudioDeviceInfo audioInput() const;
-
QMediaCaptureSession *captureSession() const;
+ void setVideoOutput(const QVariant &output);
+ QVariant videoOutput() const;
+
+ void setVideoOutput(QObject *output);
+ void setVideoOutput(QVideoSink *output);
+
public Q_SLOTS:
void record();
void pause();
void stop();
void setMuted(bool muted);
void setVolume(qreal volume);
- void setAudioInput(const QAudioDeviceInfo &device);
Q_SIGNALS:
void stateChanged(QMediaRecorder::State state);
@@ -113,8 +120,8 @@ Q_SIGNALS:
void durationChanged(qint64 duration);
void mutedChanged(bool muted);
void volumeChanged(qreal volume);
- void audioInputChanged();
void captureModeChanged();
+ void videoOutputChanged();
void error(QMediaRecorder::Error error);
diff --git a/src/multimedia/video/qvideoframe.cpp b/src/multimedia/video/qvideoframe.cpp
index 40ff468cd..91fb76ce1 100644
--- a/src/multimedia/video/qvideoframe.cpp
+++ b/src/multimedia/video/qvideoframe.cpp
@@ -143,118 +143,13 @@ QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QVideoFramePrivate);
A video frame can also have timestamp information associated with it. These timestamps can be
used to determine when to start and stop displaying the frame.
- The video pixel data in a QVideoFrame is encapsulated in a QAbstractVideoBuffer. A QVideoFrame
- may be constructed from any buffer type by subclassing the QAbstractVideoBuffer class.
+ QVideoFrame objects can consume a significant amount of memory or system resources and
+ should thus not be held for longer than required by the application.
\note Since video frames can be expensive to copy, QVideoFrame is explicitly shared, so any
change made to a video frame will also apply to any copies.
*/
-/*!
- \enum QVideoFrameFormat::PixelFormat
-
- Enumerates video data types.
-
- \value Format_Invalid
- The frame is invalid.
-
- \value Format_ARGB32
- The frame is stored using a 32-bit ARGB format (0xAARRGGBB). This is equivalent to
- QImage::Format_ARGB32.
-
- \value Format_ARGB32_Premultiplied
- The frame stored using a premultiplied 32-bit ARGB format (0xAARRGGBB). This is equivalent
- to QImage::Format_ARGB32_Premultiplied.
-
- \value Format_RGB32
- The frame stored using a 32-bit RGB format (0xffRRGGBB). This is equivalent to
- QImage::Format_RGB32
-
- \value Format_BGRA32
- The frame is stored using a 32-bit BGRA format (0xBBGGRRAA).
-
- \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).
-
- \value Format_AYUV444
- The frame is stored using a packed 32-bit AYUV format (0xAAYYUUVV).
-
- \value Format_AYUV444_Premultiplied
- The frame is stored using a packed premultiplied 32-bit AYUV format (0xAAYYUUVV).
-
- \value Format_YUV420P
- The frame is stored using an 8-bit per component planar YUV format with the U and V planes
- horizontally and vertically sub-sampled, i.e. the height and width of the U and V planes are
- half that of the Y plane.
-
- \value Format_YUV422P
- The frame is stored using an 8-bit per component planar YUV format with the U and V planes
- horizontally sub-sampled, i.e. the width of the U and V planes are
- half that of the Y plane, and height of U and V planes is the same as Y.
-
- \value Format_YV12
- The frame is stored using an 8-bit per component planar YVU format with the V and U planes
- horizontally and vertically sub-sampled, i.e. the height and width of the V and U planes are
- half that of the Y plane.
-
- \value Format_UYVY
- The frame is stored using an 8-bit per component packed YUV format with the U and V planes
- horizontally sub-sampled (U-Y-V-Y), i.e. two horizontally adjacent pixels are stored as a 32-bit
- macropixel which has a Y value for each pixel and common U and V values.
-
- \value Format_YUYV
- The frame is stored using an 8-bit per component packed YUV format with the U and V planes
- horizontally sub-sampled (Y-U-Y-V), i.e. two horizontally adjacent pixels are stored as a 32-bit
- macropixel which has a Y value for each pixel and common U and V values.
-
- \value Format_NV12
- The frame is stored using an 8-bit per component semi-planar YUV format with a Y plane (Y)
- followed by a horizontally and vertically sub-sampled, packed UV plane (U-V).
-
- \value Format_NV21
- The frame is stored using an 8-bit per component semi-planar YUV format with a Y plane (Y)
- followed by a horizontally and vertically sub-sampled, packed VU plane (V-U).
-
- \value Format_IMC1
- The frame is stored using an 8-bit per component planar YUV format with the U and V planes
- horizontally and vertically sub-sampled. This is similar to the Format_YUV420P type, except
- that the bytes per line of the U and V planes are padded out to the same stride as the Y plane.
-
- \value Format_IMC2
- The frame is stored using an 8-bit per component planar YUV format with the U and V planes
- horizontally and vertically sub-sampled. This is similar to the Format_YUV420P type, except
- that the lines of the U and V planes are interleaved, i.e. each line of U data is followed by a
- line of V data creating a single line of the same stride as the Y data.
-
- \value Format_IMC3
- The frame is stored using an 8-bit per component planar YVU format with the V and U planes
- horizontally and vertically sub-sampled. This is similar to the Format_YV12 type, except that
- the bytes per line of the V and U planes are padded out to the same stride as the Y plane.
-
- \value Format_IMC4
- The frame is stored using an 8-bit per component planar YVU format with the V and U planes
- horizontally and vertically sub-sampled. This is similar to the Format_YV12 type, except that
- the lines of the V and U planes are interleaved, i.e. each line of V data is followed by a line
- of U data creating a single line of the same stride as the Y data.
-
- \value Format_Y8
- The frame is stored using an 8-bit greyscale format.
-
- \value Format_Y16
- The frame is stored using a 16-bit linear greyscale format. Little endian.
-
- \value Format_Jpeg
- The frame is stored in compressed Jpeg format.
-
- \value Format_User
- Start value for user defined pixel formats.
-*/
/*!
Constructs a null video frame.
@@ -346,10 +241,6 @@ bool QVideoFrame::operator!=(const QVideoFrame &other) const
QVideoFrame::~QVideoFrame() = default;
/*!
- \return underlying video buffer or \c null if there is none.
- \since 5.13
-*/
-/*!
Identifies whether a video frame is valid.
An invalid frame has no video buffer associated with it.
@@ -358,7 +249,7 @@ QVideoFrame::~QVideoFrame() = default;
*/
bool QVideoFrame::isValid() const
{
- return d->buffer != nullptr;
+ return d->buffer != nullptr && d->format.pixelFormat() != QVideoFrameFormat::Format_Invalid;
}
/*!
@@ -380,6 +271,8 @@ QVideoFrameFormat QVideoFrame::surfaceFormat() const
/*!
Returns the type of a video frame's handle.
+ The handle type could either be NoHandle, meaning that the frame is memory
+ based, or a RHI texture.
*/
QVideoFrame::HandleType QVideoFrame::handleType() const
{
diff --git a/src/multimedia/video/qvideoframeformat.cpp b/src/multimedia/video/qvideoframeformat.cpp
index f41d14b31..26161812b 100644
--- a/src/multimedia/video/qvideoframeformat.cpp
+++ b/src/multimedia/video/qvideoframeformat.cpp
@@ -105,24 +105,133 @@ QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QVideoFrameFormatPrivate);
\ingroup multimedia
\ingroup multimedia_video
- A video surface presents a stream of video frames. The surface's format describes the type of
+ A video sink presents a stream of video frames. QVideoFrameFormat describes the type of
the frames and determines how they should be presented.
- The core properties of a video stream required to setup a video surface are the pixel format
+ The core properties of a video stream required to setup a video sink are the pixel format
given by pixelFormat(), and the frame dimensions given by frameSize().
- If the surface is to present frames using a frame's handle a surface format will also include
- a handle type which is given by the handleType() function.
-
The region of a frame that is actually displayed on a video surface is given by the viewport().
A stream may have a viewport less than the entire region of a frame to allow for videos smaller
than the nearest optimal size of a video frame. For example the width of a frame may be
extended so that the start of each scan line is eight byte aligned.
- Other common properties are the scanLineDirection(), and frameRate().
- Additionally a stream may have some additional type specific properties which are listed by the
- dynamicPropertyNames() function and can be accessed using the property(), and setProperty()
- functions.
+ Other common properties are the scanLineDirection(), frameRate() and the yCrCbColorSpace().
+*/
+
+/*!
+ \enum QVideoFrameFormat::PixelFormat
+
+ Enumerates video data types.
+
+ \value Format_Invalid
+ The frame is invalid.
+
+ \value Format_ARGB32
+ The frame is stored using a 32-bit ARGB format (0xAARRGGBB). This is equivalent to
+ QImage::Format_ARGB32.
+
+ \value Format_ARGB32_Premultiplied
+ The frame stored using a premultiplied 32-bit ARGB format (0xAARRGGBB). This is equivalent
+ to QImage::Format_ARGB32_Premultiplied.
+
+ \value Format_RGB32
+ The frame stored using a 32-bit RGB format (0xffRRGGBB). This is equivalent to
+ QImage::Format_RGB32
+
+ \value Format_BGRA32
+ The frame is stored using a 32-bit BGRA format (0xBBGGRRAA).
+
+ \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).
+
+ \value Format_AYUV444
+ The frame is stored using a packed 32-bit AYUV format (0xAAYYUUVV).
+
+ \value Format_AYUV444_Premultiplied
+ The frame is stored using a packed premultiplied 32-bit AYUV format (0xAAYYUUVV).
+
+ \value Format_YUV420P
+ The frame is stored using an 8-bit per component planar YUV format with the U and V planes
+ horizontally and vertically sub-sampled, i.e. the height and width of the U and V planes are
+ half that of the Y plane.
+
+ \value Format_YUV422P
+ The frame is stored using an 8-bit per component planar YUV format with the U and V planes
+ horizontally sub-sampled, i.e. the width of the U and V planes are
+ half that of the Y plane, and height of U and V planes is the same as Y.
+
+ \value Format_YV12
+ The frame is stored using an 8-bit per component planar YVU format with the V and U planes
+ horizontally and vertically sub-sampled, i.e. the height and width of the V and U planes are
+ half that of the Y plane.
+
+ \value Format_UYVY
+ The frame is stored using an 8-bit per component packed YUV format with the U and V planes
+ horizontally sub-sampled (U-Y-V-Y), i.e. two horizontally adjacent pixels are stored as a 32-bit
+ macropixel which has a Y value for each pixel and common U and V values.
+
+ \value Format_YUYV
+ The frame is stored using an 8-bit per component packed YUV format with the U and V planes
+ horizontally sub-sampled (Y-U-Y-V), i.e. two horizontally adjacent pixels are stored as a 32-bit
+ macropixel which has a Y value for each pixel and common U and V values.
+
+ \value Format_NV12
+ The frame is stored using an 8-bit per component semi-planar YUV format with a Y plane (Y)
+ followed by a horizontally and vertically sub-sampled, packed UV plane (U-V).
+
+ \value Format_NV21
+ The frame is stored using an 8-bit per component semi-planar YUV format with a Y plane (Y)
+ followed by a horizontally and vertically sub-sampled, packed VU plane (V-U).
+
+ \value Format_IMC1
+ The frame is stored using an 8-bit per component planar YUV format with the U and V planes
+ horizontally and vertically sub-sampled. This is similar to the Format_YUV420P type, except
+ that the bytes per line of the U and V planes are padded out to the same stride as the Y plane.
+
+ \value Format_IMC2
+ The frame is stored using an 8-bit per component planar YUV format with the U and V planes
+ horizontally and vertically sub-sampled. This is similar to the Format_YUV420P type, except
+ that the lines of the U and V planes are interleaved, i.e. each line of U data is followed by a
+ line of V data creating a single line of the same stride as the Y data.
+
+ \value Format_IMC3
+ The frame is stored using an 8-bit per component planar YVU format with the V and U planes
+ horizontally and vertically sub-sampled. This is similar to the Format_YV12 type, except that
+ the bytes per line of the V and U planes are padded out to the same stride as the Y plane.
+
+ \value Format_IMC4
+ The frame is stored using an 8-bit per component planar YVU format with the V and U planes
+ horizontally and vertically sub-sampled. This is similar to the Format_YV12 type, except that
+ the lines of the V and U planes are interleaved, i.e. each line of V data is followed by a line
+ of U data creating a single line of the same stride as the Y data.
+
+ \value Format_P010
+ The frame is stored using a 16bit per component semi-planar YUV format with a Y plane (Y)
+ followed by a horizontally and vertically sub-sampled, packed UV plane (U-V). Only the 10 most
+ significant bits of each component are being used.
+
+ \value Format_P016
+ The frame is stored using a 16bit per component semi-planar YUV format with a Y plane (Y)
+ followed by a horizontally and vertically sub-sampled, packed UV plane (U-V).
+
+ \value Format_Y8
+ The frame is stored using an 8-bit greyscale format.
+
+ \value Format_Y16
+ The frame is stored using a 16-bit linear greyscale format. Little endian.
+
+ \value Format_Jpeg
+ The frame is stored in compressed Jpeg format.
+
+ \value Format_User
+ Start value for user defined pixel formats.
*/
/*!
@@ -279,6 +388,12 @@ int QVideoFrameFormat::frameHeight() const
return d->frameSize.height();
}
+/*!
+ Returns the number of planes used.
+ This number is depending on the pixel format and is
+ 1 for RGB based formats, and a number between 1 and 3 for
+ YUV based formats.
+*/
int QVideoFrameFormat::planeCount() const
{
return QVideoTextureHelper::textureDescription(d->pixelFormat)->nplanes;
@@ -413,16 +528,25 @@ void QVideoFrameFormat::setMirrored(bool mirrored)
d->mirrored = mirrored;
}
+/*!
+ \internal
+*/
QString QVideoFrameFormat::vertexShaderFileName() const
{
return QVideoTextureHelper::vertexShaderFileName(d->pixelFormat);
}
+/*!
+ \internal
+*/
QString QVideoFrameFormat::fragmentShaderFileName() const
{
return QVideoTextureHelper::fragmentShaderFileName(d->pixelFormat);
}
+/*!
+ \internal
+*/
QByteArray QVideoFrameFormat::uniformData(const QMatrix4x4 &transform, float opacity) const
{
return QVideoTextureHelper::uniformData(*this, transform, opacity);
@@ -431,7 +555,7 @@ QByteArray QVideoFrameFormat::uniformData(const QMatrix4x4 &transform, float opa
/*!
Returns a video pixel format equivalent to an image \a format. If there is no equivalent
- format QVideoFrame::InvalidType is returned instead.
+ format QVideoFrameFormat::Format_Invalid is returned instead.
\note In general \l QImage does not handle YUV formats.
diff --git a/src/multimedia/video/qvideosink.cpp b/src/multimedia/video/qvideosink.cpp
index c7b336764..22692ddd7 100644
--- a/src/multimedia/video/qvideosink.cpp
+++ b/src/multimedia/video/qvideosink.cpp
@@ -369,6 +369,9 @@ void QVideoSink::paint(QPainter *painter, const QVideoFrame &f)
}
}
+/*!
+ \internal
+*/
QPlatformVideoSink *QVideoSink::platformVideoSink() const
{
return d->videoSink;
diff --git a/tests/auto/unit/multimedia/qaudiorecorder/tst_qaudiorecorder.cpp b/tests/auto/unit/multimedia/qaudiorecorder/tst_qaudiorecorder.cpp
index c3fa73fb2..df981b9ff 100644
--- a/tests/auto/unit/multimedia/qaudiorecorder/tst_qaudiorecorder.cpp
+++ b/tests/auto/unit/multimedia/qaudiorecorder/tst_qaudiorecorder.cpp
@@ -84,13 +84,6 @@ void tst_QAudioRecorder::testNullControl()
service->hasControls = false;
QVERIFY(source.isAvailable());
-
- QCOMPARE(source.audioInput(), QAudioDeviceInfo());
-
- QSignalSpy deviceNameSpy(&source, SIGNAL(audioInputChanged()));
-
- source.setAudioInput(QAudioDeviceInfo());
- QCOMPARE(deviceNameSpy.count(), 1);
}
void tst_QAudioRecorder::testAudioSource()