• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <vector>
14 
15 #include "api/video/video_stream_encoder_interface.h"
16 #include "call/rtp_video_sender_interface.h"
17 #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
18 #include "rtc_base/synchronization/mutex.h"
19 #include "system_wrappers/include/clock.h"
20 
21 namespace webrtc {
22 
23 class VideoStreamEncoderInterface;
24 
25 // This class passes feedback (such as key frame requests or loss notifications)
26 // from the RtpRtcp module.
27 class EncoderRtcpFeedback : public RtcpIntraFrameObserver,
28                             public RtcpLossNotificationObserver {
29  public:
30   EncoderRtcpFeedback(Clock* clock,
31                       const std::vector<uint32_t>& ssrcs,
32                       VideoStreamEncoderInterface* encoder);
33   ~EncoderRtcpFeedback() override = default;
34 
35   void SetRtpVideoSender(const RtpVideoSenderInterface* rtp_video_sender);
36 
37   void OnReceivedIntraFrameRequest(uint32_t ssrc) override;
38 
39   // Implements RtcpLossNotificationObserver.
40   void OnReceivedLossNotification(uint32_t ssrc,
41                                   uint16_t seq_num_of_last_decodable,
42                                   uint16_t seq_num_of_last_received,
43                                   bool decodability_flag) override;
44 
45  private:
46   bool HasSsrc(uint32_t ssrc);
47 
48   Clock* const clock_;
49   const std::vector<uint32_t> ssrcs_;
50   const RtpVideoSenderInterface* rtp_video_sender_;
51   VideoStreamEncoderInterface* const video_stream_encoder_;
52 
53   Mutex mutex_;
54   int64_t time_last_intra_request_ms_ RTC_GUARDED_BY(mutex_);
55 
56   const int min_keyframe_send_interval_ms_;
57 };
58 
59 }  // namespace webrtc
60 
61 #endif  // VIDEO_ENCODER_RTCP_FEEDBACK_H_
62