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
qqnxmediarecorder.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 Research In Motion
2// Copyright (C) 2022 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#undef QT_NO_CONTEXTLESS_CONNECT // Remove after porting connect() calls
6
8
11#include "qqnxcamera_p.h"
13
14#include <private/qplatformcamera_p.h>
15
16#include <QDebug>
17#include <QUrl>
18
20
25
26bool QQnxMediaRecorder::isLocationWritable(const QUrl &/*location*/) const
27{
28 return true;
29}
30
32{
33 m_session = session;
34}
35
36void QQnxMediaRecorder::record(QMediaEncoderSettings &settings)
37{
38 if (!m_session)
39 return;
40
41 m_audioRecorder.disconnect();
42
43 if (hasCamera()) {
44 startVideoRecording(settings);
45 } else {
46 QObject::connect(&m_audioRecorder, &QQnxAudioRecorder::durationChanged,
47 [this](qint64 d) { durationChanged(d); });
48
49 QObject::connect(&m_audioRecorder, &QQnxAudioRecorder::stateChanged,
50 [this](QMediaRecorder::RecorderState s) { stateChanged(s); });
51
52 QObject::connect(&m_audioRecorder, &QQnxAudioRecorder::actualLocationChanged,
53 [this](const QUrl &l) { actualLocationChanged(l); });
54
55 startAudioRecording(settings);
56 }
57}
58
60{
61 if (hasCamera()) {
62 stopVideoRecording();
63 } else {
64 m_audioRecorder.stop();
65 }
66}
67
68void QQnxMediaRecorder::startAudioRecording(QMediaEncoderSettings &settings)
69{
70 if (!m_session)
71 return;
72
73 QQnxAudioInput *audioInput = m_session->audioInput();
74
75 if (!audioInput)
76 return;
77
78 m_audioRecorder.setInputDeviceId(audioInput->device.id());
79 m_audioRecorder.setMediaEncoderSettings(settings);
80 m_audioRecorder.setOutputUrl(outputLocation());
81 m_audioRecorder.record();
82}
83
84void QQnxMediaRecorder::startVideoRecording(QMediaEncoderSettings &settings)
85{
86 if (!hasCamera())
87 return;
88
89 auto *camera = static_cast<QQnxPlatformCamera*>(m_session->camera());
90
91 camera->setMediaEncoderSettings(settings);
92 camera->setOutputUrl(outputLocation());
93
94 if (camera->startVideoRecording())
95 stateChanged(QMediaRecorder::RecordingState);
96}
97
98void QQnxMediaRecorder::stopVideoRecording()
99{
100 if (!hasCamera())
101 return;
102
103 auto *camera = static_cast<QQnxPlatformCamera*>(m_session->camera());
104
105 camera->stop();
106
107 stateChanged(QMediaRecorder::StoppedState);
108}
109
110bool QQnxMediaRecorder::hasCamera() const
111{
112 return m_session && m_session->camera();
113}
114
115QT_END_NAMESPACE
\inmodule QtMultimedia
QObject * parent
Definition qobject.h:73
QQnxAudioInput * audioInput() const
bool isLocationWritable(const QUrl &location) const override
void record(QMediaEncoderSettings &settings) override
void setCaptureSession(QQnxMediaCaptureSession *session)