1 /**
2  * Copyright (C) 2022 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 #ifndef AMRPARAMS_H
18 #define AMRPARAMS_H
19 
20 #include <binder/Parcel.h>
21 #include <binder/Parcelable.h>
22 #include <binder/Status.h>
23 #include <stdint.h>
24 
25 namespace android
26 {
27 
28 namespace telephony
29 {
30 
31 namespace imsmedia
32 {
33 
34 /** Native representation of android.telephony.imsmedia.AmrParams */
35 
36 /**
37  * The class represents AMR (Adaptive Multi-Rate) codec parameters.
38  */
39 class AmrParams : public Parcelable
40 {
41 public:
42     enum AmrMode
43     {
44         /** 4.75 kbps for AMR / 6.6 kbps for AMR-WB */
45         AMR_MODE_0 = 1 << 0,
46         /** 5.15 kbps for AMR / 8.855 kbps for AMR-WB */
47         AMR_MODE_1 = 1 << 1,
48         /** 5.9 kbps for AMR / 12.65 kbps for AMR-WB */
49         AMR_MODE_2 = 1 << 2,
50         /** 6.7 kbps for AMR / 14.25 kbps for AMR-WB */
51         AMR_MODE_3 = 1 << 3,
52         /** 7.4 kbps for AMR / 15.85 kbps for AMR-WB */
53         AMR_MODE_4 = 1 << 4,
54         /** 7.95 kbps for AMR / 18.25 kbps for AMR-WB */
55         AMR_MODE_5 = 1 << 5,
56         /** 10.2 kbps for AMR / 19.85 kbps for AMR-WB */
57         AMR_MODE_6 = 1 << 6,
58         /** 12.2 kbps for AMR / 23.05 kbps for AMR-WB */
59         AMR_MODE_7 = 1 << 7,
60         /** Silence frame for AMR / 23.85 kbps for AMR-WB */
61         AMR_MODE_8 = 1 << 8,
62     };
63 
64     AmrParams();
65     AmrParams(AmrParams& param);
66     virtual ~AmrParams();
67     AmrParams& operator=(const AmrParams& param);
68     bool operator==(const AmrParams& param) const;
69     bool operator!=(const AmrParams& param) const;
70     virtual status_t writeToParcel(Parcel* parcel) const;
71     virtual status_t readFromParcel(const Parcel* in);
72     void setAmrMode(const int32_t mode);
73     int32_t getAmrMode();
74     void setOctetAligned(const bool enable);
75     bool getOctetAligned();
76     void setMaxRedundancyMillis(const int32_t value);
77     int32_t getMaxRedundancyMillis();
78     void setDefaultAmrParams();
79 
80 private:
81     /** mode-set: AMR codec mode to represent the bit rate */
82     int32_t amrMode;
83     /**
84      * octet-align: If it's set to true then all fields in the AMR/AMR-WB header
85      * shall be aligned to octet boundaries by adding padding bits.
86      */
87     bool octetAligned;
88     /**
89      * max-red: It’s the maximum duration in milliseconds that elapses between the
90      * primary (first) transmission of a frame and any redundant transmission that
91      * the sender will use. This parameter allows a receiver to have a bounded delay
92      * when redundancy is used. Allowed values are between 0 (no redundancy will be
93      * used) and 65535. If the parameter is omitted, no limitation on the use of
94      * redundancy is present. See RFC 4867
95      */
96     int32_t maxRedundancyMillis;
97 
98     // Default AmrParams
99     const int32_t kAmrMode = 0;
100     const bool kOctetAligned = false;
101     const int32_t kMaxRedundancyMillis = 0;
102 };
103 
104 }  // namespace imsmedia
105 
106 }  // namespace telephony
107 
108 }  // namespace android
109 
110 #endif