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_PACKET_H__
22 #define __RTP_PACKET_H__
23 
24 #include <RtpGlobal.h>
25 #include <RtpHeader.h>
26 
27 /**
28  * @class    RtpPacket
29  * @brief    It contains Rtp packet information.
30  */
31 class RtpPacket
32 {
33 private:
34     // Rtp Header
35     RtpHeader m_objRtpHeader;
36 
37     /**
38      * Extension header buffer. This is encoded and given by app.
39      * After decoding, ExtractExtHeaders, will update this with the extension
40      * header buffer
41      */
42     RtpBuffer* m_pobjExt;
43 
44     // RTP payload
45     RtpBuffer* m_pobjRtpPayload;
46 
47 #ifdef ENABLE_PADDING
48     // Length of Pad Bytes.
49     RtpDt_UChar m_ucPadLen;
50 #endif
51 
52 public:
53     // Constructor
54     RtpPacket();
55     // Destructor
56     ~RtpPacket();
57 
58     // get method for m_objRtpHeader
59     RtpHeader* getRtpHeader();
60 
61     // set method for m_pobjRtpPayload
62     RtpDt_Void setRtpPayload(IN RtpBuffer* pobjRtpPld);
63 
64     // get method for m_pobjRtpPayload
65     RtpBuffer* getRtpPayload();
66 
67     // get method for RTP Header extension buffer
68     RtpBuffer* getExtHeader();
69 
70     /**
71      * pobjExt will stored and freed by stack.
72      *
73      * @param[in] pobjExt Header extension to be added to the packet
74      */
75     RtpDt_Void setExtHeader(IN RtpBuffer* pobjExt);
76 
77     /**
78      * Performs the encoding of the RTP packet.
79      * This function does not allocate memory required for encoding.
80      *
81      * @param[out] pobjRtpPktBuf Memory for the buffer is pre-allocated by caller
82      */
83     eRtp_Bool formPacket(OUT RtpBuffer* pobjRtpPktBuf);
84 
85     /**
86      * Decodes and stores the information of the RTP packet
87      * This function does not allocate memory required for decoding.
88      *
89      * @param[in] pobjRtpPktBuf Memory for the buffer is pre-allocated by caller
90      * @return eRTP_SUCCESS on successful decoding
91      */
92     eRtp_Bool decodePacket(IN RtpBuffer* pobjRtpPktBuf);
93 };
94 #endif  //__RTP_PACKET_H__
95 
96 /** @}*/
97