blob: 5dc0310209cab219658724a055252524062b5b85 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
pwestin@webrtc.orgf6bb77a2012-01-24 17:16:59 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_RECEIVER_H_
12#define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_RECEIVER_H_
13
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +000014#include <map>
perkj@webrtc.orgce5990c2012-01-11 13:00:08 +000015#include <vector>
16
niklase@google.com470e71d2011-07-07 08:21:25 +000017#include "typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000018#include "rtp_utility.h"
19#include "rtcp_utility.h"
20#include "rtp_rtcp_defines.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000021#include "rtcp_receiver_help.h"
pwestin@webrtc.orgcac78782012-04-05 08:30:10 +000022#include "tmmbr_help.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000023
24namespace webrtc {
pwestin@webrtc.org741da942011-09-20 13:52:04 +000025class ModuleRtpRtcpImpl;
26
pwestin@webrtc.orgcac78782012-04-05 08:30:10 +000027class RTCPReceiver : public TMMBRHelp
niklase@google.com470e71d2011-07-07 08:21:25 +000028{
29public:
pwestin@webrtc.org0644b1d2011-12-01 15:42:31 +000030 RTCPReceiver(const WebRtc_Word32 id, RtpRtcpClock* clock,
31 ModuleRtpRtcpImpl* owner);
niklase@google.com470e71d2011-07-07 08:21:25 +000032 virtual ~RTCPReceiver();
33
34 void ChangeUniqueId(const WebRtc_Word32 id);
35
36 RTCPMethod Status() const;
37 WebRtc_Word32 SetRTCPStatus(const RTCPMethod method);
38
pwestin@webrtc.org18530052012-07-03 10:41:54 +000039 WebRtc_Word64 LastReceived();
niklase@google.com470e71d2011-07-07 08:21:25 +000040
41 void SetSSRC( const WebRtc_UWord32 ssrc);
42 void SetRelaySSRC( const WebRtc_UWord32 ssrc);
43 WebRtc_Word32 SetRemoteSSRC( const WebRtc_UWord32 ssrc);
44
45 WebRtc_UWord32 RelaySSRC() const;
46
pwestin@webrtc.org49888ce2012-04-27 05:25:53 +000047 void RegisterRtcpObservers(RtcpIntraFrameObserver* intra_frame_callback,
48 RtcpBandwidthObserver* bandwidth_callback,
49 RtcpFeedback* feedback_callback);
niklase@google.com470e71d2011-07-07 08:21:25 +000050
51 WebRtc_Word32 IncomingRTCPPacket(RTCPHelp::RTCPPacketInformation& rtcpPacketInformation,
52 RTCPUtility::RTCPParserV2 *rtcpParser);
53
54 void TriggerCallbacksFromRTCPPacket(RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
55
56 // get received cname
57 WebRtc_Word32 CNAME(const WebRtc_UWord32 remoteSSRC,
pwestin@webrtc.orgf6bb77a2012-01-24 17:16:59 +000058 char cName[RTCP_CNAME_SIZE]) const;
niklase@google.com470e71d2011-07-07 08:21:25 +000059
60 // get received NTP
61 WebRtc_Word32 NTP(WebRtc_UWord32 *ReceivedNTPsecs,
pwestin@webrtc.org741da942011-09-20 13:52:04 +000062 WebRtc_UWord32 *ReceivedNTPfrac,
63 WebRtc_UWord32 *RTCPArrivalTimeSecs,
stefan@webrtc.org7c3523c2012-09-11 07:00:42 +000064 WebRtc_UWord32 *RTCPArrivalTimeFrac,
65 WebRtc_UWord32 *rtcp_timestamp) const;
niklase@google.com470e71d2011-07-07 08:21:25 +000066
67 // get rtt
68 WebRtc_Word32 RTT(const WebRtc_UWord32 remoteSSRC,
pwestin@webrtc.org741da942011-09-20 13:52:04 +000069 WebRtc_UWord16* RTT,
70 WebRtc_UWord16* avgRTT,
71 WebRtc_UWord16* minRTT,
72 WebRtc_UWord16* maxRTT) const;
niklase@google.com470e71d2011-07-07 08:21:25 +000073
mflodman@webrtc.orgd7d46882012-02-14 12:49:59 +000074 WebRtc_UWord16 RTT() const;
75
76 int SetRTT(WebRtc_UWord16 rtt);
77
niklase@google.com470e71d2011-07-07 08:21:25 +000078 WebRtc_Word32 ResetRTT(const WebRtc_UWord32 remoteSSRC);
79
niklase@google.com470e71d2011-07-07 08:21:25 +000080 WebRtc_Word32 SenderInfoReceived(RTCPSenderInfo* senderInfo) const;
81
niklase@google.com470e71d2011-07-07 08:21:25 +000082 // get statistics
perkj@webrtc.orgce5990c2012-01-11 13:00:08 +000083 WebRtc_Word32 StatisticsReceived(
84 std::vector<RTCPReportBlock>* receiveBlocks) const;
85
niklase@google.com470e71d2011-07-07 08:21:25 +000086 // Get TMMBR
87 WebRtc_Word32 TMMBRReceived(const WebRtc_UWord32 size,
pwestin@webrtc.org1da1ce02011-10-13 15:19:55 +000088 const WebRtc_UWord32 accNumCandidates,
89 TMMBRSet* candidateSet) const;
niklase@google.com470e71d2011-07-07 08:21:25 +000090
91 bool UpdateRTCPReceiveInformationTimers();
92
hta@webrtc.org65a4e4e2012-04-30 11:23:41 +000093 WebRtc_Word32 BoundingSet(bool &tmmbrOwner, TMMBRSet* boundingSetRec);
niklase@google.com470e71d2011-07-07 08:21:25 +000094
pwestin@webrtc.orgcac78782012-04-05 08:30:10 +000095 WebRtc_Word32 UpdateTMMBR();
niklase@google.com470e71d2011-07-07 08:21:25 +000096
97 WebRtc_Word32 SetPacketTimeout(const WebRtc_UWord32 timeoutMS);
98 void PacketTimeout();
99
100protected:
101 RTCPHelp::RTCPReportBlockInformation* CreateReportBlockInformation(const WebRtc_UWord32 remoteSSRC);
102 RTCPHelp::RTCPReportBlockInformation* GetReportBlockInformation(const WebRtc_UWord32 remoteSSRC) const;
103
104 RTCPUtility::RTCPCnameInformation* CreateCnameInformation(const WebRtc_UWord32 remoteSSRC);
105 RTCPUtility::RTCPCnameInformation* GetCnameInformation(const WebRtc_UWord32 remoteSSRC) const;
106
107 RTCPHelp::RTCPReceiveInformation* CreateReceiveInformation(const WebRtc_UWord32 remoteSSRC);
108 RTCPHelp::RTCPReceiveInformation* GetReceiveInformation(const WebRtc_UWord32 remoteSSRC);
109
110 void UpdateReceiveInformation( RTCPHelp::RTCPReceiveInformation& receiveInformation);
111
112 void HandleSenderReceiverReport(RTCPUtility::RTCPParserV2& rtcpParser,
113 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
114
115 void HandleReportBlock(const RTCPUtility::RTCPPacket& rtcpPacket,
116 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation,
117 const WebRtc_UWord32 remoteSSRC,
118 const WebRtc_UWord8 numberOfReportBlocks);
119
120 void HandleSDES(RTCPUtility::RTCPParserV2& rtcpParser);
121
122 void HandleSDESChunk(RTCPUtility::RTCPParserV2& rtcpParser);
123
124 void HandleXRVOIPMetric(RTCPUtility::RTCPParserV2& rtcpParser,
125 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
126
127 void HandleNACK(RTCPUtility::RTCPParserV2& rtcpParser,
128 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
129
130 void HandleNACKItem(const RTCPUtility::RTCPPacket& rtcpPacket,
131 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
132
133 void HandleBYE(RTCPUtility::RTCPParserV2& rtcpParser);
134
135 void HandlePLI(RTCPUtility::RTCPParserV2& rtcpParser,
136 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
137
138 void HandleSLI(RTCPUtility::RTCPParserV2& rtcpParser,
139 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
140
141 void HandleSLIItem(const RTCPUtility::RTCPPacket& rtcpPacket,
142 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
143
144 void HandleRPSI(RTCPUtility::RTCPParserV2& rtcpParser,
145 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
146
pwestin@webrtc.org741da942011-09-20 13:52:04 +0000147 void HandlePsfbApp(RTCPUtility::RTCPParserV2& rtcpParser,
148 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
149
150 void HandleREMBItem(RTCPUtility::RTCPParserV2& rtcpParser,
151 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
152
asapersson@webrtc.org5249cc82011-12-16 14:31:37 +0000153 void HandleIJ(RTCPUtility::RTCPParserV2& rtcpParser,
154 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
155
156 void HandleIJItem(const RTCPUtility::RTCPPacket& rtcpPacket,
157 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
158
niklase@google.com470e71d2011-07-07 08:21:25 +0000159 void HandleTMMBR(RTCPUtility::RTCPParserV2& rtcpParser,
160 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
161
162 void HandleTMMBRItem(RTCPHelp::RTCPReceiveInformation& receiveInfo,
163 const RTCPUtility::RTCPPacket& rtcpPacket,
164 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation,
165 const WebRtc_UWord32 senderSSRC);
166
hta@webrtc.org9d54cd12012-04-30 08:24:55 +0000167 void HandleTMMBN(RTCPUtility::RTCPParserV2& rtcpParser,
168 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
niklase@google.com470e71d2011-07-07 08:21:25 +0000169
170 void HandleSR_REQ(RTCPUtility::RTCPParserV2& rtcpParser,
171 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
172
173 void HandleTMMBNItem(RTCPHelp::RTCPReceiveInformation& receiveInfo,
174 const RTCPUtility::RTCPPacket& rtcpPacket);
175
176 void HandleFIR(RTCPUtility::RTCPParserV2& rtcpParser,
177 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
178
pwestin@webrtc.orgb2179c22012-05-21 12:00:49 +0000179 void HandleFIRItem(RTCPHelp::RTCPReceiveInformation* receiveInfo,
niklase@google.com470e71d2011-07-07 08:21:25 +0000180 const RTCPUtility::RTCPPacket& rtcpPacket,
181 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
182
183 void HandleAPP(RTCPUtility::RTCPParserV2& rtcpParser,
184 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
185
186 void HandleAPPItem(RTCPUtility::RTCPParserV2& rtcpParser,
187 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
188
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +0000189 private:
190 WebRtc_Word32 _id;
191 RtpRtcpClock& _clock;
192 RTCPMethod _method;
pwestin@webrtc.org18530052012-07-03 10:41:54 +0000193 WebRtc_Word64 _lastReceived;
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +0000194 ModuleRtpRtcpImpl& _rtpRtcp;
niklase@google.com470e71d2011-07-07 08:21:25 +0000195
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +0000196 CriticalSectionWrapper* _criticalSectionFeedbacks;
197 RtcpFeedback* _cbRtcpFeedback;
pwestin@webrtc.org49888ce2012-04-27 05:25:53 +0000198 RtcpBandwidthObserver* _cbRtcpBandwidthObserver;
199 RtcpIntraFrameObserver* _cbRtcpIntraFrameObserver;
niklase@google.com470e71d2011-07-07 08:21:25 +0000200
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +0000201 CriticalSectionWrapper* _criticalSectionRTCPReceiver;
202 WebRtc_UWord32 _SSRC;
203 WebRtc_UWord32 _remoteSSRC;
niklase@google.com470e71d2011-07-07 08:21:25 +0000204
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +0000205 // Received send report
206 RTCPSenderInfo _remoteSenderInfo;
207 // when did we receive the last send report
208 WebRtc_UWord32 _lastReceivedSRNTPsecs;
209 WebRtc_UWord32 _lastReceivedSRNTPfrac;
niklase@google.com470e71d2011-07-07 08:21:25 +0000210
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +0000211 // Received report blocks.
212 std::map<WebRtc_UWord32, RTCPHelp::RTCPReportBlockInformation*>
213 _receivedReportBlockMap;
214 std::map<WebRtc_UWord32, RTCPHelp::RTCPReceiveInformation*>
215 _receivedInfoMap;
216 std::map<WebRtc_UWord32, RTCPUtility::RTCPCnameInformation*>
217 _receivedCnameMap;
niklase@google.com470e71d2011-07-07 08:21:25 +0000218
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +0000219 WebRtc_UWord32 _packetTimeOutMS;
mflodman@webrtc.orgd7d46882012-02-14 12:49:59 +0000220
221 // Externally set RTT. This value can only be used if there are no valid
222 // RTT estimates.
223 WebRtc_UWord16 _rtt;
224
niklase@google.com470e71d2011-07-07 08:21:25 +0000225};
226} // namespace webrtc
227#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_RECEIVER_H_