| 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 #include "webrtc/base/criticalsection.h" | 15 |
| 16 #include "webrtc/base/basictypes.h" |
| 16 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmb_item.h" | 17 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmb_item.h" |
| 17 #include "webrtc/typedefs.h" | |
| 18 | 18 |
| 19 namespace webrtc { | 19 namespace webrtc { |
| 20 class TMMBRSet : public std::vector<rtcp::TmmbItem> | 20 void FindTMMBRBoundingSet(std::vector<rtcp::TmmbItem>* candidates); |
| 21 { | |
| 22 public: | |
| 23 void VerifyAndAllocateSet(uint32_t minimumSize); | |
| 24 void VerifyAndAllocateSetKeepingData(uint32_t minimumSize); | |
| 25 // Number of valid data items in set. | |
| 26 uint32_t lengthOfSet() const { return size(); } | |
| 27 // Presently allocated max size of set. | |
| 28 uint32_t sizeOfSet() const { return capacity(); } | |
| 29 void clearSet() { clear(); } | |
| 30 uint32_t Tmmbr(int i) const { | |
| 31 return (*this)[i].bitrate_bps() / 1000; | |
| 32 } | |
| 33 uint32_t PacketOH(int i) const { | |
| 34 return (*this)[i].packet_overhead(); | |
| 35 } | |
| 36 uint32_t Ssrc(int i) const { | |
| 37 return (*this)[i].ssrc(); | |
| 38 } | |
| 39 void SetEntry(unsigned int i, | |
| 40 uint32_t tmmbrSet, | |
| 41 uint32_t packetOHSet, | |
| 42 uint32_t ssrcSet); | |
| 43 | |
| 44 void AddEntry(uint32_t tmmbrSet, | |
| 45 uint32_t packetOHSet, | |
| 46 uint32_t ssrcSet); | |
| 47 | |
| 48 // Remove one entry from table, and move all others down. | |
| 49 void RemoveEntry(uint32_t sourceIdx); | |
| 50 | |
| 51 void SwapEntries(uint32_t firstIdx, | |
| 52 uint32_t secondIdx); | |
| 53 | |
| 54 // Set entry data to zero, but keep it in table. | |
| 55 void ClearEntry(uint32_t idx); | |
| 56 }; | |
| 57 | |
| 58 class TMMBRHelp | |
| 59 { | |
| 60 public: | |
| 61 TMMBRHelp(); | |
| 62 virtual ~TMMBRHelp(); | |
| 63 | |
| 64 TMMBRSet* BoundingSet(); // used for debuging | |
| 65 TMMBRSet* CandidateSet(); | |
| 66 | |
| 67 TMMBRSet* VerifyAndAllocateCandidateSet(const uint32_t minimumSize); | |
| 68 int32_t FindTMMBRBoundingSet(TMMBRSet*& boundingSet); | |
| 69 | |
| 70 bool IsOwner(const uint32_t ssrc, const uint32_t length) const; | |
| 71 | |
| 72 bool CalcMinBitRate(uint32_t* minBitrateKbit) const; | |
| 73 | |
| 74 protected: | |
| 75 TMMBRSet* VerifyAndAllocateBoundingSet(uint32_t minimumSize); | |
| 76 int32_t FindTMMBRBoundingSet(int32_t numCandidates, TMMBRSet& candidateSet); | |
| 77 | |
| 78 private: | |
| 79 rtc::CriticalSection _criticalSection; | |
| 80 TMMBRSet _candidateSet; | |
| 81 TMMBRSet _boundingSet; | |
| 82 | |
| 83 float* _ptrIntersectionBoundingSet; | |
| 84 float* _ptrMaxPRBoundingSet; | |
| 85 }; | |
| 86 } // namespace webrtc | 21 } // namespace webrtc |
| 87 | 22 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_TMMBR_HELP_H_ |
| 88 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_TMMBR_HELP_H_ | |
| OLD | NEW |