diff options
Diffstat (limited to 'examples/multimedia/audiorecorder/doc/src/audiorecorder.qdoc')
-rw-r--r-- | examples/multimedia/audiorecorder/doc/src/audiorecorder.qdoc | 92 |
1 files changed, 36 insertions, 56 deletions
diff --git a/examples/multimedia/audiorecorder/doc/src/audiorecorder.qdoc b/examples/multimedia/audiorecorder/doc/src/audiorecorder.qdoc index 4e4032bff..71481f24d 100644 --- a/examples/multimedia/audiorecorder/doc/src/audiorecorder.qdoc +++ b/examples/multimedia/audiorecorder/doc/src/audiorecorder.qdoc @@ -1,35 +1,14 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2015 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! - \example multimedia/audiorecorder + \example audiorecorder \title Audio Recorder Example \ingroup multimedia_examples + \ingroup audio_examples + \examplecategory {Multimedia} \brief Discovering the available devices and supported codecs. + \meta {tag} {widgets} \e{Audio Recorder} demonstrates how to identify the available devices and supported codecs, and the use of QAudioRecorder class. @@ -41,30 +20,33 @@ \section1 Displaying the Window and Audio Settings We display a window for the user to select the appropriate audio input, - codec, container, and sample rate. Allow a setting of either quality or - bitrate. Finally, the output file can be selected and recording can be - started. - - The lists are setup using the \l{QAudioRecorder::audioInputs()}{audioInputs()}, - \l{QAudioRecorder::supportedAudioCodecs()}{supportedAudioCodecs()}, - \l{QAudioRecorder::supportedContainers()}{supportedContainers()}, - \l{QAudioRecorder::supportedContainers()}{supportedContainers()}, and - \l{QAudioRecorder::supportedAudioSampleRates()}{supportedAudioSampleRates()} - methods. The quality slider is setup from 0 (zero) to - \l{QMultimedia::VeryHighQuality} with a default value of - \l{QMultimedia::NormalQuality}, while the bitrates are hardcoded + codec, container, sample rate, and channels. It allows setting of either + quality or bit rate. Finally, the output file can be selected and recording + can be started. + + The lists are populated using the following methods: + \list + \li \l{QMediaDevices::audioInputs()} + \li \l{QMediaFormat::supportedAudioCodecs} + \li \l{QMediaFormat::supportedFileFormats} + \li \l{QAudioDevice::maximumSampleRate()} + \li \l{QAudioDevice::minimumSampleRate()} + \endlist + The quality slider is setup from 0 (zero) to + \l{QMediaRecorder::VeryHighQuality} with a default value of + \l{QMediaRecorder::NormalQuality}, while the bit rate box are hard-coded into the list. \section1 Recording Audio - To record audio we simply create a QAudioRecorder object. + To record audio we simply create a QAudioRecorder object, \code audioRecorder = new QAudioRecorder(this); \endcode - And setup the lists as described above. The text on the record and pause - buttons are toggled depending on the \l{QMediaRecorder::State}{state} of + and setup the lists as described above. The text on the record and pause + buttons are toggled depending on the \l{QMediaRecorder::RecorderState}{state} of the \c audioRecorder object. This means that if the state is \l{QMediaRecorder::StoppedState} then the button text will be "Record" and "Pause". In \l{QMediaRecorder::RecordingState} the record button will have @@ -72,25 +54,23 @@ will have the text "Resume". Pressing the buttons will also result in a toggle based on the state. If - recording is stopped, then pressing the record button will setup the - \l{QAudioEncoderSettings} based on the values of the selection lists, - will set the encoding settings and container on the \c audioRecorder - object, and start recording using the - \l{QMediaRecorder::record()}{record()} method. + recording is stopped, then pressing the record button will set the encoding + settings and container on the \c audioRecorder object, and start recording + using the \l{QMediaRecorder::record()}{record()} method. \code - QAudioEncoderSettings settings; - settings.setCodec(boxValue(ui->audioCodecBox).toString()); - settings.setSampleRate(boxValue(ui->sampleRateBox).toInt()); - settings.setBitRate(boxValue(ui->bitrateBox).toInt()); - settings.setQuality(QMultimedia::EncodingQuality(ui->qualitySlider->value())); - settings.setEncodingMode(ui->constantQualityRadioButton->isChecked() ? - QMultimedia::ConstantQualityEncoding : - QMultimedia::ConstantBitRateEncoding); + QMediaFormat format; + format.setCodec(boxValue(ui->audioCodecBox).toString()); + audioRecorder->setMediaFormat(format); + audioRecorder->setSampleRate(boxValue(ui->sampleRateBox).toInt()); + audioRecorder->setBitRate(boxValue(ui->bitrateBox).toInt()); + audioRecorder->setQuality(QMediaRecorder::EncodingQuality(ui->qualitySlider->value())); + audioRecorder->setEncodingMode(ui->constantQualityRadioButton->isChecked() ? + QMediaRecorder::ConstantQualityEncoding : + QMediaRecorder::ConstantBitRateEncoding); QString container = boxValue(ui->containerBox).toString(); - audioRecorder->setEncodingSettings(settings, QVideoEncoderSettings(), container); audioRecorder->record(); \endcode |