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
avfcamerasession_p.h
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
4#ifndef AVFCAMERASESSION_H
5#define AVFCAMERASESSION_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtMultimedia/qcamera.h>
19#include <QtMultimedia/qcameradevice.h>
20#include <QtMultimedia/qvideoframe.h>
21#include <QtCore/qmutex.h>
22
23#include <camera/avfaudiopreviewdelegate_p.h>
24
25#import <AVFoundation/AVFoundation.h>
26
27@class AVFCameraSessionObserver;
28
29QT_BEGIN_NAMESPACE
30
31class AVFCamera;
34class AVFVideoSink;
35class QVideoSink;
36
38{
40public:
43
44 QCameraDevice activecameraDevice() const { return m_activeCameraDevice; }
45 void setActiveCamera(const QCameraDevice &info);
46
47 void setCameraFormat(const QCameraFormat &format);
49
50 AVFCameraRenderer *videoOutput() const { return m_videoOutput; }
51 AVCaptureAudioDataOutput *audioOutput() const { return m_audioOutput; }
52 AVFAudioPreviewDelegate *audioPreviewDelegate() const { return m_audioPreviewDelegate; }
53
54 AVCaptureSession *captureSession() const { return m_captureSession; }
57
58 bool isActive() const;
59
61
62 AVCaptureDeviceInput *videoInput() const { return m_videoInput; }
63 AVCaptureDeviceInput *audioInput() const { return m_audioInput; }
64
65 void setVideoSink(QVideoSink *sink);
66
67 void updateVideoInput();
68
69 void updateAudioInput();
70 void updateAudioOutput();
71
72public Q_SLOTS:
73 void setActive(bool active);
74
75 void setAudioInputVolume(float volume);
76 void setAudioInputMuted(bool muted);
77 void setAudioOutputMuted(bool muted);
78 void setAudioOutputVolume(float volume);
79
83
86 void activeChanged(bool);
87 void error(int error, const QString &errorString);
88 void newViewfinderFrame(const QVideoFrame &frame);
89
90private:
91 void updateCameraFormat(const QCameraFormat &format);
92
93 void setVideoOutput(AVFCameraRenderer *output);
94 void updateVideoOutput();
95
96 void addAudioCapture();
97
98 AVCaptureDevice *createVideoCaptureDevice();
99 AVCaptureDevice *createAudioCaptureDevice();
100 void attachVideoInputDevice();
101 void attachAudioInputDevice();
102 bool checkCameraPermission();
103 bool checkMicrophonePermission();
104
105 bool applyImageEncoderSettings();
106
107 QCameraDevice m_activeCameraDevice;
108 QCameraFormat m_cameraFormat;
109
110 AVFCameraService *m_service;
111 AVCaptureSession *m_captureSession;
112 AVFCameraSessionObserver *m_observer;
113
114 AVFCameraRenderer *m_videoOutput = nullptr;
115 AVFVideoSink *m_videoSink = nullptr;
116
117 AVCaptureDeviceInput *m_videoInput = nullptr;
118 AVCaptureDeviceInput *m_audioInput = nullptr;
119
120 AVCaptureAudioDataOutput *m_audioOutput = nullptr;
121 AVFAudioPreviewDelegate *m_audioPreviewDelegate = nullptr;
122
123 bool m_active = false;
124
125 float m_inputVolume = 1.0;
126 bool m_inputMuted = false;
127
128 FourCharCode m_defaultCodec;
129};
130
131QT_END_NAMESPACE
132
133#endif
void error(int error, const QString &errorString)
AVCaptureDeviceInput * videoInput() const
AVCaptureSession * captureSession() const
QCameraDevice activecameraDevice() const
void setCameraFormat(const QCameraFormat &format)
AVCaptureDevice * videoCaptureDevice() const
void setAudioOutputMuted(bool muted)
QCameraFormat cameraFormat() const
~AVFCameraSession() override
void setActiveCamera(const QCameraDevice &info)
void setAudioInputVolume(float volume)
AVFCameraRenderer * videoOutput() const
AVCaptureDevice * audioCaptureDevice() const
void newViewfinderFrame(const QVideoFrame &frame)
void setVideoSink(QVideoSink *sink)
FourCharCode defaultCodec()
void activeChanged(bool)
void setAudioOutputVolume(float volume)
AVCaptureDeviceInput * audioInput() const
void setAudioInputMuted(bool muted)
AVFAudioPreviewDelegate * audioPreviewDelegate() const
AVCaptureAudioDataOutput * audioOutput() const