diff options
Diffstat (limited to 'examples/multimedia/video/recorder')
20 files changed, 406 insertions, 779 deletions
diff --git a/examples/multimedia/video/recorder/AudioInputSelect.qml b/examples/multimedia/video/recorder/AudioInputSelect.qml index bb79f2793..d1e30f080 100644 --- a/examples/multimedia/video/recorder/AudioInputSelect.qml +++ b/examples/multimedia/video/recorder/AudioInputSelect.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import QtQuick import QtQuick.Controls @@ -54,13 +7,18 @@ import QtMultimedia Row { id: root - + height: Style.height property AudioInput selected: available ? audioInput : null property bool available: (typeof comboBox.currentValue !== 'undefined') && audioSwitch.checked + Component.onCompleted: { + audioInputModel.populate() + comboBox.currentIndex = 0 + } + MediaDevices { id: mediaDevices } - AudioInput { id: audioInput; muted: false } + AudioInput { id: audioInput; muted: !audioSwitch.checked } Switch { id: audioSwitch; @@ -68,15 +26,28 @@ Row { checked: true } + ListModel { + id: audioInputModel + property var audioInputs: mediaDevices.audioInputs + + function populate() { + audioInputModel.clear() + + for (var audioDevice of audioInputs) + audioInputModel.append({ text: audioDevice.description, value: + { type: 'audioDevice', audioDevice: audioDevice } }) + } + } ComboBox { id: comboBox width: Style.widthLong height: Style.height background: StyleRectangle { anchors.fill: parent } - model: mediaDevices.audioInputs - textRole: "description" + model: audioInputModel + textRole: "text" font.pointSize: Style.fontSize - displayText: typeof currentValue === 'undefined' ? "unavailable" : currentValue.description - onCurrentValueChanged: if (typeof comboBox.currentValue !== 'undefined') audioInput.device = currentValue + displayText: typeof currentValue === 'undefined' ? "unavailable" : currentText + valueRole: "value" + onCurrentValueChanged: if (typeof comboBox.currentValue !== 'undefined') audioInput.device = currentValue.audioDevice } } diff --git a/examples/multimedia/video/recorder/CMakeLists.txt b/examples/multimedia/video/recorder/CMakeLists.txt index 1948c5b23..116a1b817 100644 --- a/examples/multimedia/video/recorder/CMakeLists.txt +++ b/examples/multimedia/video/recorder/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + cmake_minimum_required(VERSION 3.16) project(recorder LANGUAGES CXX) @@ -18,10 +21,11 @@ qt_add_executable(recorder set(resource_files "main.qml" + "main_no_permissions.qml" "qmldir" "MediaList.qml" "AudioInputSelect.qml" - "CameraSelect.qml" + "VideoSourceSelect.qml" "RecordButton.qml" "Controls.qml" "StyleParameter.qml" diff --git a/examples/multimedia/video/recorder/CameraSelect.qml b/examples/multimedia/video/recorder/CameraSelect.qml deleted file mode 100644 index 0810d4baf..000000000 --- a/examples/multimedia/video/recorder/CameraSelect.qml +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick -import QtQuick.Controls -import QtMultimedia - -Row { - id: root - height: Style.height - property Camera selected: available ? camera : null - property bool available: (typeof comboBox.currentValue !== 'undefined') && cameraSwitch.checked - - Camera { - id: camera - active: available && selected != null - } - - MediaDevices { id: mediaDevices } - - Switch { - id: cameraSwitch - anchors.verticalCenter: parent.verticalCenter - checked: true - } - - ComboBox { - id: comboBox - width: Style.widthLong - height: Style.height - background: StyleRectangle { anchors.fill: parent } - model: mediaDevices.videoInputs - displayText: typeof currentValue === 'undefined' ? "Unavailable" : currentValue.description - font.pointSize: Style.fontSize - textRole: "description" - onCurrentValueChanged: if (typeof comboBox.currentValue !== 'undefined') camera.cameraDevice = currentValue - } -} diff --git a/examples/multimedia/video/recorder/Controls.qml b/examples/multimedia/video/recorder/Controls.qml index baaad0ddf..627c2fe04 100644 --- a/examples/multimedia/video/recorder/Controls.qml +++ b/examples/multimedia/video/recorder/Controls.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import QtQuick import QtQuick.Controls @@ -61,7 +14,9 @@ Row { property bool capturesVisible: false property alias audioInput: audioInputSelect.selected - property alias camera: cameraSelect.selected + property alias camera: videoSourceSelect.selectedCamera + property alias screenCapture: videoSourceSelect.selectedScreenCapture + property alias windowCapture: videoSourceSelect.selectedWindowCapture spacing: Style.interSpacing * Style.ratio @@ -69,7 +24,7 @@ Row { id: inputControls spacing: Style.intraSpacing - CameraSelect { id: cameraSelect } + VideoSourceSelect { id: videoSourceSelect } AudioInputSelect { id: audioInputSelect } } @@ -84,6 +39,7 @@ Row { id: recordingTime anchors.horizontalCenter: parent.horizontalCenter font.pointSize: Style.fontSize + color: palette.text } } @@ -91,6 +47,10 @@ Row { id: optionButtons spacing: Style.intraSpacing Button { + leftPadding: 0 + rightPadding: 0 + topPadding: 0 + bottomPadding: 0 height: Style.height width: Style.widthMedium background: StyleRectangle { anchors.fill: parent } @@ -99,6 +59,10 @@ Row { font.pointSize: Style.fontSize } Button { + leftPadding: 0 + rightPadding: 0 + topPadding: 0 + bottomPadding: 0 height: Style.height width: Style.widthMedium background: StyleRectangle { anchors.fill: parent } diff --git a/examples/multimedia/video/recorder/MediaList.qml b/examples/multimedia/video/recorder/MediaList.qml index 33c65d32c..5fa65393a 100644 --- a/examples/multimedia/video/recorder/MediaList.qml +++ b/examples/multimedia/video/recorder/MediaList.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import QtQuick import QtQuick.Controls diff --git a/examples/multimedia/video/recorder/Playback.qml b/examples/multimedia/video/recorder/Playback.qml index fdcfd1723..78575ae26 100644 --- a/examples/multimedia/video/recorder/Playback.qml +++ b/examples/multimedia/video/recorder/Playback.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import QtQuick import QtMultimedia diff --git a/examples/multimedia/video/recorder/RecordButton.qml b/examples/multimedia/video/recorder/RecordButton.qml index 44d8d48d1..5296a3028 100644 --- a/examples/multimedia/video/recorder/RecordButton.qml +++ b/examples/multimedia/video/recorder/RecordButton.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import QtQuick import QtQuick.Controls diff --git a/examples/multimedia/video/recorder/SettingsEncoder.qml b/examples/multimedia/video/recorder/SettingsEncoder.qml index c129eaed0..16a9590be 100644 --- a/examples/multimedia/video/recorder/SettingsEncoder.qml +++ b/examples/multimedia/video/recorder/SettingsEncoder.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import QtQuick import QtQuick.Layouts @@ -71,7 +24,10 @@ Column { function onMediaFormatChanged() { root.populateModels() } } - Text { text: "Encoder settings" } + Text { + text: "Encoder settings" + color: palette.text + } StyleParameter { label: "Quality" diff --git a/examples/multimedia/video/recorder/SettingsMetaData.qml b/examples/multimedia/video/recorder/SettingsMetaData.qml index e675e2325..7bfc2255d 100644 --- a/examples/multimedia/video/recorder/SettingsMetaData.qml +++ b/examples/multimedia/video/recorder/SettingsMetaData.qml @@ -1,70 +1,29 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import QtQuick import QtQuick.Layouts import QtQuick.Controls import QtMultimedia +pragma ComponentBehavior: Bound + ColumnLayout { + id: root required property MediaRecorder recorder - Text { text: "Metadata settings" } + Text { + text: "Metadata settings" + color: palette.text + } ListModel { id: metaDataModel } Connections { - target: recorder + target: root.recorder function onMetaDataChanged() { metaDataModel.clear() - for (var key of recorder.metaData.keys()) { + for (var key of root.recorder.metaData.keys()) { if (recorder.metaData.stringValue(key)) metaDataModel.append( { text: recorder.metaData.metaDataKeyToString(key) @@ -114,7 +73,7 @@ ColumnLayout { font.pointSize: Style.fontSize clip: true onAccepted: { - recorder.metaData.insert(metaDataType.currentValue, text) + root.recorder.metaData.insert(metaDataType.currentValue, text) recorder.metaDataChanged() text = "" textInput.deselect() @@ -168,8 +127,8 @@ ColumnLayout { anchors.bottom: parent.bottom font.pointSize: Style.fontSize clip: true - text: recorder.metaData.stringValue(r.value) - onAccepted: recorder.metaData.insert(r.value, text) + text: root.recorder.metaData.stringValue(r.value) + onAccepted: root.recorder.metaData.insert(r.value, text) } } @@ -179,7 +138,7 @@ ColumnLayout { text: "del" font.pointSize: Style.fontSize background: StyleRectangle { anchors.fill: parent } - onClicked: { recorder.metaData.remove(r.value); recorder.metaDataChanged() } + onClicked: { root.recorder.metaData.remove(r.value); recorder.metaDataChanged() } } } } diff --git a/examples/multimedia/video/recorder/Style.qml b/examples/multimedia/video/recorder/Style.qml index f00a3c9f1..d30c3b8ef 100644 --- a/examples/multimedia/video/recorder/Style.qml +++ b/examples/multimedia/video/recorder/Style.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause pragma Singleton import QtQuick diff --git a/examples/multimedia/video/recorder/StyleParameter.qml b/examples/multimedia/video/recorder/StyleParameter.qml index 2a6c3ddb3..3a7573b92 100644 --- a/examples/multimedia/video/recorder/StyleParameter.qml +++ b/examples/multimedia/video/recorder/StyleParameter.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import QtQuick import QtQuick.Controls @@ -68,7 +21,7 @@ Row { width: Style.widthShort horizontalAlignment: Text.AlignRight verticalAlignment: Text.AlignVCenter - color: root.enabled ? "black" : "gray" + color: root.enabled ? palette.text : palette.mid font.pointSize: Style.fontSize } diff --git a/examples/multimedia/video/recorder/StyleRectangle.qml b/examples/multimedia/video/recorder/StyleRectangle.qml index 7e9186fc8..e28cf4a19 100644 --- a/examples/multimedia/video/recorder/StyleRectangle.qml +++ b/examples/multimedia/video/recorder/StyleRectangle.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import QtQuick diff --git a/examples/multimedia/video/recorder/StyleSlider.qml b/examples/multimedia/video/recorder/StyleSlider.qml index 5f8e12309..a15304aaa 100644 --- a/examples/multimedia/video/recorder/StyleSlider.qml +++ b/examples/multimedia/video/recorder/StyleSlider.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import QtQuick import QtQuick.Controls @@ -69,7 +22,7 @@ Row { height: Style.height horizontalAlignment: Text.AlignRight verticalAlignment: Text.AlignVCenter - color: root.enabled ? "black" : "gray" + color: root.enabled ? palette.text : palette.mid } Slider { diff --git a/examples/multimedia/video/recorder/VideoSourceSelect.qml b/examples/multimedia/video/recorder/VideoSourceSelect.qml new file mode 100644 index 000000000..7eeed99b9 --- /dev/null +++ b/examples/multimedia/video/recorder/VideoSourceSelect.qml @@ -0,0 +1,165 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +import QtQuick +import QtQuick.Controls +import QtMultimedia + +Row { + id: root + height: Style.height + property Camera selectedCamera: cameraAvailable ? camera : null + property ScreenCapture selectedScreenCapture: screenAvailable ? screenCapture : null + property WindowCapture selectedWindowCapture: windowAvailable ? windowCapture : null + + property bool sourceAvailable: typeof comboBox.currentValue !== 'undefined' && + comboBox.currentValue.type !== 'toggler' && + videoSourceSwitch.checked + + property bool cameraAvailable: sourceAvailable && comboBox.currentValue.type === 'camera' + property bool screenAvailable: sourceAvailable && comboBox.currentValue.type === 'screen' + property bool windowAvailable: sourceAvailable && comboBox.currentValue.type === 'window' + + Component.onCompleted: { + videoSourceModel.populate() + + for (var i = 0; i < videoSourceModel.count; i++) { + if (videoSourceModel.get(i).value.type !== 'toggler') { + comboBox.currentIndex = i + break + } + } + } + + Camera { + id: camera + active: cameraAvailable + } + + ScreenCapture { + id: screenCapture + active: screenAvailable + } + + WindowCapture { + id: windowCapture + active: windowAvailable + } + + MediaDevices { id: mediaDevices + onVideoInputsChanged: { + + videoSourceModel.populate() + + for (var i = 0; i < videoSourceModel.count; i++) { + if (videoSourceModel.get(i).value.type !== 'toggler') { + comboBox.currentIndex = i + break + } + } + } + } + + Switch { + id: videoSourceSwitch + anchors.verticalCenter: parent.verticalCenter + checked: true + } + + ListModel { + id: videoSourceModel + property var enabledSources: { + 'camera': true, + 'screen': true, + 'window': false + } + + function toggleEnabledSource(type) { + enabledSources[type] = !enabledSources[type] + populate() + } + + function appendItem(text, value) { + append({ text: text, value: value}) + } + + function appendToggler(name, sourceType) { + appendItem((enabledSources[sourceType] ? "- Hide " : "+ Show ") + name, + { type: 'toggler', 'sourceType': sourceType }) + } + + function populate() { + clear() + + appendToggler('Cameras', 'camera') + if (enabledSources['camera']) + for (var camera of mediaDevices.videoInputs) + appendItem(camera.description, { type: 'camera', camera: camera }) + + appendToggler('Screens', 'screen') + if (enabledSources['screen']) + for (var screen of Application.screens) + appendItem(screen.name, { type: 'screen', screen: screen }) + + appendToggler('Windows', 'window') + if (enabledSources['window']) + for (var window of windowCapture.capturableWindows()) + appendItem(window.description, { type: 'window', window: window }) + } + } + + ComboBox { + id: comboBox + width: Style.widthLong + height: Style.height + background: StyleRectangle { anchors.fill: parent } + model: videoSourceModel + displayText: typeof currentValue === 'undefined' || + currentValue.type === 'toggler' ? "Unavailable" : currentText + font.pointSize: Style.fontSize + textRole: "text" + valueRole: "value" + onCurrentValueChanged: { + if (typeof currentValue === 'undefined') + return + if (currentValue.type === 'screen') + screenCapture.screen = currentValue.screen + else if (currentValue.type === 'camera') + camera.cameraDevice = currentValue.camera + else if (currentValue.type === 'window') + windowCapture.window = currentValue.window + else if (currentValue.type === 'toggler') + model.toggleEnabledSource(currentValue.sourceType) + } + + delegate: ItemDelegate { + property bool isToggler: value.type === 'toggler' + text: model[comboBox.textRole] + width: comboBox.width + height: comboBox.height + highlighted: comboBox.highlightedIndex === index && !isToggler + font.italic: isToggler + font.underline: isToggler + font.bold: comboBox.currentIndex === index && !isToggler || + isToggler && comboBox.highlightedIndex === index + palette.text: isToggler ? comboBox.palette.link : comboBox.palette.text + + MouseArea { + anchors.fill: parent + onClicked: { + if (isToggler) + videoSourceModel.toggleEnabledSource(value.sourceType) + else { + comboBox.currentIndex = index + comboBox.popup.close() + } + } + } + + required property var value + required property int index + required property var model + } + + } +} diff --git a/examples/multimedia/video/recorder/doc/images/qml-recorder-control-bar-overview.gif b/examples/multimedia/video/recorder/doc/images/qml-recorder-control-bar-overview.gif Binary files differnew file mode 100644 index 000000000..b02053ea5 --- /dev/null +++ b/examples/multimedia/video/recorder/doc/images/qml-recorder-control-bar-overview.gif diff --git a/examples/multimedia/video/recorder/doc/images/qml-recorder-overview.gif b/examples/multimedia/video/recorder/doc/images/qml-recorder-overview.gif Binary files differnew file mode 100644 index 000000000..2e5e39215 --- /dev/null +++ b/examples/multimedia/video/recorder/doc/images/qml-recorder-overview.gif diff --git a/examples/multimedia/video/recorder/doc/src/recorder.qdoc b/examples/multimedia/video/recorder/doc/src/recorder.qdoc index 9ced09e74..3c0de3730 100644 --- a/examples/multimedia/video/recorder/doc/src/recorder.qdoc +++ b/examples/multimedia/video/recorder/doc/src/recorder.qdoc @@ -1,46 +1,102 @@ -/**************************************************************************** -** -** Copyright (C) 2021 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) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! - \example multimedia/video/recorder - \title QML Recorder Example + \example video/recorder + \title QML Video Recorder \ingroup multimedia_examples \ingroup video_examples_qml \ingroup camera_examples_qml + \examplecategory {Multimedia} \brief Recording audio and video using Qt Quick. \meta {tag} {quick} \image qmlrecorder.jpg \e{QML Recorder} demonstrates a simple application that can record - audio and or video files using the camera and microphone. + audio and video separate or together, using a microphone, a camera, or + with screen capturing. \include examples-run.qdocinc - The example uses the QML Camera and AudioInput objects connected to a MediaCaptureSession. - A MediaRecorder object is then used to record the captured audio and video. + \section1 Overview + At its core, this is a QML application, see + \l{Getting Started Programming with Qt Quick}. This documentation is focused + on how this example uses the \l{Qt Multimedia QML Types}. + + \image qml-recorder-overview.gif "Animation cycling through qml objects declared in main.qml" + + The example uses the QML \l Camera and \l AudioInput types connected to a + \l CaptureSession. A \l MediaRecorder object is then used to record the + captured audio and video. + + In addition to QtMultimedia, features of Qt Quick Windows, Controls, and + Layouts are used to implement the graphic user interface and functionality. + Playback won't be covered here, for that see the \l{QML Media Player Example}. + + The example demonstrates the following: + \list + \li Input devices can be selected. + \li An input type switched off. + \li Settings for capturing such as quality, codec choice, file format, + and assigning metadata. + \li Captured files are stored and can be played back. + \endlist + + \section1 Recording + + The application implements recording. + + \section2 captureSession + + In \c main.qml, \c captureSession is declared like so: + + \quotefromfile video/recorder/main.qml + \skipto CaptureSession + \printto MediaRecorder + + \section2 recorder + + In \c main.qml, the \l MediaRecorder \c recorder handles recording media + as well as capturing a thumbnail for the file and appending it to a ListModel, + \c mediaList. + \printto Playback + + \c mediaList is declared in the \l Frame \c mediaListFrame + \quotefromfile video/recorder/main.qml + \skipto Frame + \printuntil playback: playback + + \section2 controls + + \image qml-recorder-control-bar-overview.gif + + These are defined in \c Controls.qml and declared in main.qml. + + Its root is a \l Row that contains the \l{Column}{Columns} \c inputControls, + \c recordButton, \c optionButtons, each defined in their own .qml files. + + \section3 Selecting a video source + + Defined in \c VideoSourceSelect.qml, \c VideoSourceSlect is comprised of a + \l Switch and a \l ComboBox and enables the user to select from available + cameras. + + \quotefromfile video/recorder/VideoSourceSelect.qml + \skipto Row + \printto ComboBox + + \c comboBox, declared in the above snippet, assigns the current video source. + + \printuntil camera.cameraDevice = currentValue.camera + + \section3 Selecting an audio input + + Implemented in the same way as \l{Selecting a video source} and defined in + \c AudioInputSelect.qml like so: + + \quotefromfile video/recorder/AudioInputSelect.qml + \skipto Row + \printto audioInput.device = currentValue + */ diff --git a/examples/multimedia/video/recorder/main.cpp b/examples/multimedia/video/recorder/main.cpp index 21067f50d..92e54cb1b 100644 --- a/examples/multimedia/video/recorder/main.cpp +++ b/examples/multimedia/video/recorder/main.cpp @@ -1,68 +1,51 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QGuiApplication> #include <QQmlApplicationEngine> +#if QT_CONFIG(permissions) + #include <QPermission> +#endif + int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine; const QUrl url(QStringLiteral("qrc:/main.qml")); - QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, - &app, [url](QObject *obj, const QUrl &objUrl) { - if (!obj && url == objUrl) - QCoreApplication::exit(-1); - }, Qt::QueuedConnection); + QObject::connect( + &engine, &QQmlApplicationEngine::objectCreated, &app, + [url](QObject *obj, const QUrl &objUrl) { + if (!obj && url == objUrl) + QCoreApplication::exit(-1); + }, + Qt::QueuedConnection); + +#if QT_CONFIG(permissions) + // If the permissions are not granted, display another main window, which + // simply contains the error message. + const QUrl noPermissionsUrl(QStringLiteral("qrc:/main_no_permissions.qml")); + QCameraPermission cameraPermission; + qApp->requestPermission(cameraPermission, [&](const QPermission &permission) { + if (permission.status() != Qt::PermissionStatus::Granted) { + qWarning("Camera permission is not granted!"); + engine.load(noPermissionsUrl); + return; + } + QMicrophonePermission micPermission; + qApp->requestPermission(micPermission, [&](const QPermission &permission) { + if (permission.status() != Qt::PermissionStatus::Granted) { + qWarning("Microphone permission is not granted!"); + engine.load(noPermissionsUrl); + } else { + engine.load(url); + } + }); + }); +#else engine.load(url); +#endif return app.exec(); } diff --git a/examples/multimedia/video/recorder/main.qml b/examples/multimedia/video/recorder/main.qml index c7e625f0e..d8d1cd54f 100644 --- a/examples/multimedia/video/recorder/main.qml +++ b/examples/multimedia/video/recorder/main.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import QtQuick import QtQuick.Window @@ -61,6 +14,8 @@ Window { width: Style.screenWidth height: Style.screenHeigth + color: palette.window + onWidthChanged:{ Style.calculateRatio(root.width, root.height) } @@ -82,6 +37,8 @@ Window { recorder: recorder audioInput: controls.audioInput camera: controls.camera + screenCapture: controls.screenCapture + windowCapture: controls.windowCapture videoOutput: videoOutput } @@ -119,7 +76,7 @@ Window { x: controls.capturesVisible ? 0 : parent.width background: Rectangle { anchors.fill: parent - color: "white" + color: palette.base opacity: 0.8 } @@ -145,7 +102,7 @@ Window { background: Rectangle { anchors.fill: parent - color: "white" + color: palette.base opacity: 0.8 } diff --git a/examples/multimedia/video/recorder/main_no_permissions.qml b/examples/multimedia/video/recorder/main_no_permissions.qml new file mode 100644 index 000000000..8c76533b0 --- /dev/null +++ b/examples/multimedia/video/recorder/main_no_permissions.qml @@ -0,0 +1,26 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +import QtQuick +import QtQuick.Window + +Window { + id: root + visible: true + title: "Media recorder" + width: Style.screenWidth + height: Style.screenHeigth + + StyleRectangle { + anchors.fill: parent + Text { + anchors.fill: parent + anchors.margins: 20 + wrapMode: Text.WordWrap + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + text: qsTr("The example is not usable without the permissions.\n" + + "Please grant all requested permissions and restart the application.") + } + } +} |