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_PROCESSING_SESSION_H 17 #define OHOS_CAMERA_DPS_DEFERRED_PHOTO_PROCESSING_SESSION_H 18 #define EXPORT_API __attribute__((visibility("default"))) 19 20 #include "deferred_photo_processing_session_stub.h" 21 #include "ideferred_photo_processing_session_callback.h" 22 #include "task_manager.h" 23 #include "deferred_photo_processor.h" 24 25 namespace OHOS { 26 namespace CameraStandard { 27 namespace DeferredProcessing { 28 29 class DeferredPhotoProcessingSession : public DeferredPhotoProcessingSessionStub { 30 public: 31 class PhotoInfo { 32 public: PhotoInfo(bool discardable,DpsMetadata metadata)33 PhotoInfo(bool discardable, DpsMetadata metadata) 34 : discardable_(discardable), metadata_(metadata) 35 {} 36 ~PhotoInfo() = default; 37 38 bool discardable_; 39 DpsMetadata metadata_; 40 }; 41 EXPORT_API DeferredPhotoProcessingSession( 42 const int32_t userId, std::shared_ptr<DeferredPhotoProcessor> deferredPhotoProcessor, 43 TaskManager* taskManager, sptr<IDeferredPhotoProcessingSessionCallback> callback); 44 45 ~DeferredPhotoProcessingSession(); 46 int32_t BeginSynchronize() override; 47 int32_t EndSynchronize() override; 48 int32_t AddImage(const std::string& imageId, DpsMetadata& metadata, bool discardable) override; 49 int32_t RemoveImage(const std::string& imageId, bool restorable) override; 50 int32_t RestoreImage(const std::string& imageId) override; 51 int32_t ProcessImage(const std::string& appName, const std::string imageId) override; 52 int32_t CancelProcessImage(const std::string& imageId) override; 53 54 private: 55 void ReportEvent(const std::string& imageId, int32_t event); 56 const int32_t userId_; 57 std::atomic<bool> inSync_; 58 std::shared_ptr<DeferredPhotoProcessor> processor_; 59 TaskManager* taskManager_; 60 sptr<IDeferredPhotoProcessingSessionCallback> callback_; 61 std::unordered_map<std::string, std::shared_ptr<PhotoInfo>> imageIds_; 62 }; 63 } // namespace DeferredProcessing 64 } // namespace CameraStandard 65 } // namespace OHOS 66 #endif // OHOS_CAMERA_DPS_DEFERRED_PHOTO_PROCESSING_SESSION_H