blob: 4fa23352487016db98734cd9ceaa7ddf12c72255 [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
15#include "api/media_transport_interface.h"
16#include "api/video/video_stream_encoder_interface.h"
17#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)
26// from either Mediatransport or the RtpRtcp module.
Niels Möllerfa89d842019-01-30 16:33:45 +010027// TODO(bugs.webrtc.org/9719): Should be eliminated when RtpMediaTransport is
28// implemented.
Elad Alon14d1c9d2019-04-08 14:16:17 +020029class EncoderRtcpFeedback : public RtcpIntraFrameObserver,
Elad Alon0a8562e2019-04-09 11:55:13 +020030 public RtcpLossNotificationObserver,
Elad Alon14d1c9d2019-04-08 14:16:17 +020031 public MediaTransportKeyFrameRequestCallback {
Niels Möllerfa89d842019-01-30 16:33:45 +010032 public:
Elad Alon14d1c9d2019-04-08 14:16:17 +020033 EncoderRtcpFeedback(Clock* clock,
34 const std::vector<uint32_t>& ssrcs,
35 VideoStreamEncoderInterface* encoder);
Elad Alon0a8562e2019-04-09 11:55:13 +020036 ~EncoderRtcpFeedback() override = default;
37
Niels Möllerfa89d842019-01-30 16:33:45 +010038 void OnReceivedIntraFrameRequest(uint32_t ssrc) override;
39
40 // Implements MediaTransportKeyFrameRequestCallback
41 void OnKeyFrameRequested(uint64_t channel_id) override;
42
Elad Alon0a8562e2019-04-09 11:55:13 +020043 // Implements RtcpLossNotificationObserver.
44 void OnReceivedLossNotification(uint32_t ssrc,
45 uint16_t seq_num_of_last_decodable,
46 uint16_t seq_num_of_last_received,
47 bool decodability_flag) override;
48
Niels Möllerfa89d842019-01-30 16:33:45 +010049 private:
50 bool HasSsrc(uint32_t ssrc);
51
52 Clock* const clock_;
53 const std::vector<uint32_t> ssrcs_;
54 VideoStreamEncoderInterface* const video_stream_encoder_;
55
56 rtc::CriticalSection crit_;
57 int64_t time_last_intra_request_ms_ RTC_GUARDED_BY(crit_);
Rasmus Brandt3dde4502019-03-21 11:46:17 +010058
59 const int min_keyframe_send_interval_ms_;
Niels Möllerfa89d842019-01-30 16:33:45 +010060};
61
62} // namespace webrtc
63
Elad Alon14d1c9d2019-04-08 14:16:17 +020064#endif // VIDEO_ENCODER_RTCP_FEEDBACK_H_