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_BASE_CHANNEL_H
17 #define OHOS_SHARING_BASE_CHANNEL_H
18 
19 #include <memory>
20 #include <cstdint>
21 #include <string>
22 #include <unordered_map>
23 #include "base_consumer.h"
24 #include "base_producer.h"
25 #include "common/event_comm.h"
26 #include "event/handle_event_base.h"
27 #include "mediachannel/media_channel_def.h"
28 
29 namespace OHOS {
30 namespace Sharing {
31 
32 class BaseChannel : public EventEmitter,
33                     public HandleEventBase,
34                     public IdentifierInfo {
35 public:
36     using Ptr = std::shared_ptr<BaseChannel>;
37 
38     virtual ~BaseChannel() = default;
39 
40     virtual uint32_t CreateProducer(std::string &className) = 0;
41     virtual SharingErrorCode CreateConsumer(std::string &className) = 0;
42 
43 protected:
44     std::unordered_map<uint32_t, BaseProducer::Ptr> producers_;
45 
46     BaseConsumer::Ptr consumer_ = nullptr;
47 };
48 
49 } // namespace Sharing
50 } // namespace OHOS
51 #endif