blob: 0575f1d0028e5d5483337221ba2a85721394585d [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
2 * Copyright (c) 2011 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_TMMBR_HELP_H_
12#define WEBRTC_MODULES_RTP_RTCP_SOURCE_TMMBR_HELP_H_
13
14#include "typedefs.h"
15
16#include "critical_section_wrapper.h"
17
18#ifndef NULL
19 #define NULL 0
20#endif
21
22namespace webrtc {
23class TMMBRSet
24{
25public:
26 TMMBRSet();
27 ~TMMBRSet();
28
29 void VerifyAndAllocateSet(WebRtc_UWord32 minimumSize);
30
31 WebRtc_UWord32* ptrTmmbrSet;
32 WebRtc_UWord32* ptrPacketOHSet;
33 WebRtc_UWord32* ptrSsrcSet;
34 WebRtc_UWord32 sizeOfSet;
35 WebRtc_UWord32 lengthOfSet;
36};
37
38class TMMBRHelp
39{
40public:
41 TMMBRHelp(const bool audio);
42 virtual ~TMMBRHelp();
43
44 TMMBRSet* BoundingSet(); // used for debuging
45 TMMBRSet* CandidateSet();
46 TMMBRSet* BoundingSetToSend();
47
48 TMMBRSet* VerifyAndAllocateCandidateSet(const WebRtc_UWord32 minimumSize);
49 WebRtc_Word32 FindTMMBRBoundingSet(TMMBRSet*& boundingSet);
50 WebRtc_Word32 SetTMMBRBoundingSetToSend(const TMMBRSet* boundingSetToSend,
51 const WebRtc_UWord32 maxBitrateKbit);
52
53 bool IsOwner(const WebRtc_UWord32 ssrc,
54 const WebRtc_UWord32 length) const;
55
56 WebRtc_Word32 CalcMinMaxBitRate(const WebRtc_UWord32 totalPacketRate,
57 const WebRtc_UWord32 lengthOfBoundingSet,
58 WebRtc_UWord32& minBitrateKbit,
59 WebRtc_UWord32& maxBitrateKbit) const;
60
61protected:
62 TMMBRSet* VerifyAndAllocateBoundingSet(WebRtc_UWord32 minimumSize);
63 WebRtc_Word32 VerifyAndAllocateBoundingSetToSend(WebRtc_UWord32 minimumSize);
64
65 WebRtc_Word32 FindTMMBRBoundingSet(WebRtc_Word32 numCandidates, TMMBRSet& candidateSet);
66
67private:
68 CriticalSectionWrapper& _criticalSection;
69 const bool _audio;
70 TMMBRSet _candidateSet;
71 TMMBRSet _boundingSet;
72 TMMBRSet _boundingSetToSend;
73
74 float* _ptrIntersectionBoundingSet;
75 float* _ptrMaxPRBoundingSet;
76};
77} // namespace webrtc
78
79#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_TMMBR_HELP_H_