• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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.os.Parcel;
22 import android.os.Parcelable;
23 import android.util.Range;
24 
25 /**
26  * Parcelable object to handle audio codec attributes.
27  * It provides the audio codec bitrate, bandwidth and their upper/lower bound.
28  *
29  * @hide
30  */
31 @SystemApi
32 public final class AudioCodecAttributes implements Parcelable {
33     // The audio codec bitrate in kbps.
34     private float mBitrateKbps;
35     // The range of the audio codec bitrate in kbps.
36     private Range<Float> mBitrateRangeKbps;
37     // The audio codec bandwidth in kHz.
38     private float mBandwidthKhz;
39     // The range of the audio codec bandwidth in kHz.
40     private Range<Float> mBandwidthRangeKhz;
41 
42 
43     /**
44      * Constructor.
45      *
46      * @param bitrateKbps        The audio codec bitrate in kbps.
47      * @param bitrateRangeKbps  The range of the audio codec bitrate in kbps.
48      * @param bandwidthKhz      The audio codec bandwidth in kHz.
49      * @param bandwidthRangeKhz The range of the audio codec bandwidth in kHz.
50      */
51 
AudioCodecAttributes(float bitrateKbps, @NonNull Range<Float> bitrateRangeKbps, float bandwidthKhz, @NonNull Range<Float> bandwidthRangeKhz)52     public AudioCodecAttributes(float bitrateKbps, @NonNull Range<Float> bitrateRangeKbps,
53             float bandwidthKhz, @NonNull Range<Float> bandwidthRangeKhz) {
54         mBitrateKbps = bitrateKbps;
55         mBitrateRangeKbps = bitrateRangeKbps;
56         mBandwidthKhz = bandwidthKhz;
57         mBandwidthRangeKhz = bandwidthRangeKhz;
58     }
59 
AudioCodecAttributes(Parcel in)60     private AudioCodecAttributes(Parcel in) {
61         mBitrateKbps = in.readFloat();
62         mBitrateRangeKbps = new Range<>(in.readFloat(), in.readFloat());
63         mBandwidthKhz = in.readFloat();
64         mBandwidthRangeKhz = new Range<>(in.readFloat(), in.readFloat());
65     }
66 
67     @Override
writeToParcel(@onNull Parcel out, int flags)68     public void writeToParcel(@NonNull Parcel out, int flags) {
69         out.writeFloat(mBitrateKbps);
70         out.writeFloat(mBitrateRangeKbps.getLower());
71         out.writeFloat(mBitrateRangeKbps.getUpper());
72         out.writeFloat(mBandwidthKhz);
73         out.writeFloat(mBandwidthRangeKhz.getLower());
74         out.writeFloat(mBandwidthRangeKhz.getUpper());
75     }
76 
77     @Override
describeContents()78     public int describeContents() {
79         return 0;
80     }
81 
82     public static final @NonNull Creator<AudioCodecAttributes> CREATOR =
83             new Creator<AudioCodecAttributes>() {
84                 @Override
85                 public AudioCodecAttributes createFromParcel(Parcel in) {
86                     return new AudioCodecAttributes(in);
87                 }
88 
89                 @Override
90                 public AudioCodecAttributes[] newArray(int size) {
91                     return new AudioCodecAttributes[size];
92                 }
93             };
94 
95     /**
96      * @return the exact value of the audio codec bitrate in kbps.
97      */
getBitrateKbps()98     public float getBitrateKbps() {
99         return mBitrateKbps;
100     }
101 
102     /**
103      * @return the range of the audio codec bitrate in kbps
104      */
getBitrateRangeKbps()105     public @NonNull Range<Float> getBitrateRangeKbps() {
106         return mBitrateRangeKbps;
107     }
108 
109     /**
110      * @return the exact value of the audio codec bandwidth in kHz.
111      */
getBandwidthKhz()112     public float getBandwidthKhz() {
113         return mBandwidthKhz;
114     }
115 
116     /**
117      * @return the range of the audio codec bandwidth in kHz.
118      */
getBandwidthRangeKhz()119     public @NonNull Range<Float> getBandwidthRangeKhz() {
120         return mBandwidthRangeKhz;
121     }
122 
123     @NonNull
124     @Override
toString()125     public String toString() {
126         return "{ bitrateKbps=" + mBitrateKbps
127                 + ", bitrateRangeKbps=" + mBitrateRangeKbps
128                 + ", bandwidthKhz=" + mBandwidthKhz
129                 + ", bandwidthRangeKhz=" + mBandwidthRangeKhz + " }";
130     }
131 }
132