diff --git a/media/base/media_constants.cc b/media/base/media_constants.cc index 689af3bacd6..319fa3f3f33 100644 --- a/media/base/media_constants.cc +++ b/media/base/media_constants.cc @@ -93,6 +93,7 @@ const char kRtcpFbParamTransportCc[] = "transport-cc"; const char kRtcpFbParamCcm[] = "ccm"; const char kRtcpFbCcmParamFir[] = "fir"; const char kRtcpFbParamRrtr[] = "rrtr"; +const char kRtcpFbNackParamRpsi[] = "rpsi"; const char kCodecParamMaxBitrate[] = "x-google-max-bitrate"; const char kCodecParamMinBitrate[] = "x-google-min-bitrate"; const char kCodecParamStartBitrate[] = "x-google-start-bitrate"; diff --git a/media/base/media_constants.h b/media/base/media_constants.h index ed213128ad3..9e05cd792b7 100644 --- a/media/base/media_constants.h +++ b/media/base/media_constants.h @@ -112,7 +112,10 @@ extern const char kRtcpFbCcmParamFir[]; // Receiver reference time report // https://tools.ietf.org/html/rfc3611 section 4.4 extern const char kRtcpFbParamRrtr[]; -// Google specific parameters +// Reference picture selection indications +// https://tools.ietf.org/html/rfc4585 section 6.3.3 +extern const char kRtcpFbNackParamRpsi[]; + // Google specific parameters extern const char kCodecParamMaxBitrate[]; extern const char kCodecParamMinBitrate[]; extern const char kCodecParamStartBitrate[]; diff --git a/media/engine/webrtc_video_engine.cc b/media/engine/webrtc_video_engine.cc index 64714f608c1..3d378f8daa6 100644 --- a/media/engine/webrtc_video_engine.cc +++ b/media/engine/webrtc_video_engine.cc @@ -101,8 +101,13 @@ void AddDefaultFeedbackParams(VideoCodec* codec, codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamCcm, kRtcpFbCcmParamFir)); codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamNack, kParamValueEmpty)); codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamNack, kRtcpFbNackParamPli)); - if (codec->name == kVp8CodecName && - IsEnabled(trials, "WebRTC-RtcpLossNotification")) { + codec->AddFeedbackParam( + FeedbackParam(kRtcpFbParamNack, kRtcpFbNackParamRpsi)); + if ((codec->name == kVp8CodecName || codec->name == kH264CodecName + || codec->name == kH265CodecName + ) && + (webrtc::field_trial::IsEnabled("WebRTC-RtcpLossNotification") || + (webrtc::field_trial::IsEnabled("OWT-LowLatencyMode")))) { codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamLntf, kParamValueEmpty)); } } diff --git a/modules/rtp_rtcp/BUILD.gn b/modules/rtp_rtcp/BUILD.gn index da1afdd08be..171956f3e75 100644 --- a/modules/rtp_rtcp/BUILD.gn +++ b/modules/rtp_rtcp/BUILD.gn @@ -35,6 +35,7 @@ rtc_library("rtp_rtcp_format") { "source/rtcp_packet/remb.h", "source/rtcp_packet/remote_estimate.h", "source/rtcp_packet/report_block.h", + "source/rtcp_packet/rpsi.h", "source/rtcp_packet/rrtr.h", "source/rtcp_packet/rtpfb.h", "source/rtcp_packet/sdes.h", @@ -74,6 +75,7 @@ rtc_library("rtp_rtcp_format") { "source/rtcp_packet/remb.cc", "source/rtcp_packet/remote_estimate.cc", "source/rtcp_packet/report_block.cc", + "source/rtcp_packet/rpsi.cc", "source/rtcp_packet/rrtr.cc", "source/rtcp_packet/rtpfb.cc", "source/rtcp_packet/sdes.cc", diff --git a/modules/rtp_rtcp/source/rtcp_packet/rpsi.cc b/modules/rtp_rtcp/source/rtcp_packet/rpsi.cc new file mode 100644 index 00000000000..ed5bfff5fbc --- /dev/null +++ b/modules/rtp_rtcp/source/rtcp_packet/rpsi.cc @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "modules/rtp_rtcp/source/rtcp_packet/rpsi.h" + +#include "modules/rtp_rtcp/source/rtcp_packet/common_header.h" +#include "rtc_base/checks.h" +#include "rtc_base/logging.h" + +namespace webrtc { +namespace rtcp { +constexpr uint8_t Rpsi::kFeedbackMessageType; +// RFC 4585: Feedback format. +// +// Common packet format: +// +// 0 1 2 3 +// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// |V=2|P| FMT | PT | length | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | SSRC of packet sender | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | SSRC of media source | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// : Feedback Control Information (FCI) : +// : : + +Rpsi::Rpsi() = default; + +Rpsi::Rpsi(const Rpsi& Rpsi) = default; + +Rpsi::~Rpsi() = default; + +// +// Reference picture selection indication(RPSI) (RFC 4585). +// FCI: no feedback control information. +bool Rpsi::Parse(const CommonHeader& packet) { + RTC_DCHECK_EQ(packet.type(), kPacketType); + RTC_DCHECK_EQ(packet.fmt(), kFeedbackMessageType); + + if (packet.payload_size_bytes() < kCommonFeedbackLength) { + RTC_LOG(LS_WARNING) << "Packet is too small to be a valid Rpsi packet"; + return false; + } + + ParseCommonFeedback(packet.payload()); + return true; +} + +size_t Rpsi::BlockLength() const { + return kHeaderLength + kCommonFeedbackLength; +} + +bool Rpsi::Create(uint8_t* packet, + size_t* index, + size_t max_length, + PacketReadyCallback callback) const { + while (*index + BlockLength() > max_length) { + if (!OnBufferFull(packet, index, callback)) + return false; + } + + CreateHeader(kFeedbackMessageType, kPacketType, HeaderLength(), packet, + index); + CreateCommonFeedback(packet + *index); + *index += kCommonFeedbackLength; + return true; +} + +} // namespace rtcp +} // namespace webrtc diff --git a/modules/rtp_rtcp/source/rtcp_packet/rpsi.h b/modules/rtp_rtcp/source/rtcp_packet/rpsi.h new file mode 100644 index 00000000000..57b144d7663 --- /dev/null +++ b/modules/rtp_rtcp/source/rtcp_packet/rpsi.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ +#ifndef MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_RPSI_H_ +#define MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_RPSI_H_ + +#include "modules/rtp_rtcp/source/rtcp_packet/psfb.h" + +namespace webrtc { +namespace rtcp { +class CommonHeader; +// Reference picture selection indication (RPSI) (RFC 4585). +// Will add detailed format fields after finalizing payload. +class Rpsi : public Psfb { + public: + static constexpr uint8_t kFeedbackMessageType = 1; + + Rpsi(); + Rpsi(const Rpsi& rpsi); + ~Rpsi() override; + + bool Parse(const CommonHeader& packet); + + size_t BlockLength() const override; + + bool Create(uint8_t* packet, + size_t* index, + size_t max_length, + PacketReadyCallback callback) const override; +}; + +} // namespace rtcp +} // namespace webrtc +#endif // MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_RPSI_H_