1 /** 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include <AmrParams.h> 18 19 namespace android 20 { 21 22 namespace telephony 23 { 24 25 namespace imsmedia 26 { 27 28 /** Native representation of android.telephony.imsmedia.AmrParams */ AmrParams()29AmrParams::AmrParams() 30 { 31 amrMode = 0; 32 octetAligned = false; 33 maxRedundancyMillis = 0; 34 } 35 AmrParams(AmrParams & param)36AmrParams::AmrParams(AmrParams& param) 37 { 38 this->amrMode = param.amrMode; 39 this->octetAligned = param.octetAligned; 40 this->maxRedundancyMillis = param.maxRedundancyMillis; 41 } 42 ~AmrParams()43AmrParams::~AmrParams() {} 44 operator =(const AmrParams & param)45AmrParams& AmrParams::operator=(const AmrParams& param) 46 { 47 if (this != ¶m) 48 { 49 this->amrMode = param.amrMode; 50 this->octetAligned = param.octetAligned; 51 this->maxRedundancyMillis = param.maxRedundancyMillis; 52 } 53 return *this; 54 } 55 operator ==(const AmrParams & param) const56bool AmrParams::operator==(const AmrParams& param) const 57 { 58 return (this->amrMode == param.amrMode && this->octetAligned == param.octetAligned && 59 this->maxRedundancyMillis == param.maxRedundancyMillis); 60 } 61 operator !=(const AmrParams & param) const62bool AmrParams::operator!=(const AmrParams& param) const 63 { 64 return (this->amrMode != param.amrMode || this->octetAligned != param.octetAligned || 65 this->maxRedundancyMillis != param.maxRedundancyMillis); 66 } 67 writeToParcel(Parcel * out) const68status_t AmrParams::writeToParcel(Parcel* out) const 69 { 70 status_t err; 71 if (out == nullptr) 72 { 73 return BAD_VALUE; 74 } 75 76 err = out->writeInt32(amrMode); 77 if (err != NO_ERROR) 78 { 79 return err; 80 } 81 82 int32_t value = 0; 83 octetAligned ? value = 1 : value = 0; 84 err = out->writeInt32(value); 85 if (err != NO_ERROR) 86 { 87 return err; 88 } 89 90 err = out->writeInt32(maxRedundancyMillis); 91 if (err != NO_ERROR) 92 { 93 return err; 94 } 95 return NO_ERROR; 96 } 97 readFromParcel(const Parcel * in)98status_t AmrParams::readFromParcel(const Parcel* in) 99 { 100 status_t err; 101 if (in == nullptr) 102 { 103 return BAD_VALUE; 104 } 105 106 err = in->readInt32(&amrMode); 107 if (err != NO_ERROR) 108 { 109 return err; 110 } 111 112 int32_t value = 0; 113 err = in->readInt32(&value); 114 if (err != NO_ERROR) 115 { 116 return err; 117 } 118 119 value == 0 ? octetAligned = false : octetAligned = true; 120 121 err = in->readInt32(&maxRedundancyMillis); 122 if (err != NO_ERROR) 123 { 124 return err; 125 } 126 127 return NO_ERROR; 128 } 129 setAmrMode(const int32_t mode)130void AmrParams::setAmrMode(const int32_t mode) 131 { 132 amrMode = mode; 133 } 134 getAmrMode()135int32_t AmrParams::getAmrMode() 136 { 137 return amrMode; 138 } 139 setOctetAligned(const bool enable)140void AmrParams::setOctetAligned(const bool enable) 141 { 142 octetAligned = enable; 143 } 144 getOctetAligned()145bool AmrParams::getOctetAligned() 146 { 147 return octetAligned; 148 } 149 setMaxRedundancyMillis(const int32_t value)150void AmrParams::setMaxRedundancyMillis(const int32_t value) 151 { 152 maxRedundancyMillis = value; 153 } 154 getMaxRedundancyMillis()155int32_t AmrParams::getMaxRedundancyMillis() 156 { 157 return maxRedundancyMillis; 158 } 159 setDefaultAmrParams()160void AmrParams::setDefaultAmrParams() 161 { 162 amrMode = kAmrMode; 163 octetAligned = kOctetAligned; 164 maxRedundancyMillis = kMaxRedundancyMillis; 165 } 166 167 } // namespace imsmedia 168 169 } // namespace telephony 170 171 } // namespace android 172