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_PROCESSING_SERVICE_H 17 #define OHOS_CAMERA_DPS_DEFERRED_PROCESSING_SERVICE_H 18 #define EXPORT_API __attribute__((visibility("default"))) 19 20 #include "ideferred_photo_processing_session.h" 21 #include "ideferred_photo_processing_session_callback.h" 22 #include "ideferred_video_processing_session.h" 23 #include "ideferred_video_processing_session_callback.h" 24 #include "singleton.h" 25 #include "task_manager.h" 26 27 namespace OHOS::Media { 28 class Picture; 29 } 30 namespace OHOS { 31 namespace CameraStandard { 32 namespace DeferredProcessing { 33 class EXPORT_API DeferredProcessingService : public RefBase, public Singleton<DeferredProcessingService> { 34 DECLARE_SINGLETON(DeferredProcessingService) 35 36 public: 37 void Initialize(); 38 void Start(); 39 void Stop(); 40 void NotifyLowQualityImage(const int32_t userId, const std::string& imageId, 41 std::shared_ptr<Media::Picture> picture); 42 sptr<IDeferredPhotoProcessingSession> CreateDeferredPhotoProcessingSession(const int32_t userId, 43 const sptr<IDeferredPhotoProcessingSessionCallback> callbacks); 44 sptr<IDeferredVideoProcessingSession> CreateDeferredVideoProcessingSession(const int32_t userId, 45 const sptr<IDeferredVideoProcessingSessionCallback> callbacks); 46 void NotifyCameraSessionStatus(const int32_t userId, 47 const std::string& cameraId, bool running, bool isSystemCamera); 48 49 private: 50 TaskManager* GetPhotoTaskManager(const int32_t userId); 51 52 std::atomic<bool> initialized_ {false}; 53 std::unordered_map<int, std::shared_ptr<TaskManager>> photoTaskManagerMap_; 54 std::mutex taskManagerMutex_; 55 }; 56 } // namespace DeferredProcessing 57 } // namespace CameraStandard 58 } // namespace OHOS 59 #endif // OHOS_CAMERA_DPS_DEFERRED_PROCESSING_SERVICE_H