1  /*
2   * Copyright (C) 2021 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 CONFERENCE_BASE_H
17  #define CONFERENCE_BASE_H
18  
19  #include <unistd.h>
20  #include <cstdio>
21  #include <cstdlib>
22  #include <set>
23  #include <memory>
24  #include <mutex>
25  
26  #include "call_manager_inner_type.h"
27  
28  namespace OHOS {
29  namespace Telephony {
30  constexpr uint16_t CS_CONFERENCE_MIN_CALLS_CNT = 2;
31  constexpr uint16_t CS_CONFERENCE_MAX_CALLS_CNT = 5;
32  
33  enum ConferenceState {
34      CONFERENCE_STATE_IDLE = 0,
35      CONFERENCE_STATE_CREATING,
36      CONFERENCE_STATE_HOLDING,
37      CONFERENCE_STATE_ACTIVE,
38      CONFERENCE_STATE_LEAVING,
39  };
40  
41  class ConferenceBase {
42  public:
43      ConferenceBase();
44      virtual ~ConferenceBase();
45      int32_t GetMainCall(); // get host call id
46      int32_t SetMainCall(int32_t callId);
47      ConferenceState GetConferenceState();
48      void SetConferenceState(ConferenceState state);
49      virtual int32_t JoinToConference(int32_t callId) = 0;
50      virtual int32_t LeaveFromConference(int32_t callId) = 0;
51      virtual int32_t HoldConference(int32_t callId) = 0;
52      virtual int32_t CanCombineConference() = 0;
53      virtual int32_t CanSeparateConference() = 0;
54      virtual int32_t CanKickOutFromConference() = 0;
55      int32_t GetSubCallIdList(
56          int32_t callId, std::vector<std::u16string> &callIdList); // get participant list except host
57      std::set<int32_t> GetSubCallIdList();
58      int32_t GetCallIdListForConference(
59          int32_t callId, std::vector<std::u16string> &callIdList); // get participant list besides host
60      ConferenceState GetOldConferenceState();
61      void SetOldConferenceState(ConferenceState state);
62      int32_t IsConferenceCallForMutiSim(int32_t callId);
63  
64  protected:
65      int32_t mainCallId_;
66      ConferenceState state_;
67      ConferenceState oldState_;
68      std::set<int32_t> subCallIdSet_;
69      std::mutex conferenceMutex_;
70      time_t beginTime_;
71      CallType conferenceType_;
72  };
73  } // namespace Telephony
74  } // namespace OHOS
75  
76  #endif
77