[rtp_rtcp] rtcp::Fir moved into own file
Cleaning/Parsing will be done in the https://codereview.webrtc.org/1544403002 BUG=webrtc:5260 R=asapersson@webrtc.org, åsapersson Review URL: https://codereview.webrtc.org/1581983003 . Cr-Commit-Position: refs/heads/master@{#11269}
This commit is contained in:
parent
a5eba6c98b
commit
5679da1291
@ -310,6 +310,7 @@
|
||||
'rtp_rtcp/source/rtcp_packet/compound_packet_unittest.cc',
|
||||
'rtp_rtcp/source/rtcp_packet/dlrr_unittest.cc',
|
||||
'rtp_rtcp/source/rtcp_packet/extended_jitter_report_unittest.cc',
|
||||
'rtp_rtcp/source/rtcp_packet/fir_unittest.cc',
|
||||
'rtp_rtcp/source/rtcp_packet/nack_unittest.cc',
|
||||
'rtp_rtcp/source/rtcp_packet/pli_unittest.cc',
|
||||
'rtp_rtcp/source/rtcp_packet/receiver_report_unittest.cc',
|
||||
|
||||
@ -56,6 +56,8 @@ source_set("rtp_rtcp") {
|
||||
"source/rtcp_packet/dlrr.h",
|
||||
"source/rtcp_packet/extended_jitter_report.cc",
|
||||
"source/rtcp_packet/extended_jitter_report.h",
|
||||
"source/rtcp_packet/fir.cc",
|
||||
"source/rtcp_packet/fir.h",
|
||||
"source/rtcp_packet/nack.cc",
|
||||
"source/rtcp_packet/nack.h",
|
||||
"source/rtcp_packet/pli.cc",
|
||||
|
||||
@ -51,6 +51,8 @@
|
||||
'source/rtcp_packet/dlrr.h',
|
||||
'source/rtcp_packet/extended_jitter_report.cc',
|
||||
'source/rtcp_packet/extended_jitter_report.h',
|
||||
'source/rtcp_packet/fir.cc',
|
||||
'source/rtcp_packet/fir.h',
|
||||
'source/rtcp_packet/nack.cc',
|
||||
'source/rtcp_packet/nack.h',
|
||||
'source/rtcp_packet/pli.cc',
|
||||
|
||||
@ -29,8 +29,6 @@ using webrtc::RTCPUtility::PT_SR;
|
||||
using webrtc::RTCPUtility::PT_XR;
|
||||
|
||||
using webrtc::RTCPUtility::RTCPPacketAPP;
|
||||
using webrtc::RTCPUtility::RTCPPacketPSFBFIR;
|
||||
using webrtc::RTCPUtility::RTCPPacketPSFBFIRItem;
|
||||
using webrtc::RTCPUtility::RTCPPacketPSFBRPSI;
|
||||
using webrtc::RTCPUtility::RTCPPacketReportBlockItem;
|
||||
using webrtc::RTCPUtility::RTCPPacketRTPFBNACK;
|
||||
@ -42,9 +40,6 @@ using webrtc::RTCPUtility::RTCPPacketXR;
|
||||
namespace webrtc {
|
||||
namespace rtcp {
|
||||
namespace {
|
||||
// Unused SSRC of media source, set to 0.
|
||||
const uint32_t kUnusedMediaSourceSsrc0 = 0;
|
||||
|
||||
void AssignUWord8(uint8_t* buffer, size_t* offset, uint8_t value) {
|
||||
buffer[(*offset)++] = value;
|
||||
}
|
||||
@ -52,10 +47,6 @@ void AssignUWord16(uint8_t* buffer, size_t* offset, uint16_t value) {
|
||||
ByteWriter<uint16_t>::WriteBigEndian(buffer + *offset, value);
|
||||
*offset += 2;
|
||||
}
|
||||
void AssignUWord24(uint8_t* buffer, size_t* offset, uint32_t value) {
|
||||
ByteWriter<uint32_t, 3>::WriteBigEndian(buffer + *offset, value);
|
||||
*offset += 3;
|
||||
}
|
||||
void AssignUWord32(uint8_t* buffer, size_t* offset, uint32_t value) {
|
||||
ByteWriter<uint32_t>::WriteBigEndian(buffer + *offset, value);
|
||||
*offset += 4;
|
||||
@ -187,29 +178,6 @@ void CreateRpsi(const RTCPPacketPSFBRPSI& rpsi,
|
||||
*pos += padding_bytes;
|
||||
}
|
||||
|
||||
// Full intra request (FIR) (RFC 5104).
|
||||
//
|
||||
// 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
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | SSRC |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | Seq nr. | Reserved |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
|
||||
void CreateFir(const RTCPPacketPSFBFIR& fir,
|
||||
const RTCPPacketPSFBFIRItem& fir_item,
|
||||
uint8_t* buffer,
|
||||
size_t* pos) {
|
||||
AssignUWord32(buffer, pos, fir.SenderSSRC);
|
||||
AssignUWord32(buffer, pos, kUnusedMediaSourceSsrc0);
|
||||
AssignUWord32(buffer, pos, fir_item.SSRC);
|
||||
AssignUWord8(buffer, pos, fir_item.CommandSequenceNumber);
|
||||
AssignUWord24(buffer, pos, 0);
|
||||
}
|
||||
|
||||
// From RFC 3611: RTP Control Protocol Extended Reports (RTCP XR).
|
||||
//
|
||||
// Format for XR packets:
|
||||
@ -437,20 +405,6 @@ void Rpsi::WithPictureId(uint64_t picture_id) {
|
||||
}
|
||||
}
|
||||
|
||||
bool Fir::Create(uint8_t* packet,
|
||||
size_t* index,
|
||||
size_t max_length,
|
||||
RtcpPacket::PacketReadyCallback* callback) const {
|
||||
while (*index + BlockLength() > max_length) {
|
||||
if (!OnBufferFull(packet, index, callback))
|
||||
return false;
|
||||
}
|
||||
const uint8_t kFmt = 4;
|
||||
CreateHeader(kFmt, PT_PSFB, HeaderLength(), packet, index);
|
||||
CreateFir(fir_, fir_item_, packet, index);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Xr::Create(uint8_t* packet,
|
||||
size_t* index,
|
||||
size_t max_length,
|
||||
|
||||
@ -306,53 +306,6 @@ class Rpsi : public RtcpPacket {
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(Rpsi);
|
||||
};
|
||||
|
||||
// Full intra request (FIR) (RFC 5104).
|
||||
//
|
||||
// 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
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | SSRC |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | Seq nr. | Reserved |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
|
||||
class Fir : public RtcpPacket {
|
||||
public:
|
||||
Fir() : RtcpPacket() {
|
||||
memset(&fir_, 0, sizeof(fir_));
|
||||
memset(&fir_item_, 0, sizeof(fir_item_));
|
||||
}
|
||||
|
||||
virtual ~Fir() {}
|
||||
|
||||
void From(uint32_t ssrc) {
|
||||
fir_.SenderSSRC = ssrc;
|
||||
}
|
||||
void To(uint32_t ssrc) {
|
||||
fir_item_.SSRC = ssrc;
|
||||
}
|
||||
void WithCommandSeqNum(uint8_t seq_num) {
|
||||
fir_item_.CommandSequenceNumber = seq_num;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool Create(uint8_t* packet,
|
||||
size_t* index,
|
||||
size_t max_length,
|
||||
RtcpPacket::PacketReadyCallback* callback) const override;
|
||||
|
||||
private:
|
||||
size_t BlockLength() const {
|
||||
const size_t kFciLength = 8;
|
||||
return kCommonFbFmtLength + kFciLength;
|
||||
}
|
||||
|
||||
RTCPUtility::RTCPPacketPSFBFIR fir_;
|
||||
RTCPUtility::RTCPPacketPSFBFIRItem fir_item_;
|
||||
};
|
||||
|
||||
// From RFC 3611: RTP Control Protocol Extended Reports (RTCP XR).
|
||||
//
|
||||
// Format for XR packets:
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
|
||||
#include "webrtc/test/rtcp_packet_parser.h"
|
||||
|
||||
|
||||
78
webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.cc
Normal file
78
webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.cc
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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/fir.h"
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/byte_io.h"
|
||||
|
||||
using webrtc::RTCPUtility::PT_PSFB;
|
||||
using webrtc::RTCPUtility::RTCPPacketPSFBFIR;
|
||||
using webrtc::RTCPUtility::RTCPPacketPSFBFIRItem;
|
||||
|
||||
namespace webrtc {
|
||||
namespace rtcp {
|
||||
namespace {
|
||||
const uint32_t kUnusedMediaSourceSsrc0 = 0;
|
||||
|
||||
void AssignUWord8(uint8_t* buffer, size_t* offset, uint8_t value) {
|
||||
buffer[(*offset)++] = value;
|
||||
}
|
||||
|
||||
void AssignUWord24(uint8_t* buffer, size_t* offset, uint32_t value) {
|
||||
ByteWriter<uint32_t, 3>::WriteBigEndian(buffer + *offset, value);
|
||||
*offset += 3;
|
||||
}
|
||||
|
||||
void AssignUWord32(uint8_t* buffer, size_t* offset, uint32_t value) {
|
||||
ByteWriter<uint32_t>::WriteBigEndian(buffer + *offset, value);
|
||||
*offset += 4;
|
||||
}
|
||||
|
||||
// Full intra request (FIR) (RFC 5104).
|
||||
//
|
||||
// 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
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | SSRC |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | Seq nr. | Reserved |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
void CreateFir(const RTCPPacketPSFBFIR& fir,
|
||||
const RTCPPacketPSFBFIRItem& fir_item,
|
||||
uint8_t* buffer,
|
||||
size_t* pos) {
|
||||
AssignUWord32(buffer, pos, fir.SenderSSRC);
|
||||
AssignUWord32(buffer, pos, kUnusedMediaSourceSsrc0);
|
||||
AssignUWord32(buffer, pos, fir_item.SSRC);
|
||||
AssignUWord8(buffer, pos, fir_item.CommandSequenceNumber);
|
||||
AssignUWord24(buffer, pos, 0);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool Fir::Create(uint8_t* packet,
|
||||
size_t* index,
|
||||
size_t max_length,
|
||||
RtcpPacket::PacketReadyCallback* callback) const {
|
||||
while (*index + BlockLength() > max_length) {
|
||||
if (!OnBufferFull(packet, index, callback))
|
||||
return false;
|
||||
}
|
||||
const uint8_t kFmt = 4;
|
||||
CreateHeader(kFmt, PT_PSFB, HeaderLength(), packet, index);
|
||||
CreateFir(fir_, fir_item_, packet, index);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace rtcp
|
||||
} // namespace webrtc
|
||||
60
webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h
Normal file
60
webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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_FIR_H_
|
||||
#define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_FIR_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 {
|
||||
|
||||
// Full intra request (FIR) (RFC 5104).
|
||||
class Fir : public RtcpPacket {
|
||||
public:
|
||||
Fir() : RtcpPacket() {
|
||||
memset(&fir_, 0, sizeof(fir_));
|
||||
memset(&fir_item_, 0, sizeof(fir_item_));
|
||||
}
|
||||
|
||||
virtual ~Fir() {}
|
||||
|
||||
void From(uint32_t ssrc) {
|
||||
fir_.SenderSSRC = ssrc;
|
||||
}
|
||||
void To(uint32_t ssrc) {
|
||||
fir_item_.SSRC = ssrc;
|
||||
}
|
||||
void WithCommandSeqNum(uint8_t seq_num) {
|
||||
fir_item_.CommandSequenceNumber = seq_num;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool Create(uint8_t* packet,
|
||||
size_t* index,
|
||||
size_t max_length,
|
||||
RtcpPacket::PacketReadyCallback* callback) const override;
|
||||
|
||||
private:
|
||||
size_t BlockLength() const {
|
||||
const size_t kFciLength = 8;
|
||||
return kCommonFbFmtLength + kFciLength;
|
||||
}
|
||||
|
||||
RTCPUtility::RTCPPacketPSFBFIR fir_;
|
||||
RTCPUtility::RTCPPacketPSFBFIRItem fir_item_;
|
||||
};
|
||||
|
||||
} // namespace rtcp
|
||||
} // namespace webrtc
|
||||
#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_FIR_H_
|
||||
42
webrtc/modules/rtp_rtcp/source/rtcp_packet/fir_unittest.cc
Normal file
42
webrtc/modules/rtp_rtcp/source/rtcp_packet/fir_unittest.cc
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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/fir.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::Fir;
|
||||
using webrtc::rtcp::RawPacket;
|
||||
using webrtc::test::RtcpPacketParser;
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
const uint32_t kSenderSsrc = 0x12345678;
|
||||
const uint32_t kRemoteSsrc = 0x23456789;
|
||||
|
||||
TEST(RtcpPacketFirTest, Fir) {
|
||||
Fir fir;
|
||||
fir.From(kSenderSsrc);
|
||||
fir.To(kRemoteSsrc);
|
||||
fir.WithCommandSeqNum(123);
|
||||
|
||||
rtc::scoped_ptr<RawPacket> packet(fir.Build());
|
||||
RtcpPacketParser parser;
|
||||
parser.Parse(packet->Buffer(), packet->Length());
|
||||
EXPECT_EQ(1, parser.fir()->num_packets());
|
||||
EXPECT_EQ(kSenderSsrc, parser.fir()->Ssrc());
|
||||
EXPECT_EQ(1, parser.fir_item()->num_packets());
|
||||
EXPECT_EQ(kRemoteSsrc, parser.fir_item()->Ssrc());
|
||||
EXPECT_EQ(123U, parser.fir_item()->SeqNum());
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@ -24,7 +24,6 @@ using ::testing::ElementsAre;
|
||||
using webrtc::rtcp::App;
|
||||
using webrtc::rtcp::Bye;
|
||||
using webrtc::rtcp::Dlrr;
|
||||
using webrtc::rtcp::Fir;
|
||||
using webrtc::rtcp::RawPacket;
|
||||
using webrtc::rtcp::ReceiverReport;
|
||||
using webrtc::rtcp::ReportBlock;
|
||||
@ -287,22 +286,6 @@ TEST(RtcpPacketTest, RpsiWithMaxPictureId) {
|
||||
EXPECT_EQ(kPictureId, parser.rpsi()->PictureId());
|
||||
}
|
||||
|
||||
TEST(RtcpPacketTest, Fir) {
|
||||
Fir fir;
|
||||
fir.From(kSenderSsrc);
|
||||
fir.To(kRemoteSsrc);
|
||||
fir.WithCommandSeqNum(123);
|
||||
|
||||
rtc::scoped_ptr<RawPacket> packet(fir.Build());
|
||||
RtcpPacketParser parser;
|
||||
parser.Parse(packet->Buffer(), packet->Length());
|
||||
EXPECT_EQ(1, parser.fir()->num_packets());
|
||||
EXPECT_EQ(kSenderSsrc, parser.fir()->Ssrc());
|
||||
EXPECT_EQ(1, parser.fir_item()->num_packets());
|
||||
EXPECT_EQ(kRemoteSsrc, parser.fir_item()->Ssrc());
|
||||
EXPECT_EQ(123U, parser.fir_item()->SeqNum());
|
||||
}
|
||||
|
||||
TEST(RtcpPacketTest, BuildWithTooSmallBuffer) {
|
||||
ReportBlock rb;
|
||||
ReceiverReport rr;
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_jitter_report.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h"
|
||||
#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"
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/compound_packet.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user