[rtcp] Pli::Parse updated not to use RTCPUtility
BUG=webrtc:5260 R=åsapersson Review URL: https://codereview.webrtc.org/1811933002 Cr-Commit-Position: refs/heads/master@{#12104}
This commit is contained in:
@ -12,8 +12,7 @@
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
|
||||
using webrtc::RTCPUtility::RtcpCommonHeader;
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace rtcp {
|
||||
@ -37,16 +36,16 @@ namespace rtcp {
|
||||
//
|
||||
// Picture loss indication (PLI) (RFC 4585).
|
||||
// FCI: no feedback control information.
|
||||
bool Pli::Parse(const RtcpCommonHeader& header, const uint8_t* payload) {
|
||||
RTC_DCHECK(header.packet_type == kPacketType);
|
||||
RTC_DCHECK(header.count_or_format == kFeedbackMessageType);
|
||||
bool Pli::Parse(const CommonHeader& packet) {
|
||||
RTC_DCHECK(packet.type() == kPacketType);
|
||||
RTC_DCHECK(packet.fmt() == kFeedbackMessageType);
|
||||
|
||||
if (header.payload_size_bytes < kCommonFeedbackLength) {
|
||||
if (packet.payload_size_bytes() < kCommonFeedbackLength) {
|
||||
LOG(LS_WARNING) << "Packet is too small to be a valid PLI packet";
|
||||
return false;
|
||||
}
|
||||
|
||||
ParseCommonFeedback(payload);
|
||||
ParseCommonFeedback(packet.payload());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -6,9 +6,7 @@
|
||||
* 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 WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_PLI_H_
|
||||
#define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_PLI_H_
|
||||
|
||||
@ -17,18 +15,16 @@
|
||||
|
||||
namespace webrtc {
|
||||
namespace rtcp {
|
||||
|
||||
class CommonHeader;
|
||||
// Picture loss indication (PLI) (RFC 4585).
|
||||
class Pli : public Psfb {
|
||||
public:
|
||||
static const uint8_t kFeedbackMessageType = 1;
|
||||
|
||||
Pli() {}
|
||||
virtual ~Pli() {}
|
||||
~Pli() override {}
|
||||
|
||||
// Parse assumes header is already parsed and validated.
|
||||
bool Parse(const RTCPUtility::RtcpCommonHeader& header,
|
||||
const uint8_t* payload); // Size of the payload is in the header.
|
||||
bool Parse(const CommonHeader& packet);
|
||||
|
||||
protected:
|
||||
bool Create(uint8_t* packet,
|
||||
|
||||
@ -10,30 +10,28 @@
|
||||
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h"
|
||||
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
|
||||
|
||||
#include "webrtc/test/rtcp_packet_parser.h"
|
||||
|
||||
using testing::ElementsAreArray;
|
||||
using testing::make_tuple;
|
||||
using webrtc::rtcp::Pli;
|
||||
using webrtc::RTCPUtility::RtcpCommonHeader;
|
||||
using webrtc::RTCPUtility::RtcpParseCommonHeader;
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
|
||||
const uint32_t kSenderSsrc = 0x12345678;
|
||||
const uint32_t kRemoteSsrc = 0x23456789;
|
||||
// Manually created Pli packet matching constants above.
|
||||
const uint8_t kPacket[] = {0x81, 206, 0x00, 0x02,
|
||||
0x12, 0x34, 0x56, 0x78,
|
||||
0x23, 0x45, 0x67, 0x89};
|
||||
const size_t kPacketLength = sizeof(kPacket);
|
||||
} // namespace
|
||||
|
||||
TEST(RtcpPacketPliTest, Parse) {
|
||||
RtcpCommonHeader header;
|
||||
EXPECT_TRUE(RtcpParseCommonHeader(kPacket, kPacketLength, &header));
|
||||
Pli mutable_parsed;
|
||||
EXPECT_TRUE(mutable_parsed.Parse(
|
||||
header, kPacket + RtcpCommonHeader::kHeaderSizeBytes));
|
||||
EXPECT_TRUE(test::ParseSinglePacket(kPacket, &mutable_parsed));
|
||||
const Pli& parsed = mutable_parsed; // Read values from constant object.
|
||||
|
||||
EXPECT_EQ(kSenderSsrc, parsed.sender_ssrc());
|
||||
@ -47,19 +45,16 @@ TEST(RtcpPacketPliTest, Create) {
|
||||
|
||||
rtc::Buffer packet = pli.Build();
|
||||
|
||||
ASSERT_EQ(kPacketLength, packet.size());
|
||||
EXPECT_EQ(0, memcmp(kPacket, packet.data(), kPacketLength));
|
||||
EXPECT_THAT(make_tuple(packet.data(), packet.size()),
|
||||
ElementsAreArray(kPacket));
|
||||
}
|
||||
|
||||
TEST(RtcpPacketPliTest, ParseFailsOnTooSmallPacket) {
|
||||
RtcpCommonHeader header;
|
||||
EXPECT_TRUE(RtcpParseCommonHeader(kPacket, kPacketLength, &header));
|
||||
header.payload_size_bytes--;
|
||||
const uint8_t kTooSmallPacket[] = {0x81, 206, 0x00, 0x01,
|
||||
0x12, 0x34, 0x56, 0x78};
|
||||
|
||||
Pli parsed;
|
||||
EXPECT_FALSE(
|
||||
parsed.Parse(header, kPacket + RtcpCommonHeader::kHeaderSizeBytes));
|
||||
EXPECT_FALSE(test::ParseSinglePacket(kTooSmallPacket, &parsed));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace webrtc
|
||||
|
||||
Reference in New Issue
Block a user