blob: 3d6f1bca0fb602f3cc8f4755d955b151c33c368c [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
11#ifndef WEBRTC_MODULES_VIDEO_CODING_TIMESTAMP_MAP_H_
12#define WEBRTC_MODULES_VIDEO_CODING_TIMESTAMP_MAP_H_
13
pbos1968d3f2015-09-28 08:52:18 -070014#include "webrtc/base/scoped_ptr.h"
pbos@webrtc.orga4407322013-07-16 12:32:05 +000015#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000016
pbos1968d3f2015-09-28 08:52:18 -070017namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000018
pbos1968d3f2015-09-28 08:52:18 -070019struct VCMFrameInformation;
niklase@google.com470e71d2011-07-07 08:21:25 +000020
pbos1968d3f2015-09-28 08:52:18 -070021class VCMTimestampMap {
22 public:
23 explicit VCMTimestampMap(size_t capacity);
24 ~VCMTimestampMap();
niklase@google.com470e71d2011-07-07 08:21:25 +000025
pbos1968d3f2015-09-28 08:52:18 -070026 // Empty the map.
27 void Reset();
niklase@google.com470e71d2011-07-07 08:21:25 +000028
pbos1968d3f2015-09-28 08:52:18 -070029 void Add(uint32_t timestamp, VCMFrameInformation* data);
30 VCMFrameInformation* Pop(uint32_t timestamp);
niklase@google.com470e71d2011-07-07 08:21:25 +000031
pbos1968d3f2015-09-28 08:52:18 -070032 private:
33 struct TimestampDataTuple {
34 uint32_t timestamp;
35 VCMFrameInformation* data;
36 };
37 bool IsEmpty() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000038
pbos1968d3f2015-09-28 08:52:18 -070039 rtc::scoped_ptr<TimestampDataTuple[]> ring_buffer_;
40 const size_t capacity_;
41 size_t next_add_idx_;
42 size_t next_pop_idx_;
niklase@google.com470e71d2011-07-07 08:21:25 +000043};
44
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000045} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000046
47#endif // WEBRTC_MODULES_VIDEO_CODING_TIMESTAMP_MAP_H_