Make the RtpHeaderParserImpl available to tests and tools only.
There are a few reasons for making this test only: * The code is only used by tests and utilities. * The pure interface has only a single implementation so an interface isn't really needed. (a followup change could remove it altogether) * The implementation always incorporates locking regardless of how the class gets used. See e.g. previous use in the Packet class. * The implementation is a layer on top of RtpUtility::RtpHeaderParser which is sufficient for most production cases. Change-Id: Ide6d50567cf8ae5127a2eb04cceeb10cf317ec36 Bug: none Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/150658 Commit-Queue: Tommi <tommi@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29010}
This commit is contained in:
@ -14,81 +14,53 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
|
||||
#include "modules/rtp_rtcp/source/rtp_utility.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
Packet::Packet(uint8_t* packet_memory,
|
||||
size_t allocated_bytes,
|
||||
double time_ms,
|
||||
const RtpHeaderParser& parser)
|
||||
: payload_memory_(packet_memory),
|
||||
payload_(NULL),
|
||||
packet_length_bytes_(allocated_bytes),
|
||||
payload_length_bytes_(0),
|
||||
virtual_packet_length_bytes_(allocated_bytes),
|
||||
virtual_payload_length_bytes_(0),
|
||||
time_ms_(time_ms) {
|
||||
valid_header_ = ParseHeader(parser);
|
||||
}
|
||||
using webrtc::RtpUtility::RtpHeaderParser;
|
||||
|
||||
Packet::Packet(uint8_t* packet_memory,
|
||||
size_t allocated_bytes,
|
||||
size_t virtual_packet_length_bytes,
|
||||
double time_ms,
|
||||
const RtpHeaderParser& parser)
|
||||
const RtpUtility::RtpHeaderParser& parser,
|
||||
const RtpHeaderExtensionMap* extension_map /*= nullptr*/)
|
||||
: payload_memory_(packet_memory),
|
||||
payload_(NULL),
|
||||
packet_length_bytes_(allocated_bytes),
|
||||
payload_length_bytes_(0),
|
||||
virtual_packet_length_bytes_(virtual_packet_length_bytes),
|
||||
virtual_payload_length_bytes_(0),
|
||||
time_ms_(time_ms) {
|
||||
valid_header_ = ParseHeader(parser);
|
||||
}
|
||||
time_ms_(time_ms),
|
||||
valid_header_(ParseHeader(parser, extension_map)) {}
|
||||
|
||||
Packet::Packet(const RTPHeader& header,
|
||||
size_t virtual_packet_length_bytes,
|
||||
size_t virtual_payload_length_bytes,
|
||||
double time_ms)
|
||||
: header_(header),
|
||||
payload_memory_(),
|
||||
payload_(NULL),
|
||||
packet_length_bytes_(0),
|
||||
payload_length_bytes_(0),
|
||||
virtual_packet_length_bytes_(virtual_packet_length_bytes),
|
||||
virtual_payload_length_bytes_(virtual_payload_length_bytes),
|
||||
time_ms_(time_ms),
|
||||
valid_header_(true) {}
|
||||
|
||||
Packet::Packet(uint8_t* packet_memory, size_t allocated_bytes, double time_ms)
|
||||
: payload_memory_(packet_memory),
|
||||
payload_(NULL),
|
||||
packet_length_bytes_(allocated_bytes),
|
||||
payload_length_bytes_(0),
|
||||
virtual_packet_length_bytes_(allocated_bytes),
|
||||
virtual_payload_length_bytes_(0),
|
||||
time_ms_(time_ms) {
|
||||
std::unique_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
|
||||
valid_header_ = ParseHeader(*parser);
|
||||
}
|
||||
: Packet(packet_memory,
|
||||
allocated_bytes,
|
||||
allocated_bytes,
|
||||
time_ms,
|
||||
RtpUtility::RtpHeaderParser(packet_memory, allocated_bytes)) {}
|
||||
|
||||
Packet::Packet(uint8_t* packet_memory,
|
||||
size_t allocated_bytes,
|
||||
size_t virtual_packet_length_bytes,
|
||||
double time_ms)
|
||||
: payload_memory_(packet_memory),
|
||||
payload_(NULL),
|
||||
packet_length_bytes_(allocated_bytes),
|
||||
payload_length_bytes_(0),
|
||||
virtual_packet_length_bytes_(virtual_packet_length_bytes),
|
||||
virtual_payload_length_bytes_(0),
|
||||
time_ms_(time_ms) {
|
||||
std::unique_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
|
||||
valid_header_ = ParseHeader(*parser);
|
||||
}
|
||||
: Packet(packet_memory,
|
||||
allocated_bytes,
|
||||
virtual_packet_length_bytes,
|
||||
time_ms,
|
||||
RtpUtility::RtpHeaderParser(packet_memory, allocated_bytes)) {}
|
||||
|
||||
Packet::~Packet() = default;
|
||||
|
||||
@ -139,9 +111,10 @@ void Packet::DeleteRedHeaders(std::list<RTPHeader*>* headers) {
|
||||
}
|
||||
}
|
||||
|
||||
bool Packet::ParseHeader(const RtpHeaderParser& parser) {
|
||||
bool valid_header = parser.Parse(
|
||||
payload_memory_.get(), static_cast<int>(packet_length_bytes_), &header_);
|
||||
bool Packet::ParseHeader(const RtpHeaderParser& parser,
|
||||
const RtpHeaderExtensionMap* extension_map) {
|
||||
bool valid_header = parser.Parse(&header_, extension_map);
|
||||
|
||||
// Special case for dummy packets that have padding marked in the RTP header.
|
||||
// This causes the RTP header parser to report failure, but is fine in this
|
||||
// context.
|
||||
|
Reference in New Issue
Block a user