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