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
7#include <QObject>
8
10
11QPlatformMediaRecorder::QPlatformMediaRecorder(QMediaRecorder *parent)
12 : q(parent)
13{
14}
15
16void QPlatformMediaRecorder::pause()
17{
18 updateError(QMediaRecorder::FormatError, QMediaRecorder::tr("Pause not supported"));
19}
20
21void QPlatformMediaRecorder::resume()
22{
23 updateError(QMediaRecorder::FormatError, QMediaRecorder::tr("Resume not supported"));
24}
25
26void QPlatformMediaRecorder::stateChanged(QMediaRecorder::RecorderState state)
27{
28 if (m_state == state)
29 return;
30 m_state = state;
31 emit q->recorderStateChanged(state);
32}
33
34void QPlatformMediaRecorder::durationChanged(qint64 duration)
35{
36 if (m_duration == duration)
37 return;
38 m_duration = duration;
39 emit q->durationChanged(duration);
40}
41
42void QPlatformMediaRecorder::actualLocationChanged(const QUrl &location)
43{
44 if (m_actualLocation == location)
45 return;
46 m_actualLocation = location;
47 emit q->actualLocationChanged(location);
48}
49
50void QPlatformMediaRecorder::updateError(QMediaRecorder::Error error, const QString &errorString)
51{
52 m_error.setAndNotify(error, errorString, *q);
53}
54
55void QPlatformMediaRecorder::metaDataChanged()
56{
57 emit q->metaDataChanged();
58}
59
60QString 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 outputLocation().toString(QUrl::PreferLocalFile), primaryLocation, settings.preferredSuffix());
68
69 Q_ASSERT(!location.isEmpty());
70
71 return location;
72}
73
74QT_END_NAMESPACE