| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #include "qplatformmediarecorder_p.h" |
| 5 | #include "qstandardpaths.h" |
| 6 | #include "qmediastoragelocation_p.h" |
| 7 | #include <QObject> |
| 8 | |
| 9 | QT_BEGIN_NAMESPACE |
| 10 | |
| 11 | QPlatformMediaRecorder::QPlatformMediaRecorder(QMediaRecorder *parent) |
| 12 | : q(parent) |
| 13 | { |
| 14 | } |
| 15 | |
| 16 | void QPlatformMediaRecorder::pause() |
| 17 | { |
| 18 | updateError(error: QMediaRecorder::FormatError, errorString: QMediaRecorder::tr(s: "Pause not supported")); |
| 19 | } |
| 20 | |
| 21 | void QPlatformMediaRecorder::resume() |
| 22 | { |
| 23 | updateError(error: QMediaRecorder::FormatError, errorString: QMediaRecorder::tr(s: "Resume not supported")); |
| 24 | } |
| 25 | |
| 26 | void QPlatformMediaRecorder::stateChanged(QMediaRecorder::RecorderState state) |
| 27 | { |
| 28 | if (m_state == state) |
| 29 | return; |
| 30 | m_state = state; |
| 31 | emit q->recorderStateChanged(state); |
| 32 | } |
| 33 | |
| 34 | void QPlatformMediaRecorder::durationChanged(qint64 duration) |
| 35 | { |
| 36 | if (m_duration == duration) |
| 37 | return; |
| 38 | m_duration = duration; |
| 39 | emit q->durationChanged(duration); |
| 40 | } |
| 41 | |
| 42 | void QPlatformMediaRecorder::actualLocationChanged(const QUrl &location) |
| 43 | { |
| 44 | if (m_actualLocation == location) |
| 45 | return; |
| 46 | m_actualLocation = location; |
| 47 | emit q->actualLocationChanged(location); |
| 48 | } |
| 49 | |
| 50 | void QPlatformMediaRecorder::updateError(QMediaRecorder::Error error, const QString &errorString) |
| 51 | { |
| 52 | m_error.setAndNotify(code: error, description: errorString, notifier&: *q); |
| 53 | } |
| 54 | |
| 55 | void QPlatformMediaRecorder::metaDataChanged() |
| 56 | { |
| 57 | emit q->metaDataChanged(); |
| 58 | } |
| 59 | |
| 60 | QString QPlatformMediaRecorder::findActualLocation(const QMediaEncoderSettings &settings) const |
| 61 | { |
| 62 | const auto audioOnly = settings.videoCodec() == QMediaFormat::VideoCodec::Unspecified; |
| 63 | |
| 64 | const auto primaryLocation = |
| 65 | audioOnly ? QStandardPaths::MusicLocation : QStandardPaths::MoviesLocation; |
| 66 | QString location = QMediaStorageLocation::generateFileName( |
| 67 | requestedName: outputLocation().toString(options: QUrl::PreferLocalFile), type: primaryLocation, extension: settings.preferredSuffix()); |
| 68 | |
| 69 | Q_ASSERT(!location.isEmpty()); |
| 70 | |
| 71 | return location; |
| 72 | } |
| 73 | |
| 74 | QT_END_NAMESPACE |
| 75 |
