• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 CALL_BASE_H
17 #define CALL_BASE_H
18 
19 #include <unistd.h>
20 #include <cstring>
21 #include <memory>
22 #include <mutex>
23 
24 #include "refbase.h"
25 #include "pac_map.h"
26 
27 #include "common_type.h"
28 #include "conference_base.h"
29 
30 /**
31  * @ClassName: CallBase
32  * @Description: an abstraction  of telephone calls, provide basic call ops interfaces
33  */
34 namespace OHOS {
35 namespace Telephony {
36 class CallBase : public virtual RefBase {
37 public:
38     CallBase(DialParaInfo &info);
39     CallBase(DialParaInfo &info, AppExecFwk::PacMap &extras);
40     virtual ~CallBase();
41 
42     virtual int32_t DialingProcess() = 0;
43     virtual int32_t AnswerCall(int32_t videoState) = 0;
44     virtual int32_t RejectCall() = 0;
45     virtual int32_t HangUpCall() = 0;
46     virtual int32_t HoldCall() = 0;
47     virtual int32_t UnHoldCall() = 0;
48     virtual int32_t SwitchCall() = 0;
49     virtual void GetCallAttributeInfo(CallAttributeInfo &info) = 0;
50     virtual bool GetEmergencyState() = 0;
51     virtual int32_t StartDtmf(char str) = 0;
52     virtual int32_t StopDtmf() = 0;
53     virtual int32_t GetSlotId() = 0;
54     virtual int32_t CombineConference() = 0;
55     virtual int32_t SeparateConference() = 0;
56     virtual int32_t CanCombineConference() = 0;
57     virtual int32_t CanSeparateConference() = 0;
58     virtual int32_t LaunchConference() = 0;
59     virtual int32_t ExitConference() = 0;
60     virtual int32_t HoldConference() = 0;
61     virtual int32_t GetMainCallId(int32_t &mainCallId) = 0;
62     virtual int32_t GetSubCallIdList(std::vector<std::u16string> &callIdList) = 0;
63     virtual int32_t GetCallIdListForConference(std::vector<std::u16string> &callIdList) = 0;
64     virtual int32_t IsSupportConferenceable() = 0;
65     virtual int32_t SetMute(int32_t mute, int32_t slotId) = 0;
66     int32_t DialCallBase();
67     int32_t IncomingCallBase();
68     int32_t AnswerCallBase();
69     int32_t RejectCallBase();
70     void GetCallAttributeBaseInfo(CallAttributeInfo &info);
71     int32_t GetCallID();
72     CallType GetCallType();
73     CallRunningState GetCallRunningState();
74     int32_t SetTelCallState(TelCallState nextState);
75     TelCallState GetTelCallState();
76     void SetTelConferenceState(TelConferenceState state);
77     TelConferenceState GetTelConferenceState();
78     VideoStateType GetVideoStateType();
79     void SetVideoStateType(VideoStateType mediaType);
80     void SetPolicyFlag(PolicyFlag flag);
81     uint64_t GetPolicyFlag();
82     ContactInfo GetCallerInfo();
83     void SetCallerInfo(const ContactInfo &contactInfo);
84     void SetCallRunningState(CallRunningState callRunningState);
85     void SetStartTime(int64_t startTime);
86     void SetCallBeginTime(time_t callBeginTime);
87     void SetCallEndTime(time_t callEndTime);
88     void SetRingBeginTime(time_t ringBeginTime);
89     void SetRingEndTime(time_t ringEndTime);
90     void SetAnswerType(CallAnswerType answerType);
91     CallEndedType GetCallEndedType();
92     int32_t SetCallEndedType(CallEndedType callEndedType);
93     void SetCallId(int32_t callId);
94     bool IsSpeakerphoneEnabled();
95     bool IsCurrentRinging();
96     std::string GetAccountNumber();
97     int32_t SetSpeakerphoneOn(bool speakerphoneOn);
98     bool IsSpeakerphoneOn();
99     void SetAudio();
100     bool CheckVoicemailNumber(std::string phoneNumber);
101     bool IsAliveState();
102 
103 protected:
104     int32_t callId_;
105     CallType callType_;
106     VideoStateType videoState_;
107     std::string accountNumber_;
108     std::string bundleName_;
109 
110 private:
111     void StateChangesToDialing();
112     void StateChangesToIncoming();
113     void StateChangesToWaiting();
114     void StateChangesToActive();
115     void StateChangesToHolding();
116     void StateChangesToDisconnected();
117     void StateChangesToDisconnecting();
118     void StateChangesToAlerting();
119 
120     CallRunningState callRunningState_;
121     TelConferenceState conferenceState_;
122     int64_t startTime_; // Call start time
123     CallDirection direction_;
124     uint64_t policyFlag_;
125     TelCallState callState_;
126     bool isSpeakerphoneOn_;
127     CallEndedType callEndedType_;
128     ContactInfo contactInfo_;
129     time_t callBeginTime_;
130     time_t callEndTime_;
131     time_t ringBeginTime_;
132     time_t ringEndTime_;
133     CallAnswerType answerType_;
134     std::mutex mutex_;
135 };
136 } // namespace Telephony
137 } // namespace OHOS
138 
139 #endif // CALL_BASE_H
140