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 */ 10 #ifndef VIDEO_ENCODER_RTCP_FEEDBACK_H_ 11 #define VIDEO_ENCODER_RTCP_FEEDBACK_H_ 12 13 #include <functional> 14 #include <vector> 15 16 #include "api/sequence_checker.h" 17 #include "api/units/time_delta.h" 18 #include "api/units/timestamp.h" 19 #include "call/rtp_video_sender_interface.h" 20 #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" 21 #include "rtc_base/system/no_unique_address.h" 22 #include "system_wrappers/include/clock.h" 23 #include "video/video_stream_encoder_interface.h" 24 25 namespace webrtc { 26 27 class VideoStreamEncoderInterface; 28 29 // This class passes feedback (such as key frame requests or loss notifications) 30 // from the RtpRtcp module. 31 class EncoderRtcpFeedback : public RtcpIntraFrameObserver, 32 public RtcpLossNotificationObserver { 33 public: 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); 41 ~EncoderRtcpFeedback() override = default; 42 43 void OnReceivedIntraFrameRequest(uint32_t ssrc) override; 44 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 51 private: 52 Clock* const clock_; 53 const std::vector<uint32_t> ssrcs_; 54 const std::function<std::vector<RtpSequenceNumberMap::Info>( 55 uint32_t ssrc, 56 const std::vector<uint16_t>& seq_nums)> 57 get_packet_infos_; 58 VideoStreamEncoderInterface* const video_stream_encoder_; 59 60 RTC_NO_UNIQUE_ADDRESS SequenceChecker packet_delivery_queue_; 61 Timestamp time_last_packet_delivery_queue_ 62 RTC_GUARDED_BY(packet_delivery_queue_); 63 64 const TimeDelta min_keyframe_send_interval_; 65 }; 66 67 } // namespace webrtc 68 69 #endif // VIDEO_ENCODER_RTCP_FEEDBACK_H_ 70