rtp_frame_reference_finder.h (2305B)
1 /* 2 * Copyright (c) 2016 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_RTP_FRAME_REFERENCE_FINDER_H_ 12 #define MODULES_VIDEO_CODING_RTP_FRAME_REFERENCE_FINDER_H_ 13 14 #include <cstdint> 15 #include <memory> 16 17 #include "absl/container/inlined_vector.h" 18 #include "modules/rtp_rtcp/source/frame_object.h" 19 20 namespace webrtc { 21 namespace internal { 22 class RtpFrameReferenceFinderImpl; 23 } // namespace internal 24 25 class RtpFrameReferenceFinder { 26 public: 27 using ReturnVector = absl::InlinedVector<std::unique_ptr<RtpFrameObject>, 3>; 28 29 RtpFrameReferenceFinder(); 30 explicit RtpFrameReferenceFinder(int64_t picture_id_offset); 31 ~RtpFrameReferenceFinder(); 32 33 // The RtpFrameReferenceFinder will hold onto the frame until: 34 // - the required information to determine its references has been received, 35 // in which case it (and possibly other) frames are returned, or 36 // - There are too many stashed frames (determined by `kMaxStashedFrames`), 37 // in which case it gets dropped, or 38 // - It gets cleared by ClearTo, in which case its dropped. 39 // - The frame is old, in which case it also gets dropped. 40 ReturnVector ManageFrame(std::unique_ptr<RtpFrameObject> frame); 41 42 // Notifies that padding has been received, which the reference finder 43 // might need to calculate the references of a frame. 44 ReturnVector PaddingReceived(uint16_t seq_num); 45 46 // Clear all stashed frames that include packets older than `seq_num`. 47 void ClearTo(uint16_t seq_num); 48 49 private: 50 void AddPictureIdOffset(ReturnVector& frames); 51 52 // How far frames have been cleared out of the buffer by RTP sequence number. 53 // A frame will be cleared if it contains a packet with a sequence number 54 // older than `cleared_to_seq_num_`. 55 int cleared_to_seq_num_ = -1; 56 const int64_t picture_id_offset_; 57 std::unique_ptr<internal::RtpFrameReferenceFinderImpl> impl_; 58 }; 59 60 } // namespace webrtc 61 62 #endif // MODULES_VIDEO_CODING_RTP_FRAME_REFERENCE_FINDER_H_