Niels Möller | fa89d84 | 2019-01-30 16:33:45 +0100 | [diff] [blame] | 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 | */ |
Elad Alon | 14d1c9d | 2019-04-08 14:16:17 +0200 | [diff] [blame] | 10 | #ifndef VIDEO_ENCODER_RTCP_FEEDBACK_H_ |
| 11 | #define VIDEO_ENCODER_RTCP_FEEDBACK_H_ |
Niels Möller | fa89d84 | 2019-01-30 16:33:45 +0100 | [diff] [blame] | 12 | |
| 13 | #include <vector> |
| 14 | |
Niels Möller | 65f17ca | 2019-09-12 13:59:36 +0200 | [diff] [blame] | 15 | #include "api/transport/media/media_transport_interface.h" |
Niels Möller | fa89d84 | 2019-01-30 16:33:45 +0100 | [diff] [blame] | 16 | #include "api/video/video_stream_encoder_interface.h" |
Elad Alon | b6ef99b | 2019-04-10 16:37:07 +0200 | [diff] [blame] | 17 | #include "call/rtp_video_sender_interface.h" |
Niels Möller | fa89d84 | 2019-01-30 16:33:45 +0100 | [diff] [blame] | 18 | #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 19 | #include "rtc_base/critical_section.h" |
| 20 | #include "system_wrappers/include/clock.h" |
| 21 | |
| 22 | namespace webrtc { |
| 23 | |
| 24 | class VideoStreamEncoderInterface; |
| 25 | |
Elad Alon | 14d1c9d | 2019-04-08 14:16:17 +0200 | [diff] [blame] | 26 | // This class passes feedback (such as key frame requests or loss notifications) |
| 27 | // from either Mediatransport or the RtpRtcp module. |
Niels Möller | fa89d84 | 2019-01-30 16:33:45 +0100 | [diff] [blame] | 28 | // TODO(bugs.webrtc.org/9719): Should be eliminated when RtpMediaTransport is |
| 29 | // implemented. |
Elad Alon | 14d1c9d | 2019-04-08 14:16:17 +0200 | [diff] [blame] | 30 | class EncoderRtcpFeedback : public RtcpIntraFrameObserver, |
Elad Alon | 0a8562e | 2019-04-09 11:55:13 +0200 | [diff] [blame] | 31 | public RtcpLossNotificationObserver, |
Elad Alon | 14d1c9d | 2019-04-08 14:16:17 +0200 | [diff] [blame] | 32 | public MediaTransportKeyFrameRequestCallback { |
Niels Möller | fa89d84 | 2019-01-30 16:33:45 +0100 | [diff] [blame] | 33 | public: |
Elad Alon | 14d1c9d | 2019-04-08 14:16:17 +0200 | [diff] [blame] | 34 | EncoderRtcpFeedback(Clock* clock, |
| 35 | const std::vector<uint32_t>& ssrcs, |
| 36 | VideoStreamEncoderInterface* encoder); |
Elad Alon | 0a8562e | 2019-04-09 11:55:13 +0200 | [diff] [blame] | 37 | ~EncoderRtcpFeedback() override = default; |
| 38 | |
Elad Alon | b6ef99b | 2019-04-10 16:37:07 +0200 | [diff] [blame] | 39 | void SetRtpVideoSender(const RtpVideoSenderInterface* rtp_video_sender); |
| 40 | |
Niels Möller | fa89d84 | 2019-01-30 16:33:45 +0100 | [diff] [blame] | 41 | void OnReceivedIntraFrameRequest(uint32_t ssrc) override; |
| 42 | |
| 43 | // Implements MediaTransportKeyFrameRequestCallback |
| 44 | void OnKeyFrameRequested(uint64_t channel_id) override; |
| 45 | |
Elad Alon | 0a8562e | 2019-04-09 11:55:13 +0200 | [diff] [blame] | 46 | // 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öller | fa89d84 | 2019-01-30 16:33:45 +0100 | [diff] [blame] | 52 | private: |
| 53 | bool HasSsrc(uint32_t ssrc); |
| 54 | |
| 55 | Clock* const clock_; |
| 56 | const std::vector<uint32_t> ssrcs_; |
Elad Alon | b6ef99b | 2019-04-10 16:37:07 +0200 | [diff] [blame] | 57 | const RtpVideoSenderInterface* rtp_video_sender_; |
Niels Möller | fa89d84 | 2019-01-30 16:33:45 +0100 | [diff] [blame] | 58 | VideoStreamEncoderInterface* const video_stream_encoder_; |
| 59 | |
| 60 | rtc::CriticalSection crit_; |
| 61 | int64_t time_last_intra_request_ms_ RTC_GUARDED_BY(crit_); |
Rasmus Brandt | 3dde450 | 2019-03-21 11:46:17 +0100 | [diff] [blame] | 62 | |
| 63 | const int min_keyframe_send_interval_ms_; |
Niels Möller | fa89d84 | 2019-01-30 16:33:45 +0100 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | } // namespace webrtc |
| 67 | |
Elad Alon | 14d1c9d | 2019-04-08 14:16:17 +0200 | [diff] [blame] | 68 | #endif // VIDEO_ENCODER_RTCP_FEEDBACK_H_ |