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