webrtc_m130/modules/rtp_rtcp/source/fec_test_helper.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

126 lines
4.0 KiB
C
Raw Normal View History

/*
* Copyright (c) 2012 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_FEC_TEST_HELPER_H_
#define MODULES_RTP_RTCP_SOURCE_FEC_TEST_HELPER_H_
#include <memory>
#include "modules/rtp_rtcp/source/forward_error_correction.h"
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
#include "rtc_base/random.h"
namespace webrtc {
namespace test {
namespace fec {
struct AugmentedPacket : public ForwardErrorCorrection::Packet {
RTPHeader header;
};
// TODO(brandtr): Consider merging MediaPacketGenerator and
// AugmentedPacketGenerator into a single class, since their functionality is
// similar.
// This class generates media packets corresponding to a single frame.
class MediaPacketGenerator {
public:
MediaPacketGenerator(uint32_t min_packet_size,
uint32_t max_packet_size,
uint32_t ssrc,
Reland "Enable and fix chromium clang warnings in rtp_rtcp test targets" This reverts commit 01aa210fad68f1006528d32d388b307c22990734. Reason for revert: downstream project adjusted Original change's description: > Revert "Enable and fix chromium clang warnings in rtp_rtcp test targets" > > This reverts commit 9486b117daac09c9f7ac8450ccda835938cf3150. > > Reason for revert: Breaks downstream project > > Original change's description: > > Enable and fix chromium clang warnings in rtp_rtcp test targets > > > > Bug: webrtc:163 > > Change-Id: I4ed3e63296d8bf06536a83196d597c7a906ba11c > > Reviewed-on: https://webrtc-review.googlesource.com/60802 > > Reviewed-by: Björn Terelius <terelius@webrtc.org> > > Reviewed-by: Patrik Höglund <phoglund@webrtc.org> > > Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#22357} > > TBR=danilchap@webrtc.org,phoglund@webrtc.org,terelius@webrtc.org > > Change-Id: I2c3777ea9f26813bdb395e7fd68f6b49443586ea > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:163 > Reviewed-on: https://webrtc-review.googlesource.com/61060 > Reviewed-by: Oleh Prypin <oprypin@webrtc.org> > Commit-Queue: Oleh Prypin <oprypin@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22365} TBR=danilchap@webrtc.org,phoglund@webrtc.org,oprypin@webrtc.org,terelius@webrtc.org Change-Id: I0b4cb6d05b37caeb52cca9abf95417ad3ad6f76b No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:163 Reviewed-on: https://webrtc-review.googlesource.com/61080 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22368}
2018-03-09 15:37:03 +00:00
Random* random);
~MediaPacketGenerator();
// Construct the media packets, up to |num_media_packets| packets.
ForwardErrorCorrection::PacketList ConstructMediaPackets(
int num_media_packets,
uint16_t start_seq_num);
ForwardErrorCorrection::PacketList ConstructMediaPackets(
int num_media_packets);
Reland of Only compare sequence numbers from the same SSRC in ForwardErrorCorrection. (patchset #1 id:1 of https://codereview.webrtc.org/2919313005/ ) Reason for revert: Fix RtpStreamReceiver to not recover RTX packets with incorrect SSRC. Original issue's description: > Revert of Only compare sequence numbers from the same SSRC in ForwardErrorCorrection. (patchset #5 id:120001 of https://codereview.webrtc.org/2893293003/ ) > > Reason for revert: > Breaks fuzzer. > > Original issue's description: > > Only compare sequence numbers from the same SSRC in ForwardErrorCorrection. > > > > Prior to this CL, the ForwardErrorCorrection state would be reset whenever > > the difference in sequence numbers of the last recovered media packet > > and the new packet (media or FEC) was too large. This comparison did not > > take into account that FlexFEC uses a different SSRC for the FEC packets, > > meaning that the the state would be reset very frequently when FlexFEC > > is used. This should not have led to any major problems, except for a > > decreased decoding efficiency. > > > > This CL verifies that whenever we compare sequence numbers in > > ForwardErrorCorrection, they do indeed belong to the same SSRC. > > > > BUG=webrtc:5654 > > > > Review-Url: https://codereview.webrtc.org/2893293003 > > Cr-Commit-Position: refs/heads/master@{#18399} > > Committed: https://chromium.googlesource.com/external/webrtc/+/1476a9d789db03457595cf7dbea7e362972f2a4d > > TBR=stefan@webrtc.org,holmer@google.com > # Not skipping CQ checks because original CL landed more than 1 days ago. > BUG=webrtc:5654 > > Review-Url: https://codereview.webrtc.org/2919313005 > Cr-Commit-Position: refs/heads/master@{#18446} > Committed: https://chromium.googlesource.com/external/webrtc/+/92732ecc5ccc81e17c1dea75ecc5e34c7ff6274f R=stefan@webrtc.org BUG=webrtc:5654 Review-Url: https://codereview.webrtc.org/2918333002 Cr-Commit-Position: refs/heads/master@{#18827}
2017-06-29 02:45:35 -07:00
uint16_t GetNextSeqNum();
private:
uint32_t min_packet_size_;
uint32_t max_packet_size_;
uint32_t ssrc_;
Random* random_;
ForwardErrorCorrection::PacketList media_packets_;
Reland of Only compare sequence numbers from the same SSRC in ForwardErrorCorrection. (patchset #1 id:1 of https://codereview.webrtc.org/2919313005/ ) Reason for revert: Fix RtpStreamReceiver to not recover RTX packets with incorrect SSRC. Original issue's description: > Revert of Only compare sequence numbers from the same SSRC in ForwardErrorCorrection. (patchset #5 id:120001 of https://codereview.webrtc.org/2893293003/ ) > > Reason for revert: > Breaks fuzzer. > > Original issue's description: > > Only compare sequence numbers from the same SSRC in ForwardErrorCorrection. > > > > Prior to this CL, the ForwardErrorCorrection state would be reset whenever > > the difference in sequence numbers of the last recovered media packet > > and the new packet (media or FEC) was too large. This comparison did not > > take into account that FlexFEC uses a different SSRC for the FEC packets, > > meaning that the the state would be reset very frequently when FlexFEC > > is used. This should not have led to any major problems, except for a > > decreased decoding efficiency. > > > > This CL verifies that whenever we compare sequence numbers in > > ForwardErrorCorrection, they do indeed belong to the same SSRC. > > > > BUG=webrtc:5654 > > > > Review-Url: https://codereview.webrtc.org/2893293003 > > Cr-Commit-Position: refs/heads/master@{#18399} > > Committed: https://chromium.googlesource.com/external/webrtc/+/1476a9d789db03457595cf7dbea7e362972f2a4d > > TBR=stefan@webrtc.org,holmer@google.com > # Not skipping CQ checks because original CL landed more than 1 days ago. > BUG=webrtc:5654 > > Review-Url: https://codereview.webrtc.org/2919313005 > Cr-Commit-Position: refs/heads/master@{#18446} > Committed: https://chromium.googlesource.com/external/webrtc/+/92732ecc5ccc81e17c1dea75ecc5e34c7ff6274f R=stefan@webrtc.org BUG=webrtc:5654 Review-Url: https://codereview.webrtc.org/2918333002 Cr-Commit-Position: refs/heads/master@{#18827}
2017-06-29 02:45:35 -07:00
uint16_t next_seq_num_;
};
// This class generates media packets with a certain structure of the payload.
class AugmentedPacketGenerator {
public:
explicit AugmentedPacketGenerator(uint32_t ssrc);
// Prepare for generating a new set of packets, corresponding to a frame.
void NewFrame(size_t num_packets);
// Increment and return the newly incremented sequence number.
uint16_t NextPacketSeqNum();
// Return the next packet in the current frame.
std::unique_ptr<AugmentedPacket> NextPacket(size_t offset, size_t length);
protected:
// Given |header|, writes the appropriate RTP header fields in |data|.
static void WriteRtpHeader(const RTPHeader& header, uint8_t* data);
// Number of packets left to generate, in the current frame.
size_t num_packets_;
private:
uint32_t ssrc_;
uint16_t seq_num_;
uint32_t timestamp_;
};
// This class generates media and FlexFEC packets for a single frame.
class FlexfecPacketGenerator : public AugmentedPacketGenerator {
public:
FlexfecPacketGenerator(uint32_t media_ssrc, uint32_t flexfec_ssrc);
// Creates a new AugmentedPacket (with RTP headers) from a
// FlexFEC packet (without RTP headers).
std::unique_ptr<AugmentedPacket> BuildFlexfecPacket(
const ForwardErrorCorrection::Packet& packet);
private:
uint32_t flexfec_ssrc_;
uint16_t flexfec_seq_num_;
uint32_t flexfec_timestamp_;
};
// This class generates media and ULPFEC packets (both encapsulated in RED)
// for a single frame.
class UlpfecPacketGenerator : public AugmentedPacketGenerator {
public:
explicit UlpfecPacketGenerator(uint32_t ssrc);
// Creates a new RtpPacket with the RED header added to the packet.
static RtpPacketReceived BuildMediaRedPacket(const AugmentedPacket& packet,
bool is_recovered);
// Creates a new RtpPacket with FEC payload and RED header. Does this by
// creating a new fake media AugmentedPacket, clears the marker bit and adds a
// RED header. Finally replaces the payload with the content of
// |packet->data|.
RtpPacketReceived BuildUlpfecRedPacket(
const ForwardErrorCorrection::Packet& packet);
};
} // namespace fec
} // namespace test
} // namespace webrtc
#endif // MODULES_RTP_RTCP_SOURCE_FEC_TEST_HELPER_H_