1/*
2 *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 *
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_HELP_H_
12#define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_RECEIVER_HELP_H_
13
14
15#include "webrtc/base/constructormagic.h"
16#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"  // RTCPReportBlock
17#include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
18#include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h"
19#include "webrtc/system_wrappers/interface/scoped_ptr.h"
20#include "webrtc/typedefs.h"
21
22namespace webrtc {
23namespace RTCPHelp
24{
25
26class RTCPReportBlockInformation
27{
28public:
29    RTCPReportBlockInformation();
30    ~RTCPReportBlockInformation();
31
32    // Statistics
33    RTCPReportBlock remoteReceiveBlock;
34    uint32_t        remoteMaxJitter;
35
36    // RTT
37    uint16_t    RTT;
38    uint16_t    minRTT;
39    uint16_t    maxRTT;
40    uint16_t    avgRTT;
41    uint32_t    numAverageCalcs;
42};
43
44class RTCPPacketInformation
45{
46public:
47    RTCPPacketInformation();
48    ~RTCPPacketInformation();
49
50    void AddVoIPMetric(const RTCPVoIPMetric*  metric);
51
52    void AddApplicationData(const uint8_t* data,
53                            const uint16_t size);
54
55    void AddNACKPacket(const uint16_t packetID);
56    void ResetNACKPacketIdArray();
57
58    void AddReportInfo(const RTCPReportBlockInformation& report_block_info);
59
60    uint32_t  rtcpPacketTypeFlags; // RTCPPacketTypeFlags bit field
61    uint32_t  remoteSSRC;
62
63    std::list<uint16_t> nackSequenceNumbers;
64
65    uint8_t   applicationSubType;
66    uint32_t  applicationName;
67    uint8_t*  applicationData;
68    uint16_t  applicationLength;
69
70    ReportBlockList report_blocks;
71    uint16_t rtt;
72
73    uint32_t  interArrivalJitter;
74
75    uint8_t   sliPictureId;
76    uint64_t  rpsiPictureId;
77    uint32_t  receiverEstimatedMaxBitrate;
78
79    uint32_t ntp_secs;
80    uint32_t ntp_frac;
81    uint32_t rtp_timestamp;
82
83    uint32_t xr_originator_ssrc;
84    bool xr_dlrr_item;
85    RTCPVoIPMetric*  VoIPMetric;
86
87private:
88    DISALLOW_COPY_AND_ASSIGN(RTCPPacketInformation);
89};
90
91class RTCPReceiveInformation
92{
93public:
94    RTCPReceiveInformation();
95    ~RTCPReceiveInformation();
96
97    void VerifyAndAllocateBoundingSet(const uint32_t minimumSize);
98    void VerifyAndAllocateTMMBRSet(const uint32_t minimumSize);
99
100    void InsertTMMBRItem(const uint32_t senderSSRC,
101                         const RTCPUtility::RTCPPacketRTPFBTMMBRItem& TMMBRItem,
102                         const int64_t currentTimeMS);
103
104    // get
105    int32_t GetTMMBRSet(const uint32_t sourceIdx,
106                        const uint32_t targetIdx,
107                        TMMBRSet* candidateSet,
108                        const int64_t currentTimeMS);
109
110    int64_t lastTimeReceived;
111
112    // FIR
113    int32_t lastFIRSequenceNumber;
114    int64_t lastFIRRequest;
115
116    // TMMBN
117    TMMBRSet        TmmbnBoundingSet;
118
119    // TMMBR
120    TMMBRSet        TmmbrSet;
121
122    bool            readyForDelete;
123private:
124    std::vector<int64_t> _tmmbrSetTimeouts;
125};
126
127}  // end namespace RTCPHelp
128}  // namespace webrtc
129
130#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_RECEIVER_HELP_H_
131