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 __RTCP_SR_PACKET_H__
22 #define __RTCP_SR_PACKET_H__
23 
24 #include <RtpGlobal.h>
25 #include <RtcpRrPacket.h>
26 
27 /**
28  * @class    RtcpSrPacket
29  * @brief    It holds SR packet information
30  */
31 class RtcpSrPacket
32 {
33 private:
34     /**
35      * It holds the RR packet information
36      */
37     RtcpRrPacket m_objRrPkt;
38 
39     /**
40      * NTP timestamp, most significant word
41      * NTP timestamp, least significant word
42      */
43     tRTP_NTP_TIME m_stNtpTimestamp;
44 
45     // Rtp time stamp
46     RtpDt_UInt32 m_uiRtpTimestamp;
47 
48     // Sender's packet count
49     RtpDt_UInt32 m_uiSendPktCount;
50 
51     // Sender's octet count
52     RtpDt_UInt32 m_uiSendOctCount;
53 
54 public:
55     // Constructor
56     RtcpSrPacket();
57 
58     // Destructor
59     ~RtcpSrPacket();
60 
61     /**
62      * Set RTCP header information.
63      */
64     RtpDt_Void setRtcpHdrInfo(RtcpHeader& rtcpHeader);
65 
66     /**
67      * Get RTCP header information.
68      */
69     RtcpHeader* getRtcpHdrInfo();
70 
71     /**
72      * get method for m_objRrPkt
73      */
74     RtcpRrPacket* getRrPktInfo();
75 
76     /**
77      * get method for m_stNtpTimestamp
78      */
79     tRTP_NTP_TIME* getNtpTime();
80 
81     /**
82      * set method for m_uiRtpTimestamp
83      */
84     RtpDt_Void setRtpTimestamp(IN RtpDt_UInt32 uiRtpTimestamp);
85 
86     /**
87      *  get method for m_uiRtpTimestamp
88      */
89     RtpDt_UInt32 getRtpTimestamp();
90 
91     /**
92      * set method for m_uiSendPktCount
93      */
94     RtpDt_Void setSendPktCount(IN RtpDt_UInt32 uiPktCount);
95 
96     /**
97      * get method for m_uiSendPktCount
98      */
99     RtpDt_UInt32 getSendPktCount();
100 
101     /**
102      * set method for m_uiSendOctCount
103      */
104     RtpDt_Void setSendOctetCount(IN RtpDt_UInt32 uiOctetCount);
105 
106     /**
107      * get method for m_uiSendOctCount
108      */
109     RtpDt_UInt32 getSendOctetCount();
110 
111     /**
112      * Decodes and stores the information of the RTCP SR packet
113      * This function does not allocate memory required for decoding
114      * @param[in] pucSrPktBuf raw buffer for RTCP SR packet
115      * @param[in] usSrPktLen length of the RTCP SR packet
116      * @param[in] usExtHdrLen profile extension header length
117      * @return RTP_SUCCESS on successful decoding
118      */
119     eRTP_STATUS_CODE decodeSrPacket(
120             IN RtpDt_UChar* pucSrPktBuf, IN RtpDt_UInt16 usSrPktLen, IN RtpDt_UInt16 usExtHdrLen);
121 
122     /**
123      * Performs the encoding of the RTCP SR packet.
124      * This function does not allocate memory required for encoding.
125      * @param[out] pobjRtcpPktBuf Memory for the buffer is pre-allocated by caller
126      * @return RTP_SUCCESS on successful encoding
127      */
128     eRTP_STATUS_CODE formSrPacket(OUT RtpBuffer* pobjRtcpPktBuf);
129 
130 };  // end of RtcpSrPacket
131 
132 #endif  //__RTCP_SR_PACKET_H__
133 
134 /** @}*/
135