OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_TMMBR_HELP_H_ | 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_TMMBR_HELP_H_ |
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_TMMBR_HELP_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_TMMBR_HELP_H_ |
13 | 13 |
14 #include <vector> | 14 #include <vector> |
15 | 15 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmb_item.h" |
16 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 16 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
17 #include "webrtc/typedefs.h" | 17 #include "webrtc/typedefs.h" |
18 | 18 |
19 namespace webrtc { | 19 namespace webrtc { |
20 class TMMBRSet | 20 class TMMBRSet : public std::vector<rtcp::TmmbItem> |
21 { | 21 { |
22 public: | 22 public: |
23 TMMBRSet(); | |
24 ~TMMBRSet(); | |
25 | |
26 void VerifyAndAllocateSet(uint32_t minimumSize); | 23 void VerifyAndAllocateSet(uint32_t minimumSize); |
27 void VerifyAndAllocateSetKeepingData(uint32_t minimumSize); | 24 void VerifyAndAllocateSetKeepingData(uint32_t minimumSize); |
28 // Number of valid data items in set. | 25 // Number of valid data items in set. |
29 uint32_t lengthOfSet() const { return _lengthOfSet; } | 26 uint32_t lengthOfSet() const { return size(); } |
30 // Presently allocated max size of set. | 27 // Presently allocated max size of set. |
31 uint32_t sizeOfSet() const { return _sizeOfSet; } | 28 uint32_t sizeOfSet() const { return capacity(); } |
32 void clearSet() { | 29 void clearSet() { clear(); } |
33 _lengthOfSet = 0; | |
34 } | |
35 uint32_t Tmmbr(int i) const { | 30 uint32_t Tmmbr(int i) const { |
36 return _data.at(i).tmmbr; | 31 return (*this)[i].bitrate_bps() / 1000; |
37 } | 32 } |
38 uint32_t PacketOH(int i) const { | 33 uint32_t PacketOH(int i) const { |
39 return _data.at(i).packet_oh; | 34 return (*this)[i].packet_overhead(); |
40 } | 35 } |
41 uint32_t Ssrc(int i) const { | 36 uint32_t Ssrc(int i) const { |
42 return _data.at(i).ssrc; | 37 return (*this)[i].ssrc(); |
43 } | 38 } |
44 void SetEntry(unsigned int i, | 39 void SetEntry(unsigned int i, |
45 uint32_t tmmbrSet, | 40 uint32_t tmmbrSet, |
46 uint32_t packetOHSet, | 41 uint32_t packetOHSet, |
47 uint32_t ssrcSet); | 42 uint32_t ssrcSet); |
48 | 43 |
49 void AddEntry(uint32_t tmmbrSet, | 44 void AddEntry(uint32_t tmmbrSet, |
50 uint32_t packetOHSet, | 45 uint32_t packetOHSet, |
51 uint32_t ssrcSet); | 46 uint32_t ssrcSet); |
52 | 47 |
53 // Remove one entry from table, and move all others down. | 48 // Remove one entry from table, and move all others down. |
54 void RemoveEntry(uint32_t sourceIdx); | 49 void RemoveEntry(uint32_t sourceIdx); |
55 | 50 |
56 void SwapEntries(uint32_t firstIdx, | 51 void SwapEntries(uint32_t firstIdx, |
57 uint32_t secondIdx); | 52 uint32_t secondIdx); |
58 | 53 |
59 // Set entry data to zero, but keep it in table. | 54 // Set entry data to zero, but keep it in table. |
60 void ClearEntry(uint32_t idx); | 55 void ClearEntry(uint32_t idx); |
61 | |
62 private: | |
63 class SetElement { | |
64 public: | |
65 SetElement() : tmmbr(0), packet_oh(0), ssrc(0) {} | |
66 uint32_t tmmbr; | |
67 uint32_t packet_oh; | |
68 uint32_t ssrc; | |
69 }; | |
70 | |
71 std::vector<SetElement> _data; | |
72 // Number of places allocated. | |
73 uint32_t _sizeOfSet; | |
74 // NUmber of places currently in use. | |
75 uint32_t _lengthOfSet; | |
76 }; | 56 }; |
77 | 57 |
78 class TMMBRHelp | 58 class TMMBRHelp |
79 { | 59 { |
80 public: | 60 public: |
81 TMMBRHelp(); | 61 TMMBRHelp(); |
82 virtual ~TMMBRHelp(); | 62 virtual ~TMMBRHelp(); |
83 | 63 |
84 TMMBRSet* BoundingSet(); // used for debuging | 64 TMMBRSet* BoundingSet(); // used for debuging |
85 TMMBRSet* CandidateSet(); | 65 TMMBRSet* CandidateSet(); |
(...skipping 18 matching lines...) Expand all Loading... |
104 TMMBRSet _candidateSet; | 84 TMMBRSet _candidateSet; |
105 TMMBRSet _boundingSet; | 85 TMMBRSet _boundingSet; |
106 TMMBRSet _boundingSetToSend; | 86 TMMBRSet _boundingSetToSend; |
107 | 87 |
108 float* _ptrIntersectionBoundingSet; | 88 float* _ptrIntersectionBoundingSet; |
109 float* _ptrMaxPRBoundingSet; | 89 float* _ptrMaxPRBoundingSet; |
110 }; | 90 }; |
111 } // namespace webrtc | 91 } // namespace webrtc |
112 | 92 |
113 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_TMMBR_HELP_H_ | 93 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_TMMBR_HELP_H_ |
OLD | NEW |