blob: 1a58a671373e9808f816b38f68d817f14852cc66 [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,
30 public MediaTransportKeyFrameRequestCallback {
Niels Möllerfa89d842019-01-30 16:33:45 +010031 public:
Elad Alon14d1c9d2019-04-08 14:16:17 +020032 EncoderRtcpFeedback(Clock* clock,
33 const std::vector<uint32_t>& ssrcs,
34 VideoStreamEncoderInterface* encoder);
Niels Möllerfa89d842019-01-30 16:33:45 +010035 void OnReceivedIntraFrameRequest(uint32_t ssrc) override;
36
37 // Implements MediaTransportKeyFrameRequestCallback
38 void OnKeyFrameRequested(uint64_t channel_id) override;
39
40 private:
41 bool HasSsrc(uint32_t ssrc);
42
43 Clock* const clock_;
44 const std::vector<uint32_t> ssrcs_;
45 VideoStreamEncoderInterface* const video_stream_encoder_;
46
47 rtc::CriticalSection crit_;
48 int64_t time_last_intra_request_ms_ RTC_GUARDED_BY(crit_);
Rasmus Brandt3dde4502019-03-21 11:46:17 +010049
50 const int min_keyframe_send_interval_ms_;
Niels Möllerfa89d842019-01-30 16:33:45 +010051};
52
53} // namespace webrtc
54
Elad Alon14d1c9d2019-04-08 14:16:17 +020055#endif // VIDEO_ENCODER_RTCP_FEEDBACK_H_