1/*
2 * Copyright (c) 2013 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
17package com.android.ims;
18
19import android.os.Parcel;
20import android.os.Parcelable;
21
22/**
23 * Parcelable object to handle IMS stream media profile.
24 * It provides the media direction, quality of audio and/or video.
25 *
26 * @hide
27 */
28public class ImsStreamMediaProfile implements Parcelable {
29    private static final String TAG = "ImsStreamMediaProfile";
30
31    /**
32     * Media directions
33     */
34    public static final int DIRECTION_INVALID = (-1);
35    public static final int DIRECTION_INACTIVE = 0;
36    public static final int DIRECTION_RECEIVE = 1;
37    public static final int DIRECTION_SEND = 2;
38    public static final int DIRECTION_SEND_RECEIVE = 3;
39
40    /**
41     * Audio information
42     */
43    public static final int AUDIO_QUALITY_NONE = 0;
44    public static final int AUDIO_QUALITY_AMR = 1;
45    public static final int AUDIO_QUALITY_AMR_WB = 2;
46    public static final int AUDIO_QUALITY_QCELP13K = 3;
47    public static final int AUDIO_QUALITY_EVRC = 4;
48    public static final int AUDIO_QUALITY_EVRC_B = 5;
49    public static final int AUDIO_QUALITY_EVRC_WB = 6;
50    public static final int AUDIO_QUALITY_EVRC_NW = 7;
51    public static final int AUDIO_QUALITY_GSM_EFR = 8;
52    public static final int AUDIO_QUALITY_GSM_FR = 9;
53    public static final int AUDIO_QUALITY_GSM_HR = 10;
54
55   /**
56     * Video information
57     */
58    public static final int VIDEO_QUALITY_NONE = 0;
59    public static final int VIDEO_QUALITY_QCIF = (1 << 0);
60    public static final int VIDEO_QUALITY_QVGA_LANDSCAPE = (1 << 1);
61    public static final int VIDEO_QUALITY_QVGA_PORTRAIT = (1 << 2);
62    public static final int VIDEO_QUALITY_VGA_LANDSCAPE = (1 << 3);
63    public static final int VIDEO_QUALITY_VGA_PORTRAIT = (1 << 4);
64
65    // Audio related information
66    public int mAudioQuality;
67    public int mAudioDirection;
68    // Video related information
69    public int mVideoQuality;
70    public int mVideoDirection;
71
72
73
74    public ImsStreamMediaProfile(Parcel in) {
75        readFromParcel(in);
76    }
77
78    public ImsStreamMediaProfile() {
79        mAudioQuality = AUDIO_QUALITY_AMR_WB;
80        mAudioDirection = DIRECTION_SEND_RECEIVE;
81        mVideoQuality = VIDEO_QUALITY_NONE;
82        mVideoDirection = DIRECTION_INVALID;
83    }
84
85    public ImsStreamMediaProfile(int audioQuality, int audioDirection,
86            int videoQuality, int videoDirection) {
87        mAudioQuality = audioQuality;
88        mAudioDirection = audioDirection;
89        mVideoQuality = videoQuality;
90        mVideoDirection = videoDirection;
91    }
92
93    public void copyFrom(ImsStreamMediaProfile profile) {
94        mAudioQuality = profile.mAudioQuality;
95        mAudioDirection = profile.mAudioDirection;
96        mVideoQuality = profile.mVideoQuality;
97        mVideoDirection = profile.mVideoDirection;
98    }
99
100    @Override
101    public String toString() {
102        return "{ audioQuality=" + mAudioQuality +
103                ", audioDirection=" + mAudioDirection +
104                ", videoQuality=" + mVideoQuality +
105                ", videoDirection=" + mVideoDirection + " }";
106    }
107
108    @Override
109    public int describeContents() {
110        return 0;
111    }
112
113    @Override
114    public void writeToParcel(Parcel out, int flags) {
115        out.writeInt(mAudioQuality);
116        out.writeInt(mAudioDirection);
117        out.writeInt(mVideoQuality);
118        out.writeInt(mVideoDirection);
119    }
120
121    private void readFromParcel(Parcel in) {
122        mAudioQuality = in.readInt();
123        mAudioDirection = in.readInt();
124        mVideoQuality = in.readInt();
125        mVideoDirection = in.readInt();
126    }
127
128    public static final Creator<ImsStreamMediaProfile> CREATOR =
129            new Creator<ImsStreamMediaProfile>() {
130        @Override
131        public ImsStreamMediaProfile createFromParcel(Parcel in) {
132            return new ImsStreamMediaProfile(in);
133        }
134
135        @Override
136        public ImsStreamMediaProfile[] newArray(int size) {
137            return new ImsStreamMediaProfile[size];
138        }
139    };
140}
141