• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 RTPCONFIG_H
18 #define RTPCONFIG_H
19 
20 #include <binder/Parcel.h>
21 #include <binder/Parcelable.h>
22 #include <binder/Status.h>
23 #include <RtcpConfig.h>
24 #include <RtpContextParams.h>
25 #include <AnbrMode.h>
26 #include <stdint.h>
27 
28 namespace android
29 {
30 
31 namespace telephony
32 {
33 
34 namespace imsmedia
35 {
36 
37 /** Native representation of android.telephony.imsmedia.RtpConfig */
38 
39 /**
40  * The class to encapsulate RTP (Real Time Protocol) configurations
41  */
42 class RtpConfig : public Parcelable
43 {
44 public:
45     enum MediaDirection
46     {
47         /** Device neither transmits nor receives any RTP */
48         MEDIA_DIRECTION_NO_FLOW,
49         /**
50          * Device transmits outgoing RTP but but doesn't receive incoming RTP.
51          * Eg. Other party muted the call
52          */
53         MEDIA_DIRECTION_SEND_ONLY,
54         /**
55          * Device receives the incoming RTP but doesn't transmit any outgoing RTP.
56          * Eg. User muted the call
57          */
58         MEDIA_DIRECTION_RECEIVE_ONLY,
59         /** Device transmits and receives RTP in both the directions */
60         MEDIA_DIRECTION_SEND_RECEIVE,
61         /** No RTP flow however RTCP continues to flow. Eg. HOLD */
62         MEDIA_DIRECTION_INACTIVE,
63     };
64 
65     virtual ~RtpConfig();
66     RtpConfig& operator=(const RtpConfig& config);
67     bool operator==(const RtpConfig& c2) const;
68     bool operator!=(const RtpConfig& c2) const;
69     virtual status_t writeToParcel(Parcel* parcel) const;
70     virtual status_t readFromParcel(const Parcel* in);
71     void setMediaDirection(const int32_t direction);
72     int32_t getMediaDirection();
73     void setAccessNetwork(const int32_t network);
74     int32_t getAccessNetwork();
75     void setRemoteAddress(const String8& address);
76     String8 getRemoteAddress();
77     void setRemotePort(const int32_t port);
78     int32_t getRemotePort();
79     void setRtcpConfig(const RtcpConfig& config);
80     RtcpConfig getRtcpConfig();
81     void setDscp(const int8_t dscp);
82     int8_t getDscp();
83     void setRxPayloadTypeNumber(const int8_t num);
84     int8_t getRxPayloadTypeNumber();
85     void setTxPayloadTypeNumber(const int8_t num);
86     int8_t getTxPayloadTypeNumber();
87     void setSamplingRateKHz(const int8_t sample);
88     int8_t getSamplingRateKHz();
89     RtpContextParams getRtpContextParams();
90     void setRtpContextParams(RtpContextParams& rtpContextParams);
91     void setAnbrMode(const AnbrMode& anbrMode);
92     AnbrMode getAnbrMode();
93 
94 protected:
95     RtpConfig(int32_t type);
96     RtpConfig(RtpConfig* config);
97     RtpConfig(const RtpConfig& config);
98 
99     /* definition of uninitialized port number*/
100     const static int32_t UNINITIALIZED_PORT = -1;
101     /* media types */
102     const static int32_t TYPE_AUDIO = 0;
103     const static int32_t TYPE_VIDEO = 1;
104     const static int32_t TYPE_TEXT = 2;
105 
106     /**
107      * @brief media type.
108      */
109     int32_t type;
110 
111     /**
112      * @brief RTP media flow direction
113      */
114     int32_t direction;
115     /**
116      * @brief source Radio Access Network to RTP stack
117      */
118     int32_t accessNetwork;
119     /**
120      * @brief ip address of other party
121      */
122     String8 remoteAddress;
123     /**
124      * @brief port number of other party
125      */
126     int32_t remotePort;
127     /**
128      * @brief Rtcp configuration
129      */
130     RtcpConfig rtcpConfig;
131     /**
132      * @brief Differentiated Services Field Code Point value, see RFC 2474
133      */
134     int8_t dscp;
135     /**
136      * @brief Static or dynamic payload type number negotiated through the SDP for
137      * the incoming RTP packets. This value shall be matched with the PT value
138      * of the incoming RTP header. Values 0 to 127, see RFC 3551 section 6
139      */
140     int8_t rxPayloadTypeNumber;
141     /**
142      * @brief Static or dynamic payload type number negotiated through the SDP for
143      * the outgoing RTP packets. This value shall be set to the PT value
144      * of the outgoing RTP header. Values 0 to 127, see RFC 3551 section 6
145      */
146     int8_t txPayloadTypeNumber;
147     /**
148      * @brief Sampling rate in kHz
149      */
150     int8_t samplingRateKHz;
151 
152     /**
153      * @brief Holds the rtp parameters such as ssrc, timestamp and sequence number. Used to transfer
154      * RTP context information between RTP stacks (ex: during handover). Helps to maintain contunity
155      * in RTP steams even after switching between RTP stacks.
156      */
157     RtpContextParams rtpContextParams;
158 
159     /**
160      * @brief anbrMode The codec mode of the current activated codec in the EvsParams
161      * and the AmrParams
162      */
163     AnbrMode anbrMode;
164 };
165 
166 }  // namespace imsmedia
167 
168 }  // namespace telephony
169 
170 }  // namespace android
171 
172 #endif
173