• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025-2025 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_H_CAPTURE_SESSION_MANAGER_H
17 #define OHOS_CAMERA_H_CAPTURE_SESSION_MANAGER_H
18 
19 #include <iterator>
20 #include <list>
21 #include <memory>
22 #include <mutex>
23 #include <cstdint>
24 #include <unordered_map>
25 
26 #include "camera_util.h"
27 #include "refbase.h"
28 #include "singleton.h"
29 
30 namespace OHOS {
31 namespace CameraStandard {
32 class HCaptureSession;
33 class SessionGroup : public std::list<sptr<HCaptureSession>> {};
34 class HCameraSessionManager : public Singleton<HCameraSessionManager> {
35 public:
36     size_t GetTotalSessionSize();
37     size_t GetGroupCount();
38     size_t GetSessionSize(pid_t pid);
39     std::list<sptr<HCaptureSession>> GetTotalSession();
40     std::list<sptr<HCaptureSession>> GetGroupSessions(pid_t pid);
41     sptr<HCaptureSession> GetGroupDefaultSession(pid_t pid);
42     CamServiceError AddSession(sptr<HCaptureSession> session);
43     void RemoveSession(sptr<HCaptureSession> session);
44     void RemoveGroup(pid_t pid);
45     void PreemptOverflowSessions(pid_t pid);
46 
47 private:
48     void RemoveGroupNoLock(std::unordered_map<pid_t, SessionGroup>::iterator mapIt);
49 
50     std::mutex totalSessionMapMutex_;
51     std::unordered_map<pid_t, SessionGroup> totalSessionMap_;
52 };
53 } // namespace CameraStandard
54 } // namespace OHOS
55 
56 #endif