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
6
7#include "camera/qqnxplatformcamera_p.h"
8#include "common/qqnxaudioinput_p.h"
9#include "camera/qqnxcamera_p.h"
11
12#include <private/qplatformcamera_p.h>
13
14#include <QDebug>
15#include <QUrl>
16
18
23
24bool QQnxMediaRecorder::isLocationWritable(const QUrl &/*location*/) const
25{
26 return true;
27}
28
30{
31 m_session = session;
32}
33
34void QQnxMediaRecorder::record(QMediaEncoderSettings &settings)
35{
36 if (!m_session)
37 return;
38
39 m_audioRecorder.disconnect();
40
41 if (hasCamera()) {
42 startVideoRecording(settings);
43 } else {
44 QObject::connect(&m_audioRecorder, &QQnxAudioRecorder::durationChanged,
45 &m_audioRecorder, [this](qint64 d) { durationChanged(d); });
46
47 QObject::connect(&m_audioRecorder, &QQnxAudioRecorder::stateChanged,
48 &m_audioRecorder, [this](QMediaRecorder::RecorderState s) { stateChanged(s); });
49
50 QObject::connect(&m_audioRecorder, &QQnxAudioRecorder::actualLocationChanged,
51 &m_audioRecorder, [this](const QUrl &l) { actualLocationChanged(l); });
52
53 startAudioRecording(settings);
54 }
55}
56
58{
59 if (hasCamera()) {
60 stopVideoRecording();
61 } else {
62 m_audioRecorder.stop();
63 }
64}
65
66void QQnxMediaRecorder::startAudioRecording(QMediaEncoderSettings &settings)
67{
68 if (!m_session)
69 return;
70
71 QQnxAudioInput *audioInput = m_session->audioInput();
72
73 if (!audioInput)
74 return;
75
76 m_audioRecorder.setInputDeviceId(audioInput->device.id());
77 m_audioRecorder.setMediaEncoderSettings(settings);
78 m_audioRecorder.setOutputUrl(outputLocation());
79 m_audioRecorder.record();
80}
81
82void QQnxMediaRecorder::startVideoRecording(QMediaEncoderSettings &settings)
83{
84 if (!hasCamera())
85 return;
86
87 auto *camera = static_cast<QQnxPlatformCamera*>(m_session->camera());
88
89 camera->setMediaEncoderSettings(settings);
90 camera->setOutputUrl(outputLocation());
91
92 if (camera->startVideoRecording())
93 stateChanged(QMediaRecorder::RecordingState);
94}
95
96void QQnxMediaRecorder::stopVideoRecording()
97{
98 if (!hasCamera())
99 return;
100
101 auto *camera = static_cast<QQnxPlatformCamera*>(m_session->camera());
102
103 camera->stop();
104
105 stateChanged(QMediaRecorder::StoppedState);
106}
107
108bool QQnxMediaRecorder::hasCamera() const
109{
110 return m_session && m_session->camera();
111}
112
113QT_END_NAMESPACE
\inmodule QtMultimedia
QObject * parent
Definition qobject.h:74
QQnxAudioInput * audioInput() const
bool isLocationWritable(const QUrl &location) const override
void record(QMediaEncoderSettings &settings) override
void setCaptureSession(QQnxMediaCaptureSession *session)
Combined button and popup list for selecting options.