1 /* 2 * Copyright (c) 2023-2023 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_JOB_H 17 #define OHOS_CAMERA_DPS_DEFERRED_PHOTO_JOB_H 18 19 #include <map> 20 #include <memory> 21 #include <string> 22 23 #include "basic_definitions.h" 24 #include "foundation/multimedia/camera_framework/interfaces/inner_api/native/camera/include/utils/dps_metadata_info.h" 25 26 namespace OHOS { 27 namespace CameraStandard { 28 namespace DeferredProcessing { 29 enum class PhotoJobStatus { 30 NONE = 0, 31 PENDING, 32 RUNNING, 33 FAILED, 34 COMPLETED, 35 DELETED 36 }; 37 38 enum class PhotoJobPriority { 39 NONE = 0, 40 LOW, 41 NORMAL, 42 HIGH, 43 DELETED 44 }; 45 46 enum class PhotoJobType { 47 OFFLINE = 0, 48 BACKGROUND 49 }; 50 51 class DeferredPhotoJob { 52 public: 53 DeferredPhotoJob(const std::string& imageId, bool discardable, DpsMetadata& metadata); 54 ~DeferredPhotoJob(); 55 56 PhotoJobPriority GetCurPriority(); 57 PhotoJobPriority GetPrePriority(); 58 PhotoJobPriority GetRunningPriority(); 59 PhotoJobStatus GetCurStatus(); 60 PhotoJobStatus GetPreStatus(); 61 std::string& GetImageId(); 62 int GetDeferredProcType(); 63 64 private: 65 friend class PhotoJobRepository; 66 67 bool SetJobStatus(PhotoJobStatus curStatus); 68 bool SetJobPriority(PhotoJobPriority priority); 69 void RecordJobRunningPriority(); 70 void SetJobType(PhotoJobType photoJobType); 71 bool GetDiscardable(); 72 int GetPhotoJobType(); 73 void SetPhotoJobType(int photoJobType); 74 75 std::string imageId_; 76 bool discardable_; 77 DpsMetadata metadata_; 78 PhotoJobPriority prePriority_; 79 PhotoJobPriority curPriority_; 80 PhotoJobPriority runningPriority_; 81 PhotoJobStatus preStatus_; 82 PhotoJobStatus curStatus_; 83 int photoJobType_; 84 }; 85 using DeferredPhotoJobPtr = std::shared_ptr<DeferredPhotoJob>; 86 87 class DeferredPhotoWork { 88 public: 89 DeferredPhotoWork(DeferredPhotoJobPtr jobPtr, ExecutionMode mode); 90 ~DeferredPhotoWork(); 91 DeferredPhotoJobPtr GetDeferredPhotoJob(); 92 ExecutionMode GetExecutionMode(); 93 94 private: 95 DeferredPhotoJobPtr jobPtr_; 96 ExecutionMode executionMode_; 97 }; 98 using DeferredPhotoWorkPtr = std::shared_ptr<DeferredPhotoWork>; 99 } // namespace DeferredProcessing 100 } // namespace CameraStandard 101 } // namespace OHOS 102 #endif // OHOS_CAMERA_DPS_DEFERRED_PHOTO_JOB_H