mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 13:50:40 +01:00

Bug: None Change-Id: Ia6fd05f284e8304cf56ab9ddf944fb222a4c9573 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/158676 Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Reviewed-by: Philip Eliasson <philipel@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29656}
44 lines
1.5 KiB
C++
44 lines
1.5 KiB
C++
/*
|
|
* Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
#ifndef MODULES_VIDEO_CODING_UNIQUE_TIMESTAMP_COUNTER_H_
|
|
#define MODULES_VIDEO_CODING_UNIQUE_TIMESTAMP_COUNTER_H_
|
|
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <set>
|
|
|
|
namespace webrtc {
|
|
|
|
// Counts number of uniquly seen frames (aka pictures, aka temporal units)
|
|
// identified by their rtp timestamp.
|
|
class UniqueTimestampCounter {
|
|
public:
|
|
UniqueTimestampCounter();
|
|
UniqueTimestampCounter(const UniqueTimestampCounter&) = delete;
|
|
UniqueTimestampCounter& operator=(const UniqueTimestampCounter&) = delete;
|
|
~UniqueTimestampCounter() = default;
|
|
|
|
void Add(uint32_t timestamp);
|
|
// Returns number of different |timestamp| passed to the UniqueCounter.
|
|
int GetUniqueSeen() const { return unique_seen_; }
|
|
|
|
private:
|
|
int unique_seen_ = 0;
|
|
// Stores several last seen unique values for quick search.
|
|
std::set<uint32_t> search_index_;
|
|
// The same unique values in the circular buffer in the insertion order.
|
|
std::unique_ptr<uint32_t[]> latest_;
|
|
// Last inserted value for optimization purpose.
|
|
int64_t last_ = -1;
|
|
};
|
|
|
|
} // namespace webrtc
|
|
|
|
#endif // MODULES_VIDEO_CODING_UNIQUE_TIMESTAMP_COUNTER_H_
|