Converting picture_id to bitstring pushed from WithPictureId to Create function.
Added Parse and accessor functions. BUG=webrtc:5260 R=åsapersson Review URL: https://codereview.webrtc.org/1550293003 Cr-Commit-Position: refs/heads/master@{#11439}
This commit is contained in:
parent
6b231e0719
commit
44efbece68
@ -10,93 +10,139 @@
|
||||
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rpsi.h"
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/byte_io.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
|
||||
|
||||
using webrtc::RTCPUtility::PT_PSFB;
|
||||
using webrtc::RTCPUtility::RTCPPacketPSFBRPSI;
|
||||
using webrtc::RTCPUtility::RtcpCommonHeader;
|
||||
using webrtc::RtpUtility::Word32Align;
|
||||
|
||||
namespace webrtc {
|
||||
namespace rtcp {
|
||||
namespace {
|
||||
void AssignUWord8(uint8_t* buffer, size_t* offset, uint8_t value) {
|
||||
buffer[(*offset)++] = value;
|
||||
}
|
||||
|
||||
void AssignUWord32(uint8_t* buffer, size_t* offset, uint32_t value) {
|
||||
ByteWriter<uint32_t>::WriteBigEndian(buffer + *offset, value);
|
||||
*offset += 4;
|
||||
}
|
||||
|
||||
// RFC 4585: Feedback format.
|
||||
// Reference picture selection indication (RPSI) (RFC 4585).
|
||||
//
|
||||
// FCI:
|
||||
//
|
||||
// 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
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | PB |0| Payload Type| Native RPSI bit string |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | defined per codec ... | Padding (0) |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
void CreateRpsi(const RTCPPacketPSFBRPSI& rpsi,
|
||||
uint8_t padding_bytes,
|
||||
uint8_t* buffer,
|
||||
size_t* pos) {
|
||||
// Native bit string should be a multiple of 8 bits.
|
||||
assert(rpsi.NumberOfValidBits % 8 == 0);
|
||||
AssignUWord32(buffer, pos, rpsi.SenderSSRC);
|
||||
AssignUWord32(buffer, pos, rpsi.MediaSSRC);
|
||||
AssignUWord8(buffer, pos, padding_bytes * 8);
|
||||
AssignUWord8(buffer, pos, rpsi.PayloadType);
|
||||
memcpy(buffer + *pos, rpsi.NativeBitString, rpsi.NumberOfValidBits / 8);
|
||||
*pos += rpsi.NumberOfValidBits / 8;
|
||||
memset(buffer + *pos, 0, padding_bytes);
|
||||
*pos += padding_bytes;
|
||||
// 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| RPSI=3 | PT=PSFB=206 | length |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// 0 | SSRC of packet sender |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// 4 | SSRC of media source |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// 8 | Padding Bits |
|
||||
// 9 |0| Payload Type|
|
||||
// 10 | Native RPSI bit string :
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// : defined per codec ... | Padding (0) |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
namespace {
|
||||
const size_t kPaddingSizeOffset = 8;
|
||||
const size_t kPayloadTypeOffset = 9;
|
||||
const size_t kBitStringOffset = 10;
|
||||
|
||||
const size_t kPidBits = 7;
|
||||
// Calculates number of bytes required to store given picture id.
|
||||
uint8_t RequiredBytes(uint64_t picture_id) {
|
||||
uint8_t required_bytes = 0;
|
||||
uint64_t shifted_pid = picture_id;
|
||||
do {
|
||||
++required_bytes;
|
||||
shifted_pid >>= kPidBits;
|
||||
} while (shifted_pid > 0);
|
||||
|
||||
return required_bytes;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Rpsi::Rpsi()
|
||||
: payload_type_(0),
|
||||
picture_id_(0),
|
||||
block_length_(CalculateBlockLength(1)) {}
|
||||
|
||||
bool Rpsi::Parse(const RTCPUtility::RtcpCommonHeader& header,
|
||||
const uint8_t* payload) {
|
||||
RTC_CHECK(header.packet_type == kPacketType);
|
||||
RTC_CHECK(header.count_or_format == kFeedbackMessageType);
|
||||
|
||||
if (header.payload_size_bytes < kCommonFeedbackLength + 4) {
|
||||
LOG(LS_WARNING) << "Packet is too small to be a valid RPSI packet.";
|
||||
return false;
|
||||
}
|
||||
|
||||
ParseCommonFeedback(payload);
|
||||
|
||||
uint8_t padding_bits = payload[kPaddingSizeOffset];
|
||||
if (padding_bits % 8 != 0) {
|
||||
LOG(LS_WARNING) << "Unknown rpsi packet with fractional number of bytes.";
|
||||
return false;
|
||||
}
|
||||
size_t padding_bytes = padding_bits / 8;
|
||||
if (padding_bytes + kBitStringOffset >= header.payload_size_bytes) {
|
||||
LOG(LS_WARNING) << "Too many padding bytes in a RPSI packet.";
|
||||
return false;
|
||||
}
|
||||
size_t padding_offset = header.payload_size_bytes - padding_bytes;
|
||||
payload_type_ = payload[kPayloadTypeOffset] & 0x7f;
|
||||
picture_id_ = 0;
|
||||
for (size_t pos = kBitStringOffset; pos < padding_offset; ++pos) {
|
||||
picture_id_ <<= kPidBits;
|
||||
picture_id_ |= (payload[pos] & 0x7f);
|
||||
}
|
||||
// Required bytes might become less than came in the packet.
|
||||
block_length_ = CalculateBlockLength(RequiredBytes(picture_id_));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Rpsi::Create(uint8_t* packet,
|
||||
size_t* index,
|
||||
size_t max_length,
|
||||
RtcpPacket::PacketReadyCallback* callback) const {
|
||||
assert(rpsi_.NumberOfValidBits > 0);
|
||||
while (*index + BlockLength() > max_length) {
|
||||
if (!OnBufferFull(packet, index, callback))
|
||||
return false;
|
||||
}
|
||||
const uint8_t kFmt = 3;
|
||||
CreateHeader(kFmt, PT_PSFB, HeaderLength(), packet, index);
|
||||
CreateRpsi(rpsi_, padding_bytes_, packet, index);
|
||||
size_t index_end = *index + BlockLength();
|
||||
|
||||
CreateHeader(kFeedbackMessageType, kPacketType, HeaderLength(), packet,
|
||||
index);
|
||||
CreateCommonFeedback(packet + *index);
|
||||
*index += kCommonFeedbackLength;
|
||||
|
||||
size_t bitstring_size_bytes = RequiredBytes(picture_id_);
|
||||
size_t padding_bytes =
|
||||
Word32Align(2 + bitstring_size_bytes) - (2 + bitstring_size_bytes);
|
||||
packet[(*index)++] = padding_bytes * 8;
|
||||
packet[(*index)++] = payload_type_;
|
||||
|
||||
// Convert picture id to native bit string (defined by the video codec).
|
||||
for (size_t i = bitstring_size_bytes - 1; i > 0; --i) {
|
||||
packet[(*index)++] =
|
||||
0x80 | static_cast<uint8_t>(picture_id_ >> (i * kPidBits));
|
||||
}
|
||||
packet[(*index)++] = static_cast<uint8_t>(picture_id_ & 0x7f);
|
||||
const uint8_t kPadding = 0;
|
||||
for (size_t i = 0; i < padding_bytes; ++i)
|
||||
packet[(*index)++] = kPadding;
|
||||
RTC_CHECK_EQ(*index, index_end);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Rpsi::WithPictureId(uint64_t picture_id) {
|
||||
const uint32_t kPidBits = 7;
|
||||
const uint64_t k7MsbZeroMask = 0x1ffffffffffffffULL;
|
||||
uint8_t required_bytes = 0;
|
||||
uint64_t shifted_pid = picture_id;
|
||||
do {
|
||||
++required_bytes;
|
||||
shifted_pid = (shifted_pid >> kPidBits) & k7MsbZeroMask;
|
||||
} while (shifted_pid > 0);
|
||||
|
||||
// Convert picture id to native bit string (natively defined by the video
|
||||
// codec).
|
||||
int pos = 0;
|
||||
for (int i = required_bytes - 1; i > 0; i--) {
|
||||
rpsi_.NativeBitString[pos++] =
|
||||
0x80 | static_cast<uint8_t>(picture_id >> (i * kPidBits));
|
||||
}
|
||||
rpsi_.NativeBitString[pos++] = static_cast<uint8_t>(picture_id & 0x7f);
|
||||
rpsi_.NumberOfValidBits = pos * 8;
|
||||
|
||||
// Calculate padding bytes (to reach next 32-bit boundary, 1, 2 or 3 bytes).
|
||||
padding_bytes_ = 4 - ((2 + required_bytes) % 4);
|
||||
if (padding_bytes_ == 4) {
|
||||
padding_bytes_ = 0;
|
||||
}
|
||||
void Rpsi::WithPayloadType(uint8_t payload) {
|
||||
RTC_DCHECK_LE(payload, 0x7f);
|
||||
payload_type_ = payload;
|
||||
}
|
||||
|
||||
void Rpsi::WithPictureId(uint64_t picture_id) {
|
||||
picture_id_ = picture_id;
|
||||
block_length_ = CalculateBlockLength(RequiredBytes(picture_id_));
|
||||
}
|
||||
|
||||
size_t Rpsi::CalculateBlockLength(uint8_t bitstring_size_bytes) {
|
||||
return RtcpPacket::kHeaderLength + Psfb::kCommonFeedbackLength +
|
||||
Word32Align(2 + bitstring_size_bytes);
|
||||
}
|
||||
} // namespace rtcp
|
||||
} // namespace webrtc
|
||||
|
||||
@ -12,34 +12,29 @@
|
||||
#define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_RPSI_H_
|
||||
|
||||
#include "webrtc/base/basictypes.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/psfb.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace rtcp {
|
||||
// Reference picture selection indication (RPSI) (RFC 4585).
|
||||
class Rpsi : public RtcpPacket {
|
||||
// Assumes native bit string stores PictureId (VP8, VP9).
|
||||
class Rpsi : public Psfb {
|
||||
public:
|
||||
Rpsi()
|
||||
: RtcpPacket(),
|
||||
padding_bytes_(0) {
|
||||
memset(&rpsi_, 0, sizeof(rpsi_));
|
||||
}
|
||||
static const uint8_t kFeedbackMessageType = 3;
|
||||
Rpsi();
|
||||
~Rpsi() override {}
|
||||
|
||||
virtual ~Rpsi() {}
|
||||
// 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.
|
||||
|
||||
void From(uint32_t ssrc) {
|
||||
rpsi_.SenderSSRC = ssrc;
|
||||
}
|
||||
void To(uint32_t ssrc) {
|
||||
rpsi_.MediaSSRC = ssrc;
|
||||
}
|
||||
void WithPayloadType(uint8_t payload) {
|
||||
assert(payload <= 0x7f);
|
||||
rpsi_.PayloadType = payload;
|
||||
}
|
||||
void WithPayloadType(uint8_t payload);
|
||||
void WithPictureId(uint64_t picture_id);
|
||||
|
||||
uint8_t payload_type() const { return payload_type_; }
|
||||
uint64_t picture_id() const { return picture_id_; }
|
||||
|
||||
protected:
|
||||
bool Create(uint8_t* packet,
|
||||
size_t* index,
|
||||
@ -47,13 +42,12 @@ class Rpsi : public RtcpPacket {
|
||||
RtcpPacket::PacketReadyCallback* callback) const override;
|
||||
|
||||
private:
|
||||
size_t BlockLength() const {
|
||||
size_t fci_length = 2 + (rpsi_.NumberOfValidBits / 8) + padding_bytes_;
|
||||
return kCommonFbFmtLength + fci_length;
|
||||
}
|
||||
size_t BlockLength() const override { return block_length_; }
|
||||
static size_t CalculateBlockLength(uint8_t bitstring_size_bytes);
|
||||
|
||||
uint8_t padding_bytes_;
|
||||
RTCPUtility::RTCPPacketPSFBRPSI rpsi_;
|
||||
uint8_t payload_type_;
|
||||
uint64_t picture_id_;
|
||||
size_t block_length_;
|
||||
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(Rpsi);
|
||||
};
|
||||
|
||||
@ -12,29 +12,128 @@
|
||||
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
|
||||
#include "webrtc/test/rtcp_packet_parser.h"
|
||||
|
||||
using testing::ElementsAreArray;
|
||||
using testing::make_tuple;
|
||||
using webrtc::rtcp::RawPacket;
|
||||
using webrtc::rtcp::Rpsi;
|
||||
using webrtc::test::RtcpPacketParser;
|
||||
using webrtc::RTCPUtility::RtcpCommonHeader;
|
||||
using webrtc::RTCPUtility::RtcpParseCommonHeader;
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
const uint32_t kSenderSsrc = 0x12345678;
|
||||
const uint32_t kRemoteSsrc = 0x23456789;
|
||||
// 10000|01 100001|0 1000011 (7 bits = 1 byte in native string).
|
||||
const uint64_t kPictureId = 0x106143;
|
||||
const uint8_t kPayloadType = 100;
|
||||
// Manually created Rpsi packet matching constants above.
|
||||
const uint8_t kPacket[] = {0x83, 206, 0x00, 0x04,
|
||||
0x12, 0x34, 0x56, 0x78,
|
||||
0x23, 0x45, 0x67, 0x89,
|
||||
24, 100, 0xc1, 0xc2,
|
||||
0x43, 0, 0, 0};
|
||||
|
||||
bool ParseRpsi(const uint8_t* buffer, size_t length, Rpsi* rpsi) {
|
||||
RtcpCommonHeader header;
|
||||
EXPECT_TRUE(RtcpParseCommonHeader(buffer, length, &header));
|
||||
EXPECT_EQ(length, header.BlockSize());
|
||||
return rpsi->Parse(header, buffer + RtcpCommonHeader::kHeaderSizeBytes);
|
||||
}
|
||||
// Testing function when test only interested if parse is successful.
|
||||
bool ParseRpsi(const uint8_t* buffer, size_t length) {
|
||||
Rpsi rpsi;
|
||||
return ParseRpsi(buffer, length, &rpsi);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
TEST(RtcpPacketRpsiTest, Parse) {
|
||||
Rpsi mutable_parsed;
|
||||
EXPECT_TRUE(ParseRpsi(kPacket, sizeof(kPacket), &mutable_parsed));
|
||||
const Rpsi& parsed = mutable_parsed; // Read values from constant object.
|
||||
|
||||
EXPECT_EQ(kSenderSsrc, parsed.sender_ssrc());
|
||||
EXPECT_EQ(kRemoteSsrc, parsed.media_ssrc());
|
||||
EXPECT_EQ(kPayloadType, parsed.payload_type());
|
||||
EXPECT_EQ(kPictureId, parsed.picture_id());
|
||||
}
|
||||
|
||||
TEST(RtcpPacketRpsiTest, Create) {
|
||||
Rpsi rpsi;
|
||||
rpsi.From(kSenderSsrc);
|
||||
rpsi.To(kRemoteSsrc);
|
||||
rpsi.WithPayloadType(kPayloadType);
|
||||
rpsi.WithPictureId(kPictureId);
|
||||
|
||||
rtc::scoped_ptr<RawPacket> packet = rpsi.Build();
|
||||
|
||||
EXPECT_THAT(make_tuple(packet->Buffer(), packet->Length()),
|
||||
ElementsAreArray(kPacket));
|
||||
}
|
||||
|
||||
TEST(RtcpPacketRpsiTest, ParseFailsOnTooSmallPacket) {
|
||||
Rpsi rpsi;
|
||||
rpsi.From(kSenderSsrc);
|
||||
rpsi.To(kRemoteSsrc);
|
||||
|
||||
rtc::scoped_ptr<RawPacket> packet = rpsi.Build();
|
||||
packet->MutableBuffer()[3]--; // Reduce size field by one word (4 bytes).
|
||||
|
||||
EXPECT_FALSE(ParseRpsi(packet->Buffer(), packet->Length() - 4));
|
||||
}
|
||||
|
||||
TEST(RtcpPacketRpsiTest, ParseFailsOnFractionalPaddingBytes) {
|
||||
Rpsi rpsi;
|
||||
rpsi.From(kSenderSsrc);
|
||||
rpsi.To(kRemoteSsrc);
|
||||
rpsi.WithPictureId(kPictureId);
|
||||
rtc::scoped_ptr<RawPacket> packet = rpsi.Build();
|
||||
uint8_t* padding_bits = packet->MutableBuffer() + 12;
|
||||
uint8_t saved_padding_bits = *padding_bits;
|
||||
ASSERT_TRUE(ParseRpsi(packet->Buffer(), packet->Length()));
|
||||
|
||||
for (uint8_t i = 1; i < 8; ++i) {
|
||||
*padding_bits = saved_padding_bits + i;
|
||||
EXPECT_FALSE(ParseRpsi(packet->Buffer(), packet->Length()));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(RtcpPacketRpsiTest, ParseFailsOnTooBigPadding) {
|
||||
Rpsi rpsi;
|
||||
rpsi.From(kSenderSsrc);
|
||||
rpsi.To(kRemoteSsrc);
|
||||
rpsi.WithPictureId(1); // Small picture id that occupy just 1 byte.
|
||||
rtc::scoped_ptr<RawPacket> packet = rpsi.Build();
|
||||
uint8_t* padding_bits = packet->MutableBuffer() + 12;
|
||||
ASSERT_TRUE(ParseRpsi(packet->Buffer(), packet->Length()));
|
||||
|
||||
*padding_bits += 8;
|
||||
EXPECT_FALSE(ParseRpsi(packet->Buffer(), packet->Length()));
|
||||
}
|
||||
|
||||
// For raw rpsi packet extract how many bytes are used to store picture_id.
|
||||
size_t UsedBytes(const RawPacket& packet) { // Works for small packets only.
|
||||
RTC_CHECK_EQ(packet.Buffer()[2], 0); // Assume packet is small.
|
||||
size_t total_rpsi_payload_bytes = 4 * (packet.Buffer()[3] - 2) - 2;
|
||||
uint8_t padding_bits = packet.Buffer()[12];
|
||||
RTC_CHECK_EQ(padding_bits % 8, 0);
|
||||
return total_rpsi_payload_bytes - (padding_bits / 8);
|
||||
}
|
||||
|
||||
TEST(RtcpPacketRpsiTest, WithOneByteNativeString) {
|
||||
Rpsi rpsi;
|
||||
// 1000001 (7 bits = 1 byte in native string).
|
||||
const uint64_t kPictureId = 0x41;
|
||||
const uint16_t kNumberOfValidBytes = 1;
|
||||
rpsi.WithPayloadType(100);
|
||||
rpsi.WithPictureId(kPictureId);
|
||||
|
||||
rtc::scoped_ptr<RawPacket> packet(rpsi.Build());
|
||||
RtcpPacketParser parser;
|
||||
parser.Parse(packet->Buffer(), packet->Length());
|
||||
EXPECT_EQ(100, parser.rpsi()->PayloadType());
|
||||
EXPECT_EQ(kNumberOfValidBytes * 8, parser.rpsi()->NumberOfValidBits());
|
||||
EXPECT_EQ(kPictureId, parser.rpsi()->PictureId());
|
||||
rtc::scoped_ptr<RawPacket> packet = rpsi.Build();
|
||||
EXPECT_EQ(kNumberOfValidBytes, UsedBytes(*packet));
|
||||
|
||||
Rpsi parsed;
|
||||
EXPECT_TRUE(ParseRpsi(packet->Buffer(), packet->Length(), &parsed));
|
||||
EXPECT_EQ(kPictureId, parsed.picture_id());
|
||||
}
|
||||
|
||||
TEST(RtcpPacketRpsiTest, WithTwoByteNativeString) {
|
||||
@ -44,11 +143,12 @@ TEST(RtcpPacketRpsiTest, WithTwoByteNativeString) {
|
||||
const uint16_t kNumberOfValidBytes = 2;
|
||||
rpsi.WithPictureId(kPictureId);
|
||||
|
||||
rtc::scoped_ptr<RawPacket> packet(rpsi.Build());
|
||||
RtcpPacketParser parser;
|
||||
parser.Parse(packet->Buffer(), packet->Length());
|
||||
EXPECT_EQ(kNumberOfValidBytes * 8, parser.rpsi()->NumberOfValidBits());
|
||||
EXPECT_EQ(kPictureId, parser.rpsi()->PictureId());
|
||||
rtc::scoped_ptr<RawPacket> packet = rpsi.Build();
|
||||
EXPECT_EQ(kNumberOfValidBytes, UsedBytes(*packet));
|
||||
|
||||
Rpsi parsed;
|
||||
EXPECT_TRUE(ParseRpsi(packet->Buffer(), packet->Length(), &parsed));
|
||||
EXPECT_EQ(kPictureId, parsed.picture_id());
|
||||
}
|
||||
|
||||
TEST(RtcpPacketRpsiTest, WithThreeByteNativeString) {
|
||||
@ -58,11 +158,12 @@ TEST(RtcpPacketRpsiTest, WithThreeByteNativeString) {
|
||||
const uint16_t kNumberOfValidBytes = 3;
|
||||
rpsi.WithPictureId(kPictureId);
|
||||
|
||||
rtc::scoped_ptr<RawPacket> packet(rpsi.Build());
|
||||
RtcpPacketParser parser;
|
||||
parser.Parse(packet->Buffer(), packet->Length());
|
||||
EXPECT_EQ(kNumberOfValidBytes * 8, parser.rpsi()->NumberOfValidBits());
|
||||
EXPECT_EQ(kPictureId, parser.rpsi()->PictureId());
|
||||
rtc::scoped_ptr<RawPacket> packet = rpsi.Build();
|
||||
EXPECT_EQ(kNumberOfValidBytes, UsedBytes(*packet));
|
||||
|
||||
Rpsi parsed;
|
||||
EXPECT_TRUE(ParseRpsi(packet->Buffer(), packet->Length(), &parsed));
|
||||
EXPECT_EQ(kPictureId, parsed.picture_id());
|
||||
}
|
||||
|
||||
TEST(RtcpPacketRpsiTest, WithFourByteNativeString) {
|
||||
@ -72,11 +173,12 @@ TEST(RtcpPacketRpsiTest, WithFourByteNativeString) {
|
||||
const uint16_t kNumberOfValidBytes = 4;
|
||||
rpsi.WithPictureId(kPictureId);
|
||||
|
||||
rtc::scoped_ptr<RawPacket> packet(rpsi.Build());
|
||||
RtcpPacketParser parser;
|
||||
parser.Parse(packet->Buffer(), packet->Length());
|
||||
EXPECT_EQ(kNumberOfValidBytes * 8, parser.rpsi()->NumberOfValidBits());
|
||||
EXPECT_EQ(kPictureId, parser.rpsi()->PictureId());
|
||||
rtc::scoped_ptr<RawPacket> packet = rpsi.Build();
|
||||
EXPECT_EQ(kNumberOfValidBytes, UsedBytes(*packet));
|
||||
|
||||
Rpsi parsed;
|
||||
EXPECT_TRUE(ParseRpsi(packet->Buffer(), packet->Length(), &parsed));
|
||||
EXPECT_EQ(kPictureId, parsed.picture_id());
|
||||
}
|
||||
|
||||
TEST(RtcpPacketRpsiTest, WithMaxPictureId) {
|
||||
@ -87,11 +189,11 @@ TEST(RtcpPacketRpsiTest, WithMaxPictureId) {
|
||||
const uint16_t kNumberOfValidBytes = 10;
|
||||
rpsi.WithPictureId(kPictureId);
|
||||
|
||||
rtc::scoped_ptr<RawPacket> packet(rpsi.Build());
|
||||
RtcpPacketParser parser;
|
||||
parser.Parse(packet->Buffer(), packet->Length());
|
||||
EXPECT_EQ(kNumberOfValidBytes * 8, parser.rpsi()->NumberOfValidBits());
|
||||
EXPECT_EQ(kPictureId, parser.rpsi()->PictureId());
|
||||
}
|
||||
rtc::scoped_ptr<RawPacket> packet = rpsi.Build();
|
||||
EXPECT_EQ(kNumberOfValidBytes, UsedBytes(*packet));
|
||||
|
||||
Rpsi parsed;
|
||||
EXPECT_TRUE(ParseRpsi(packet->Buffer(), packet->Length(), &parsed));
|
||||
EXPECT_EQ(kPictureId, parsed.picture_id());
|
||||
}
|
||||
} // namespace webrtc
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user