1 /** \addtogroup RTP_Stack 2 * @{ 3 */ 4 5 /** 6 * @class RtpStackUtl 7 * @brief This class provides RTP utility functions 8 */ 9 10 /** 11 * Copyright (C) 2022 The Android Open Source Project 12 * 13 * Licensed under the Apache License, Version 2.0 (the "License"); 14 * you may not use this file except in compliance with the License. 15 * You may obtain a copy of the License at 16 * 17 * http://www.apache.org/licenses/LICENSE-2.0 18 * 19 * Unless required by applicable law or agreed to in writing, software 20 * distributed under the License is distributed on an "AS IS" BASIS, 21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 * See the License for the specific language governing permissions and 23 * limitations under the License. 24 */ 25 26 #ifndef __RTP_STACK_UTIL_H__ 27 #define __RTP_STACK_UTIL_H__ 28 29 #include <RtpGlobal.h> 30 #include <RtpBuffer.h> 31 32 class RtpStackUtil 33 { 34 public: 35 // Constructor 36 RtpStackUtil(); 37 // Destructor 38 ~RtpStackUtil(); 39 40 /** 41 * @brief Parse and retrieve seq number from a RTP packet 42 * @param pucRtpHdrBuf RTP packet buffer from network 43 * @return Retrieved sequence Number 44 */ 45 static RtpDt_UInt16 getSequenceNumber(IN RtpDt_UChar* pucRtpHdrBuf); 46 47 /** 48 * @brief Parse and retrieve ssrc from a RTP packet 49 * @param pucRecvdRtpPkt RTP packet buffer from network 50 * @return Retrieved ssrc 51 */ 52 static RtpDt_UInt32 getRtpSsrc(IN RtpDt_UChar* pucRecvdRtpPkt); 53 54 /** 55 * @brief Parse and retrieve ssrc from a RTCP packet 56 * @param pucRecvdRtcpPkt RTCP packet from network 57 * @return Retrieved ssrc 58 */ 59 static RtpDt_UInt32 getRtcpSsrc(IN RtpDt_UChar* pucRecvdRtcpPkt); 60 61 /** 62 * @brief Utility to generate new ssrc 63 * @param uiTermNum Terminal number 64 * @return new generated ssrc 65 */ 66 static RtpDt_UInt32 generateNewSsrc(IN RtpDt_UInt32 uiTermNum); 67 68 /** 69 * @brief It gets middle four octets from Ntp timestamp 70 * @param pstNtpTs Ntp timestamp 71 * @return Middle four octets of Ntp timestamp 72 */ 73 static RtpDt_UInt32 getMidFourOctets(IN tRTP_NTP_TIME* pstNtpTs); 74 75 /** 76 * @brief Calculates RTP time stamp 77 * @param uiPrevRtpTs Previous Rtp timestamp 78 * @param pstCurNtpTs Current Ntp timestamp 79 * @param pstPrevNtpTs Previous Ntp timestamp 80 * @param uiSamplingRate Sampling Rate 81 * @return Calculated RTP time stamp 82 */ 83 static RtpDt_UInt32 calcRtpTimestamp(IN RtpDt_UInt32 uiPrevRtpTs, IN tRTP_NTP_TIME* pstCurNtpTs, 84 IN tRTP_NTP_TIME* pstPrevNtpTs, IN RtpDt_UInt32 uiSamplingRate); 85 }; 86 87 #endif //__RTP_STACK_UTIL_H__ 88 /** @}*/ 89