1 /* 2 * Copyright (C) 2018 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 package android.telephony.ims; 18 19 import android.annotation.SystemApi; 20 import android.annotation.UnsupportedAppUsage; 21 import android.os.Parcel; 22 import android.os.Parcelable; 23 24 /** 25 * Parcelable object to handle IMS stream media profile. 26 * It provides the media direction, quality of audio and/or video. 27 * 28 * @hide 29 */ 30 @SystemApi 31 public final class ImsStreamMediaProfile implements Parcelable { 32 private static final String TAG = "ImsStreamMediaProfile"; 33 34 /** 35 * Media directions 36 */ 37 public static final int DIRECTION_INVALID = (-1); 38 public static final int DIRECTION_INACTIVE = 0; 39 public static final int DIRECTION_RECEIVE = 1; 40 public static final int DIRECTION_SEND = 2; 41 public static final int DIRECTION_SEND_RECEIVE = 3; 42 43 /** 44 * Audio information 45 */ 46 public static final int AUDIO_QUALITY_NONE = 0; 47 public static final int AUDIO_QUALITY_AMR = 1; 48 public static final int AUDIO_QUALITY_AMR_WB = 2; 49 public static final int AUDIO_QUALITY_QCELP13K = 3; 50 public static final int AUDIO_QUALITY_EVRC = 4; 51 public static final int AUDIO_QUALITY_EVRC_B = 5; 52 public static final int AUDIO_QUALITY_EVRC_WB = 6; 53 public static final int AUDIO_QUALITY_EVRC_NW = 7; 54 public static final int AUDIO_QUALITY_GSM_EFR = 8; 55 public static final int AUDIO_QUALITY_GSM_FR = 9; 56 public static final int AUDIO_QUALITY_GSM_HR = 10; 57 public static final int AUDIO_QUALITY_G711U = 11; 58 public static final int AUDIO_QUALITY_G723 = 12; 59 public static final int AUDIO_QUALITY_G711A = 13; 60 public static final int AUDIO_QUALITY_G722 = 14; 61 public static final int AUDIO_QUALITY_G711AB = 15; 62 public static final int AUDIO_QUALITY_G729 = 16; 63 public static final int AUDIO_QUALITY_EVS_NB = 17; 64 public static final int AUDIO_QUALITY_EVS_WB = 18; 65 public static final int AUDIO_QUALITY_EVS_SWB = 19; 66 public static final int AUDIO_QUALITY_EVS_FB = 20; 67 68 /** 69 * Video information 70 */ 71 public static final int VIDEO_QUALITY_NONE = 0; 72 public static final int VIDEO_QUALITY_QCIF = (1 << 0); 73 public static final int VIDEO_QUALITY_QVGA_LANDSCAPE = (1 << 1); 74 public static final int VIDEO_QUALITY_QVGA_PORTRAIT = (1 << 2); 75 public static final int VIDEO_QUALITY_VGA_LANDSCAPE = (1 << 3); 76 public static final int VIDEO_QUALITY_VGA_PORTRAIT = (1 << 4); 77 78 /** 79 * RTT Modes 80 */ 81 public static final int RTT_MODE_DISABLED = 0; 82 public static final int RTT_MODE_FULL = 1; 83 84 // Audio related information 85 /** @hide */ 86 @UnsupportedAppUsage 87 public int mAudioQuality; 88 /** @hide */ 89 @UnsupportedAppUsage 90 public int mAudioDirection; 91 // Video related information 92 /** @hide */ 93 public int mVideoQuality; 94 /** @hide */ 95 @UnsupportedAppUsage 96 public int mVideoDirection; 97 // Rtt related information 98 /** @hide */ 99 public int mRttMode; 100 // RTT Audio Speech Indicator 101 /** @hide */ 102 public boolean mIsReceivingRttAudio = false; 103 104 /** @hide */ ImsStreamMediaProfile(Parcel in)105 public ImsStreamMediaProfile(Parcel in) { 106 readFromParcel(in); 107 } 108 109 /** 110 * Constructor. 111 * 112 * @param audioQuality The audio quality. Can be one of the following: 113 * {@link #AUDIO_QUALITY_AMR}, 114 * {@link #AUDIO_QUALITY_AMR_WB}, 115 * {@link #AUDIO_QUALITY_QCELP13K}, 116 * {@link #AUDIO_QUALITY_EVRC}, 117 * {@link #AUDIO_QUALITY_EVRC_B}, 118 * {@link #AUDIO_QUALITY_EVRC_WB}, 119 * {@link #AUDIO_QUALITY_EVRC_NW}, 120 * {@link #AUDIO_QUALITY_GSM_EFR}, 121 * {@link #AUDIO_QUALITY_GSM_FR}, 122 * {@link #AUDIO_QUALITY_GSM_HR}, 123 * {@link #AUDIO_QUALITY_G711U}, 124 * {@link #AUDIO_QUALITY_G723}, 125 * {@link #AUDIO_QUALITY_G711A}, 126 * {@link #AUDIO_QUALITY_G722}, 127 * {@link #AUDIO_QUALITY_G711AB}, 128 * {@link #AUDIO_QUALITY_G729}, 129 * {@link #AUDIO_QUALITY_EVS_NB}, 130 * {@link #AUDIO_QUALITY_EVS_WB}, 131 * {@link #AUDIO_QUALITY_EVS_SWB}, 132 * {@link #AUDIO_QUALITY_EVS_FB}, 133 * @param audioDirection The audio direction. Can be one of the following: 134 * {@link #DIRECTION_INVALID}, 135 * {@link #DIRECTION_INACTIVE}, 136 * {@link #DIRECTION_RECEIVE}, 137 * {@link #DIRECTION_SEND}, 138 * {@link #DIRECTION_SEND_RECEIVE}, 139 * @param videoQuality The video quality. Can be one of the following: 140 * {@link #VIDEO_QUALITY_NONE}, 141 * {@link #VIDEO_QUALITY_QCIF}, 142 * {@link #VIDEO_QUALITY_QVGA_LANDSCAPE}, 143 * {@link #VIDEO_QUALITY_QVGA_PORTRAIT}, 144 * {@link #VIDEO_QUALITY_VGA_LANDSCAPE}, 145 * {@link #VIDEO_QUALITY_VGA_PORTRAIT}, 146 * @param videoDirection The video direction. Can be one of the following: 147 * {@link #DIRECTION_INVALID}, 148 * {@link #DIRECTION_INACTIVE}, 149 * {@link #DIRECTION_RECEIVE}, 150 * {@link #DIRECTION_SEND}, 151 * {@link #DIRECTION_SEND_RECEIVE}, 152 * @param rttMode The rtt mode. Can be one of the following: 153 * {@link #RTT_MODE_DISABLED}, 154 * {@link #RTT_MODE_FULL} 155 */ ImsStreamMediaProfile(int audioQuality, int audioDirection, int videoQuality, int videoDirection, int rttMode)156 public ImsStreamMediaProfile(int audioQuality, int audioDirection, 157 int videoQuality, int videoDirection, int rttMode) { 158 mAudioQuality = audioQuality; 159 mAudioDirection = audioDirection; 160 mVideoQuality = videoQuality; 161 mVideoDirection = videoDirection; 162 mRttMode = rttMode; 163 } 164 165 /** @hide */ 166 @UnsupportedAppUsage ImsStreamMediaProfile()167 public ImsStreamMediaProfile() { 168 mAudioQuality = AUDIO_QUALITY_NONE; 169 mAudioDirection = DIRECTION_SEND_RECEIVE; 170 mVideoQuality = VIDEO_QUALITY_NONE; 171 mVideoDirection = DIRECTION_INVALID; 172 mRttMode = RTT_MODE_DISABLED; 173 } 174 175 /** @hide */ ImsStreamMediaProfile(int audioQuality, int audioDirection, int videoQuality, int videoDirection)176 public ImsStreamMediaProfile(int audioQuality, int audioDirection, 177 int videoQuality, int videoDirection) { 178 mAudioQuality = audioQuality; 179 mAudioDirection = audioDirection; 180 mVideoQuality = videoQuality; 181 mVideoDirection = videoDirection; 182 } 183 184 /** @hide */ ImsStreamMediaProfile(int rttMode)185 public ImsStreamMediaProfile(int rttMode) { 186 mRttMode = rttMode; 187 } 188 copyFrom(ImsStreamMediaProfile profile)189 public void copyFrom(ImsStreamMediaProfile profile) { 190 mAudioQuality = profile.mAudioQuality; 191 mAudioDirection = profile.mAudioDirection; 192 mVideoQuality = profile.mVideoQuality; 193 mVideoDirection = profile.mVideoDirection; 194 mRttMode = profile.mRttMode; 195 } 196 197 @Override toString()198 public String toString() { 199 return "{ audioQuality=" + mAudioQuality + 200 ", audioDirection=" + mAudioDirection + 201 ", videoQuality=" + mVideoQuality + 202 ", videoDirection=" + mVideoDirection + 203 ", rttMode=" + mRttMode + 204 ", hasRttAudioSpeech=" + mIsReceivingRttAudio + " }"; 205 } 206 207 @Override describeContents()208 public int describeContents() { 209 return 0; 210 } 211 212 @Override writeToParcel(Parcel out, int flags)213 public void writeToParcel(Parcel out, int flags) { 214 out.writeInt(mAudioQuality); 215 out.writeInt(mAudioDirection); 216 out.writeInt(mVideoQuality); 217 out.writeInt(mVideoDirection); 218 out.writeInt(mRttMode); 219 out.writeBoolean(mIsReceivingRttAudio); 220 } 221 readFromParcel(Parcel in)222 private void readFromParcel(Parcel in) { 223 mAudioQuality = in.readInt(); 224 mAudioDirection = in.readInt(); 225 mVideoQuality = in.readInt(); 226 mVideoDirection = in.readInt(); 227 mRttMode = in.readInt(); 228 mIsReceivingRttAudio = in.readBoolean(); 229 } 230 231 public static final @android.annotation.NonNull Creator<ImsStreamMediaProfile> CREATOR = 232 new Creator<ImsStreamMediaProfile>() { 233 @Override 234 public ImsStreamMediaProfile createFromParcel(Parcel in) { 235 return new ImsStreamMediaProfile(in); 236 } 237 238 @Override 239 public ImsStreamMediaProfile[] newArray(int size) { 240 return new ImsStreamMediaProfile[size]; 241 } 242 }; 243 244 /** 245 * Determines if it's RTT call 246 * @return true if RTT call, false otherwise. 247 */ isRttCall()248 public boolean isRttCall() { 249 return (mRttMode == RTT_MODE_FULL); 250 } 251 252 /** 253 * Updates the RttCall attribute 254 */ setRttMode(int rttMode)255 public void setRttMode(int rttMode) { 256 mRttMode = rttMode; 257 } 258 259 /** 260 * Sets whether the remote party is transmitting audio over the RTT call. 261 * @param audioOn true if audio is being received, false otherwise. 262 */ setReceivingRttAudio(boolean audioOn)263 public void setReceivingRttAudio(boolean audioOn) { 264 mIsReceivingRttAudio = audioOn; 265 } 266 getAudioQuality()267 public int getAudioQuality() { 268 return mAudioQuality; 269 } 270 getAudioDirection()271 public int getAudioDirection() { 272 return mAudioDirection; 273 } 274 getVideoQuality()275 public int getVideoQuality() { 276 return mVideoQuality; 277 } 278 getVideoDirection()279 public int getVideoDirection() { 280 return mVideoDirection; 281 } 282 getRttMode()283 public int getRttMode() { 284 return mRttMode; 285 } 286 287 /** 288 * @return true if remote party is transmitting audio, false otherwise. 289 */ isReceivingRttAudio()290 public boolean isReceivingRttAudio() { 291 return mIsReceivingRttAudio; 292 } 293 } 294