57 void setCamera(
const QCameraDevice &camera);
69 bool isReadyForCapture()
const {
return m_active && m_photoOutput && !m_captureInProgress; }
70 int capture(
const QString &fileName,
bool toBuffer =
false);
77 bool startRecording(
const QMediaEncoderSettings &settings,
const QString &location);
104 void onApplicationStateChanged();
107 void emitReadyForCaptureChanged();
111 void releaseSession();
112 bool ensureManager();
113 Camera_Device *findDevice(
const QByteArray &id);
114 bool createPhotoPath(Camera_OutputCapability *caps, Camera_Profile *previewProfile);
115 void destroyPhotoPath();
116 bool attachVideoOutput(
const Camera_VideoProfile &profile,
const QByteArray &surfaceId);
117 void detachVideoOutput();
118 void destroyRecorder();
119 bool findVideoProfile(
const QMediaEncoderSettings &settings, Camera_VideoProfile *out);
121 static void recorderStateCallback(OH_AVRecorder *recorder, OH_AVRecorder_State state,
122 OH_AVRecorder_StateChangeReason reason,
void *userData);
123 static void recorderErrorCallback(OH_AVRecorder *recorder, int32_t errorCode,
124 const char *errorMsg,
void *userData);
126 Camera_Manager *m_manager{
nullptr };
127 Camera_Device *m_supportedDevices{
nullptr };
128 uint32_t m_supportedDeviceCount{ 0 };
130 Camera_Input *m_cameraInput{
nullptr };
131 Camera_CaptureSession *m_captureSession{
nullptr };
132 Camera_PreviewOutput *m_previewOutput{
nullptr };
133 Camera_PhotoOutput *m_photoOutput{
nullptr };
134 Camera_VideoOutput *m_videoOutputCamera{
nullptr };
136 OH_ImageReceiverNative *m_imageReceiver{
nullptr };
137 OH_ImageReceiverOptions *m_imageReceiverOptions{
nullptr };
139 OH_AVRecorder *m_recorder{
nullptr };
140 OHNativeWindow *m_recorderWindow{
nullptr };
142 QUrl m_recorderActualLocation;
143 QElapsedTimer m_recorderTimer;
144 qint64 m_recorderPausedMs{ 0 };
145 qint64 m_recorderResumeStartMs{ 0 };
147 QCameraDevice m_cameraDevice;
148 QCameraFormat m_cameraFormat;
149 QPointer<QVideoSink> m_videoSink;
150 std::unique_ptr<QOhosVideoOutput> m_videoOutput;
152 QImageEncoderSettings m_imageSettings;
153 std::atomic<
int> m_lastCaptureId{ 0 };
154 int m_pendingCaptureId{ 0 };
155 QString m_pendingCaptureFileName;
156 bool m_pendingCaptureToBuffer{
false };
157 bool m_captureInProgress{
false };
159 bool m_active{
false };
160 bool m_pendingStart{
false };
161 bool m_restoreOnForeground{
false };
162 QByteArray m_previewSurfaceId;
163 std::optional<
bool> m_lastReadyForCapture;