[rtp_rtcp] rtcp::Rpsi moved into own file
Cleaning/Parsing will be done in the https://codereview.webrtc.org/1550293003/ BUG=webrtc:5260 R=asapersson@webrtc.org, åsapersson Review URL: https://codereview.webrtc.org/1583233007 . Cr-Commit-Position: refs/heads/master@{#11272}
This commit is contained in:
parent
256e5b23f8
commit
2c13297bf5
@ -317,6 +317,7 @@
|
||||
'rtp_rtcp/source/rtcp_packet/receiver_report_unittest.cc',
|
||||
'rtp_rtcp/source/rtcp_packet/remb_unittest.cc',
|
||||
'rtp_rtcp/source/rtcp_packet/report_block_unittest.cc',
|
||||
'rtp_rtcp/source/rtcp_packet/rpsi_unittest.cc',
|
||||
'rtp_rtcp/source/rtcp_packet/rrtr_unittest.cc',
|
||||
'rtp_rtcp/source/rtcp_packet/sli_unittest.cc',
|
||||
'rtp_rtcp/source/rtcp_packet/tmmbn_unittest.cc',
|
||||
|
||||
@ -72,6 +72,8 @@ source_set("rtp_rtcp") {
|
||||
"source/rtcp_packet/remb.h",
|
||||
"source/rtcp_packet/report_block.cc",
|
||||
"source/rtcp_packet/report_block.h",
|
||||
"source/rtcp_packet/rpsi.cc",
|
||||
"source/rtcp_packet/rpsi.h",
|
||||
"source/rtcp_packet/rrtr.cc",
|
||||
"source/rtcp_packet/rrtr.h",
|
||||
"source/rtcp_packet/rtpfb.cc",
|
||||
|
||||
@ -67,6 +67,8 @@
|
||||
'source/rtcp_packet/remb.h',
|
||||
'source/rtcp_packet/report_block.cc',
|
||||
'source/rtcp_packet/report_block.h',
|
||||
'source/rtcp_packet/rpsi.cc',
|
||||
'source/rtcp_packet/rpsi.h',
|
||||
'source/rtcp_packet/rrtr.cc',
|
||||
'source/rtcp_packet/rrtr.h',
|
||||
'source/rtcp_packet/rtpfb.cc',
|
||||
|
||||
@ -18,13 +18,11 @@
|
||||
|
||||
using webrtc::RTCPUtility::PT_APP;
|
||||
using webrtc::RTCPUtility::PT_IJ;
|
||||
using webrtc::RTCPUtility::PT_PSFB;
|
||||
using webrtc::RTCPUtility::PT_RTPFB;
|
||||
using webrtc::RTCPUtility::PT_SDES;
|
||||
using webrtc::RTCPUtility::PT_SR;
|
||||
|
||||
using webrtc::RTCPUtility::RTCPPacketAPP;
|
||||
using webrtc::RTCPUtility::RTCPPacketPSFBRPSI;
|
||||
using webrtc::RTCPUtility::RTCPPacketReportBlockItem;
|
||||
using webrtc::RTCPUtility::RTCPPacketRTPFBNACK;
|
||||
using webrtc::RTCPUtility::RTCPPacketRTPFBNACKItem;
|
||||
@ -142,34 +140,6 @@ void CreateSdes(const std::vector<Sdes::Chunk>& chunks,
|
||||
*pos += (*it).null_octets;
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void RtcpPacket::Append(RtcpPacket* packet) {
|
||||
@ -335,48 +305,6 @@ size_t Sdes::BlockLength() const {
|
||||
return length;
|
||||
}
|
||||
|
||||
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);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
RawPacket::RawPacket(size_t buffer_length)
|
||||
: buffer_length_(buffer_length), length_(0) {
|
||||
buffer_.reset(new uint8_t[buffer_length]);
|
||||
|
||||
@ -250,58 +250,6 @@ class Sdes : public RtcpPacket {
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(Sdes);
|
||||
};
|
||||
|
||||
// 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) |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
|
||||
class Rpsi : public RtcpPacket {
|
||||
public:
|
||||
Rpsi()
|
||||
: RtcpPacket(),
|
||||
padding_bytes_(0) {
|
||||
memset(&rpsi_, 0, sizeof(rpsi_));
|
||||
}
|
||||
|
||||
virtual ~Rpsi() {}
|
||||
|
||||
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 WithPictureId(uint64_t picture_id);
|
||||
|
||||
protected:
|
||||
bool Create(uint8_t* packet,
|
||||
size_t* index,
|
||||
size_t max_length,
|
||||
RtcpPacket::PacketReadyCallback* callback) const override;
|
||||
|
||||
private:
|
||||
size_t BlockLength() const {
|
||||
size_t fci_length = 2 + (rpsi_.NumberOfValidBits / 8) + padding_bytes_;
|
||||
return kCommonFbFmtLength + fci_length;
|
||||
}
|
||||
|
||||
uint8_t padding_bytes_;
|
||||
RTCPUtility::RTCPPacketPSFBRPSI rpsi_;
|
||||
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(Rpsi);
|
||||
};
|
||||
|
||||
// Class holding a RTCP packet.
|
||||
//
|
||||
// Takes a built rtcp packet.
|
||||
|
||||
102
webrtc/modules/rtp_rtcp/source/rtcp_packet/rpsi.cc
Normal file
102
webrtc/modules/rtp_rtcp/source/rtcp_packet/rpsi.cc
Normal file
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2016 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.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rpsi.h"
|
||||
|
||||
#include "webrtc/modules/rtp_rtcp/source/byte_io.h"
|
||||
|
||||
using webrtc::RTCPUtility::PT_PSFB;
|
||||
using webrtc::RTCPUtility::RTCPPacketPSFBRPSI;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
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);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace rtcp
|
||||
} // namespace webrtc
|
||||
62
webrtc/modules/rtp_rtcp/source/rtcp_packet/rpsi.h
Normal file
62
webrtc/modules/rtp_rtcp/source/rtcp_packet/rpsi.h
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2016 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 WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_RPSI_H_
|
||||
#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_utility.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace rtcp {
|
||||
// Reference picture selection indication (RPSI) (RFC 4585).
|
||||
class Rpsi : public RtcpPacket {
|
||||
public:
|
||||
Rpsi()
|
||||
: RtcpPacket(),
|
||||
padding_bytes_(0) {
|
||||
memset(&rpsi_, 0, sizeof(rpsi_));
|
||||
}
|
||||
|
||||
virtual ~Rpsi() {}
|
||||
|
||||
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 WithPictureId(uint64_t picture_id);
|
||||
|
||||
protected:
|
||||
bool Create(uint8_t* packet,
|
||||
size_t* index,
|
||||
size_t max_length,
|
||||
RtcpPacket::PacketReadyCallback* callback) const override;
|
||||
|
||||
private:
|
||||
size_t BlockLength() const {
|
||||
size_t fci_length = 2 + (rpsi_.NumberOfValidBits / 8) + padding_bytes_;
|
||||
return kCommonFbFmtLength + fci_length;
|
||||
}
|
||||
|
||||
uint8_t padding_bytes_;
|
||||
RTCPUtility::RTCPPacketPSFBRPSI rpsi_;
|
||||
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(Rpsi);
|
||||
};
|
||||
} // namespace rtcp
|
||||
} // namespace webrtc
|
||||
#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_RPSI_H_
|
||||
97
webrtc/modules/rtp_rtcp/source/rtcp_packet/rpsi_unittest.cc
Normal file
97
webrtc/modules/rtp_rtcp/source/rtcp_packet/rpsi_unittest.cc
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2016 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.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rpsi.h"
|
||||
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
#include "webrtc/test/rtcp_packet_parser.h"
|
||||
|
||||
using webrtc::rtcp::RawPacket;
|
||||
using webrtc::rtcp::Rpsi;
|
||||
using webrtc::test::RtcpPacketParser;
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
TEST(RtcpPacketRpsiTest, WithTwoByteNativeString) {
|
||||
Rpsi rpsi;
|
||||
// |1 0000001 (7 bits = 1 byte in native string).
|
||||
const uint64_t kPictureId = 0x81;
|
||||
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());
|
||||
}
|
||||
|
||||
TEST(RtcpPacketRpsiTest, WithThreeByteNativeString) {
|
||||
Rpsi rpsi;
|
||||
// 10000|00 100000|0 1000000 (7 bits = 1 byte in native string).
|
||||
const uint64_t kPictureId = 0x102040;
|
||||
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());
|
||||
}
|
||||
|
||||
TEST(RtcpPacketRpsiTest, WithFourByteNativeString) {
|
||||
Rpsi rpsi;
|
||||
// 1000|001 00001|01 100001|1 1000010 (7 bits = 1 byte in native string).
|
||||
const uint64_t kPictureId = 0x84161C2;
|
||||
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());
|
||||
}
|
||||
|
||||
TEST(RtcpPacketRpsiTest, WithMaxPictureId) {
|
||||
Rpsi rpsi;
|
||||
// 1 1111111| 1111111 1|111111 11|11111 111|1111 1111|111 11111|
|
||||
// 11 111111|1 1111111 (7 bits = 1 byte in native string).
|
||||
const uint64_t kPictureId = 0xffffffffffffffff;
|
||||
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());
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@ -26,7 +26,6 @@ using webrtc::rtcp::Bye;
|
||||
using webrtc::rtcp::RawPacket;
|
||||
using webrtc::rtcp::ReceiverReport;
|
||||
using webrtc::rtcp::ReportBlock;
|
||||
using webrtc::rtcp::Rpsi;
|
||||
using webrtc::rtcp::Sdes;
|
||||
using webrtc::rtcp::SenderReport;
|
||||
using webrtc::test::RtcpPacketParser;
|
||||
@ -209,78 +208,6 @@ TEST(RtcpPacketTest, CnameItemWithEmptyString) {
|
||||
EXPECT_EQ("", parser.sdes_chunk()->Cname());
|
||||
}
|
||||
|
||||
TEST(RtcpPacketTest, Rpsi) {
|
||||
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());
|
||||
}
|
||||
|
||||
TEST(RtcpPacketTest, RpsiWithTwoByteNativeString) {
|
||||
Rpsi rpsi;
|
||||
// |1 0000001 (7 bits = 1 byte in native string).
|
||||
const uint64_t kPictureId = 0x81;
|
||||
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());
|
||||
}
|
||||
|
||||
TEST(RtcpPacketTest, RpsiWithThreeByteNativeString) {
|
||||
Rpsi rpsi;
|
||||
// 10000|00 100000|0 1000000 (7 bits = 1 byte in native string).
|
||||
const uint64_t kPictureId = 0x102040;
|
||||
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());
|
||||
}
|
||||
|
||||
TEST(RtcpPacketTest, RpsiWithFourByteNativeString) {
|
||||
Rpsi rpsi;
|
||||
// 1000|001 00001|01 100001|1 1000010 (7 bits = 1 byte in native string).
|
||||
const uint64_t kPictureId = 0x84161C2;
|
||||
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());
|
||||
}
|
||||
|
||||
TEST(RtcpPacketTest, RpsiWithMaxPictureId) {
|
||||
Rpsi rpsi;
|
||||
// 1 1111111| 1111111 1|111111 11|11111 111|1111 1111|111 11111|
|
||||
// 11 111111|1 1111111 (7 bits = 1 byte in native string).
|
||||
const uint64_t kPictureId = 0xffffffffffffffff;
|
||||
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());
|
||||
}
|
||||
|
||||
TEST(RtcpPacketTest, BuildWithTooSmallBuffer) {
|
||||
ReportBlock rb;
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rpsi.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sli.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbn.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbr.h"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user