Niels Möller | fa89d84 | 2019-01-30 15:33:45 | [diff] [blame] | 1 | /* |
| 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 Alon | 14d1c9d | 2019-04-08 12:16:17 | [diff] [blame] | 10 | #ifndef VIDEO_ENCODER_RTCP_FEEDBACK_H_ |
| 11 | #define VIDEO_ENCODER_RTCP_FEEDBACK_H_ |
Niels Möller | fa89d84 | 2019-01-30 15:33:45 | [diff] [blame] | 12 | |
Tommi | 28e9653 | 2021-06-03 09:52:15 | [diff] [blame] | 13 | #include <functional> |
Niels Möller | fa89d84 | 2019-01-30 15:33:45 | [diff] [blame] | 14 | #include <vector> |
| 15 | |
Danil Chapovalov | b57178b | 2024-05-02 14:48:16 | [diff] [blame] | 16 | #include "api/environment/environment.h" |
Tommi | 28e9653 | 2021-06-03 09:52:15 | [diff] [blame] | 17 | #include "api/sequence_checker.h" |
| 18 | #include "api/units/time_delta.h" |
| 19 | #include "api/units/timestamp.h" |
Elad Alon | b6ef99b | 2019-04-10 14:37:07 | [diff] [blame] | 20 | #include "call/rtp_video_sender_interface.h" |
Niels Möller | fa89d84 | 2019-01-30 15:33:45 | [diff] [blame] | 21 | #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
Tommi | 28e9653 | 2021-06-03 09:52:15 | [diff] [blame] | 22 | #include "rtc_base/system/no_unique_address.h" |
Jonas Oreland | 6c2dae2 | 2022-09-29 08:28:24 | [diff] [blame] | 23 | #include "video/video_stream_encoder_interface.h" |
Niels Möller | fa89d84 | 2019-01-30 15:33:45 | [diff] [blame] | 24 | |
| 25 | namespace webrtc { |
| 26 | |
| 27 | class VideoStreamEncoderInterface; |
| 28 | |
Elad Alon | 14d1c9d | 2019-04-08 12:16:17 | [diff] [blame] | 29 | // This class passes feedback (such as key frame requests or loss notifications) |
Bjorn A Mellem | 7a9a092 | 2019-11-26 17:19:40 | [diff] [blame] | 30 | // from the RtpRtcp module. |
Elad Alon | 14d1c9d | 2019-04-08 12:16:17 | [diff] [blame] | 31 | class EncoderRtcpFeedback : public RtcpIntraFrameObserver, |
Bjorn A Mellem | 7a9a092 | 2019-11-26 17:19:40 | [diff] [blame] | 32 | public RtcpLossNotificationObserver { |
Niels Möller | fa89d84 | 2019-01-30 15:33:45 | [diff] [blame] | 33 | public: |
Tommi | 28e9653 | 2021-06-03 09:52:15 | [diff] [blame] | 34 | EncoderRtcpFeedback( |
Danil Chapovalov | b57178b | 2024-05-02 14:48:16 | [diff] [blame] | 35 | const Environment& env, |
Philipp Hancke | 7c5f9cf | 2024-02-20 14:28:14 | [diff] [blame] | 36 | bool per_layer_keyframes, |
Tommi | 28e9653 | 2021-06-03 09:52:15 | [diff] [blame] | 37 | const std::vector<uint32_t>& ssrcs, |
| 38 | VideoStreamEncoderInterface* encoder, |
| 39 | std::function<std::vector<RtpSequenceNumberMap::Info>( |
| 40 | uint32_t ssrc, |
| 41 | const std::vector<uint16_t>& seq_nums)> get_packet_infos); |
Elad Alon | 0a8562e | 2019-04-09 09:55:13 | [diff] [blame] | 42 | ~EncoderRtcpFeedback() override = default; |
| 43 | |
Niels Möller | fa89d84 | 2019-01-30 15:33:45 | [diff] [blame] | 44 | void OnReceivedIntraFrameRequest(uint32_t ssrc) override; |
| 45 | |
Elad Alon | 0a8562e | 2019-04-09 09:55:13 | [diff] [blame] | 46 | // Implements RtcpLossNotificationObserver. |
| 47 | void OnReceivedLossNotification(uint32_t ssrc, |
| 48 | uint16_t seq_num_of_last_decodable, |
| 49 | uint16_t seq_num_of_last_received, |
| 50 | bool decodability_flag) override; |
| 51 | |
Niels Möller | fa89d84 | 2019-01-30 15:33:45 | [diff] [blame] | 52 | private: |
Danil Chapovalov | b57178b | 2024-05-02 14:48:16 | [diff] [blame] | 53 | const Environment env_; |
Niels Möller | fa89d84 | 2019-01-30 15:33:45 | [diff] [blame] | 54 | const std::vector<uint32_t> ssrcs_; |
Philipp Hancke | 7c5f9cf | 2024-02-20 14:28:14 | [diff] [blame] | 55 | const bool per_layer_keyframes_; |
Tommi | 28e9653 | 2021-06-03 09:52:15 | [diff] [blame] | 56 | const std::function<std::vector<RtpSequenceNumberMap::Info>( |
| 57 | uint32_t ssrc, |
| 58 | const std::vector<uint16_t>& seq_nums)> |
| 59 | get_packet_infos_; |
Niels Möller | fa89d84 | 2019-01-30 15:33:45 | [diff] [blame] | 60 | VideoStreamEncoderInterface* const video_stream_encoder_; |
| 61 | |
Tommi | 28e9653 | 2021-06-03 09:52:15 | [diff] [blame] | 62 | RTC_NO_UNIQUE_ADDRESS SequenceChecker packet_delivery_queue_; |
Philipp Hancke | 7c5f9cf | 2024-02-20 14:28:14 | [diff] [blame] | 63 | std::vector<Timestamp> time_last_packet_delivery_queue_ |
Tommi | 28e9653 | 2021-06-03 09:52:15 | [diff] [blame] | 64 | RTC_GUARDED_BY(packet_delivery_queue_); |
Rasmus Brandt | 3dde450 | 2019-03-21 10:46:17 | [diff] [blame] | 65 | |
Tommi | 28e9653 | 2021-06-03 09:52:15 | [diff] [blame] | 66 | const TimeDelta min_keyframe_send_interval_; |
Niels Möller | fa89d84 | 2019-01-30 15:33:45 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | } // namespace webrtc |
| 70 | |
Elad Alon | 14d1c9d | 2019-04-08 12:16:17 | [diff] [blame] | 71 | #endif // VIDEO_ENCODER_RTCP_FEEDBACK_H_ |