• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef MULTISTAGES_CAPTURE_DEFERRED_PHOTO_PROC_SESSION_CALLBACK_H
17 #define MULTISTAGES_CAPTURE_DEFERRED_PHOTO_PROC_SESSION_CALLBACK_H
18 
19 #ifdef ABILITY_CAMERA_SUPPORT
20 #include <memory>
21 #include <string>
22 
23 #include "deferred_photo_proc_session.h"
24 #include "result_set_utils.h"
25 #include "medialibrary_command.h"
26 
27 namespace OHOS {
28 namespace Media {
29 class Picture;
30 #define EXPORT __attribute__ ((visibility ("default")))
31 using ProcessDoneHandler = std::function<void(bool, const std::string &)>;
32 class MultiStagesCaptureDeferredPhotoProcSessionCallback : public CameraStandard::IDeferredPhotoProcSessionCallback {
33 public:
34     EXPORT MultiStagesCaptureDeferredPhotoProcSessionCallback();
35     EXPORT ~MultiStagesCaptureDeferredPhotoProcSessionCallback();
36 
37     void OnProcessImageDone(const std::string &imageId, const uint8_t *addr, const long bytes,
38         uint32_t cloudImageEnhanceFlag) override;
39     void OnProcessImageDone(const std::string &imageId, std::shared_ptr<CameraStandard::PictureIntf> picture,
40         uint32_t cloudImageEnhanceFlag) override;
41     void OnDeliveryLowQualityImage(const std::string &imageId,
42         std::shared_ptr<CameraStandard::PictureIntf> picture) override;
43     EXPORT void OnError(const std::string &imageId, const CameraStandard::DpsErrorCode error) override;
44     void OnStateChanged(const CameraStandard::DpsStatusCode state) override;
45 
46     void SetProcessImageDoneCallback(const ProcessDoneHandler &func);
47 
48 private:
49     EXPORT int32_t UpdatePhotoQuality(const std::string &photoId);
50     EXPORT void UpdateCEAvailable(const std::string &photoId, uint32_t cloudImageEnhanceFlag, int32_t modifyType = 0);
51     EXPORT void GetCommandByImageId(const std::string &imageId, MediaLibraryCommand &cmd);
52     EXPORT void UpdateHighQualityPictureInfo(const std::string &imageId, uint32_t cloudImageEnhanceFlag,
53         int32_t modifyType = 0);
54     EXPORT void NotifyIfTempFile(std::shared_ptr<NativeRdb::ResultSet> resultSet, bool isError = false);
55     EXPORT void ProcessAndSaveHighQualityImage(const std::string& imageId, std::shared_ptr<Media::Picture> picture,
56         std::shared_ptr<NativeRdb::ResultSet> resultSet, uint32_t cloudImageEnhanceFlag, int32_t modifyType = 0);
57     void CallProcessImageDone(bool success, const std::string &photoId);
58 
59 private:
60     ProcessDoneHandler processDoneCallback_;
61 };
62 } // namespace Media
63 } // namespace OHOS
64 #endif
65 #endif  // MULTISTAGES_CAPTURE_DEFERRED_PHOTO_PROC_SESSION_CALLBACK_H