blob: 6657787ac219009ae10bf935ced8fac4b08be49a [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
pbos1968d3f2015-09-28 08:52:18 -070016namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000017
pbos1968d3f2015-09-28 08:52:18 -070018struct VCMFrameInformation;
niklase@google.com470e71d2011-07-07 08:21:25 +000019
pbos1968d3f2015-09-28 08:52:18 -070020class VCMTimestampMap {
21 public:
22 explicit VCMTimestampMap(size_t capacity);
23 ~VCMTimestampMap();
niklase@google.com470e71d2011-07-07 08:21:25 +000024
pbos1968d3f2015-09-28 08:52:18 -070025 // Empty the map.
26 void Reset();
niklase@google.com470e71d2011-07-07 08:21:25 +000027
pbos1968d3f2015-09-28 08:52:18 -070028 void Add(uint32_t timestamp, VCMFrameInformation* data);
29 VCMFrameInformation* Pop(uint32_t timestamp);
niklase@google.com470e71d2011-07-07 08:21:25 +000030
pbos1968d3f2015-09-28 08:52:18 -070031 private:
32 struct TimestampDataTuple {
33 uint32_t timestamp;
34 VCMFrameInformation* data;
35 };
36 bool IsEmpty() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000037
kwiberg3f55dea2016-02-29 05:51:59 -080038 std::unique_ptr<TimestampDataTuple[]> ring_buffer_;
pbos1968d3f2015-09-28 08:52:18 -070039 const size_t capacity_;
40 size_t next_add_idx_;
41 size_t next_pop_idx_;
niklase@google.com470e71d2011-07-07 08:21:25 +000042};
43
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000044} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000045
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020046#endif // MODULES_VIDEO_CODING_TIMESTAMP_MAP_H_