• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_VIDEO_CONTROLLER_H
17 #define OHOS_CAMERA_DPS_DEFERRED_VIDEO_CONTROLLER_H
18 
19 #include "deferred_video_processor.h"
20 #include "video_strategy_center.h"
21 
22 namespace OHOS {
23 namespace CameraStandard {
24 namespace DeferredProcessing {
25 class DeferredVideoController : public std::enable_shared_from_this<DeferredVideoController> {
26 public:
27     ~DeferredVideoController();
28 
29     void Initialize();
30     void HandleServiceDied();
31     void HandleSuccess(const DeferredVideoWorkPtr& work);
32     void HandleError(const DeferredVideoWorkPtr& work, DpsError errorCode);
33 
34 protected:
35     DeferredVideoController(const int32_t userId, const std::shared_ptr<VideoJobRepository>& repository,
36         const std::shared_ptr<DeferredVideoProcessor>& processor);
37 
38 private:
39     class StateListener;
40     class VideoJobRepositoryListener;
41 
42     void OnSchedulerChanged(const SchedulerType& type, const SchedulerInfo& scheduleInfo);
43     void OnVideoJobChanged(const DeferredVideoJobPtr& jobPtr);
44     void TryDoSchedule();
45     void PauseRequests(const SchedulerType& type);
46     void PostProcess(const DeferredVideoWorkPtr& work);
47     void SetDefaultExecutionMode();
48     void StartSuspendLock();
49     void StopSuspendLock();
50     void HandleNormalSchedule(const DeferredVideoWorkPtr& work);
51     void OnTimerOut();
52 
53     const int32_t userId_;
54     uint32_t normalTimeId_ {INVALID_TIMERID};
55     std::shared_ptr<DeferredVideoProcessor> videoProcessor_;
56     std::shared_ptr<VideoJobRepository> repository_;
57     std::shared_ptr<VideoStrategyCenter> videoStrategyCenter_ {nullptr};
58     std::shared_ptr<StateListener> videoStateChangeListener_ {nullptr};
59     std::shared_ptr<VideoJobRepositoryListener> videoJobChangeListener_ {nullptr};
60 };
61 } // namespace DeferredProcessing
62 } // namespace CameraStandard
63 } // namespace OHOS
64 #endif // OHOS_CAMERA_DPS_DEFERRED_VIDEO_CONTROLLER_H