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 EVSPARAMS_H
18 #define EVSPARAMS_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.EvsParams */
35 
36 /**
37  * The class represents EVS (Enhanced Voice Services) codec parameters.
38  */
39 class EvsParams : public Parcelable
40 {
41 public:
42     enum EvsMode
43     {
44         /** 6.6 kbps for EVS AMR-WB IO */
45         EVS_MODE_0 = 1 << 0,
46         /** 8.855 kbps for AMR-WB IO */
47         EVS_MODE_1 = 1 << 1,
48         /** 12.65 kbps for AMR-WB IO */
49         EVS_MODE_2 = 1 << 2,
50         /** 14.25 kbps for AMR-WB IO */
51         EVS_MODE_3 = 1 << 3,
52         /** 15.85 kbps for AMR-WB IO */
53         EVS_MODE_4 = 1 << 4,
54         /** 18.25 kbps for AMR-WB IO */
55         EVS_MODE_5 = 1 << 5,
56         /** 19.85 kbps for AMR-WB IO */
57         EVS_MODE_6 = 1 << 6,
58         /** 23.05 kbps for AMR-WB IO */
59         EVS_MODE_7 = 1 << 7,
60         /** 23.85 kbps for AMR-WB IO */
61         EVS_MODE_8 = 1 << 8,
62         /** 5.9 kbps for EVS primary */
63         EVS_MODE_9 = 1 << 9,
64         /** 7.2 kbps for EVS primary */
65         EVS_MODE_10 = 1 << 10,
66         /** 8.0 kbps for EVS primary */
67         EVS_MODE_11 = 1 << 11,
68         /** 9.6 kbps for EVS primary */
69         EVS_MODE_12 = 1 << 12,
70         /** 13.2 kbps for EVS primary */
71         EVS_MODE_13 = 1 << 13,
72         /** 16.4 kbps for EVS primary */
73         EVS_MODE_14 = 1 << 14,
74         /** 24.4 kbps for EVS primary */
75         EVS_MODE_15 = 1 << 15,
76         /** 32.0 kbps for EVS primary */
77         EVS_MODE_16 = 1 << 16,
78         /** 48.0 kbps for EVS primary */
79         EVS_MODE_17 = 1 << 17,
80         /** 64.0 kbps for EVS primary */
81         EVS_MODE_18 = 1 << 18,
82         /** 96.0 kbps for EVS primary */
83         EVS_MODE_19 = 1 << 19,
84         /** 128.0 kbps for EVS primary */
85         EVS_MODE_20 = 1 << 20,
86     };
87 
88     enum EvsBandwidth
89     {
90         EVS_BAND_NONE = 0,
91         EVS_NARROW_BAND = 1 << 0,
92         EVS_WIDE_BAND = 1 << 1,
93         EVS_SUPER_WIDE_BAND = 1 << 2,
94         EVS_FULL_BAND = 1 << 3,
95     };
96 
97     EvsParams();
98     EvsParams(EvsParams& params);
99     virtual ~EvsParams();
100     EvsParams& operator=(const EvsParams& param);
101     bool operator==(const EvsParams& param) const;
102     bool operator!=(const EvsParams& param) const;
103     virtual status_t writeToParcel(Parcel* parcel) const;
104     virtual status_t readFromParcel(const Parcel* in);
105     void setEvsBandwidth(const int32_t EvsBandwidth);
106     int32_t getEvsBandwidth();
107     void setEvsMode(const int32_t EvsMode);
108     int32_t getEvsMode();
109     void setChannelAwareMode(int8_t channelAwMode);
110     int8_t getChannelAwareMode();
111     void setUseHeaderFullOnly(const bool enable);
112     bool getUseHeaderFullOnly();
113     void setCodecModeRequest(int8_t cmr);
114     int8_t getCodecModeRequest();
115     void setDefaultEvsParams();
116 
117 private:
118     /** bw: EVS codec bandwidth range */
119     int32_t evsBandwidth;
120     /** mode-set: EVS codec mode to represent the bit rate */
121     int32_t evsMode;
122     /**
123      * ch-aw-recv: Channel aware mode for the receive direction. Permissible values
124      * are -1, 0, 2, 3, 5, and 7. If -1, channel-aware mode is disabled in the
125      * session for the receive direction. If 0 or not present, partial redundancy
126      * (channel-aware mode) is not used at the start of the session for the receive
127      * direction. If positive (2, 3, 5, or 7), partial redundancy (channel-aware
128      * mode) is used at the start of the session for the receive direction using the
129      * value as the offset, See 3GPP TS 26.445 section 4.4.5
130      */
131     int8_t channelAwareMode;
132     /**
133      * hf-only: Header full only is used for the outgoing/incoming packets. If it's true then
134      * the session shall support header full format only else the session could
135      * support both header full format and compact format.
136      */
137     bool useHeaderFullOnly;
138     /**
139      * cmr: Codec mode request is used to request the speech codec encoder of the
140      * other party to set the frame type index of speech mode via RTP header, See
141      * 3GPP TS 26.445 section A.3. Allowed values are -1, 0 and 1.
142      */
143     int8_t codecModeRequest;
144 
145     // Default EvsParams
146     const int32_t kBandwidth = EvsParams::EVS_BAND_NONE;
147     const int32_t kEvsMode = 0;
148     const int8_t kChannelAwareMode = 0;
149     const bool kUseHeaderFullOnly = false;
150     const int8_t kcodecModeRequest = 0;
151 };
152 
153 }  // namespace imsmedia
154 
155 }  // namespace telephony
156 
157 }  // namespace android
158 
159 #endif
160