2016-05-13 06:01:03 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_VIDEO_CODING_RTP_FRAME_REFERENCE_FINDER_H_
|
|
|
|
|
#define MODULES_VIDEO_CODING_RTP_FRAME_REFERENCE_FINDER_H_
|
2016-05-13 06:01:03 -07:00
|
|
|
|
2016-05-14 19:44:11 -07:00
|
|
|
#include <memory>
|
2016-05-13 06:01:03 -07:00
|
|
|
|
2020-11-27 17:56:37 +01:00
|
|
|
#include "modules/video_coding/frame_object.h"
|
2016-05-13 06:01:03 -07:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
namespace video_coding {
|
2020-11-27 17:56:37 +01:00
|
|
|
namespace internal {
|
|
|
|
|
class RtpFrameReferenceFinderImpl;
|
|
|
|
|
} // namespace internal
|
2016-08-11 15:09:26 +02:00
|
|
|
|
|
|
|
|
// A complete frame is a frame which has received all its packets and all its
|
|
|
|
|
// references are known.
|
|
|
|
|
class OnCompleteFrameCallback {
|
|
|
|
|
public:
|
|
|
|
|
virtual ~OnCompleteFrameCallback() {}
|
2018-02-22 14:35:06 +01:00
|
|
|
virtual void OnCompleteFrame(std::unique_ptr<EncodedFrame> frame) = 0;
|
2016-08-11 15:09:26 +02:00
|
|
|
};
|
2016-05-13 06:01:03 -07:00
|
|
|
|
|
|
|
|
class RtpFrameReferenceFinder {
|
|
|
|
|
public:
|
2020-11-27 17:56:37 +01:00
|
|
|
using ReturnVector = absl::InlinedVector<std::unique_ptr<RtpFrameObject>, 3>;
|
|
|
|
|
|
2016-05-13 06:01:03 -07:00
|
|
|
explicit RtpFrameReferenceFinder(OnCompleteFrameCallback* frame_callback);
|
2019-09-26 11:25:52 +02:00
|
|
|
explicit RtpFrameReferenceFinder(OnCompleteFrameCallback* frame_callback,
|
|
|
|
|
int64_t picture_id_offset);
|
2018-08-28 16:30:18 +02:00
|
|
|
~RtpFrameReferenceFinder();
|
2016-09-09 03:32:44 -07:00
|
|
|
|
|
|
|
|
// Manage this frame until:
|
|
|
|
|
// - We have all information needed to determine its references, after
|
|
|
|
|
// which |frame_callback_| is called with the completed frame, or
|
2017-04-26 08:17:35 -07:00
|
|
|
// - We have too many stashed frames (determined by |kMaxStashedFrames|)
|
2016-09-09 03:32:44 -07:00
|
|
|
// so we drop this frame, or
|
|
|
|
|
// - It gets cleared by ClearTo, which also means we drop it.
|
2016-05-13 06:01:03 -07:00
|
|
|
void ManageFrame(std::unique_ptr<RtpFrameObject> frame);
|
2016-09-09 03:32:44 -07:00
|
|
|
|
|
|
|
|
// Notifies that padding has been received, which the reference finder
|
|
|
|
|
// might need to calculate the references of a frame.
|
2016-07-05 05:04:46 -07:00
|
|
|
void PaddingReceived(uint16_t seq_num);
|
2016-05-13 06:01:03 -07:00
|
|
|
|
2016-09-09 03:32:44 -07:00
|
|
|
// Clear all stashed frames that include packets older than |seq_num|.
|
|
|
|
|
void ClearTo(uint16_t seq_num);
|
|
|
|
|
|
2016-05-13 06:01:03 -07:00
|
|
|
private:
|
2020-11-27 17:56:37 +01:00
|
|
|
void HandOffFrames(ReturnVector frames);
|
2018-07-03 18:09:32 +02:00
|
|
|
|
2020-11-27 17:56:37 +01:00
|
|
|
// How far frames have been cleared out of the buffer by RTP sequence number.
|
|
|
|
|
// A frame will be cleared if it contains a packet with a sequence number
|
|
|
|
|
// older than |cleared_to_seq_num_|.
|
|
|
|
|
int cleared_to_seq_num_ = -1;
|
2019-09-26 11:25:52 +02:00
|
|
|
const int64_t picture_id_offset_;
|
2020-11-27 17:56:37 +01:00
|
|
|
OnCompleteFrameCallback* frame_callback_;
|
|
|
|
|
std::unique_ptr<internal::RtpFrameReferenceFinderImpl> impl_;
|
2016-05-13 06:01:03 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace video_coding
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_VIDEO_CODING_RTP_FRAME_REFERENCE_FINDER_H_
|