summaryrefslogtreecommitdiffstats
path: root/src/multimedia/doc
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-06-11 12:49:26 +0200
committerLars Knoll <lars.knoll@qt.io>2021-06-16 10:03:03 +0200
commit9c309ede2feb598908b1476062b79d0d23759bf3 (patch)
tree29e68c3ce8698272206b4fdda78d6b3641da2a8e /src/multimedia/doc
parentfde5d6f7cce6118cac4ce7b92cd056225737917f (diff)
Get rid of QMediaEncoderSettings
As per API review, fold this class into QMediaRecorder as that's the only place where it is being used. This removes one level of indirection from the API and also makes it possible to use from QML. Change-Id: Id9157df04512382cce28e89b082433ec67d36b28 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/multimedia/doc')
-rw-r--r--src/multimedia/doc/snippets/multimedia-snippets/camera.cpp19
-rw-r--r--src/multimedia/doc/snippets/multimedia-snippets/media.cpp52
-rw-r--r--src/multimedia/doc/src/changes.qdoc8
3 files changed, 28 insertions, 51 deletions
diff --git a/src/multimedia/doc/snippets/multimedia-snippets/camera.cpp b/src/multimedia/doc/snippets/multimedia-snippets/camera.cpp
index 2306265b7..3fa1cdc6e 100644
--- a/src/multimedia/doc/snippets/multimedia-snippets/camera.cpp
+++ b/src/multimedia/doc/snippets/multimedia-snippets/camera.cpp
@@ -53,7 +53,7 @@
/* Globals so that everything is consistent. */
QCamera *camera = 0;
-QMediaRecorder *encoder = 0;
+QMediaRecorder *recorder = 0;
QCameraImageCapture *imageCapture = 0;
//! [Camera overview check]
@@ -151,23 +151,22 @@ void overview_movie()
QMediaCaptureSession captureSession;
camera = new QCamera;
captureSession.setCamera(camera);
- encoder = new QMediaRecorder(camera);
- captureSession.setEncoder(encoder);
+ recorder = new QMediaRecorder(camera);
+ captureSession.setMediaEncoder(recorder);
camera->start();
- // setup output format for the encoder
+ // setup output format for the recorder
QMediaFormat format(QMediaFormat::MPEG4);
- format.setVideoCodec(QMediaEncoderSettings::VideoCodec::H264);
- format.setAudioCodec(QMediaEncoderSettings::AudioCodec::MP3);
- QMediaEncoderSettings settings(format);
- encoder->setEncoderSettings(settings);
+ format.setVideoCodec(QMediaRecorder::VideoCodec::H264);
+ format.setAudioCodec(QMediaRecorder::AudioCodec::MP3);
+ recorder->setMediaFormat(settings);
//on shutter button pressed
- encoder->record();
+ recorder->record();
// sometime later, or on another press
- encoder->stop();
+ recorder->stop();
//! [Camera overview movie]
}
diff --git a/src/multimedia/doc/snippets/multimedia-snippets/media.cpp b/src/multimedia/doc/snippets/multimedia-snippets/media.cpp
index f2ed71cf7..fd76e679e 100644
--- a/src/multimedia/doc/snippets/multimedia-snippets/media.cpp
+++ b/src/multimedia/doc/snippets/multimedia-snippets/media.cpp
@@ -59,10 +59,9 @@ class MediaExample : public QObject {
void MediaControl();
void MediaPlayer();
- void MediaRecorder();
void AudioRecorder();
- void EncoderSettings();
- void ImageEncoderSettings();
+ void recorderSettings();
+ void imageSettings();
private:
// Common naming
@@ -87,26 +86,22 @@ void MediaExample::MediaControl()
}
-void MediaExample::EncoderSettings()
+void MediaExample::recorderSettings()
{
//! [Media encoder settings]
QMediaFormat format(QMediaFormat::MPEG4);
- format.setVideoCodec(QMediaEncoderSettings::VideoCodec::H264);
- format.setAudioCodec(QMediaEncoderSettings::AudioCodec::MP3);
- QMediaEncoderSettings settings(format);
+ format.setVideoCodec(QMediaRecorder::VideoCodec::H264);
+ format.setAudioCodec(QMediaRecorder::AudioCodec::MP3);
- recorder->setEncoderSettings(settings);
+ recorder->setMediaFormat(settings);
//! [Media encoder settings]
}
-void MediaExample::ImageEncoderSettings()
+void MediaExample::imageSettings()
{
//! [Image encoder settings]
- QImageEncoderSettings imageSettings;
- imageSettings.setFormat(QCameraImageCapture::JPEG);
- imageSettings.setResolution(1600, 1200);
-
- imageCapture->setEncodingSettings(imageSettings);
+ imageCapture->setFileFormat(QCameraImageCapture::JPEG);
+ imageCapture->setResolution(1600, 1200);
//! [Image encoder settings]
}
@@ -129,33 +124,16 @@ void MediaExample::MediaPlayer()
//! [Local playback]
}
-void MediaExample::MediaRecorder()
-{
- //! [Media recorder]
- recorder = new QMediaRecorder(camera);
-
- QMediaEncoderSettings audioSettings(QMediaFormat::MP3);
- audioSettings.setQuality(QMediaEncoderSettings::HighQuality);
-
- recorder->setAudioSettings(audioSettings);
-
- recorder->setOutputLocation(QUrl::fromLocalFile(fileName));
- recorder->record();
- //! [Media recorder]
-}
-
void MediaExample::AudioRecorder()
{
//! [Audio recorder]
+ QMediaCaptureSession session;
+ QAudioInput audioInput;
+ session.setAudioInput(&input);
QMediaRecorder recorder;
- recorder.setCaptureMode(QMediaRecorder::AudioOnly);
-
- QMediaEncoderSettings audioSettings(QMediaFormat::MP3);
- audioSettings.setQuality(QMediaEncoderSettings::HighQuality);
-
- recorder.setEncoderSettings(audioSettings);
-
- recorder.setOutputLocation(QUrl::fromLocalFile("test.amr"));
+ session.setMediaEncoder(&recorder);
+ recorder.setQuality(QMediaRecorder::HighQuality);
+ recorder.setOutputLocation(QUrl::fromLocalFile("test.mp3"));
recorder.record();
//! [Audio recorder]
}
diff --git a/src/multimedia/doc/src/changes.qdoc b/src/multimedia/doc/src/changes.qdoc
index 4855620a4..cab8c3b15 100644
--- a/src/multimedia/doc/src/changes.qdoc
+++ b/src/multimedia/doc/src/changes.qdoc
@@ -67,7 +67,7 @@ QMediaEncoderSettings for details
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
+ \li Use a QMediaCaptureSession or the CaptureSession QML type
\row
\li QMediaObject and QMediaBindableInterface
\li These classes have been removed in favor of a more direct API for setting up connections
@@ -125,11 +125,11 @@ changed in ways that may affect previously written code. This table highlights s
to enum based keys, and reducing the set of supported keys to the ones that
can be supported on most platforms.
\row
- \li QMediaFormat and QMediaEncoderSettings
- \li Handling of formats for encoded media and the settings for the media encoder have
+ \li QMediaFormat
+ \li Handling of formats for encoded media and the settings for the media recorder 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
+ and other settings in QMediaRecorder. 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.