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