1 /* 2 * Copyright (c) 2023 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 OHOS_AVCALL_STATE_H 17 #define OHOS_AVCALL_STATE_H 18 19 #include <bitset> 20 #include <parcel.h> 21 #include "want_agent.h" 22 23 namespace OHOS::AVSession { 24 class AVCallState : public Parcelable { 25 public: 26 enum { 27 AVCALL_STATE_IDLE = 0, 28 AVCALL_STATE_INCOMING = 1, 29 AVCALL_STATE_ACTIVE = 2, 30 AVCALL_STATE_DIALING = 3, 31 AVCALL_STATE_WAITING = 4, 32 AVCALL_STATE_HOLDING = 5, 33 AVCALL_STATE_DISCONNECTING = 6, 34 AVCALL_STATE_MAX = 7, 35 }; 36 37 enum { 38 AVCALL_STATE_KEY_STATE = 0, 39 AVCALL_STATE_KEY_IS_MUTED = 1, 40 AVCALL_STATE_KEY_MAX = 2, 41 }; 42 43 using AVCallStateMaskType = std::bitset<AVCALL_STATE_KEY_MAX>; 44 45 AVCallState(); 46 ~AVCallState() override = default; 47 48 static AVCallState* Unmarshalling(Parcel& parcel); 49 bool Marshalling(Parcel& parcel) const override; 50 51 bool IsValid() const; 52 53 void SetAVCallState(int32_t avCallState); 54 int32_t GetAVCallState() const; 55 56 void SetAVCallMuted(bool isAVCallMuted); 57 bool IsAVCallMuted() const; 58 59 AVCallStateMaskType GetMask() const; 60 61 bool CopyToByMask(AVCallStateMaskType& mask, AVCallState& out) const; 62 bool CopyFrom(const AVCallState& in); 63 64 const static inline std::vector<int32_t> localCapability { 65 AVCALL_STATE_KEY_STATE, 66 AVCALL_STATE_KEY_IS_MUTED, 67 }; 68 69 private: 70 AVCallStateMaskType mask_; 71 72 int32_t avCallState_ = AVCALL_STATE_IDLE; 73 bool isAVCallMuted_ = false; 74 75 static void CloneAVCallState(const AVCallState& from, AVCallState& to); 76 static void CloneAVCallIsMuted(const AVCallState& from, AVCallState& to); 77 78 using CloneActionType = void(*)(const AVCallState& from, AVCallState& to); 79 static inline CloneActionType cloneActions[AVCALL_STATE_KEY_MAX] = { 80 &AVCallState::CloneAVCallState, 81 &AVCallState::CloneAVCallIsMuted, 82 }; 83 }; 84 } // namespace OHOS::AVSession 85 #endif // OHOS_AVCALL_STATE_H 86