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);
106 void emitReadyForCaptureChanged();
110 void releaseSession();
111 bool ensureManager();
112 Camera_Device *findDevice(
const QByteArray &id);
113 bool createPhotoPath(Camera_OutputCapability *caps, Camera_Profile *previewProfile);
114 void destroyPhotoPath();
115 bool attachVideoOutput(
const Camera_VideoProfile &profile,
const QByteArray &surfaceId);
116 void detachVideoOutput();
117 void destroyRecorder();
118 bool findVideoProfile(
const QMediaEncoderSettings &settings, Camera_VideoProfile *out);
120 static void recorderStateCallback(OH_AVRecorder *recorder, OH_AVRecorder_State state,
121 OH_AVRecorder_StateChangeReason reason,
void *userData);
122 static void recorderErrorCallback(OH_AVRecorder *recorder, int32_t errorCode,
123 const char *errorMsg,
void *userData);
125 Camera_Manager *m_manager{
nullptr };
126 Camera_Device *m_supportedDevices{
nullptr };
127 uint32_t m_supportedDeviceCount{ 0 };
129 Camera_Input *m_cameraInput{
nullptr };
130 Camera_CaptureSession *m_captureSession{
nullptr };
131 Camera_PreviewOutput *m_previewOutput{
nullptr };
132 Camera_PhotoOutput *m_photoOutput{
nullptr };
133 Camera_VideoOutput *m_videoOutputCamera{
nullptr };
135 OH_ImageReceiverNative *m_imageReceiver{
nullptr };
136 OH_ImageReceiverOptions *m_imageReceiverOptions{
nullptr };
138 OH_AVRecorder *m_recorder{
nullptr };
139 OHNativeWindow *m_recorderWindow{
nullptr };
141 QUrl m_recorderActualLocation;
142 QElapsedTimer m_recorderTimer;
143 qint64 m_recorderPausedMs{ 0 };
144 qint64 m_recorderResumeStartMs{ 0 };
146 QCameraDevice m_cameraDevice;
147 QCameraFormat m_cameraFormat;
148 QPointer<QVideoSink> m_videoSink;
149 std::unique_ptr<QOhosVideoOutput> m_videoOutput;
151 QImageEncoderSettings m_imageSettings;
152 std::atomic<
int> m_lastCaptureId{ 0 };
153 int m_pendingCaptureId{ 0 };
154 QString m_pendingCaptureFileName;
155 bool m_pendingCaptureToBuffer{
false };
156 bool m_captureInProgress{
false };
158 bool m_active{
false };
159 bool m_pendingStart{
false };
160 std::optional<
bool> m_lastReadyForCapture;