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 | |
| 11 | #ifndef WEBRTC_MODULES_VIDEO_CODING_TIMESTAMP_MAP_H_ |
| 12 | #define WEBRTC_MODULES_VIDEO_CODING_TIMESTAMP_MAP_H_ |
| 13 | |
pbos | 1968d3f | 2015-09-28 08:52:18 -0700 | [diff] [blame] | 14 | #include "webrtc/base/scoped_ptr.h" |
pbos@webrtc.org | a440732 | 2013-07-16 12:32:05 +0000 | [diff] [blame] | 15 | #include "webrtc/typedefs.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 16 | |
pbos | 1968d3f | 2015-09-28 08:52:18 -0700 | [diff] [blame] | 17 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 18 | |
pbos | 1968d3f | 2015-09-28 08:52:18 -0700 | [diff] [blame] | 19 | struct VCMFrameInformation; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 20 | |
pbos | 1968d3f | 2015-09-28 08:52:18 -0700 | [diff] [blame] | 21 | class VCMTimestampMap { |
| 22 | public: |
| 23 | explicit VCMTimestampMap(size_t capacity); |
| 24 | ~VCMTimestampMap(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 25 | |
pbos | 1968d3f | 2015-09-28 08:52:18 -0700 | [diff] [blame] | 26 | // Empty the map. |
| 27 | void Reset(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 28 | |
pbos | 1968d3f | 2015-09-28 08:52:18 -0700 | [diff] [blame] | 29 | void Add(uint32_t timestamp, VCMFrameInformation* data); |
| 30 | VCMFrameInformation* Pop(uint32_t timestamp); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 31 | |
pbos | 1968d3f | 2015-09-28 08:52:18 -0700 | [diff] [blame] | 32 | private: |
| 33 | struct TimestampDataTuple { |
| 34 | uint32_t timestamp; |
| 35 | VCMFrameInformation* data; |
| 36 | }; |
| 37 | bool IsEmpty() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 38 | |
pbos | 1968d3f | 2015-09-28 08:52:18 -0700 | [diff] [blame] | 39 | 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 43 | }; |
| 44 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 45 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 46 | |
| 47 | #endif // WEBRTC_MODULES_VIDEO_CODING_TIMESTAMP_MAP_H_ |