niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
| 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_VIDEO_CODING_TIMESTAMP_MAP_H_ |
| 12 | #define MODULES_VIDEO_CODING_TIMESTAMP_MAP_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
kwiberg | 3f55dea | 2016-02-29 05:51:59 -0800 | [diff] [blame] | 14 | #include <memory> |
| 15 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 16 | #include "typedefs.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 17 | |
pbos | 1968d3f | 2015-09-28 08:52:18 -0700 | [diff] [blame] | 18 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 19 | |
pbos | 1968d3f | 2015-09-28 08:52:18 -0700 | [diff] [blame] | 20 | struct VCMFrameInformation; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 21 | |
pbos | 1968d3f | 2015-09-28 08:52:18 -0700 | [diff] [blame] | 22 | class VCMTimestampMap { |
| 23 | public: |
| 24 | explicit VCMTimestampMap(size_t capacity); |
| 25 | ~VCMTimestampMap(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 26 | |
pbos | 1968d3f | 2015-09-28 08:52:18 -0700 | [diff] [blame] | 27 | // Empty the map. |
| 28 | void Reset(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 29 | |
pbos | 1968d3f | 2015-09-28 08:52:18 -0700 | [diff] [blame] | 30 | void Add(uint32_t timestamp, VCMFrameInformation* data); |
| 31 | VCMFrameInformation* Pop(uint32_t timestamp); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 32 | |
pbos | 1968d3f | 2015-09-28 08:52:18 -0700 | [diff] [blame] | 33 | private: |
| 34 | struct TimestampDataTuple { |
| 35 | uint32_t timestamp; |
| 36 | VCMFrameInformation* data; |
| 37 | }; |
| 38 | bool IsEmpty() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 39 | |
kwiberg | 3f55dea | 2016-02-29 05:51:59 -0800 | [diff] [blame] | 40 | std::unique_ptr<TimestampDataTuple[]> ring_buffer_; |
pbos | 1968d3f | 2015-09-28 08:52:18 -0700 | [diff] [blame] | 41 | const size_t capacity_; |
| 42 | size_t next_add_idx_; |
| 43 | size_t next_pop_idx_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 44 | }; |
| 45 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 46 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 47 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 48 | #endif // MODULES_VIDEO_CODING_TIMESTAMP_MAP_H_ |