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 /** \addtogroup RTP_Stack 18 * @{ 19 */ 20 21 #ifndef __RTP_HEADER_H__ 22 #define __RTP_HEADER_H__ 23 24 #include <RtpGlobal.h> 25 #include <RtpBuffer.h> 26 #include <list> 27 28 // It defines the RTP Header information. 29 30 /** 31 * @class RtpHeader 32 * @brief It defines the RTP packet header. 33 * This class stores the fixed header values and csrc list of RTP packet. 34 * It encodes and decodes the RTP header 35 */ 36 37 class RtpHeader 38 { 39 private: 40 // m_ucVersion identifies the version of RTP 41 RtpDt_UChar m_ucVersion; 42 43 // m_ucPadding identifies the padding bit. 44 /** 45 * If the padding bit is set, the packet contains one or more 46 * additional padding octets at the end which are not part of the 47 * payload. 48 */ 49 RtpDt_UChar m_ucPadding; 50 51 /** 52 * If the extension bit is set, the fixed header MUST be followed by 53 * exactly one header extension. Refer RFC 3550 Section 5.1 for more details. 54 */ 55 RtpDt_UChar m_ucExtension; 56 57 /** 58 * m_ucCsrcCount contains the number of CSRC identifiers that follow the fixed header. 59 */ 60 RtpDt_UChar m_ucCsrcCount; 61 62 /** 63 * It contains CSRC list. 64 */ 65 std::list<RtpDt_UInt32> m_uiCsrcList; 66 67 /** 68 * m_ucMarker contains marker bit. 69 */ 70 RtpDt_UChar m_ucMarker; 71 72 /** 73 * m_ucPayloadType identifies the format of the Rtp payload. 74 */ 75 RtpDt_UChar m_ucPayloadType; 76 77 /** 78 * Sequence number 79 */ 80 RtpDt_UInt16 m_usSequenceNumber; 81 82 /** 83 * The m_uiTimestamp reflects the sampling instant of the first octet 84 * in the RTP data packet. 85 */ 86 RtpDt_UInt32 m_uiTimestamp; 87 88 /** 89 * Synchronization source. 90 */ 91 RtpDt_UInt32 m_uiSsrc; 92 93 /** 94 * add element to m_uiCsrcList 95 */ 96 RtpDt_Void addElementToCsrcList(IN RtpDt_UInt32 uiCsrc); 97 98 public: 99 // Constructor 100 RtpHeader(); 101 102 // Destructor 103 ~RtpHeader(); 104 105 /** 106 * set method for m_ucVersion 107 */ 108 RtpDt_Void setVersion(IN RtpDt_UChar ucVersion); 109 110 /** 111 * get method for m_ucVersion 112 */ 113 RtpDt_UChar getVersion(); 114 115 /** 116 * set method for m_ucPadding 117 */ 118 RtpDt_Void setPadding(); 119 120 /** 121 * get method for m_ucPadding 122 */ 123 RtpDt_UChar getPadding(); 124 125 /** 126 * set method for m_ucExtension 127 */ 128 RtpDt_Void setExtension(RtpDt_UChar ext); 129 130 /** 131 * get method for m_ucExtension 132 */ 133 RtpDt_UChar getExtension(); 134 135 /** 136 * set method for m_ucCsrcCount 137 */ 138 RtpDt_Void setCsrcCount(IN RtpDt_UChar ucCsrcCnt); 139 140 /** 141 * get method for m_ucCsrcCount 142 */ 143 RtpDt_UChar getCsrcCount(); 144 145 /** 146 * get method for m_uiCsrcList 147 */ 148 std::list<RtpDt_UInt32>& getCsrcList(); 149 150 /** 151 * set method for m_ucMarker 152 */ 153 RtpDt_Void setMarker(); 154 155 /** 156 * get method for m_ucMarker 157 */ 158 RtpDt_UChar getMarker(); 159 160 /** 161 * set method for m_ucPayloadType 162 */ 163 RtpDt_Void setPayloadType(IN RtpDt_UChar ucPldType); 164 165 /** 166 * get method for m_ucPayloadType 167 */ 168 RtpDt_UChar getPayloadType(); 169 170 /** 171 * set method for m_usSeqNum 172 */ 173 RtpDt_Void setSequenceNumber(IN RtpDt_UInt16 usSeqNum); 174 175 /** 176 * get method for m_usSeqNum 177 */ 178 RtpDt_UInt16 getSequenceNumber(); 179 180 /** 181 * set method for m_uiTimestamp 182 */ 183 RtpDt_Void setRtpTimestamp(IN RtpDt_UInt32 uiTimestamp); 184 185 /** 186 * get method for m_uiTimestamp 187 */ 188 RtpDt_UInt32 getRtpTimestamp(); 189 190 /** 191 * set method for m_uiSsrc 192 */ 193 RtpDt_Void setRtpSsrc(IN RtpDt_UInt32 uiSsrc); 194 195 /** 196 * get method for m_uiSsrc 197 */ 198 RtpDt_UInt32 getRtpSsrc(); 199 200 /** 201 * Performs the fixed header encoding of the RTP packet. 202 * This function does not allocate memory required for encoding. 203 * 204 * @param pobjRtpPktBuf Memory for the buffer is pre-allocated by caller 205 */ 206 eRtp_Bool formHeader(IN RtpBuffer* pobjRtpPktBuf); 207 208 /** 209 * Decodes and stores the information of the fixed header in the RTP packet 210 * This function does not allocate memory required for decoding. 211 * @param pobjRtpPktBuf Memory for the buffer is pre-allocated by caller 212 * @param uiBufPos returns current buffer position 213 */ 214 eRtp_Bool decodeHeader(IN RtpBuffer* pobjRtpPktBuf, OUT RtpDt_UInt32& uiBufPos); 215 }; 216 217 #endif /* __RTP_HEADER_H__ */ 218 /** @}*/ 219