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 | |
Johannes Kron | b6b782d | 2021-03-03 14:39:44 +0100 | [diff] [blame^] | 16 | #include "absl/types/optional.h" |
| 17 | #include "api/rtp_packet_infos.h" |
| 18 | #include "api/units/timestamp.h" |
| 19 | #include "api/video/encoded_image.h" |
| 20 | #include "api/video/video_content_type.h" |
| 21 | #include "api/video/video_rotation.h" |
| 22 | #include "api/video/video_timing.h" |
| 23 | |
pbos | 1968d3f | 2015-09-28 08:52:18 -0700 | [diff] [blame] | 24 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 25 | |
Johannes Kron | b6b782d | 2021-03-03 14:39:44 +0100 | [diff] [blame^] | 26 | struct VCMFrameInformation { |
| 27 | int64_t renderTimeMs; |
| 28 | absl::optional<Timestamp> decodeStart; |
| 29 | void* userData; |
| 30 | VideoRotation rotation; |
| 31 | VideoContentType content_type; |
| 32 | EncodedImage::Timing timing; |
| 33 | int64_t ntp_time_ms; |
| 34 | RtpPacketInfos packet_infos; |
| 35 | // ColorSpace is not stored here, as it might be modified by decoders. |
| 36 | }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 37 | |
pbos | 1968d3f | 2015-09-28 08:52:18 -0700 | [diff] [blame] | 38 | class VCMTimestampMap { |
| 39 | public: |
| 40 | explicit VCMTimestampMap(size_t capacity); |
| 41 | ~VCMTimestampMap(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 42 | |
Johannes Kron | b6b782d | 2021-03-03 14:39:44 +0100 | [diff] [blame^] | 43 | void Add(uint32_t timestamp, const VCMFrameInformation& data); |
| 44 | absl::optional<VCMFrameInformation> Pop(uint32_t timestamp); |
Johannes Kron | 111e981 | 2020-10-26 13:54:40 +0100 | [diff] [blame] | 45 | size_t Size() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 46 | |
pbos | 1968d3f | 2015-09-28 08:52:18 -0700 | [diff] [blame] | 47 | private: |
| 48 | struct TimestampDataTuple { |
| 49 | uint32_t timestamp; |
Johannes Kron | b6b782d | 2021-03-03 14:39:44 +0100 | [diff] [blame^] | 50 | VCMFrameInformation data; |
pbos | 1968d3f | 2015-09-28 08:52:18 -0700 | [diff] [blame] | 51 | }; |
| 52 | bool IsEmpty() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 53 | |
kwiberg | 3f55dea | 2016-02-29 05:51:59 -0800 | [diff] [blame] | 54 | std::unique_ptr<TimestampDataTuple[]> ring_buffer_; |
pbos | 1968d3f | 2015-09-28 08:52:18 -0700 | [diff] [blame] | 55 | const size_t capacity_; |
| 56 | size_t next_add_idx_; |
| 57 | size_t next_pop_idx_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 58 | }; |
| 59 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 60 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 61 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 62 | #endif // MODULES_VIDEO_CODING_TIMESTAMP_MAP_H_ |