blob: b5dd0288f34d29765778313141e1af6ae76c7b67 [file] [log] [blame]
Niels Möllerfa89d842019-01-30 16:33:45 +01001/*
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 14:16:17 +020010#ifndef VIDEO_ENCODER_RTCP_FEEDBACK_H_
11#define VIDEO_ENCODER_RTCP_FEEDBACK_H_
Niels Möllerfa89d842019-01-30 16:33:45 +010012
13#include <vector>
14
Niels Möllerfa89d842019-01-30 16:33:45 +010015#include "api/video/video_stream_encoder_interface.h"
Elad Alonb6ef99b2019-04-10 16:37:07 +020016#include "call/rtp_video_sender_interface.h"
Niels Möllerfa89d842019-01-30 16:33:45 +010017#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
18#include "rtc_base/critical_section.h"
19#include "system_wrappers/include/clock.h"
20
21namespace webrtc {
22
23class VideoStreamEncoderInterface;
24
Elad Alon14d1c9d2019-04-08 14:16:17 +020025// This class passes feedback (such as key frame requests or loss notifications)
Bjorn A Mellem7a9a0922019-11-26 09:19:40 -080026// from the RtpRtcp module.
Elad Alon14d1c9d2019-04-08 14:16:17 +020027class EncoderRtcpFeedback : public RtcpIntraFrameObserver,
Bjorn A Mellem7a9a0922019-11-26 09:19:40 -080028 public RtcpLossNotificationObserver {
Niels Möllerfa89d842019-01-30 16:33:45 +010029 public:
Elad Alon14d1c9d2019-04-08 14:16:17 +020030 EncoderRtcpFeedback(Clock* clock,
31 const std::vector<uint32_t>& ssrcs,
32 VideoStreamEncoderInterface* encoder);
Elad Alon0a8562e2019-04-09 11:55:13 +020033 ~EncoderRtcpFeedback() override = default;
34
Elad Alonb6ef99b2019-04-10 16:37:07 +020035 void SetRtpVideoSender(const RtpVideoSenderInterface* rtp_video_sender);
36
Niels Möllerfa89d842019-01-30 16:33:45 +010037 void OnReceivedIntraFrameRequest(uint32_t ssrc) override;
38
Elad Alon0a8562e2019-04-09 11:55:13 +020039 // 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
Niels Möllerfa89d842019-01-30 16:33:45 +010045 private:
46 bool HasSsrc(uint32_t ssrc);
47
48 Clock* const clock_;
49 const std::vector<uint32_t> ssrcs_;
Elad Alonb6ef99b2019-04-10 16:37:07 +020050 const RtpVideoSenderInterface* rtp_video_sender_;
Niels Möllerfa89d842019-01-30 16:33:45 +010051 VideoStreamEncoderInterface* const video_stream_encoder_;
52
53 rtc::CriticalSection crit_;
54 int64_t time_last_intra_request_ms_ RTC_GUARDED_BY(crit_);
Rasmus Brandt3dde4502019-03-21 11:46:17 +010055
56 const int min_keyframe_send_interval_ms_;
Niels Möllerfa89d842019-01-30 16:33:45 +010057};
58
59} // namespace webrtc
60
Elad Alon14d1c9d2019-04-08 14:16:17 +020061#endif // VIDEO_ENCODER_RTCP_FEEDBACK_H_