1 /*
2  * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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_SHARING_CHANNEL_MGR_H
17 #define OHOS_SHARING_CHANNEL_MGR_H
18 
19 #include <memory>
20 #include <singleton.h>
21 #include <cstdint>
22 #include <unordered_map>
23 #include "event/handle_event_base.h"
24 
25 namespace OHOS {
26 namespace Sharing {
27 
28 class MediaChannel;
29 class ChannelManager : public Singleton<ChannelManager>,
30                        public EventEmitter,
31                        public HandleEventBase {
32     friend class Singleton<ChannelManager>;
33 
34 public:
35     ChannelManager();
36     virtual ~ChannelManager();
37 
38     void Init();
39     int32_t HandleEvent(SharingEvent &event);
40     std::shared_ptr<MediaChannel> GetMediaChannel(uint32_t mediaChannelId);
41 
42 private:
43     SharingErrorCode HandleMediaChannelCreate(SharingEvent &event);
44     SharingErrorCode HandleMediaChannelDestroy(SharingEvent &event);
45 
46 private:
47     std::mutex mutex_;
48     std::mutex mixMutex_;
49 
50     std::unordered_map<uint32_t, std::shared_ptr<MediaChannel>> mediaChannels_;
51 };
52 
53 } // namespace Sharing
54 } // namespace OHOS
55 #endif