blob: ff6f19af9bf5d831f23a7c79e499ed2a55753414 [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
39 WebRtc_UWord32 LastReceived();
40
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,
64 WebRtc_UWord32 *RTCPArrivalTimeFrac) const;
niklase@google.com470e71d2011-07-07 08:21:25 +000065
66 // get rtt
67 WebRtc_Word32 RTT(const WebRtc_UWord32 remoteSSRC,
pwestin@webrtc.org741da942011-09-20 13:52:04 +000068 WebRtc_UWord16* RTT,
69 WebRtc_UWord16* avgRTT,
70 WebRtc_UWord16* minRTT,
71 WebRtc_UWord16* maxRTT) const;
niklase@google.com470e71d2011-07-07 08:21:25 +000072
mflodman@webrtc.orgd7d46882012-02-14 12:49:59 +000073 WebRtc_UWord16 RTT() const;
74
75 int SetRTT(WebRtc_UWord16 rtt);
76
niklase@google.com470e71d2011-07-07 08:21:25 +000077 WebRtc_Word32 ResetRTT(const WebRtc_UWord32 remoteSSRC);
78
niklase@google.com470e71d2011-07-07 08:21:25 +000079 WebRtc_Word32 SenderInfoReceived(RTCPSenderInfo* senderInfo) const;
80
niklase@google.com470e71d2011-07-07 08:21:25 +000081 // get statistics
perkj@webrtc.orgce5990c2012-01-11 13:00:08 +000082 WebRtc_Word32 StatisticsReceived(
83 std::vector<RTCPReportBlock>* receiveBlocks) const;
84
niklase@google.com470e71d2011-07-07 08:21:25 +000085 // Get TMMBR
86 WebRtc_Word32 TMMBRReceived(const WebRtc_UWord32 size,
pwestin@webrtc.org1da1ce02011-10-13 15:19:55 +000087 const WebRtc_UWord32 accNumCandidates,
88 TMMBRSet* candidateSet) const;
niklase@google.com470e71d2011-07-07 08:21:25 +000089
90 bool UpdateRTCPReceiveInformationTimers();
91
hta@webrtc.org65a4e4e2012-04-30 11:23:41 +000092 WebRtc_Word32 BoundingSet(bool &tmmbrOwner, TMMBRSet* boundingSetRec);
niklase@google.com470e71d2011-07-07 08:21:25 +000093
pwestin@webrtc.orgcac78782012-04-05 08:30:10 +000094 WebRtc_Word32 UpdateTMMBR();
niklase@google.com470e71d2011-07-07 08:21:25 +000095
96 WebRtc_Word32 SetPacketTimeout(const WebRtc_UWord32 timeoutMS);
97 void PacketTimeout();
98
99protected:
100 RTCPHelp::RTCPReportBlockInformation* CreateReportBlockInformation(const WebRtc_UWord32 remoteSSRC);
101 RTCPHelp::RTCPReportBlockInformation* GetReportBlockInformation(const WebRtc_UWord32 remoteSSRC) const;
102
103 RTCPUtility::RTCPCnameInformation* CreateCnameInformation(const WebRtc_UWord32 remoteSSRC);
104 RTCPUtility::RTCPCnameInformation* GetCnameInformation(const WebRtc_UWord32 remoteSSRC) const;
105
106 RTCPHelp::RTCPReceiveInformation* CreateReceiveInformation(const WebRtc_UWord32 remoteSSRC);
107 RTCPHelp::RTCPReceiveInformation* GetReceiveInformation(const WebRtc_UWord32 remoteSSRC);
108
109 void UpdateReceiveInformation( RTCPHelp::RTCPReceiveInformation& receiveInformation);
110
111 void HandleSenderReceiverReport(RTCPUtility::RTCPParserV2& rtcpParser,
112 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
113
114 void HandleReportBlock(const RTCPUtility::RTCPPacket& rtcpPacket,
115 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation,
116 const WebRtc_UWord32 remoteSSRC,
117 const WebRtc_UWord8 numberOfReportBlocks);
118
119 void HandleSDES(RTCPUtility::RTCPParserV2& rtcpParser);
120
121 void HandleSDESChunk(RTCPUtility::RTCPParserV2& rtcpParser);
122
123 void HandleXRVOIPMetric(RTCPUtility::RTCPParserV2& rtcpParser,
124 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
125
126 void HandleNACK(RTCPUtility::RTCPParserV2& rtcpParser,
127 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
128
129 void HandleNACKItem(const RTCPUtility::RTCPPacket& rtcpPacket,
130 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
131
132 void HandleBYE(RTCPUtility::RTCPParserV2& rtcpParser);
133
134 void HandlePLI(RTCPUtility::RTCPParserV2& rtcpParser,
135 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
136
137 void HandleSLI(RTCPUtility::RTCPParserV2& rtcpParser,
138 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
139
140 void HandleSLIItem(const RTCPUtility::RTCPPacket& rtcpPacket,
141 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
142
143 void HandleRPSI(RTCPUtility::RTCPParserV2& rtcpParser,
144 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
145
pwestin@webrtc.org741da942011-09-20 13:52:04 +0000146 void HandlePsfbApp(RTCPUtility::RTCPParserV2& rtcpParser,
147 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
148
149 void HandleREMBItem(RTCPUtility::RTCPParserV2& rtcpParser,
150 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
151
asapersson@webrtc.org5249cc82011-12-16 14:31:37 +0000152 void HandleIJ(RTCPUtility::RTCPParserV2& rtcpParser,
153 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
154
155 void HandleIJItem(const RTCPUtility::RTCPPacket& rtcpPacket,
156 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
157
niklase@google.com470e71d2011-07-07 08:21:25 +0000158 void HandleTMMBR(RTCPUtility::RTCPParserV2& rtcpParser,
159 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
160
161 void HandleTMMBRItem(RTCPHelp::RTCPReceiveInformation& receiveInfo,
162 const RTCPUtility::RTCPPacket& rtcpPacket,
163 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation,
164 const WebRtc_UWord32 senderSSRC);
165
hta@webrtc.org9d54cd12012-04-30 08:24:55 +0000166 void HandleTMMBN(RTCPUtility::RTCPParserV2& rtcpParser,
167 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
niklase@google.com470e71d2011-07-07 08:21:25 +0000168
169 void HandleSR_REQ(RTCPUtility::RTCPParserV2& rtcpParser,
170 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
171
172 void HandleTMMBNItem(RTCPHelp::RTCPReceiveInformation& receiveInfo,
173 const RTCPUtility::RTCPPacket& rtcpPacket);
174
175 void HandleFIR(RTCPUtility::RTCPParserV2& rtcpParser,
176 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
177
pwestin@webrtc.orgb2179c22012-05-21 12:00:49 +0000178 void HandleFIRItem(RTCPHelp::RTCPReceiveInformation* receiveInfo,
niklase@google.com470e71d2011-07-07 08:21:25 +0000179 const RTCPUtility::RTCPPacket& rtcpPacket,
180 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
181
182 void HandleAPP(RTCPUtility::RTCPParserV2& rtcpParser,
183 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
184
185 void HandleAPPItem(RTCPUtility::RTCPParserV2& rtcpParser,
186 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
187
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +0000188 private:
189 WebRtc_Word32 _id;
190 RtpRtcpClock& _clock;
191 RTCPMethod _method;
192 WebRtc_UWord32 _lastReceived;
193 ModuleRtpRtcpImpl& _rtpRtcp;
niklase@google.com470e71d2011-07-07 08:21:25 +0000194
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +0000195 CriticalSectionWrapper* _criticalSectionFeedbacks;
196 RtcpFeedback* _cbRtcpFeedback;
pwestin@webrtc.org49888ce2012-04-27 05:25:53 +0000197 RtcpBandwidthObserver* _cbRtcpBandwidthObserver;
198 RtcpIntraFrameObserver* _cbRtcpIntraFrameObserver;
niklase@google.com470e71d2011-07-07 08:21:25 +0000199
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +0000200 CriticalSectionWrapper* _criticalSectionRTCPReceiver;
201 WebRtc_UWord32 _SSRC;
202 WebRtc_UWord32 _remoteSSRC;
niklase@google.com470e71d2011-07-07 08:21:25 +0000203
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +0000204 // Received send report
205 RTCPSenderInfo _remoteSenderInfo;
206 // when did we receive the last send report
207 WebRtc_UWord32 _lastReceivedSRNTPsecs;
208 WebRtc_UWord32 _lastReceivedSRNTPfrac;
niklase@google.com470e71d2011-07-07 08:21:25 +0000209
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +0000210 // Received report blocks.
211 std::map<WebRtc_UWord32, RTCPHelp::RTCPReportBlockInformation*>
212 _receivedReportBlockMap;
213 std::map<WebRtc_UWord32, RTCPHelp::RTCPReceiveInformation*>
214 _receivedInfoMap;
215 std::map<WebRtc_UWord32, RTCPUtility::RTCPCnameInformation*>
216 _receivedCnameMap;
niklase@google.com470e71d2011-07-07 08:21:25 +0000217
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +0000218 WebRtc_UWord32 _packetTimeOutMS;
mflodman@webrtc.orgd7d46882012-02-14 12:49:59 +0000219
220 // Externally set RTT. This value can only be used if there are no valid
221 // RTT estimates.
222 WebRtc_UWord16 _rtt;
223
niklase@google.com470e71d2011-07-07 08:21:25 +0000224};
225} // namespace webrtc
226#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_RECEIVER_H_