• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2025 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 OHOS_CAMERA_DPS_DEFERRED_PHOTO_PROCESSING_SESSION_H
17 #define OHOS_CAMERA_DPS_DEFERRED_PHOTO_PROCESSING_SESSION_H
18 
19 #include "deferred_photo_processing_session_stub.h"
20 
21 namespace OHOS {
22 namespace CameraStandard {
23 namespace DeferredProcessing {
24 
25 class DeferredPhotoProcessingSession : public DeferredPhotoProcessingSessionStub {
26 public:
27     class PhotoInfo {
28     public:
PhotoInfo(bool discardable,DpsMetadata metadata)29         PhotoInfo(bool discardable, DpsMetadata metadata)
30             : discardable_(discardable), metadata_(metadata)
31         {}
32         ~PhotoInfo() = default;
33 
34         bool discardable_;
35         DpsMetadata metadata_;
36     };
37 
38     DeferredPhotoProcessingSession(const int32_t userId);
39     ~DeferredPhotoProcessingSession();
40 
41     int32_t BeginSynchronize() override;
42     int32_t EndSynchronize() override;
43     int32_t AddImage(const std::string& imageId, const DpsMetadata& metadata, bool discardable) override;
44     int32_t RemoveImage(const std::string& imageId, bool restorable) override;
45     int32_t RestoreImage(const std::string& imageId) override;
46     int32_t ProcessImage(const std::string& appName, const std::string& imageId) override;
47     int32_t CancelProcessImage(const std::string& imageId) override;
48 
49 private:
50     void ReportEvent(const std::string& imageId, int32_t event);
51 
52     std::mutex mutex_;
53     const int32_t userId_;
54     std::atomic<bool> inSync_ {false};
55     std::unordered_map<std::string, std::shared_ptr<PhotoInfo>> imageIds_ {};
56 };
57 } // namespace DeferredProcessing
58 } // namespace CameraStandard
59 } // namespace OHOS
60 #endif // OHOS_CAMERA_DPS_DEFERRED_PHOTO_PROCESSING_SESSION_H