blob: 86ce55bf3d58907da3c756928a2a34d87510db32 [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
Johannes Kronb6b782d2021-03-03 14:39:44 +010016#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
pbos1968d3f2015-09-28 08:52:18 -070024namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000025
Johannes Kronb6b782d2021-03-03 14:39:44 +010026struct 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.com470e71d2011-07-07 08:21:25 +000037
pbos1968d3f2015-09-28 08:52:18 -070038class VCMTimestampMap {
39 public:
40 explicit VCMTimestampMap(size_t capacity);
41 ~VCMTimestampMap();
niklase@google.com470e71d2011-07-07 08:21:25 +000042
Johannes Kronb6b782d2021-03-03 14:39:44 +010043 void Add(uint32_t timestamp, const VCMFrameInformation& data);
44 absl::optional<VCMFrameInformation> Pop(uint32_t timestamp);
Johannes Kron111e9812020-10-26 13:54:40 +010045 size_t Size() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000046
pbos1968d3f2015-09-28 08:52:18 -070047 private:
48 struct TimestampDataTuple {
49 uint32_t timestamp;
Johannes Kronb6b782d2021-03-03 14:39:44 +010050 VCMFrameInformation data;
pbos1968d3f2015-09-28 08:52:18 -070051 };
52 bool IsEmpty() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000053
kwiberg3f55dea2016-02-29 05:51:59 -080054 std::unique_ptr<TimestampDataTuple[]> ring_buffer_;
pbos1968d3f2015-09-28 08:52:18 -070055 const size_t capacity_;
56 size_t next_add_idx_;
57 size_t next_pop_idx_;
niklase@google.com470e71d2011-07-07 08:21:25 +000058};
59
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000060} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000061
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020062#endif // MODULES_VIDEO_CODING_TIMESTAMP_MAP_H_