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 __IRTP_APPINTERFACE_H__ 22 #define __IRTP_APPINTERFACE_H__ 23 24 #include <RtpGlobal.h> 25 #include <RtpBuffer.h> 26 27 typedef RtpDt_Void (*RTPCB_TIMERHANDLER)(RtpDt_Void* pvTimerId, RtpDt_Void* pvData); 28 29 class RtpSession; 30 31 /** 32 * @class IRtpAppInterface 33 * 34 * @brief It is an interface class to the application. Callbacks will be implemented by the 35 * application. 36 */ 37 class IRtpAppInterface 38 { 39 // application handle. 40 41 public: 42 // Destructor ~IRtpAppInterface()43 virtual ~IRtpAppInterface(){}; 44 45 /** 46 * This callback function should handle SSRC collision reported by RTP stack. 47 * If there is collision between the SSRC used by RTPstack and that chosen by another 48 * participant then, 49 * it must send an RTCP BYE for the original SSRC and select another SSRC for itself. 50 * 51 * @param uiOldSsrc Old SSRC received as part of RTP packets header. 52 * @param uiNewSsrc New SSRC received as part of latest RTP packet header. 53 */ 54 virtual eRtp_Bool rtpSsrcCollisionInd(IN RtpDt_Int32 uiOldSsrc, IN RtpDt_Int32 uiNewSsrc) = 0; 55 56 /** 57 * Store appdata that can be used when the call back is called on this object 58 * 59 * @param pvAppdata pointer to app data which must be stored/associated with the RTP session. 60 */ 61 virtual RtpDt_Void setAppdata(IN RtpDt_Void* pvAppdata) = 0; 62 63 /** 64 * Get method to fetch app data associated with the RTP session. 65 * 66 * @return pointer to app associated with the RTP session which was previously set using 67 * setAppdata. 68 * 69 * @see setAppdata 70 */ 71 virtual RtpDt_Void* getAppdata() = 0; 72 73 /** 74 * This Callback function is called by RTP stack when an RTP packet with new SSRC is received. 75 * 76 * @uiSsrc SSRC of the member who joined the session. 77 */ 78 virtual eRtp_Bool rtpNewMemberJoinInd(IN RtpDt_Int32 uiSsrc) = 0; 79 80 /** 81 * Callback function called by RTP stack when a participant has left the conference or 82 * has sent bye to resolve collision of ssrc. 83 * The application should not treat this as a reason to delete/close the session 84 * 85 * @param eLeaveReason This param indicates if the leave reason is RTCP BYE or no RTP packets 86 * are received by the member identified by uiSSrc. 87 * 88 * @param uiSsrc SSRC of the participant. 89 */ 90 virtual eRtp_Bool rtpMemberLeaveInd( 91 IN eRTP_LEAVE_REASON eLeaveReason, IN RtpDt_Int32 uiSsrc) = 0; 92 /** 93 * This Callback is called when stack wants to send RTCP packet buffer 94 * received to the network node. 95 * 96 * @param pobjRtcpPkt RTCP packet buffer to be sent. 97 * 98 * @param pobjRtpSession RTP Session which is sending the RTCP packet. 99 */ 100 virtual eRtp_Bool rtcpPacketSendInd( 101 IN RtpBuffer* pobjRtcpPkt, IN RtpSession* pobjRtpSession) = 0; 102 103 /** 104 * This callback is called by RTP Stack when it is forming app packet and the App 105 * should provide stack with the sub-type, name of the packet and payload. 106 * 107 * @param usSubType This is an App defined sub-type. It can be used to differentiate between 108 * app defined packet types. 109 * 110 * @param uiName App name String. 111 * 112 * @param pobjPayload App Payload Data. 113 */ 114 virtual eRtp_Bool rtcpAppPayloadReqInd( 115 OUT RtpDt_UInt16& usSubType, OUT RtpDt_UInt32& uiName, OUT RtpBuffer* pobjPayload) = 0; 116 /** 117 * This function is called when RTP Stack is preparing RTCP report block. 118 * App need to fill the RTP extension header buffer. 119 * 120 * @param pobjExtHdrInfo RTP extension header buffer to be filled by the app. 121 */ 122 virtual eRtp_Bool getRtpHdrExtInfo(OUT RtpBuffer* pobjExtHdrInfo) = 0; 123 124 /** 125 * This callback is called when receiver has left the rtp session or when the rtp session is 126 * going to stop. 127 * 128 * @param uiRemoteSsrc SSRC of the participant/peer. 129 * 130 * @param pobjDestAddr IPAddress of the participant. 131 * 132 * @param usRemotePort RTP port of the participant. 133 */ 134 virtual eRtp_Bool deleteRcvrInfo(IN RtpDt_UInt32 uiRemoteSsrc, IN RtpBuffer* pobjDestAddr, 135 IN RtpDt_UInt16 usRemotePort) = 0; 136 137 /** 138 * This callback is called when there is any error while processing (packing or parsing) 139 * RTCP packets. 140 * 141 * @param eStatus error enum indicating the error type. 142 */ 143 virtual eRtp_Bool rtcpTimerHdlErrorInd(IN eRTP_STATUS_CODE eStatus) = 0; 144 145 /** 146 * This callback is called whenever RTP stacks needs to start the timer for sending periodic 147 * RTCP packets. 148 * App need to make sure that the timer expiry function pfnTimerCb is called at the uiDuration 149 * intervals. 150 * 151 * @param uiDuration Timer expiry interval. 152 * 153 * @param bRepeat If the timer should repeat or one-time expire. 154 * 155 * @param pfnTimerCb Callback to be called when the timer expires. 156 * 157 * @param pvData Data to be passed to callback when timer expires. 158 * 159 * @return returns timer-id. 160 */ 161 virtual RtpDt_Void* RtpStartTimer(IN RtpDt_UInt32 uiDuration, IN eRtp_Bool bRepeat, 162 IN RTPCB_TIMERHANDLER pfnTimerCb, IN RtpDt_Void* pvData) = 0; 163 164 /** 165 * This callback is called when the RTCP timer need to be cancelled. 166 * 167 * @param pTimerId Id of the timer to be stopeed. 168 */ 169 virtual eRtp_Bool RtpStopTimer(IN RtpDt_Void* pTimerId, OUT RtpDt_Void** pUserData) = 0; 170 }; 171 172 #endif //__IRTP_APPINTERFACE_H__ 173 174 /** @}*/ 175