blob: 2aadcc34e76743d51b27d87f795ff9fae6ffd34f [file] [log] [blame]
Niels Möllerfa89d842019-01-30 15:33:451/*
2 * Copyright (c) 2012 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 */
Elad Alon14d1c9d2019-04-08 12:16:1710#ifndef VIDEO_ENCODER_RTCP_FEEDBACK_H_
11#define VIDEO_ENCODER_RTCP_FEEDBACK_H_
Niels Möllerfa89d842019-01-30 15:33:4512
Tommi28e96532021-06-03 09:52:1513#include <functional>
Niels Möllerfa89d842019-01-30 15:33:4514#include <vector>
15
Tommi28e96532021-06-03 09:52:1516#include "api/sequence_checker.h"
17#include "api/units/time_delta.h"
18#include "api/units/timestamp.h"
Niels Möllerfa89d842019-01-30 15:33:4519#include "api/video/video_stream_encoder_interface.h"
Elad Alonb6ef99b2019-04-10 14:37:0720#include "call/rtp_video_sender_interface.h"
Niels Möllerfa89d842019-01-30 15:33:4521#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
Tommi28e96532021-06-03 09:52:1522#include "rtc_base/system/no_unique_address.h"
Niels Möllerfa89d842019-01-30 15:33:4523#include "system_wrappers/include/clock.h"
24
25namespace webrtc {
26
27class VideoStreamEncoderInterface;
28
Elad Alon14d1c9d2019-04-08 12:16:1729// This class passes feedback (such as key frame requests or loss notifications)
Bjorn A Mellem7a9a0922019-11-26 17:19:4030// from the RtpRtcp module.
Elad Alon14d1c9d2019-04-08 12:16:1731class EncoderRtcpFeedback : public RtcpIntraFrameObserver,
Bjorn A Mellem7a9a0922019-11-26 17:19:4032 public RtcpLossNotificationObserver {
Niels Möllerfa89d842019-01-30 15:33:4533 public:
Tommi28e96532021-06-03 09:52:1534 EncoderRtcpFeedback(
35 Clock* clock,
36 const std::vector<uint32_t>& ssrcs,
37 VideoStreamEncoderInterface* encoder,
38 std::function<std::vector<RtpSequenceNumberMap::Info>(
39 uint32_t ssrc,
40 const std::vector<uint16_t>& seq_nums)> get_packet_infos);
Elad Alon0a8562e2019-04-09 09:55:1341 ~EncoderRtcpFeedback() override = default;
42
Niels Möllerfa89d842019-01-30 15:33:4543 void OnReceivedIntraFrameRequest(uint32_t ssrc) override;
44
Elad Alon0a8562e2019-04-09 09:55:1345 // Implements RtcpLossNotificationObserver.
46 void OnReceivedLossNotification(uint32_t ssrc,
47 uint16_t seq_num_of_last_decodable,
48 uint16_t seq_num_of_last_received,
49 bool decodability_flag) override;
50
Niels Möllerfa89d842019-01-30 15:33:4551 private:
Niels Möllerfa89d842019-01-30 15:33:4552 Clock* const clock_;
53 const std::vector<uint32_t> ssrcs_;
Tommi28e96532021-06-03 09:52:1554 const std::function<std::vector<RtpSequenceNumberMap::Info>(
55 uint32_t ssrc,
56 const std::vector<uint16_t>& seq_nums)>
57 get_packet_infos_;
Niels Möllerfa89d842019-01-30 15:33:4558 VideoStreamEncoderInterface* const video_stream_encoder_;
59
Tommi28e96532021-06-03 09:52:1560 RTC_NO_UNIQUE_ADDRESS SequenceChecker packet_delivery_queue_;
61 Timestamp time_last_packet_delivery_queue_
62 RTC_GUARDED_BY(packet_delivery_queue_);
Rasmus Brandt3dde4502019-03-21 10:46:1763
Tommi28e96532021-06-03 09:52:1564 const TimeDelta min_keyframe_send_interval_;
Niels Möllerfa89d842019-01-30 15:33:4565};
66
67} // namespace webrtc
68
Elad Alon14d1c9d2019-04-08 12:16:1769#endif // VIDEO_ENCODER_RTCP_FEEDBACK_H_