blob: 21624dbdaac2f27c9e13a2ca5f41c59c48bb8c25 [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öller65f17ca2019-09-12 13:59:36 +020015#include "api/transport/media/media_transport_interface.h"
Niels Möllerfa89d842019-01-30 16:33:45 +010016#include "api/video/video_stream_encoder_interface.h"
Elad Alonb6ef99b2019-04-10 16:37:07 +020017#include "call/rtp_video_sender_interface.h"
Niels Möllerfa89d842019-01-30 16:33:45 +010018#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
19#include "rtc_base/critical_section.h"
20#include "system_wrappers/include/clock.h"
21
22namespace webrtc {
23
24class VideoStreamEncoderInterface;
25
Elad Alon14d1c9d2019-04-08 14:16:17 +020026// This class passes feedback (such as key frame requests or loss notifications)
27// from either Mediatransport or the RtpRtcp module.
Niels Möllerfa89d842019-01-30 16:33:45 +010028// TODO(bugs.webrtc.org/9719): Should be eliminated when RtpMediaTransport is
29// implemented.
Elad Alon14d1c9d2019-04-08 14:16:17 +020030class EncoderRtcpFeedback : public RtcpIntraFrameObserver,
Elad Alon0a8562e2019-04-09 11:55:13 +020031 public RtcpLossNotificationObserver,
Elad Alon14d1c9d2019-04-08 14:16:17 +020032 public MediaTransportKeyFrameRequestCallback {
Niels Möllerfa89d842019-01-30 16:33:45 +010033 public:
Elad Alon14d1c9d2019-04-08 14:16:17 +020034 EncoderRtcpFeedback(Clock* clock,
35 const std::vector<uint32_t>& ssrcs,
36 VideoStreamEncoderInterface* encoder);
Elad Alon0a8562e2019-04-09 11:55:13 +020037 ~EncoderRtcpFeedback() override = default;
38
Elad Alonb6ef99b2019-04-10 16:37:07 +020039 void SetRtpVideoSender(const RtpVideoSenderInterface* rtp_video_sender);
40
Niels Möllerfa89d842019-01-30 16:33:45 +010041 void OnReceivedIntraFrameRequest(uint32_t ssrc) override;
42
43 // Implements MediaTransportKeyFrameRequestCallback
44 void OnKeyFrameRequested(uint64_t channel_id) override;
45
Elad Alon0a8562e2019-04-09 11:55:13 +020046 // 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öllerfa89d842019-01-30 16:33:45 +010052 private:
53 bool HasSsrc(uint32_t ssrc);
54
55 Clock* const clock_;
56 const std::vector<uint32_t> ssrcs_;
Elad Alonb6ef99b2019-04-10 16:37:07 +020057 const RtpVideoSenderInterface* rtp_video_sender_;
Niels Möllerfa89d842019-01-30 16:33:45 +010058 VideoStreamEncoderInterface* const video_stream_encoder_;
59
60 rtc::CriticalSection crit_;
61 int64_t time_last_intra_request_ms_ RTC_GUARDED_BY(crit_);
Rasmus Brandt3dde4502019-03-21 11:46:17 +010062
63 const int min_keyframe_send_interval_ms_;
Niels Möllerfa89d842019-01-30 16:33:45 +010064};
65
66} // namespace webrtc
67
Elad Alon14d1c9d2019-04-08 14:16:17 +020068#endif // VIDEO_ENCODER_RTCP_FEEDBACK_H_