Rename FecReceiver to UlpfecReceiver.
BUG=webrtc:5654 Review-Url: https://codereview.webrtc.org/2451643002 Cr-Commit-Position: refs/heads/master@{#14846}
This commit is contained in:
parent
6b825df37e
commit
d55c3f68c8
@ -413,7 +413,6 @@ if (rtc_include_tests) {
|
||||
"remote_bitrate_estimator/test/estimators/nada_unittest.cc",
|
||||
"remote_bitrate_estimator/test/metric_recorder_unittest.cc",
|
||||
"rtp_rtcp/source/byte_io_unittest.cc",
|
||||
"rtp_rtcp/source/fec_receiver_unittest.cc",
|
||||
"rtp_rtcp/source/fec_test_helper.cc",
|
||||
"rtp_rtcp/source/fec_test_helper.h",
|
||||
"rtp_rtcp/source/flexfec_header_reader_writer_unittest.cc",
|
||||
@ -466,6 +465,7 @@ if (rtc_include_tests) {
|
||||
"rtp_rtcp/source/rtp_sender_unittest.cc",
|
||||
"rtp_rtcp/source/time_util_unittest.cc",
|
||||
"rtp_rtcp/source/ulpfec_header_reader_writer_unittest.cc",
|
||||
"rtp_rtcp/source/ulpfec_receiver_unittest.cc",
|
||||
"rtp_rtcp/source/vp8_partition_aggregator_unittest.cc",
|
||||
"rtp_rtcp/test/testAPI/test_api.cc",
|
||||
"rtp_rtcp/test/testAPI/test_api.h",
|
||||
|
||||
@ -10,7 +10,6 @@ import("../../build/webrtc.gni")
|
||||
|
||||
rtc_static_library("rtp_rtcp") {
|
||||
sources = [
|
||||
"include/fec_receiver.h",
|
||||
"include/flexfec_receiver.h",
|
||||
"include/receive_statistics.h",
|
||||
"include/remote_ntp_time_estimator.h",
|
||||
@ -19,14 +18,13 @@ rtc_static_library("rtp_rtcp") {
|
||||
"include/rtp_receiver.h",
|
||||
"include/rtp_rtcp.h",
|
||||
"include/rtp_rtcp_defines.h",
|
||||
"include/ulpfec_receiver.h",
|
||||
"mocks/mock_rtp_rtcp.h",
|
||||
"source/byte_io.h",
|
||||
"source/dtmf_queue.cc",
|
||||
"source/dtmf_queue.h",
|
||||
"source/fec_private_tables_bursty.h",
|
||||
"source/fec_private_tables_random.h",
|
||||
"source/fec_receiver_impl.cc",
|
||||
"source/fec_receiver_impl.h",
|
||||
"source/flexfec_header_reader_writer.cc",
|
||||
"source/flexfec_header_reader_writer.h",
|
||||
"source/flexfec_receiver_impl.cc",
|
||||
@ -154,6 +152,8 @@ rtc_static_library("rtp_rtcp") {
|
||||
"source/tmmbr_help.h",
|
||||
"source/ulpfec_header_reader_writer.cc",
|
||||
"source/ulpfec_header_reader_writer.h",
|
||||
"source/ulpfec_receiver_impl.cc",
|
||||
"source/ulpfec_receiver_impl.h",
|
||||
"source/video_codec_information.h",
|
||||
"source/vp8_partition_aggregator.cc",
|
||||
"source/vp8_partition_aggregator.h",
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/base/basictypes.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/fec_receiver.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/ulpfec_receiver.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
@ -8,8 +8,8 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_RTP_RTCP_INCLUDE_FEC_RECEIVER_H_
|
||||
#define WEBRTC_MODULES_RTP_RTCP_INCLUDE_FEC_RECEIVER_H_
|
||||
#ifndef WEBRTC_MODULES_RTP_RTCP_INCLUDE_ULPFEC_RECEIVER_H_
|
||||
#define WEBRTC_MODULES_RTP_RTCP_INCLUDE_ULPFEC_RECEIVER_H_
|
||||
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
@ -18,20 +18,18 @@ namespace webrtc {
|
||||
|
||||
struct FecPacketCounter {
|
||||
FecPacketCounter()
|
||||
: num_packets(0),
|
||||
num_fec_packets(0),
|
||||
num_recovered_packets(0) {}
|
||||
: num_packets(0), num_fec_packets(0), num_recovered_packets(0) {}
|
||||
|
||||
size_t num_packets; // Number of received packets.
|
||||
size_t num_fec_packets; // Number of received FEC packets.
|
||||
size_t num_recovered_packets; // Number of recovered media packets using FEC.
|
||||
};
|
||||
|
||||
class FecReceiver {
|
||||
class UlpfecReceiver {
|
||||
public:
|
||||
static FecReceiver* Create(RtpData* callback);
|
||||
static UlpfecReceiver* Create(RtpData* callback);
|
||||
|
||||
virtual ~FecReceiver() {}
|
||||
virtual ~UlpfecReceiver() {}
|
||||
|
||||
// Takes a RED packet, strips the RED header, and adds the resulting
|
||||
// "virtual" RTP packet(s) into the internal buffer.
|
||||
@ -51,4 +49,4 @@ class FecReceiver {
|
||||
virtual FecPacketCounter GetPacketCounter() const = 0;
|
||||
};
|
||||
} // namespace webrtc
|
||||
#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_FEC_RECEIVER_H_
|
||||
#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_ULPFEC_RECEIVER_H_
|
||||
@ -18,7 +18,6 @@
|
||||
],
|
||||
'sources': [
|
||||
# Common
|
||||
'include/fec_receiver.h',
|
||||
'include/flexfec_receiver.h',
|
||||
'include/receive_statistics.h',
|
||||
'include/remote_ntp_time_estimator.h',
|
||||
@ -27,9 +26,8 @@
|
||||
'include/rtp_receiver.h',
|
||||
'include/rtp_rtcp.h',
|
||||
'include/rtp_rtcp_defines.h',
|
||||
'include/ulpfec_receiver.h',
|
||||
'source/byte_io.h',
|
||||
'source/fec_receiver_impl.cc',
|
||||
'source/fec_receiver_impl.h',
|
||||
'source/flexfec_receiver_impl.cc',
|
||||
'source/flexfec_receiver_impl.h',
|
||||
'source/packet_loss_stats.cc',
|
||||
@ -163,6 +161,8 @@
|
||||
'source/rtp_format_video_generic.h',
|
||||
'source/ulpfec_header_reader_writer.cc',
|
||||
'source/ulpfec_header_reader_writer.h',
|
||||
'source/ulpfec_receiver_impl.cc',
|
||||
'source/ulpfec_receiver_impl.h',
|
||||
'source/vp8_partition_aggregator.cc',
|
||||
'source/vp8_partition_aggregator.h',
|
||||
# Mocks
|
||||
|
||||
@ -131,9 +131,9 @@ bool FlexfecReceiverImpl::AddReceivedPacket(const uint8_t* packet,
|
||||
}
|
||||
|
||||
// Note that the implementation of this member function and the implementation
|
||||
// in FecReceiver::ProcessReceivedFec() are slightly different.
|
||||
// in UlpfecReceiver::ProcessReceivedFec() are slightly different.
|
||||
// This implementation only returns _recovered_ media packets through the
|
||||
// callback, whereas the implementation in FecReceiver returns _all inserted_
|
||||
// callback, whereas the implementation in UlpfecReceiver returns _all inserted_
|
||||
// media packets through the callback. The latter behaviour makes sense
|
||||
// for ULPFEC, since the ULPFEC receiver is owned by the RtpStreamReceiver.
|
||||
// Here, however, the received media pipeline is more decoupled from the
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/rtp_rtcp/source/fec_receiver_impl.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/ulpfec_receiver_impl.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
@ -20,20 +20,20 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
FecReceiver* FecReceiver::Create(RtpData* callback) {
|
||||
return new FecReceiverImpl(callback);
|
||||
UlpfecReceiver* UlpfecReceiver::Create(RtpData* callback) {
|
||||
return new UlpfecReceiverImpl(callback);
|
||||
}
|
||||
|
||||
FecReceiverImpl::FecReceiverImpl(RtpData* callback)
|
||||
UlpfecReceiverImpl::UlpfecReceiverImpl(RtpData* callback)
|
||||
: recovered_packet_callback_(callback),
|
||||
fec_(ForwardErrorCorrection::CreateUlpfec()) {}
|
||||
|
||||
FecReceiverImpl::~FecReceiverImpl() {
|
||||
UlpfecReceiverImpl::~UlpfecReceiverImpl() {
|
||||
received_packets_.clear();
|
||||
fec_->ResetState(&recovered_packets_);
|
||||
}
|
||||
|
||||
FecPacketCounter FecReceiverImpl::GetPacketCounter() const {
|
||||
FecPacketCounter UlpfecReceiverImpl::GetPacketCounter() const {
|
||||
rtc::CritScope cs(&crit_sect_);
|
||||
return packet_counter_;
|
||||
}
|
||||
@ -66,9 +66,11 @@ FecPacketCounter FecReceiverImpl::GetPacketCounter() const {
|
||||
// block length: 10 bits Length in bytes of the corresponding data
|
||||
// block excluding header.
|
||||
|
||||
int32_t FecReceiverImpl::AddReceivedRedPacket(
|
||||
const RTPHeader& header, const uint8_t* incoming_rtp_packet,
|
||||
size_t packet_length, uint8_t ulpfec_payload_type) {
|
||||
int32_t UlpfecReceiverImpl::AddReceivedRedPacket(
|
||||
const RTPHeader& header,
|
||||
const uint8_t* incoming_rtp_packet,
|
||||
size_t packet_length,
|
||||
uint8_t ulpfec_payload_type) {
|
||||
rtc::CritScope cs(&crit_sect_);
|
||||
|
||||
uint8_t red_header_length = 1;
|
||||
@ -100,8 +102,7 @@ int32_t FecReceiverImpl::AddReceivedRedPacket(
|
||||
|
||||
uint16_t timestamp_offset = incoming_rtp_packet[header.headerLength + 1]
|
||||
<< 8;
|
||||
timestamp_offset +=
|
||||
incoming_rtp_packet[header.headerLength + 2];
|
||||
timestamp_offset += incoming_rtp_packet[header.headerLength + 2];
|
||||
timestamp_offset = timestamp_offset >> 2;
|
||||
if (timestamp_offset != 0) {
|
||||
LOG(LS_WARNING) << "Corrupt payload found.";
|
||||
@ -199,7 +200,7 @@ int32_t FecReceiverImpl::AddReceivedRedPacket(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t FecReceiverImpl::ProcessReceivedFec() {
|
||||
int32_t UlpfecReceiverImpl::ProcessReceivedFec() {
|
||||
crit_sect_.Enter();
|
||||
if (!received_packets_.empty()) {
|
||||
// Send received media packet to VCM.
|
||||
@ -8,23 +8,23 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_FEC_RECEIVER_IMPL_H_
|
||||
#define WEBRTC_MODULES_RTP_RTCP_SOURCE_FEC_RECEIVER_IMPL_H_
|
||||
#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_ULPFEC_RECEIVER_IMPL_H_
|
||||
#define WEBRTC_MODULES_RTP_RTCP_SOURCE_ULPFEC_RECEIVER_IMPL_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/fec_receiver.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/ulpfec_receiver.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class FecReceiverImpl : public FecReceiver {
|
||||
class UlpfecReceiverImpl : public UlpfecReceiver {
|
||||
public:
|
||||
explicit FecReceiverImpl(RtpData* callback);
|
||||
virtual ~FecReceiverImpl();
|
||||
explicit UlpfecReceiverImpl(RtpData* callback);
|
||||
virtual ~UlpfecReceiverImpl();
|
||||
|
||||
int32_t AddReceivedRedPacket(const RTPHeader& rtp_header,
|
||||
const uint8_t* incoming_rtp_packet,
|
||||
@ -49,4 +49,4 @@ class FecReceiverImpl : public FecReceiver {
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_FEC_RECEIVER_IMPL_H_
|
||||
#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_ULPFEC_RECEIVER_IMPL_H_
|
||||
@ -13,8 +13,8 @@
|
||||
#include <list>
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/modules/rtp_rtcp/include/fec_receiver.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/ulpfec_receiver.h"
|
||||
#include "webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/byte_io.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/fec_test_helper.h"
|
||||
@ -38,11 +38,11 @@ constexpr int kFecPayloadType = 96;
|
||||
constexpr uint32_t kMediaSsrc = 835424;
|
||||
} // namespace
|
||||
|
||||
class ReceiverFecTest : public ::testing::Test {
|
||||
class UlpfecReceiverTest : public ::testing::Test {
|
||||
protected:
|
||||
ReceiverFecTest()
|
||||
UlpfecReceiverTest()
|
||||
: fec_(ForwardErrorCorrection::CreateUlpfec()),
|
||||
receiver_fec_(FecReceiver::Create(&rtp_data_callback_)),
|
||||
receiver_fec_(UlpfecReceiver::Create(&rtp_data_callback_)),
|
||||
packet_generator_(kMediaSsrc) {}
|
||||
|
||||
// Generates |num_fec_packets| FEC packets, given |media_packets|.
|
||||
@ -77,11 +77,11 @@ class ReceiverFecTest : public ::testing::Test {
|
||||
|
||||
MockRtpData rtp_data_callback_;
|
||||
std::unique_ptr<ForwardErrorCorrection> fec_;
|
||||
std::unique_ptr<FecReceiver> receiver_fec_;
|
||||
std::unique_ptr<UlpfecReceiver> receiver_fec_;
|
||||
UlpfecPacketGenerator packet_generator_;
|
||||
};
|
||||
|
||||
void ReceiverFecTest::EncodeFec(
|
||||
void UlpfecReceiverTest::EncodeFec(
|
||||
const ForwardErrorCorrection::PacketList& media_packets,
|
||||
size_t num_fec_packets,
|
||||
std::list<ForwardErrorCorrection::Packet*>* fec_packets) {
|
||||
@ -98,7 +98,7 @@ void ReceiverFecTest::EncodeFec(
|
||||
ASSERT_EQ(num_fec_packets, fec_packets->size());
|
||||
}
|
||||
|
||||
void ReceiverFecTest::PacketizeFrame(
|
||||
void UlpfecReceiverTest::PacketizeFrame(
|
||||
size_t num_media_packets,
|
||||
size_t frame_offset,
|
||||
std::list<AugmentedPacket*>* augmented_packets,
|
||||
@ -112,7 +112,7 @@ void ReceiverFecTest::PacketizeFrame(
|
||||
}
|
||||
}
|
||||
|
||||
void ReceiverFecTest::BuildAndAddRedMediaPacket(AugmentedPacket* packet) {
|
||||
void UlpfecReceiverTest::BuildAndAddRedMediaPacket(AugmentedPacket* packet) {
|
||||
std::unique_ptr<AugmentedPacket> red_packet(
|
||||
packet_generator_.BuildMediaRedPacket(*packet));
|
||||
EXPECT_EQ(0, receiver_fec_->AddReceivedRedPacket(
|
||||
@ -120,7 +120,7 @@ void ReceiverFecTest::BuildAndAddRedMediaPacket(AugmentedPacket* packet) {
|
||||
red_packet->length, kFecPayloadType));
|
||||
}
|
||||
|
||||
void ReceiverFecTest::BuildAndAddRedFecPacket(Packet* packet) {
|
||||
void UlpfecReceiverTest::BuildAndAddRedFecPacket(Packet* packet) {
|
||||
std::unique_ptr<AugmentedPacket> red_packet(
|
||||
packet_generator_.BuildUlpfecRedPacket(*packet));
|
||||
EXPECT_EQ(0, receiver_fec_->AddReceivedRedPacket(
|
||||
@ -128,7 +128,7 @@ void ReceiverFecTest::BuildAndAddRedFecPacket(Packet* packet) {
|
||||
red_packet->length, kFecPayloadType));
|
||||
}
|
||||
|
||||
void ReceiverFecTest::VerifyReconstructedMediaPacket(
|
||||
void UlpfecReceiverTest::VerifyReconstructedMediaPacket(
|
||||
const AugmentedPacket& packet,
|
||||
size_t times) {
|
||||
// Verify that the content of the reconstructed packet is equal to the
|
||||
@ -140,7 +140,7 @@ void ReceiverFecTest::VerifyReconstructedMediaPacket(
|
||||
.WillRepeatedly(Return(true));
|
||||
}
|
||||
|
||||
void ReceiverFecTest::InjectGarbagePacketLength(size_t fec_garbage_offset) {
|
||||
void UlpfecReceiverTest::InjectGarbagePacketLength(size_t fec_garbage_offset) {
|
||||
EXPECT_CALL(rtp_data_callback_, OnRecoveredPacket(_, _))
|
||||
.WillRepeatedly(Return(true));
|
||||
|
||||
@ -165,22 +165,21 @@ void ReceiverFecTest::InjectGarbagePacketLength(size_t fec_garbage_offset) {
|
||||
EXPECT_EQ(0U, counter.num_recovered_packets);
|
||||
}
|
||||
|
||||
void ReceiverFecTest::SurvivesMaliciousPacket(const uint8_t* data,
|
||||
size_t length,
|
||||
uint8_t ulpfec_payload_type) {
|
||||
webrtc::RTPHeader header;
|
||||
std::unique_ptr<webrtc::RtpHeaderParser> parser(
|
||||
webrtc::RtpHeaderParser::Create());
|
||||
void UlpfecReceiverTest::SurvivesMaliciousPacket(const uint8_t* data,
|
||||
size_t length,
|
||||
uint8_t ulpfec_payload_type) {
|
||||
RTPHeader header;
|
||||
std::unique_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
|
||||
ASSERT_TRUE(parser->Parse(data, length, &header));
|
||||
|
||||
webrtc::NullRtpData null_callback;
|
||||
std::unique_ptr<webrtc::FecReceiver> receiver_fec(
|
||||
webrtc::FecReceiver::Create(&null_callback));
|
||||
NullRtpData null_callback;
|
||||
std::unique_ptr<UlpfecReceiver> receiver_fec(
|
||||
UlpfecReceiver::Create(&null_callback));
|
||||
|
||||
receiver_fec->AddReceivedRedPacket(header, data, length, ulpfec_payload_type);
|
||||
}
|
||||
|
||||
TEST_F(ReceiverFecTest, TwoMediaOneFec) {
|
||||
TEST_F(UlpfecReceiverTest, TwoMediaOneFec) {
|
||||
constexpr size_t kNumFecPackets = 1u;
|
||||
std::list<AugmentedPacket*> augmented_media_packets;
|
||||
ForwardErrorCorrection::PacketList media_packets;
|
||||
@ -206,18 +205,18 @@ TEST_F(ReceiverFecTest, TwoMediaOneFec) {
|
||||
EXPECT_EQ(1u, counter.num_recovered_packets);
|
||||
}
|
||||
|
||||
TEST_F(ReceiverFecTest, InjectGarbageFecHeaderLengthRecovery) {
|
||||
TEST_F(UlpfecReceiverTest, InjectGarbageFecHeaderLengthRecovery) {
|
||||
// Byte offset 8 is the 'length recovery' field of the FEC header.
|
||||
InjectGarbagePacketLength(8);
|
||||
}
|
||||
|
||||
TEST_F(ReceiverFecTest, InjectGarbageFecLevelHeaderProtectionLength) {
|
||||
TEST_F(UlpfecReceiverTest, InjectGarbageFecLevelHeaderProtectionLength) {
|
||||
// Byte offset 10 is the 'protection length' field in the first FEC level
|
||||
// header.
|
||||
InjectGarbagePacketLength(10);
|
||||
}
|
||||
|
||||
TEST_F(ReceiverFecTest, TwoMediaTwoFec) {
|
||||
TEST_F(UlpfecReceiverTest, TwoMediaTwoFec) {
|
||||
const size_t kNumFecPackets = 2;
|
||||
std::list<AugmentedPacket*> augmented_media_packets;
|
||||
ForwardErrorCorrection::PacketList media_packets;
|
||||
@ -239,7 +238,7 @@ TEST_F(ReceiverFecTest, TwoMediaTwoFec) {
|
||||
EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec());
|
||||
}
|
||||
|
||||
TEST_F(ReceiverFecTest, TwoFramesOneFec) {
|
||||
TEST_F(UlpfecReceiverTest, TwoFramesOneFec) {
|
||||
const size_t kNumFecPackets = 1;
|
||||
std::list<AugmentedPacket*> augmented_media_packets;
|
||||
ForwardErrorCorrection::PacketList media_packets;
|
||||
@ -260,7 +259,7 @@ TEST_F(ReceiverFecTest, TwoFramesOneFec) {
|
||||
EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec());
|
||||
}
|
||||
|
||||
TEST_F(ReceiverFecTest, OneCompleteOneUnrecoverableFrame) {
|
||||
TEST_F(UlpfecReceiverTest, OneCompleteOneUnrecoverableFrame) {
|
||||
const size_t kNumFecPackets = 1;
|
||||
std::list<AugmentedPacket*> augmented_media_packets;
|
||||
ForwardErrorCorrection::PacketList media_packets;
|
||||
@ -281,7 +280,7 @@ TEST_F(ReceiverFecTest, OneCompleteOneUnrecoverableFrame) {
|
||||
EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec());
|
||||
}
|
||||
|
||||
TEST_F(ReceiverFecTest, MaxFramesOneFec) {
|
||||
TEST_F(UlpfecReceiverTest, MaxFramesOneFec) {
|
||||
const size_t kNumFecPackets = 1;
|
||||
const size_t kNumMediaPackets = 48;
|
||||
std::list<AugmentedPacket*> augmented_media_packets;
|
||||
@ -306,7 +305,7 @@ TEST_F(ReceiverFecTest, MaxFramesOneFec) {
|
||||
EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec());
|
||||
}
|
||||
|
||||
TEST_F(ReceiverFecTest, TooManyFrames) {
|
||||
TEST_F(UlpfecReceiverTest, TooManyFrames) {
|
||||
const size_t kNumFecPackets = 1;
|
||||
const size_t kNumMediaPackets = 49;
|
||||
std::list<AugmentedPacket*> augmented_media_packets;
|
||||
@ -320,7 +319,7 @@ TEST_F(ReceiverFecTest, TooManyFrames) {
|
||||
false, kFecMaskBursty, &fec_packets));
|
||||
}
|
||||
|
||||
TEST_F(ReceiverFecTest, PacketNotDroppedTooEarly) {
|
||||
TEST_F(UlpfecReceiverTest, PacketNotDroppedTooEarly) {
|
||||
// 1 frame with 2 media packets and one FEC packet. One media packet missing.
|
||||
// Delay the FEC packet.
|
||||
Packet* delayed_fec = nullptr;
|
||||
@ -335,7 +334,8 @@ TEST_F(ReceiverFecTest, PacketNotDroppedTooEarly) {
|
||||
|
||||
BuildAndAddRedMediaPacket(augmented_media_packets_batch1.front());
|
||||
EXPECT_CALL(rtp_data_callback_, OnRecoveredPacket(_, _))
|
||||
.Times(1).WillRepeatedly(Return(true));
|
||||
.Times(1)
|
||||
.WillRepeatedly(Return(true));
|
||||
EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec());
|
||||
delayed_fec = fec_packets.front();
|
||||
|
||||
@ -351,18 +351,20 @@ TEST_F(ReceiverFecTest, PacketNotDroppedTooEarly) {
|
||||
it != augmented_media_packets_batch2.end(); ++it) {
|
||||
BuildAndAddRedMediaPacket(*it);
|
||||
EXPECT_CALL(rtp_data_callback_, OnRecoveredPacket(_, _))
|
||||
.Times(1).WillRepeatedly(Return(true));
|
||||
.Times(1)
|
||||
.WillRepeatedly(Return(true));
|
||||
EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec());
|
||||
}
|
||||
|
||||
// Add the delayed FEC packet. One packet should be reconstructed.
|
||||
BuildAndAddRedFecPacket(delayed_fec);
|
||||
EXPECT_CALL(rtp_data_callback_, OnRecoveredPacket(_, _))
|
||||
.Times(1).WillRepeatedly(Return(true));
|
||||
.Times(1)
|
||||
.WillRepeatedly(Return(true));
|
||||
EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec());
|
||||
}
|
||||
|
||||
TEST_F(ReceiverFecTest, PacketDroppedWhenTooOld) {
|
||||
TEST_F(UlpfecReceiverTest, PacketDroppedWhenTooOld) {
|
||||
// 1 frame with 2 media packets and one FEC packet. One media packet missing.
|
||||
// Delay the FEC packet.
|
||||
Packet* delayed_fec = nullptr;
|
||||
@ -377,7 +379,8 @@ TEST_F(ReceiverFecTest, PacketDroppedWhenTooOld) {
|
||||
|
||||
BuildAndAddRedMediaPacket(augmented_media_packets_batch1.front());
|
||||
EXPECT_CALL(rtp_data_callback_, OnRecoveredPacket(_, _))
|
||||
.Times(1).WillRepeatedly(Return(true));
|
||||
.Times(1)
|
||||
.WillRepeatedly(Return(true));
|
||||
EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec());
|
||||
delayed_fec = fec_packets.front();
|
||||
|
||||
@ -393,19 +396,19 @@ TEST_F(ReceiverFecTest, PacketDroppedWhenTooOld) {
|
||||
it != augmented_media_packets_batch2.end(); ++it) {
|
||||
BuildAndAddRedMediaPacket(*it);
|
||||
EXPECT_CALL(rtp_data_callback_, OnRecoveredPacket(_, _))
|
||||
.Times(1).WillRepeatedly(Return(true));
|
||||
.Times(1)
|
||||
.WillRepeatedly(Return(true));
|
||||
EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec());
|
||||
}
|
||||
|
||||
// Add the delayed FEC packet. No packet should be reconstructed since the
|
||||
// first media packet of that frame has been dropped due to being too old.
|
||||
BuildAndAddRedFecPacket(delayed_fec);
|
||||
EXPECT_CALL(rtp_data_callback_, OnRecoveredPacket(_, _))
|
||||
.Times(0);
|
||||
EXPECT_CALL(rtp_data_callback_, OnRecoveredPacket(_, _)).Times(0);
|
||||
EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec());
|
||||
}
|
||||
|
||||
TEST_F(ReceiverFecTest, OldFecPacketDropped) {
|
||||
TEST_F(UlpfecReceiverTest, OldFecPacketDropped) {
|
||||
// 49 frames with 2 media packets and one FEC packet. All media packets
|
||||
// missing.
|
||||
const size_t kNumMediaPackets = 49 * 2;
|
||||
@ -420,8 +423,7 @@ TEST_F(ReceiverFecTest, OldFecPacketDropped) {
|
||||
for (auto it = fec_packets.begin(); it != fec_packets.end(); ++it) {
|
||||
// Only FEC packets inserted. No packets recoverable at this time.
|
||||
BuildAndAddRedFecPacket(*it);
|
||||
EXPECT_CALL(rtp_data_callback_, OnRecoveredPacket(_, _))
|
||||
.Times(0);
|
||||
EXPECT_CALL(rtp_data_callback_, OnRecoveredPacket(_, _)).Times(0);
|
||||
EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec());
|
||||
}
|
||||
// Move unique_ptr's to media_packets for lifetime management.
|
||||
@ -437,120 +439,34 @@ TEST_F(ReceiverFecTest, OldFecPacketDropped) {
|
||||
// returned.
|
||||
BuildAndAddRedMediaPacket(augmented_media_packets.front());
|
||||
EXPECT_CALL(rtp_data_callback_, OnRecoveredPacket(_, _))
|
||||
.Times(1).WillRepeatedly(Return(true));
|
||||
.Times(1)
|
||||
.WillRepeatedly(Return(true));
|
||||
EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec());
|
||||
}
|
||||
|
||||
TEST_F(ReceiverFecTest, TruncatedPacketWithFBitSet) {
|
||||
const uint8_t kTruncatedPacket[] = {0x80,
|
||||
0x2a,
|
||||
0x68,
|
||||
0x71,
|
||||
0x29,
|
||||
0xa1,
|
||||
0x27,
|
||||
0x3a,
|
||||
0x29,
|
||||
0x12,
|
||||
0x2a,
|
||||
0x98,
|
||||
0xe0,
|
||||
0x29};
|
||||
TEST_F(UlpfecReceiverTest, TruncatedPacketWithFBitSet) {
|
||||
const uint8_t kTruncatedPacket[] = {0x80, 0x2a, 0x68, 0x71, 0x29, 0xa1, 0x27,
|
||||
0x3a, 0x29, 0x12, 0x2a, 0x98, 0xe0, 0x29};
|
||||
|
||||
SurvivesMaliciousPacket(kTruncatedPacket, sizeof(kTruncatedPacket), 100);
|
||||
}
|
||||
|
||||
TEST_F(ReceiverFecTest, TruncatedPacketWithFBitSetEndingAfterFirstRedHeader) {
|
||||
const uint8_t kPacket[] = {0x89,
|
||||
0x27,
|
||||
0x3a,
|
||||
0x83,
|
||||
0x27,
|
||||
0x3a,
|
||||
0x3a,
|
||||
0xf3,
|
||||
0x67,
|
||||
0xbe,
|
||||
0x2a,
|
||||
0xa9,
|
||||
0x27,
|
||||
0x54,
|
||||
0x3a,
|
||||
0x3a,
|
||||
0x2a,
|
||||
0x67,
|
||||
0x3a,
|
||||
0xf3,
|
||||
0x67,
|
||||
0xbe,
|
||||
0x2a,
|
||||
0x27,
|
||||
0xe6,
|
||||
0xf6,
|
||||
0x03,
|
||||
0x3e,
|
||||
0x29,
|
||||
0x27,
|
||||
0x21,
|
||||
0x27,
|
||||
0x2a,
|
||||
0x29,
|
||||
0x21,
|
||||
0x4b,
|
||||
0x29,
|
||||
0x3a,
|
||||
0x28,
|
||||
0x29,
|
||||
0xbf,
|
||||
0x29,
|
||||
0x2a,
|
||||
0x26,
|
||||
0x29,
|
||||
0xae,
|
||||
0x27,
|
||||
0xa6,
|
||||
0xf6,
|
||||
0x00,
|
||||
0x03,
|
||||
0x3e};
|
||||
TEST_F(UlpfecReceiverTest,
|
||||
TruncatedPacketWithFBitSetEndingAfterFirstRedHeader) {
|
||||
const uint8_t kPacket[] = {
|
||||
0x89, 0x27, 0x3a, 0x83, 0x27, 0x3a, 0x3a, 0xf3, 0x67, 0xbe, 0x2a,
|
||||
0xa9, 0x27, 0x54, 0x3a, 0x3a, 0x2a, 0x67, 0x3a, 0xf3, 0x67, 0xbe,
|
||||
0x2a, 0x27, 0xe6, 0xf6, 0x03, 0x3e, 0x29, 0x27, 0x21, 0x27, 0x2a,
|
||||
0x29, 0x21, 0x4b, 0x29, 0x3a, 0x28, 0x29, 0xbf, 0x29, 0x2a, 0x26,
|
||||
0x29, 0xae, 0x27, 0xa6, 0xf6, 0x00, 0x03, 0x3e};
|
||||
SurvivesMaliciousPacket(kPacket, sizeof(kPacket), 100);
|
||||
}
|
||||
|
||||
TEST_F(ReceiverFecTest, TruncatedPacketWithoutDataPastFirstBlock) {
|
||||
const uint8_t kPacket[] = {0x82,
|
||||
0x38,
|
||||
0x92,
|
||||
0x38,
|
||||
0x92,
|
||||
0x38,
|
||||
0xde,
|
||||
0x2a,
|
||||
0x11,
|
||||
0xc8,
|
||||
0xa3,
|
||||
0xc4,
|
||||
0x82,
|
||||
0x38,
|
||||
0x2a,
|
||||
0x21,
|
||||
0x2a,
|
||||
0x28,
|
||||
0x92,
|
||||
0x38,
|
||||
0x92,
|
||||
0x00,
|
||||
0x00,
|
||||
0x0a,
|
||||
0x3a,
|
||||
0xc8,
|
||||
0xa3,
|
||||
0x3a,
|
||||
0x27,
|
||||
0xc4,
|
||||
0x2a,
|
||||
0x21,
|
||||
0x2a,
|
||||
0x28};
|
||||
TEST_F(UlpfecReceiverTest, TruncatedPacketWithoutDataPastFirstBlock) {
|
||||
const uint8_t kPacket[] = {
|
||||
0x82, 0x38, 0x92, 0x38, 0x92, 0x38, 0xde, 0x2a, 0x11, 0xc8, 0xa3, 0xc4,
|
||||
0x82, 0x38, 0x2a, 0x21, 0x2a, 0x28, 0x92, 0x38, 0x92, 0x00, 0x00, 0x0a,
|
||||
0x3a, 0xc8, 0xa3, 0x3a, 0x27, 0xc4, 0x2a, 0x21, 0x2a, 0x28};
|
||||
SurvivesMaliciousPacket(kPacket, sizeof(kPacket), 100);
|
||||
}
|
||||
|
||||
@ -18,12 +18,12 @@
|
||||
#include "webrtc/config.h"
|
||||
#include "webrtc/modules/pacing/packet_router.h"
|
||||
#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/fec_receiver.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/receive_statistics.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/ulpfec_receiver.h"
|
||||
#include "webrtc/modules/video_coding/video_coding_impl.h"
|
||||
#include "webrtc/system_wrappers/include/metrics.h"
|
||||
#include "webrtc/system_wrappers/include/timestamp_extrapolator.h"
|
||||
@ -99,7 +99,7 @@ RtpStreamReceiver::RtpStreamReceiver(
|
||||
this,
|
||||
&rtp_payload_registry_)),
|
||||
rtp_receive_statistics_(ReceiveStatistics::Create(clock_)),
|
||||
fec_receiver_(FecReceiver::Create(this)),
|
||||
ulpfec_receiver_(UlpfecReceiver::Create(this)),
|
||||
receiving_(false),
|
||||
restored_packet_in_use_(false),
|
||||
last_packet_log_ms_(-1),
|
||||
@ -384,11 +384,11 @@ bool RtpStreamReceiver::ParseAndHandleEncapsulatingHeader(
|
||||
// packets.
|
||||
NotifyReceiverOfFecPacket(header);
|
||||
}
|
||||
if (fec_receiver_->AddReceivedRedPacket(
|
||||
header, packet, packet_length, ulpfec_pt) != 0) {
|
||||
if (ulpfec_receiver_->AddReceivedRedPacket(header, packet, packet_length,
|
||||
ulpfec_pt) != 0) {
|
||||
return false;
|
||||
}
|
||||
return fec_receiver_->ProcessReceivedFec() == 0;
|
||||
return ulpfec_receiver_->ProcessReceivedFec() == 0;
|
||||
} else if (rtp_payload_registry_.IsRtx(header)) {
|
||||
if (header.headerLength + header.paddingLength == packet_length) {
|
||||
// This is an empty packet and should be silently dropped before trying to
|
||||
@ -519,7 +519,7 @@ bool RtpStreamReceiver::IsPacketRetransmitted(const RTPHeader& header,
|
||||
}
|
||||
|
||||
void RtpStreamReceiver::UpdateHistograms() {
|
||||
FecPacketCounter counter = fec_receiver_->GetPacketCounter();
|
||||
FecPacketCounter counter = ulpfec_receiver_->GetPacketCounter();
|
||||
if (counter.num_packets > 0) {
|
||||
RTC_HISTOGRAM_PERCENTAGE(
|
||||
"WebRTC.Video.ReceivedFecPacketsInPercent",
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class FecReceiver;
|
||||
class PacedSender;
|
||||
class PacketRouter;
|
||||
class ProcessThread;
|
||||
@ -42,6 +41,7 @@ class RtpHeaderParser;
|
||||
class RTPPayloadRegistry;
|
||||
class RtpReceiver;
|
||||
class Transport;
|
||||
class UlpfecReceiver;
|
||||
class VieRemb;
|
||||
|
||||
namespace vcm {
|
||||
@ -142,7 +142,7 @@ class RtpStreamReceiver : public RtpData, public RtpFeedback,
|
||||
const std::unique_ptr<RtpHeaderParser> rtp_header_parser_;
|
||||
const std::unique_ptr<RtpReceiver> rtp_receiver_;
|
||||
const std::unique_ptr<ReceiveStatistics> rtp_receive_statistics_;
|
||||
std::unique_ptr<FecReceiver> fec_receiver_;
|
||||
std::unique_ptr<UlpfecReceiver> ulpfec_receiver_;
|
||||
|
||||
rtc::CriticalSection receive_cs_;
|
||||
bool receiving_ GUARDED_BY(receive_cs_);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user