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_CONTROLLER_H 17 #define OHOS_CAMERA_DPS_DEFERRED_PHOTO_CONTROLLER_H 18 19 #include "background_strategy.h" 20 #include "deferred_photo_job.h" 21 #include "deferred_photo_processor.h" 22 #include "user_initiated_strategy.h" 23 24 namespace OHOS { 25 namespace CameraStandard { 26 namespace DeferredProcessing { 27 class DeferredPhotoController : public std::enable_shared_from_this<DeferredPhotoController> { 28 public: 29 ~DeferredPhotoController(); 30 31 void Initialize(); 32 33 protected: 34 DeferredPhotoController(const int32_t userId, const std::shared_ptr<PhotoJobRepository>& repository, 35 const std::shared_ptr<DeferredPhotoProcessor>& processor); 36 37 private: 38 class EventsListener; 39 class PhotoJobRepositoryListener; 40 41 void TryDoSchedule(); 42 void PostProcess(DeferredPhotoWorkPtr work); 43 void SetDefaultExecutionMode(); 44 void NotifyPressureLevelChanged(SystemPressureLevel level); 45 void NotifyHdiStatusChanged(HdiStatus status); 46 void NotifyMediaLibStatusChanged(MediaLibraryStatus status); 47 void NotifyCameraStatusChanged(CameraSessionStatus status); 48 void OnPhotoJobChanged(bool priorityChanged, bool statusChanged, DeferredPhotoJobPtr jobPtr); 49 void StartWaitForUser(); 50 void StopWaitForUser(); 51 void NotifyScheduleState(bool workAvailable); 52 53 const int32_t userId_; 54 DpsStatus scheduleState_; 55 uint32_t timeId_ {INVALID_TIMEID}; 56 std::unique_ptr<UserInitiatedStrategy> userInitiatedStrategy_ {nullptr}; 57 std::unique_ptr<BackgroundStrategy> backgroundStrategy_ {nullptr}; 58 std::shared_ptr<PhotoJobRepository> photoJobRepository_; 59 std::shared_ptr<DeferredPhotoProcessor> photoProcessor_; 60 std::shared_ptr<EventsListener> eventsListener_; 61 std::shared_ptr<PhotoJobRepositoryListener> photoJobRepositoryListener_; 62 }; 63 } // namespace DeferredProcessing 64 } // namespace CameraStandard 65 } // namespace OHOS 66 #endif // OHOS_CAMERA_DPS_DEFERRED_PHOTO_CONTROLLER_H