1 /* 2 * Copyright (c) 2019 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 MODULES_VIDEO_CODING_UTILITY_DECODED_FRAMES_HISTORY_H_ 12 #define MODULES_VIDEO_CODING_UTILITY_DECODED_FRAMES_HISTORY_H_ 13 14 #include <stdint.h> 15 16 #include <bitset> 17 #include <vector> 18 19 #include "absl/types/optional.h" 20 #include "api/video/encoded_frame.h" 21 22 namespace webrtc { 23 namespace video_coding { 24 25 class DecodedFramesHistory { 26 public: 27 // window_size - how much frames back to the past are actually remembered. 28 explicit DecodedFramesHistory(size_t window_size); 29 ~DecodedFramesHistory(); 30 // Called for each decoded frame. Assumes frame id's are non-decreasing. 31 void InsertDecoded(int64_t frame_id, uint32_t timestamp); 32 // Query if the following (frame_id, spatial_id) pair was inserted before. 33 // Should be at most less by window_size-1 than the last inserted frame id. 34 bool WasDecoded(int64_t frame_id) const; 35 36 void Clear(); 37 38 absl::optional<int64_t> GetLastDecodedFrameId() const; 39 absl::optional<uint32_t> GetLastDecodedFrameTimestamp() const; 40 41 private: 42 int FrameIdToIndex(int64_t frame_id) const; 43 44 std::vector<bool> buffer_; 45 absl::optional<int64_t> last_frame_id_; 46 absl::optional<int64_t> last_decoded_frame_; 47 absl::optional<uint32_t> last_decoded_frame_timestamp_; 48 }; 49 50 } // namespace video_coding 51 } // namespace webrtc 52 #endif // MODULES_VIDEO_CODING_UTILITY_DECODED_FRAMES_HISTORY_H_ 53