Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qplatformmediarecorder.cpp
Go to the documentation of this file.
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
5
6#include <QtMultimedia/private/qmediastoragelocation_p.h>
7#include <QtCore/qobject.h>
8#include <QtCore/qstandardpaths.h>
9
11
12QPlatformMediaRecorder::QPlatformMediaRecorder(QMediaRecorder *parent)
13 : q(parent)
14{
15}
16
17void QPlatformMediaRecorder::pause()
18{
19 updateError(QMediaRecorder::FormatError, QMediaRecorder::tr("Pause not supported"));
20}
21
22void QPlatformMediaRecorder::resume()
23{
24 updateError(QMediaRecorder::FormatError, QMediaRecorder::tr("Resume not supported"));
25}
26
27void QPlatformMediaRecorder::stateChanged(QMediaRecorder::RecorderState state)
28{
29 if (m_state == state)
30 return;
31 m_state = state;
32 emit q->recorderStateChanged(state);
33}
34
35void QPlatformMediaRecorder::durationChanged(qint64 duration)
36{
37 if (m_duration == duration)
38 return;
39 m_duration = duration;
40 emit q->durationChanged(duration);
41}
42
43void QPlatformMediaRecorder::actualLocationChanged(const QUrl &location)
44{
45 if (m_actualLocation == location)
46 return;
47 m_actualLocation = location;
48 emit q->actualLocationChanged(location);
49}
50
51void QPlatformMediaRecorder::updateError(QMediaRecorder::Error error, const QString &errorString)
52{
53 m_error.setAndNotify(error, errorString, *q);
54}
55
56void QPlatformMediaRecorder::metaDataChanged()
57{
58 emit q->metaDataChanged();
59}
60
61QString QPlatformMediaRecorder::findActualLocation(const QMediaEncoderSettings &settings) const
62{
63 const auto audioOnly = settings.videoCodec() == QMediaFormat::VideoCodec::Unspecified;
64
65 const auto primaryLocation =
66 audioOnly ? QStandardPaths::MusicLocation : QStandardPaths::MoviesLocation;
67 QString location = QMediaStorageLocation::generateFileName(
68 outputLocation().toString(QUrl::PreferLocalFile), primaryLocation, settings.preferredSuffix());
69
70 Q_ASSERT(!location.isEmpty());
71
72 return location;
73}
74
75QT_END_NAMESPACE
Combined button and popup list for selecting options.