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 | |
Tommi | 28e9653 | 2021-06-03 09:52:15 | [diff] [blame] | 16 | #include "api/sequence_checker.h" |
| 17 | #include "api/units/time_delta.h" |
| 18 | #include "api/units/timestamp.h" |
Niels Möller | fa89d84 | 2019-01-30 15:33:45 | [diff] [blame] | 19 | #include "api/video/video_stream_encoder_interface.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" |
Niels Möller | fa89d84 | 2019-01-30 15:33:45 | [diff] [blame] | 23 | #include "system_wrappers/include/clock.h" |
| 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( |
| 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 Alon | 0a8562e | 2019-04-09 09:55:13 | [diff] [blame] | 41 | ~EncoderRtcpFeedback() override = default; |
| 42 | |
Niels Möller | fa89d84 | 2019-01-30 15:33:45 | [diff] [blame] | 43 | void OnReceivedIntraFrameRequest(uint32_t ssrc) override; |
| 44 | |
Elad Alon | 0a8562e | 2019-04-09 09:55:13 | [diff] [blame] | 45 | // 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öller | fa89d84 | 2019-01-30 15:33:45 | [diff] [blame] | 51 | private: |
Niels Möller | fa89d84 | 2019-01-30 15:33:45 | [diff] [blame] | 52 | Clock* const clock_; |
| 53 | const std::vector<uint32_t> ssrcs_; |
Tommi | 28e9653 | 2021-06-03 09:52:15 | [diff] [blame] | 54 | 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öller | fa89d84 | 2019-01-30 15:33:45 | [diff] [blame] | 58 | VideoStreamEncoderInterface* const video_stream_encoder_; |
| 59 | |
Tommi | 28e9653 | 2021-06-03 09:52:15 | [diff] [blame] | 60 | RTC_NO_UNIQUE_ADDRESS SequenceChecker packet_delivery_queue_; |
| 61 | Timestamp time_last_packet_delivery_queue_ |
| 62 | RTC_GUARDED_BY(packet_delivery_queue_); |
Rasmus Brandt | 3dde450 | 2019-03-21 10:46:17 | [diff] [blame] | 63 | |
Tommi | 28e9653 | 2021-06-03 09:52:15 | [diff] [blame] | 64 | const TimeDelta min_keyframe_send_interval_; |
Niels Möller | fa89d84 | 2019-01-30 15:33:45 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | } // namespace webrtc |
| 68 | |
Elad Alon | 14d1c9d | 2019-04-08 12:16:17 | [diff] [blame] | 69 | #endif // VIDEO_ENCODER_RTCP_FEEDBACK_H_ |