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