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() = 0; 62 virtual std::vector<std::u16string> GetSubCallIdList() = 0; 63 virtual std::vector<std::u16string> GetCallIdListForConference() = 0; 64 virtual int32_t IsSupportConferenceable() = 0; 65 int32_t DialCallBase(); 66 int32_t IncomingCallBase(); 67 int32_t AnswerCallBase(); 68 int32_t RejectCallBase(); 69 void GetCallAttributeBaseInfo(CallAttributeInfo &info); 70 int32_t GetCallID(); 71 CallType GetCallType(); 72 CallRunningState GetCallRunningState(); 73 int32_t SetTelCallState(TelCallState nextState); 74 TelCallState GetTelCallState(); 75 void SetTelConferenceState(TelConferenceState state); 76 TelConferenceState GetTelConferenceState(); 77 VideoStateType GetVideoStateType(); 78 void SetVideoStateType(VideoStateType mediaType); 79 void SetPolicyFlag(PolicyFlag flag); 80 uint64_t GetPolicyFlag(); 81 bool GetCallerInfo(ContactInfo &info); 82 void SetCallerInfo(const ContactInfo &contactInfo); 83 CallEndedType GetCallEndedType(); 84 int32_t SetCallEndedType(CallEndedType callEndedType); 85 bool IsSpeakerphoneEnabled(); 86 bool IsCurrentRinging(); 87 std::string GetAccountNumber(); 88 int32_t SetSpeakerphoneOn(bool speakerphoneOn); 89 bool IsSpeakerphoneOn(); 90 void SetAudio(); 91 bool CheckVoicemailNumber(std::string phoneNumber); 92 bool IsAliveState(); 93 94 protected: 95 int32_t callId_; 96 CallType callType_; 97 VideoStateType videoState_; 98 std::string accountNumber_; 99 std::string bundleName_; 100 101 private: 102 void StateChangesToDialing(); 103 void StateChangesToIncoming(); 104 void StateChangesToWaiting(); 105 void StateChangesToActive(); 106 void StateChangesToHolding(); 107 void StateChangesToDisconnected(); 108 void StateChangesToDisconnecting(); 109 void StateChangesToAlerting(); 110 111 CallRunningState callRunningState_; 112 TelConferenceState conferenceState_; 113 int64_t startTime_; // Call start time 114 CallDirection direction_; 115 uint64_t policyFlag_; 116 TelCallState callState_; 117 bool isSpeakerphoneOn_; 118 CallEndedType callEndedType_; 119 ContactInfo contactInfo_; 120 time_t callBeginTime_; 121 time_t callEndTime_; 122 time_t ringBeginTime_; 123 time_t ringEndTime_; 124 CallAnswerType answerType_; 125 std::mutex mutex_; 126 }; 127 } // namespace Telephony 128 } // namespace OHOS 129 130 #endif // CALL_BASE_H 131