Detach LossNotificationController from RtpGenericFrameDescriptor

To allow to use the LossNotificationController with
an updated version of the frame descriptor extension

Bug: webrtc:10342
Change-Id: I5ac44dc5549dfcfc73bf81ad1e8eab8bd5dd136e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166166
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Reviewed-by: Elad Alon <eladalon@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30369}
This commit is contained in:
Danil Chapovalov
2020-01-23 15:17:52 +01:00
committed by Commit Bot
parent 88636c6dac
commit 159c414ff8
6 changed files with 188 additions and 113 deletions

View File

@ -11,39 +11,45 @@
#ifndef MODULES_VIDEO_CODING_LOSS_NOTIFICATION_CONTROLLER_H_
#define MODULES_VIDEO_CODING_LOSS_NOTIFICATION_CONTROLLER_H_
#include <stdint.h>
#include <set>
#include "absl/types/optional.h"
#include "api/array_view.h"
#include "modules/include/module_common_types.h"
#include "modules/rtp_rtcp/source/rtp_generic_frame_descriptor.h"
#include "rtc_base/numerics/sequence_number_util.h"
#include "rtc_base/synchronization/sequence_checker.h"
namespace webrtc {
class LossNotificationController {
public:
struct FrameDetails {
bool is_keyframe;
int64_t frame_id;
rtc::ArrayView<const int64_t> frame_dependencies;
};
LossNotificationController(KeyFrameRequestSender* key_frame_request_sender,
LossNotificationSender* loss_notification_sender);
~LossNotificationController();
// An RTP packet was received from the network.
void OnReceivedPacket(uint16_t sequence_number,
const RtpGenericFrameDescriptor& generic_descriptor);
// |frame| is non-null iff the packet is the first packet in the frame.
void OnReceivedPacket(uint16_t rtp_seq_num, const FrameDetails* frame);
// A frame was assembled from packets previously received.
// (Should be called even if the frame was composed of a single packet.)
void OnAssembledFrame(uint16_t first_seq_num,
uint16_t frame_id,
int64_t frame_id,
bool discardable,
rtc::ArrayView<const uint16_t> frame_dependency_diffs);
rtc::ArrayView<const int64_t> frame_dependencies);
private:
void DiscardOldInformation();
bool AllDependenciesDecodable(
int64_t unwrapped_frame_id,
rtc::ArrayView<const uint16_t> frame_dependency_diffs) const;
rtc::ArrayView<const int64_t> frame_dependencies) const;
// When the loss of a packet or the non-decodability of a frame is detected,
// produces a key frame request or a loss notification.
@ -67,11 +73,8 @@ class LossNotificationController {
LossNotificationSender* const loss_notification_sender_
RTC_GUARDED_BY(sequence_checker_);
SeqNumUnwrapper<uint16_t> frame_id_unwrapper_
RTC_GUARDED_BY(sequence_checker_);
// Tracked to avoid processing repeated frames (buggy/malicious remote).
absl::optional<int64_t> last_received_unwrapped_frame_id_
absl::optional<int64_t> last_received_frame_id_
RTC_GUARDED_BY(sequence_checker_);
// Tracked to avoid processing repeated packets.
@ -97,8 +100,7 @@ class LossNotificationController {
// Track which frames are decodable. Later frames are also decodable if
// all of their dependencies can be found in this container.
// (Naturally, later frames must also be assemblable to be decodable.)
std::set<int64_t> decodable_unwrapped_frame_ids_
RTC_GUARDED_BY(sequence_checker_);
std::set<int64_t> decodable_frame_ids_ RTC_GUARDED_BY(sequence_checker_);
SequenceChecker sequence_checker_;
};