Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qwasmmediacapturesession.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 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
6
7#include "qwasmcamera_p.h"
8#include <private/qplatformmediadevices_p.h>
9#include <private/qwasmmediadevices_p.h>
10
11Q_LOGGING_CATEGORY(qWasmMediaCaptureSession, "qt.multimedia.wasm.capturesession")
12
14{
15 QWasmMediaDevices *wasmMediaDevices = static_cast<QWasmMediaDevices *>(QPlatformMediaDevices::instance());
16 wasmMediaDevices->initDevices();
17}
18
20
22{
23 return m_camera.data();
24}
25
27{
28 if (!camera) {
29 if (m_camera == nullptr)
30 return;
31 m_camera.reset(nullptr);
32 } else {
33 QWasmCamera *wasmCamera = static_cast<QWasmCamera *>(camera);
34 if (m_camera.data() == wasmCamera)
35 return;
36 m_camera.reset(wasmCamera);
37 m_camera->setCaptureSession(this);
38 }
40}
41
43{
44 return m_imageCapture;
45}
46
48{
49 if (m_imageCapture == imageCapture)
50 return;
51
52 if (m_imageCapture)
53 m_imageCapture->setCaptureSession(nullptr);
54
55 m_imageCapture = static_cast<QWasmImageCapture *>(imageCapture);
56
57 if (m_imageCapture) {
58 m_imageCapture->setCaptureSession(this);
59
60 m_imageCapture->setReadyForCapture(true);
62 }
63}
64
66{
67 return m_mediaRecorder;
68}
69
71{
72 if (m_mediaRecorder == mediaRecorder)
73 return;
74
75 if (m_mediaRecorder)
76 m_mediaRecorder->setCaptureSession(nullptr);
77
78 m_mediaRecorder = static_cast<QWasmMediaRecorder *>(mediaRecorder);
79
80 if (m_mediaRecorder)
81 m_mediaRecorder->setCaptureSession(this);
82}
83
85{
86 if (m_audioInput == input)
87 return;
88
89 m_needsAudio = (bool)input;
90 m_audioInput = input;
91}
92
94{
95 return m_needsAudio;
96}
97
99{
100 if (m_wasmSink == sink)
101 return;
102 m_wasmSink = sink;
103}
104
106{
107 if (m_audioOutput == output)
108 return;
109 m_audioOutput = output;
110}
static QPlatformMediaDevices * instance()
T * data() const noexcept
Returns the value of the pointer referenced by this object.
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
The QVideoSink class represents a generic sink for video data.
Definition qvideosink.h:22
void setCaptureSession(QPlatformMediaCaptureSession *session) override
void setReadyForCapture(bool isReady)
void setCaptureSession(QPlatformMediaCaptureSession *session)
void setMediaRecorder(QPlatformMediaRecorder *recorder) override
void setAudioInput(QPlatformAudioInput *input) override
void setAudioOutput(QPlatformAudioOutput *output) override
QPlatformImageCapture * imageCapture() override
QPlatformMediaRecorder * mediaRecorder() override
void setImageCapture(QPlatformImageCapture *imageCapture) override
void setCamera(QPlatformCamera *camera) override
~QWasmMediaCaptureSession() override
void setVideoPreview(QVideoSink *sink) override
QPlatformCamera * camera() override
void setCaptureSession(QPlatformMediaCaptureSession *session)
QCamera * camera
Definition camera.cpp:19
QImageCapture * imageCapture
Definition camera.cpp:21
#define Q_LOGGING_CATEGORY(name,...)
GLsizei GLenum GLboolean sink
GLenum GLenum GLenum input
#define emit
QT_BEGIN_NAMESPACE typedef uchar * output