blob: eca820cdf7cb62a73fdbae3926a844ae93dc8b2d [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
2 * Copyright (c) 2011 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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_VIDEO_CODING_TIMESTAMP_MAP_H_
12#define MODULES_VIDEO_CODING_TIMESTAMP_MAP_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
kwiberg3f55dea2016-02-29 05:51:59 -080014#include <memory>
15
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000017
pbos1968d3f2015-09-28 08:52:18 -070018namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000019
pbos1968d3f2015-09-28 08:52:18 -070020struct VCMFrameInformation;
niklase@google.com470e71d2011-07-07 08:21:25 +000021
pbos1968d3f2015-09-28 08:52:18 -070022class VCMTimestampMap {
23 public:
24 explicit VCMTimestampMap(size_t capacity);
25 ~VCMTimestampMap();
niklase@google.com470e71d2011-07-07 08:21:25 +000026
pbos1968d3f2015-09-28 08:52:18 -070027 // Empty the map.
28 void Reset();
niklase@google.com470e71d2011-07-07 08:21:25 +000029
pbos1968d3f2015-09-28 08:52:18 -070030 void Add(uint32_t timestamp, VCMFrameInformation* data);
31 VCMFrameInformation* Pop(uint32_t timestamp);
niklase@google.com470e71d2011-07-07 08:21:25 +000032
pbos1968d3f2015-09-28 08:52:18 -070033 private:
34 struct TimestampDataTuple {
35 uint32_t timestamp;
36 VCMFrameInformation* data;
37 };
38 bool IsEmpty() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000039
kwiberg3f55dea2016-02-29 05:51:59 -080040 std::unique_ptr<TimestampDataTuple[]> ring_buffer_;
pbos1968d3f2015-09-28 08:52:18 -070041 const size_t capacity_;
42 size_t next_add_idx_;
43 size_t next_pop_idx_;
niklase@google.com470e71d2011-07-07 08:21:25 +000044};
45
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000046} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000047
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020048#endif // MODULES_VIDEO_CODING_TIMESTAMP_MAP_H_