Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Set generic frame descriptor extension for HEVC

* Enable more rtcp feedbacks for loss/reference indication
  • Loading branch information
taste1981 authored and jianjunz committed Dec 7, 2022
1 parent 8110732 commit 5dd188c
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 3 deletions.
1 change: 1 addition & 0 deletions media/base/media_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
5 changes: 4 additions & 1 deletion media/base/media_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
9 changes: 7 additions & 2 deletions media/engine/webrtc_video_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down
2 changes: 2 additions & 0 deletions modules/rtp_rtcp/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
79 changes: 79 additions & 0 deletions modules/rtp_rtcp/source/rtcp_packet/rpsi.cc
Original file line number Diff line number Diff line change
@@ -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
40 changes: 40 additions & 0 deletions modules/rtp_rtcp/source/rtcp_packet/rpsi.h
Original file line number Diff line number Diff line change
@@ -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_

0 comments on commit 5dd188c

Please sign in to comment.