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 #ifndef RTCPDECODERNODE_H
18 #define RTCPDECODERNODE_H
19 
20 #include <BaseNode.h>
21 #include <IRtpSession.h>
22 #include <ImsMediaBitReader.h>
23 
24 class RtcpDecoderNode : public BaseNode, public IRtcpDecoderListener
25 {
26 public:
27     RtcpDecoderNode(BaseSessionCallback* callback = nullptr);
28     virtual ~RtcpDecoderNode();
29     virtual kBaseNodeId GetNodeId();
30     virtual ImsMediaResult Start();
31     virtual void Stop();
32     virtual void OnDataFromFrontNode(ImsMediaSubType subtype, uint8_t* pData, uint32_t nDataSize,
33             uint32_t nTimeStamp, bool mark, uint32_t nSeqNum,
34             ImsMediaSubType nDataType = MEDIASUBTYPE_UNDEFINED, uint32_t arrivalTime = 0);
35     virtual bool IsRunTime();
36     virtual bool IsSourceNode();
37     void SetConfig(void* config);
38     virtual bool IsSameConfig(void* config);
39     virtual void OnRtcpInd(tRtpSvc_IndicationFromStack eIndType, void* pMsg);
40     virtual void OnNumReceivedPacket(uint32_t nNumRTCPSRPacket, uint32_t nNumRTCPRRPacket);
41     virtual void OnEvent(uint32_t event, uint32_t param);
42 
43     /**
44      * @brief Set the local ip address and port number
45      */
46     void SetLocalAddress(const RtpAddress& address);
47 
48     /**
49      * @brief Set the peer ip address and port number
50      */
51     void SetPeerAddress(const RtpAddress& address);
52 
53     /**
54      * @brief Set the inactivity timer in second unit
55      */
56     void SetInactivityTimerSec(const uint32_t time);
57 
58     /**
59      * @brief Invokes when the tmmbr received from the RtpStack. This methods sends bitrate change
60      * event and request to send TMMBN.
61      *
62      * @param pstRtcp The payload object set received.
63      */
64     void ReceiveTmmbr(const tRtpSvcIndSt_ReceiveRtcpFeedbackInd* pstRtcp);
65 
66     /**
67      * @brief Requests to send event to send IDR frame set to encoder
68      */
69     void RequestIdrFrame();
70 
71 private:
72     IRtpSession* mRtpSession;
73     RtpAddress mLocalAddress;
74     RtpAddress mPeerAddress;
75     uint32_t mInactivityTime;
76     uint32_t mNoRtcpTime;
77     ImsMediaBitReader mBitReader;
78 };
79 
80 #endif  // RTCPDECODERNODE_H
81