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_SESSION_MANAGER_H
17 #define OHOS_CAMERA_DPS_SESSION_MANAGER_H
18 
19 #include "session_info.h"
20 #include "session_coordinator.h"
21 #include "task_manager.h"
22 #include "video_session_info.h"
23 
24 namespace OHOS {
25 namespace CameraStandard {
26 namespace DeferredProcessing {
27 class SessionManager {
28 public:
29     static std::shared_ptr<SessionManager> Create();
30     SessionManager();
31     ~SessionManager();
32 
33     void Initialize();
34     void Start();
35     void Stop();
36     sptr<IDeferredPhotoProcessingSession> CreateDeferredPhotoProcessingSession(
37         const int32_t userId, const sptr<IDeferredPhotoProcessingSessionCallback> callback,
38         std::shared_ptr<DeferredPhotoProcessor> processor, TaskManager* taskManager);
39     std::shared_ptr<IImageProcessCallbacks> GetImageProcCallbacks();
40     sptr<IDeferredPhotoProcessingSessionCallback> GetCallback(const int32_t userId);
41     sptr<IDeferredPhotoProcessingSession> GetDeferredPhotoProcessingSession();
42     sptr<IDeferredVideoProcessingSession> CreateDeferredVideoProcessingSession(const int32_t userId,
43         const sptr<IDeferredVideoProcessingSessionCallback> callback);
44     std::shared_ptr<SessionCoordinator> GetSessionCoordinator();
45     sptr<VideoSessionInfo> GetSessionInfo(const int32_t userId);
46     void OnCallbackDied(const int32_t userId);
47 
48 private:
49     std::mutex mutex_;
50     std::atomic<bool> initialized_;
51     std::unordered_map<int32_t, sptr<SessionInfo>> photoSessionInfos_;
52     SafeMap<int32_t, sptr<VideoSessionInfo>> videoSessionInfos_;
53     std::shared_ptr<SessionCoordinator> coordinator_;
54 };
55 } // namespace DeferredProcessing
56 } // namespace CameraStandard
57 } // namespace OHOS
58 #endif // OHOS_CAMERA_DPS_SESSION_MANAGER_H