Niels Möller | af17595 | 2018-08-13 13:23:08 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018 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 MODULES_RTP_RTCP_SOURCE_CONTRIBUTING_SOURCES_H_ |
| 12 | #define MODULES_RTP_RTCP_SOURCE_CONTRIBUTING_SOURCES_H_ |
| 13 | |
| 14 | #include <stdint.h> |
| 15 | |
| 16 | #include <map> |
| 17 | #include <vector> |
| 18 | |
| 19 | #include "absl/types/optional.h" |
| 20 | #include "api/array_view.h" |
| 21 | #include "api/rtpreceiverinterface.h" |
| 22 | |
| 23 | namespace webrtc { |
| 24 | |
| 25 | class ContributingSources { |
| 26 | public: |
| 27 | ContributingSources(); |
| 28 | ~ContributingSources(); |
| 29 | |
| 30 | // TODO(bugs.webrtc.org/3333): Needs to be extended with audio-level, to |
| 31 | // support RFC6465. |
| 32 | void Update(int64_t now_ms, rtc::ArrayView<const uint32_t> csrcs); |
| 33 | |
| 34 | // Returns contributing sources seen the last 10 s. |
| 35 | std::vector<RtpSource> GetSources(int64_t now_ms) const; |
| 36 | |
| 37 | private: |
| 38 | void DeleteOldEntries(int64_t now_ms); |
| 39 | |
| 40 | // Indexed by csrc. |
| 41 | std::map<uint32_t, int64_t> last_seen_ms_; |
| 42 | absl::optional<int64_t> next_pruning_ms_; |
| 43 | }; |
| 44 | |
| 45 | } // namespace webrtc |
| 46 | |
| 47 | #endif // MODULES_RTP_RTCP_SOURCE_CONTRIBUTING_SOURCES_H_ |