Reland "Remove RTPVideoHeader::h264() accessors."
Downstream projects have been updated, so this can now be relanded. This is a revert (and rebase) of: https://webrtc-review.googlesource.com/c/src/+/88820 Bug: none Change-Id: I424664ddef7aeebd3c6c94ae67c7f70a342dc9a4 Reviewed-on: https://webrtc-review.googlesource.com/92082 Reviewed-by: Niels Moller <nisse@webrtc.org> Reviewed-by: Åsa Persson <asapersson@webrtc.org> Commit-Queue: Philip Eliasson <philipel@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24181}
This commit is contained in:
@ -36,14 +36,15 @@ H264SpsPpsTracker::PacketAction H264SpsPpsTracker::CopyAndFixBitstream(
|
||||
const uint8_t* data = packet->dataPtr;
|
||||
const size_t data_size = packet->sizeBytes;
|
||||
const RTPVideoHeader& video_header = packet->video_header;
|
||||
RTPVideoHeaderH264* codec_header = &packet->video_header.h264();
|
||||
auto& h264_header =
|
||||
absl::get<RTPVideoHeaderH264>(packet->video_header.video_type_header);
|
||||
|
||||
bool append_sps_pps = false;
|
||||
auto sps = sps_data_.end();
|
||||
auto pps = pps_data_.end();
|
||||
|
||||
for (size_t i = 0; i < codec_header->nalus_length; ++i) {
|
||||
const NaluInfo& nalu = codec_header->nalus[i];
|
||||
for (size_t i = 0; i < h264_header.nalus_length; ++i) {
|
||||
const NaluInfo& nalu = h264_header.nalus[i];
|
||||
switch (nalu.type) {
|
||||
case H264::NaluType::kSps: {
|
||||
sps_data_[nalu.sps_id].width = packet->width;
|
||||
@ -110,7 +111,7 @@ H264SpsPpsTracker::PacketAction H264SpsPpsTracker::CopyAndFixBitstream(
|
||||
required_size += pps->second.size + sizeof(start_code_h264);
|
||||
}
|
||||
|
||||
if (codec_header->packetization_type == kH264StapA) {
|
||||
if (h264_header.packetization_type == kH264StapA) {
|
||||
const uint8_t* nalu_ptr = data + 1;
|
||||
while (nalu_ptr < data + data_size) {
|
||||
RTC_DCHECK(video_header.is_first_packet_in_frame);
|
||||
@ -155,9 +156,9 @@ H264SpsPpsTracker::PacketAction H264SpsPpsTracker::CopyAndFixBitstream(
|
||||
pps_info.type = H264::NaluType::kPps;
|
||||
pps_info.sps_id = sps->first;
|
||||
pps_info.pps_id = pps->first;
|
||||
if (codec_header->nalus_length + 2 <= kMaxNalusPerPacket) {
|
||||
codec_header->nalus[codec_header->nalus_length++] = sps_info;
|
||||
codec_header->nalus[codec_header->nalus_length++] = pps_info;
|
||||
if (h264_header.nalus_length + 2 <= kMaxNalusPerPacket) {
|
||||
h264_header.nalus[h264_header.nalus_length++] = sps_info;
|
||||
h264_header.nalus[h264_header.nalus_length++] = pps_info;
|
||||
} else {
|
||||
RTC_LOG(LS_WARNING) << "Not enough space in H.264 codec header to insert "
|
||||
"SPS/PPS provided out-of-band.";
|
||||
@ -165,7 +166,7 @@ H264SpsPpsTracker::PacketAction H264SpsPpsTracker::CopyAndFixBitstream(
|
||||
}
|
||||
|
||||
// Copy the rest of the bitstream and insert start codes.
|
||||
if (codec_header->packetization_type == kH264StapA) {
|
||||
if (h264_header.packetization_type == kH264StapA) {
|
||||
const uint8_t* nalu_ptr = data + 1;
|
||||
while (nalu_ptr < data + data_size) {
|
||||
memcpy(insert_at, start_code_h264, sizeof(start_code_h264));
|
||||
|
||||
@ -46,21 +46,29 @@ void ExpectSpsPpsIdr(const RTPVideoHeaderH264& codec_header,
|
||||
EXPECT_TRUE(contains_idr);
|
||||
}
|
||||
|
||||
class H264VcmPacket : public VCMPacket {
|
||||
public:
|
||||
H264VcmPacket() {
|
||||
codec = kVideoCodecH264;
|
||||
video_header.is_first_packet_in_frame = false;
|
||||
auto& type_header =
|
||||
video_header.video_type_header.emplace<RTPVideoHeaderH264>();
|
||||
type_header.nalus_length = 0;
|
||||
type_header.packetization_type = kH264SingleNalu;
|
||||
}
|
||||
|
||||
RTPVideoHeaderH264& h264() {
|
||||
return absl::get<RTPVideoHeaderH264>(video_header.video_type_header);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
class TestH264SpsPpsTracker : public ::testing::Test {
|
||||
public:
|
||||
VCMPacket GetDefaultPacket() {
|
||||
VCMPacket packet;
|
||||
packet.codec = kVideoCodecH264;
|
||||
packet.video_header.h264().nalus_length = 0;
|
||||
packet.video_header.is_first_packet_in_frame = false;
|
||||
packet.video_header.h264().packetization_type = kH264SingleNalu;
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
void AddSps(VCMPacket* packet, uint8_t sps_id, std::vector<uint8_t>* data) {
|
||||
void AddSps(H264VcmPacket* packet,
|
||||
uint8_t sps_id,
|
||||
std::vector<uint8_t>* data) {
|
||||
NaluInfo info;
|
||||
info.type = H264::NaluType::kSps;
|
||||
info.sps_id = sps_id;
|
||||
@ -68,11 +76,10 @@ class TestH264SpsPpsTracker : public ::testing::Test {
|
||||
data->push_back(H264::NaluType::kSps);
|
||||
data->push_back(sps_id); // The sps data, just a single byte.
|
||||
|
||||
packet->video_header.h264()
|
||||
.nalus[packet->video_header.h264().nalus_length++] = info;
|
||||
packet->h264().nalus[packet->h264().nalus_length++] = info;
|
||||
}
|
||||
|
||||
void AddPps(VCMPacket* packet,
|
||||
void AddPps(H264VcmPacket* packet,
|
||||
uint8_t sps_id,
|
||||
uint8_t pps_id,
|
||||
std::vector<uint8_t>* data) {
|
||||
@ -83,18 +90,16 @@ class TestH264SpsPpsTracker : public ::testing::Test {
|
||||
data->push_back(H264::NaluType::kPps);
|
||||
data->push_back(pps_id); // The pps data, just a single byte.
|
||||
|
||||
packet->video_header.h264()
|
||||
.nalus[packet->video_header.h264().nalus_length++] = info;
|
||||
packet->h264().nalus[packet->h264().nalus_length++] = info;
|
||||
}
|
||||
|
||||
void AddIdr(VCMPacket* packet, int pps_id) {
|
||||
void AddIdr(H264VcmPacket* packet, int pps_id) {
|
||||
NaluInfo info;
|
||||
info.type = H264::NaluType::kIdr;
|
||||
info.sps_id = -1;
|
||||
info.pps_id = pps_id;
|
||||
|
||||
packet->video_header.h264()
|
||||
.nalus[packet->video_header.h264().nalus_length++] = info;
|
||||
packet->h264().nalus[packet->h264().nalus_length++] = info;
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -103,8 +108,8 @@ class TestH264SpsPpsTracker : public ::testing::Test {
|
||||
|
||||
TEST_F(TestH264SpsPpsTracker, NoNalus) {
|
||||
uint8_t data[] = {1, 2, 3};
|
||||
VCMPacket packet = GetDefaultPacket();
|
||||
packet.video_header.h264().packetization_type = kH264FuA;
|
||||
H264VcmPacket packet;
|
||||
packet.h264().packetization_type = kH264FuA;
|
||||
packet.dataPtr = data;
|
||||
packet.sizeBytes = sizeof(data);
|
||||
|
||||
@ -115,8 +120,8 @@ TEST_F(TestH264SpsPpsTracker, NoNalus) {
|
||||
|
||||
TEST_F(TestH264SpsPpsTracker, FuAFirstPacket) {
|
||||
uint8_t data[] = {1, 2, 3};
|
||||
VCMPacket packet = GetDefaultPacket();
|
||||
packet.video_header.h264().packetization_type = kH264FuA;
|
||||
H264VcmPacket packet;
|
||||
packet.h264().packetization_type = kH264FuA;
|
||||
packet.video_header.is_first_packet_in_frame = true;
|
||||
packet.dataPtr = data;
|
||||
packet.sizeBytes = sizeof(data);
|
||||
@ -131,8 +136,8 @@ TEST_F(TestH264SpsPpsTracker, FuAFirstPacket) {
|
||||
|
||||
TEST_F(TestH264SpsPpsTracker, StapAIncorrectSegmentLength) {
|
||||
uint8_t data[] = {0, 0, 2, 0};
|
||||
VCMPacket packet = GetDefaultPacket();
|
||||
packet.video_header.h264().packetization_type = kH264StapA;
|
||||
H264VcmPacket packet;
|
||||
packet.h264().packetization_type = kH264StapA;
|
||||
packet.video_header.is_first_packet_in_frame = true;
|
||||
packet.dataPtr = data;
|
||||
packet.sizeBytes = sizeof(data);
|
||||
@ -142,7 +147,7 @@ TEST_F(TestH264SpsPpsTracker, StapAIncorrectSegmentLength) {
|
||||
|
||||
TEST_F(TestH264SpsPpsTracker, NoNalusFirstPacket) {
|
||||
uint8_t data[] = {1, 2, 3};
|
||||
VCMPacket packet = GetDefaultPacket();
|
||||
H264VcmPacket packet;
|
||||
packet.video_header.is_first_packet_in_frame = true;
|
||||
packet.dataPtr = data;
|
||||
packet.sizeBytes = sizeof(data);
|
||||
@ -157,8 +162,8 @@ TEST_F(TestH264SpsPpsTracker, NoNalusFirstPacket) {
|
||||
|
||||
TEST_F(TestH264SpsPpsTracker, IdrNoSpsPpsInserted) {
|
||||
std::vector<uint8_t> data = {1, 2, 3};
|
||||
VCMPacket packet = GetDefaultPacket();
|
||||
packet.video_header.h264().packetization_type = kH264FuA;
|
||||
H264VcmPacket packet;
|
||||
packet.h264().packetization_type = kH264FuA;
|
||||
|
||||
AddIdr(&packet, 0);
|
||||
packet.dataPtr = data.data();
|
||||
@ -171,7 +176,7 @@ TEST_F(TestH264SpsPpsTracker, IdrNoSpsPpsInserted) {
|
||||
|
||||
TEST_F(TestH264SpsPpsTracker, IdrFirstPacketNoSpsPpsInserted) {
|
||||
std::vector<uint8_t> data = {1, 2, 3};
|
||||
VCMPacket packet = GetDefaultPacket();
|
||||
H264VcmPacket packet;
|
||||
packet.video_header.is_first_packet_in_frame = true;
|
||||
|
||||
AddIdr(&packet, 0);
|
||||
@ -184,7 +189,7 @@ TEST_F(TestH264SpsPpsTracker, IdrFirstPacketNoSpsPpsInserted) {
|
||||
|
||||
TEST_F(TestH264SpsPpsTracker, IdrFirstPacketNoPpsInserted) {
|
||||
std::vector<uint8_t> data = {1, 2, 3};
|
||||
VCMPacket packet = GetDefaultPacket();
|
||||
H264VcmPacket packet;
|
||||
packet.video_header.is_first_packet_in_frame = true;
|
||||
|
||||
AddSps(&packet, 0, &data);
|
||||
@ -198,7 +203,7 @@ TEST_F(TestH264SpsPpsTracker, IdrFirstPacketNoPpsInserted) {
|
||||
|
||||
TEST_F(TestH264SpsPpsTracker, IdrFirstPacketNoSpsInserted) {
|
||||
std::vector<uint8_t> data = {1, 2, 3};
|
||||
VCMPacket packet = GetDefaultPacket();
|
||||
H264VcmPacket packet;
|
||||
packet.video_header.is_first_packet_in_frame = true;
|
||||
|
||||
AddPps(&packet, 0, 0, &data);
|
||||
@ -212,7 +217,7 @@ TEST_F(TestH264SpsPpsTracker, IdrFirstPacketNoSpsInserted) {
|
||||
|
||||
TEST_F(TestH264SpsPpsTracker, SpsPpsPacketThenIdrFirstPacket) {
|
||||
std::vector<uint8_t> data;
|
||||
VCMPacket sps_pps_packet = GetDefaultPacket();
|
||||
H264VcmPacket sps_pps_packet;
|
||||
|
||||
// Insert SPS/PPS
|
||||
AddSps(&sps_pps_packet, 0, &data);
|
||||
@ -225,7 +230,7 @@ TEST_F(TestH264SpsPpsTracker, SpsPpsPacketThenIdrFirstPacket) {
|
||||
data.clear();
|
||||
|
||||
// Insert first packet of the IDR
|
||||
VCMPacket idr_packet = GetDefaultPacket();
|
||||
H264VcmPacket idr_packet;
|
||||
idr_packet.video_header.is_first_packet_in_frame = true;
|
||||
AddIdr(&idr_packet, 1);
|
||||
data.insert(data.end(), {1, 2, 3});
|
||||
@ -243,8 +248,8 @@ TEST_F(TestH264SpsPpsTracker, SpsPpsPacketThenIdrFirstPacket) {
|
||||
|
||||
TEST_F(TestH264SpsPpsTracker, SpsPpsIdrInStapA) {
|
||||
std::vector<uint8_t> data;
|
||||
VCMPacket packet = GetDefaultPacket();
|
||||
packet.video_header.h264().packetization_type = kH264StapA;
|
||||
H264VcmPacket packet;
|
||||
packet.h264().packetization_type = kH264StapA;
|
||||
packet.video_header.is_first_packet_in_frame = true; // Always true for StapA
|
||||
|
||||
data.insert(data.end(), {0}); // First byte is ignored
|
||||
@ -284,18 +289,18 @@ TEST_F(TestH264SpsPpsTracker, SpsPpsOutOfBand) {
|
||||
tracker_.InsertSpsPpsNalus(sps, pps);
|
||||
|
||||
// Insert first packet of the IDR.
|
||||
VCMPacket idr_packet = GetDefaultPacket();
|
||||
H264VcmPacket idr_packet;
|
||||
idr_packet.video_header.is_first_packet_in_frame = true;
|
||||
AddIdr(&idr_packet, 0);
|
||||
idr_packet.dataPtr = kData;
|
||||
idr_packet.sizeBytes = sizeof(kData);
|
||||
EXPECT_EQ(1u, idr_packet.video_header.h264().nalus_length);
|
||||
EXPECT_EQ(1u, idr_packet.h264().nalus_length);
|
||||
EXPECT_EQ(H264SpsPpsTracker::kInsert,
|
||||
tracker_.CopyAndFixBitstream(&idr_packet));
|
||||
EXPECT_EQ(3u, idr_packet.video_header.h264().nalus_length);
|
||||
EXPECT_EQ(3u, idr_packet.h264().nalus_length);
|
||||
EXPECT_EQ(320, idr_packet.width);
|
||||
EXPECT_EQ(240, idr_packet.height);
|
||||
ExpectSpsPpsIdr(idr_packet.video_header.h264(), 0, 0);
|
||||
ExpectSpsPpsIdr(idr_packet.h264(), 0, 0);
|
||||
|
||||
if (idr_packet.dataPtr != kData) {
|
||||
// In case CopyAndFixBitStream() prepends SPS/PPS nalus to the packet, it
|
||||
@ -317,7 +322,7 @@ TEST_F(TestH264SpsPpsTracker, SpsPpsOutOfBandWrongNaluHeader) {
|
||||
tracker_.InsertSpsPpsNalus(sps, pps);
|
||||
|
||||
// Insert first packet of the IDR.
|
||||
VCMPacket idr_packet = GetDefaultPacket();
|
||||
H264VcmPacket idr_packet;
|
||||
idr_packet.video_header.is_first_packet_in_frame = true;
|
||||
AddIdr(&idr_packet, 0);
|
||||
idr_packet.dataPtr = kData;
|
||||
@ -336,7 +341,7 @@ TEST_F(TestH264SpsPpsTracker, SpsPpsOutOfBandIncompleteNalu) {
|
||||
tracker_.InsertSpsPpsNalus(sps, pps);
|
||||
|
||||
// Insert first packet of the IDR.
|
||||
VCMPacket idr_packet = GetDefaultPacket();
|
||||
H264VcmPacket idr_packet;
|
||||
idr_packet.video_header.is_first_packet_in_frame = true;
|
||||
AddIdr(&idr_packet, 0);
|
||||
idr_packet.dataPtr = kData;
|
||||
@ -350,7 +355,7 @@ TEST_F(TestH264SpsPpsTracker, SaveRestoreWidthHeight) {
|
||||
|
||||
// Insert an SPS/PPS packet with width/height and make sure
|
||||
// that information is set on the first IDR packet.
|
||||
VCMPacket sps_pps_packet = GetDefaultPacket();
|
||||
H264VcmPacket sps_pps_packet;
|
||||
AddSps(&sps_pps_packet, 0, &data);
|
||||
AddPps(&sps_pps_packet, 0, 1, &data);
|
||||
sps_pps_packet.dataPtr = data.data();
|
||||
@ -361,7 +366,7 @@ TEST_F(TestH264SpsPpsTracker, SaveRestoreWidthHeight) {
|
||||
tracker_.CopyAndFixBitstream(&sps_pps_packet));
|
||||
delete[] sps_pps_packet.dataPtr;
|
||||
|
||||
VCMPacket idr_packet = GetDefaultPacket();
|
||||
H264VcmPacket idr_packet;
|
||||
idr_packet.video_header.is_first_packet_in_frame = true;
|
||||
AddIdr(&idr_packet, 1);
|
||||
data.insert(data.end(), {1, 2, 3});
|
||||
|
||||
@ -1155,17 +1155,19 @@ TEST_F(TestBasicJitterBuffer, H264InsertStartCode) {
|
||||
TEST_F(TestBasicJitterBuffer, SpsAndPpsHandling) {
|
||||
jitter_buffer_->SetDecodeErrorMode(kNoErrors);
|
||||
|
||||
auto& h264_header =
|
||||
packet_->video_header.video_type_header.emplace<RTPVideoHeaderH264>();
|
||||
packet_->timestamp = timestamp_;
|
||||
packet_->frameType = kVideoFrameKey;
|
||||
packet_->is_first_packet_in_frame = true;
|
||||
packet_->markerBit = true;
|
||||
packet_->codec = kVideoCodecH264;
|
||||
packet_->video_header.codec = kVideoCodecH264;
|
||||
packet_->video_header.h264().nalu_type = H264::NaluType::kIdr;
|
||||
packet_->video_header.h264().nalus[0].type = H264::NaluType::kIdr;
|
||||
packet_->video_header.h264().nalus[0].sps_id = -1;
|
||||
packet_->video_header.h264().nalus[0].pps_id = 0;
|
||||
packet_->video_header.h264().nalus_length = 1;
|
||||
h264_header.nalu_type = H264::NaluType::kIdr;
|
||||
h264_header.nalus[0].type = H264::NaluType::kIdr;
|
||||
h264_header.nalus[0].sps_id = -1;
|
||||
h264_header.nalus[0].pps_id = 0;
|
||||
h264_header.nalus_length = 1;
|
||||
bool retransmitted = false;
|
||||
EXPECT_EQ(kCompleteSession,
|
||||
jitter_buffer_->InsertPacket(*packet_, &retransmitted));
|
||||
@ -1181,14 +1183,14 @@ TEST_F(TestBasicJitterBuffer, SpsAndPpsHandling) {
|
||||
packet_->markerBit = false;
|
||||
packet_->codec = kVideoCodecH264;
|
||||
packet_->video_header.codec = kVideoCodecH264;
|
||||
packet_->video_header.h264().nalu_type = H264::NaluType::kStapA;
|
||||
packet_->video_header.h264().nalus[0].type = H264::NaluType::kSps;
|
||||
packet_->video_header.h264().nalus[0].sps_id = 0;
|
||||
packet_->video_header.h264().nalus[0].pps_id = -1;
|
||||
packet_->video_header.h264().nalus[1].type = H264::NaluType::kPps;
|
||||
packet_->video_header.h264().nalus[1].sps_id = 0;
|
||||
packet_->video_header.h264().nalus[1].pps_id = 0;
|
||||
packet_->video_header.h264().nalus_length = 2;
|
||||
h264_header.nalu_type = H264::NaluType::kStapA;
|
||||
h264_header.nalus[0].type = H264::NaluType::kSps;
|
||||
h264_header.nalus[0].sps_id = 0;
|
||||
h264_header.nalus[0].pps_id = -1;
|
||||
h264_header.nalus[1].type = H264::NaluType::kPps;
|
||||
h264_header.nalus[1].sps_id = 0;
|
||||
h264_header.nalus[1].pps_id = 0;
|
||||
h264_header.nalus_length = 2;
|
||||
// Not complete since the marker bit hasn't been received.
|
||||
EXPECT_EQ(kIncomplete,
|
||||
jitter_buffer_->InsertPacket(*packet_, &retransmitted));
|
||||
@ -1200,11 +1202,11 @@ TEST_F(TestBasicJitterBuffer, SpsAndPpsHandling) {
|
||||
packet_->markerBit = true;
|
||||
packet_->codec = kVideoCodecH264;
|
||||
packet_->video_header.codec = kVideoCodecH264;
|
||||
packet_->video_header.h264().nalu_type = H264::NaluType::kIdr;
|
||||
packet_->video_header.h264().nalus[0].type = H264::NaluType::kIdr;
|
||||
packet_->video_header.h264().nalus[0].sps_id = -1;
|
||||
packet_->video_header.h264().nalus[0].pps_id = 0;
|
||||
packet_->video_header.h264().nalus_length = 1;
|
||||
h264_header.nalu_type = H264::NaluType::kIdr;
|
||||
h264_header.nalus[0].type = H264::NaluType::kIdr;
|
||||
h264_header.nalus[0].sps_id = -1;
|
||||
h264_header.nalus[0].pps_id = 0;
|
||||
h264_header.nalus_length = 1;
|
||||
// Complete and decodable since the pps and sps are received in the first
|
||||
// packet of this frame.
|
||||
EXPECT_EQ(kCompleteSession,
|
||||
@ -1222,11 +1224,11 @@ TEST_F(TestBasicJitterBuffer, SpsAndPpsHandling) {
|
||||
packet_->markerBit = true;
|
||||
packet_->codec = kVideoCodecH264;
|
||||
packet_->video_header.codec = kVideoCodecH264;
|
||||
packet_->video_header.h264().nalu_type = H264::NaluType::kSlice;
|
||||
packet_->video_header.h264().nalus[0].type = H264::NaluType::kSlice;
|
||||
packet_->video_header.h264().nalus[0].sps_id = -1;
|
||||
packet_->video_header.h264().nalus[0].pps_id = 0;
|
||||
packet_->video_header.h264().nalus_length = 1;
|
||||
h264_header.nalu_type = H264::NaluType::kSlice;
|
||||
h264_header.nalus[0].type = H264::NaluType::kSlice;
|
||||
h264_header.nalus[0].sps_id = -1;
|
||||
h264_header.nalus[0].pps_id = 0;
|
||||
h264_header.nalus_length = 1;
|
||||
// Complete and decodable since sps, pps and key frame has been received.
|
||||
EXPECT_EQ(kCompleteSession,
|
||||
jitter_buffer_->InsertPacket(*packet_, &retransmitted));
|
||||
|
||||
@ -303,18 +303,17 @@ std::vector<std::unique_ptr<RtpFrameObject>> PacketBuffer::FindFrames(
|
||||
break;
|
||||
|
||||
if (is_h264 && !is_h264_keyframe) {
|
||||
const RTPVideoHeaderH264& header =
|
||||
data_buffer_[start_index].video_header.h264();
|
||||
|
||||
if (header.nalus_length >= kMaxNalusPerPacket)
|
||||
const auto* h264_header = absl::get_if<RTPVideoHeaderH264>(
|
||||
&data_buffer_[start_index].video_header.video_type_header);
|
||||
if (!h264_header || h264_header->nalus_length >= kMaxNalusPerPacket)
|
||||
return found_frames;
|
||||
|
||||
for (size_t j = 0; j < header.nalus_length; ++j) {
|
||||
if (header.nalus[j].type == H264::NaluType::kSps) {
|
||||
for (size_t j = 0; j < h264_header->nalus_length; ++j) {
|
||||
if (h264_header->nalus[j].type == H264::NaluType::kSps) {
|
||||
has_h264_sps = true;
|
||||
} else if (header.nalus[j].type == H264::NaluType::kPps) {
|
||||
} else if (h264_header->nalus[j].type == H264::NaluType::kPps) {
|
||||
has_h264_pps = true;
|
||||
} else if (header.nalus[j].type == H264::NaluType::kIdr) {
|
||||
} else if (h264_header->nalus[j].type == H264::NaluType::kIdr) {
|
||||
has_h264_idr = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,8 +112,10 @@ std::vector<NaluInfo> VCMSessionInfo::GetNaluInfos() const {
|
||||
return std::vector<NaluInfo>();
|
||||
std::vector<NaluInfo> nalu_infos;
|
||||
for (const VCMPacket& packet : packets_) {
|
||||
for (size_t i = 0; i < packet.video_header.h264().nalus_length; ++i) {
|
||||
nalu_infos.push_back(packet.video_header.h264().nalus[i]);
|
||||
const auto& h264 =
|
||||
absl::get<RTPVideoHeaderH264>(packet.video_header.video_type_header);
|
||||
for (size_t i = 0; i < h264.nalus_length; ++i) {
|
||||
nalu_infos.push_back(h264.nalus[i]);
|
||||
}
|
||||
}
|
||||
return nalu_infos;
|
||||
@ -177,8 +179,9 @@ size_t VCMSessionInfo::InsertBuffer(uint8_t* frame_buffer,
|
||||
// header supplied by the H264 depacketizer.
|
||||
const size_t kH264NALHeaderLengthInBytes = 1;
|
||||
const size_t kLengthFieldLength = 2;
|
||||
if (packet.video_header.codec == kVideoCodecH264 &&
|
||||
packet.video_header.h264().packetization_type == kH264StapA) {
|
||||
const auto* h264 =
|
||||
absl::get_if<RTPVideoHeaderH264>(&packet.video_header.video_type_header);
|
||||
if (h264 && h264->packetization_type == kH264StapA) {
|
||||
size_t required_length = 0;
|
||||
const uint8_t* nalu_ptr = packet_buffer + kH264NALHeaderLengthInBytes;
|
||||
while (nalu_ptr < packet_buffer + packet.sizeBytes) {
|
||||
|
||||
@ -508,17 +508,19 @@ class TestPacketBufferH264 : public TestPacketBuffer {
|
||||
uint8_t* data = nullptr) { // data pointer
|
||||
VCMPacket packet;
|
||||
packet.codec = kVideoCodecH264;
|
||||
auto& h264_header =
|
||||
packet.video_header.video_type_header.emplace<RTPVideoHeaderH264>();
|
||||
packet.seqNum = seq_num;
|
||||
packet.timestamp = timestamp;
|
||||
if (keyframe == kKeyFrame) {
|
||||
if (sps_pps_idr_is_keyframe_) {
|
||||
packet.video_header.h264().nalus[0].type = H264::NaluType::kSps;
|
||||
packet.video_header.h264().nalus[1].type = H264::NaluType::kPps;
|
||||
packet.video_header.h264().nalus[2].type = H264::NaluType::kIdr;
|
||||
packet.video_header.h264().nalus_length = 3;
|
||||
h264_header.nalus[0].type = H264::NaluType::kSps;
|
||||
h264_header.nalus[1].type = H264::NaluType::kPps;
|
||||
h264_header.nalus[2].type = H264::NaluType::kIdr;
|
||||
h264_header.nalus_length = 3;
|
||||
} else {
|
||||
packet.video_header.h264().nalus[0].type = H264::NaluType::kIdr;
|
||||
packet.video_header.h264().nalus_length = 1;
|
||||
h264_header.nalus[0].type = H264::NaluType::kIdr;
|
||||
h264_header.nalus_length = 1;
|
||||
}
|
||||
}
|
||||
packet.is_first_packet_in_frame = first == kFirst;
|
||||
@ -592,12 +594,14 @@ TEST_P(TestPacketBufferH264Parameterized, GetBitstreamBufferPadding) {
|
||||
new uint8_t[sizeof(data_data) + EncodedImage::kBufferPaddingBytesH264]);
|
||||
|
||||
VCMPacket packet;
|
||||
packet.video_header.h264().nalus_length = 1;
|
||||
packet.video_header.h264().nalus[0].type = H264::NaluType::kIdr;
|
||||
auto& h264_header =
|
||||
packet.video_header.video_type_header.emplace<RTPVideoHeaderH264>();
|
||||
h264_header.nalus_length = 1;
|
||||
h264_header.nalus[0].type = H264::NaluType::kIdr;
|
||||
h264_header.packetization_type = kH264SingleNalu;
|
||||
packet.seqNum = seq_num;
|
||||
packet.codec = kVideoCodecH264;
|
||||
packet.insertStartCode = true;
|
||||
packet.video_header.h264().packetization_type = kH264SingleNalu;
|
||||
packet.dataPtr = data;
|
||||
packet.sizeBytes = sizeof(data_data);
|
||||
packet.is_first_packet_in_frame = true;
|
||||
@ -755,7 +759,9 @@ TEST_F(TestPacketBuffer, IncomingCodecChange) {
|
||||
EXPECT_TRUE(packet_buffer_->InsertPacket(&packet));
|
||||
|
||||
packet.codec = kVideoCodecH264;
|
||||
packet.video_header.h264().nalus_length = 1;
|
||||
auto& h264_header =
|
||||
packet.video_header.video_type_header.emplace<RTPVideoHeaderH264>();
|
||||
h264_header.nalus_length = 1;
|
||||
packet.timestamp = 3;
|
||||
packet.seqNum = 3;
|
||||
EXPECT_TRUE(packet_buffer_->InsertPacket(&packet));
|
||||
@ -778,7 +784,9 @@ TEST_F(TestPacketBuffer, TooManyNalusInPacket) {
|
||||
packet.frameType = kVideoFrameKey;
|
||||
packet.is_first_packet_in_frame = true;
|
||||
packet.markerBit = true;
|
||||
packet.video_header.h264().nalus_length = kMaxNalusPerPacket;
|
||||
auto& h264_header =
|
||||
packet.video_header.video_type_header.emplace<RTPVideoHeaderH264>();
|
||||
h264_header.nalus_length = kMaxNalusPerPacket;
|
||||
packet.sizeBytes = 0;
|
||||
packet.dataPtr = nullptr;
|
||||
EXPECT_TRUE(packet_buffer_->InsertPacket(&packet));
|
||||
@ -873,9 +881,10 @@ class TestPacketBufferH264IdrIsKeyframe
|
||||
};
|
||||
|
||||
TEST_F(TestPacketBufferH264IdrIsKeyframe, IdrIsKeyframe) {
|
||||
packet_.video_header.h264().nalus[0].type = H264::NaluType::kIdr;
|
||||
packet_.video_header.h264().nalus_length = 1;
|
||||
|
||||
auto& h264_header =
|
||||
packet_.video_header.video_type_header.emplace<RTPVideoHeaderH264>();
|
||||
h264_header.nalus[0].type = H264::NaluType::kIdr;
|
||||
h264_header.nalus_length = 1;
|
||||
packet_buffer_->InsertPacket(&packet_);
|
||||
|
||||
ASSERT_EQ(1u, frames_from_callback_.size());
|
||||
@ -883,10 +892,12 @@ TEST_F(TestPacketBufferH264IdrIsKeyframe, IdrIsKeyframe) {
|
||||
}
|
||||
|
||||
TEST_F(TestPacketBufferH264IdrIsKeyframe, SpsPpsIdrIsKeyframe) {
|
||||
packet_.video_header.h264().nalus[0].type = H264::NaluType::kSps;
|
||||
packet_.video_header.h264().nalus[1].type = H264::NaluType::kPps;
|
||||
packet_.video_header.h264().nalus[2].type = H264::NaluType::kIdr;
|
||||
packet_.video_header.h264().nalus_length = 3;
|
||||
auto& h264_header =
|
||||
packet_.video_header.video_type_header.emplace<RTPVideoHeaderH264>();
|
||||
h264_header.nalus[0].type = H264::NaluType::kSps;
|
||||
h264_header.nalus[1].type = H264::NaluType::kPps;
|
||||
h264_header.nalus[2].type = H264::NaluType::kIdr;
|
||||
h264_header.nalus_length = 3;
|
||||
|
||||
packet_buffer_->InsertPacket(&packet_);
|
||||
|
||||
@ -902,8 +913,10 @@ class TestPacketBufferH264SpsPpsIdrIsKeyframe
|
||||
};
|
||||
|
||||
TEST_F(TestPacketBufferH264SpsPpsIdrIsKeyframe, IdrIsNotKeyframe) {
|
||||
packet_.video_header.h264().nalus[0].type = H264::NaluType::kIdr;
|
||||
packet_.video_header.h264().nalus_length = 1;
|
||||
auto& h264_header =
|
||||
packet_.video_header.video_type_header.emplace<RTPVideoHeaderH264>();
|
||||
h264_header.nalus[0].type = H264::NaluType::kIdr;
|
||||
h264_header.nalus_length = 1;
|
||||
|
||||
packet_buffer_->InsertPacket(&packet_);
|
||||
|
||||
@ -912,9 +925,11 @@ TEST_F(TestPacketBufferH264SpsPpsIdrIsKeyframe, IdrIsNotKeyframe) {
|
||||
}
|
||||
|
||||
TEST_F(TestPacketBufferH264SpsPpsIdrIsKeyframe, SpsPpsIsNotKeyframe) {
|
||||
packet_.video_header.h264().nalus[0].type = H264::NaluType::kSps;
|
||||
packet_.video_header.h264().nalus[1].type = H264::NaluType::kPps;
|
||||
packet_.video_header.h264().nalus_length = 2;
|
||||
auto& h264_header =
|
||||
packet_.video_header.video_type_header.emplace<RTPVideoHeaderH264>();
|
||||
h264_header.nalus[0].type = H264::NaluType::kSps;
|
||||
h264_header.nalus[1].type = H264::NaluType::kPps;
|
||||
h264_header.nalus_length = 2;
|
||||
|
||||
packet_buffer_->InsertPacket(&packet_);
|
||||
|
||||
@ -923,10 +938,12 @@ TEST_F(TestPacketBufferH264SpsPpsIdrIsKeyframe, SpsPpsIsNotKeyframe) {
|
||||
}
|
||||
|
||||
TEST_F(TestPacketBufferH264SpsPpsIdrIsKeyframe, SpsPpsIdrIsKeyframe) {
|
||||
packet_.video_header.h264().nalus[0].type = H264::NaluType::kSps;
|
||||
packet_.video_header.h264().nalus[1].type = H264::NaluType::kPps;
|
||||
packet_.video_header.h264().nalus[2].type = H264::NaluType::kIdr;
|
||||
packet_.video_header.h264().nalus_length = 3;
|
||||
auto& h264_header =
|
||||
packet_.video_header.video_type_header.emplace<RTPVideoHeaderH264>();
|
||||
h264_header.nalus[0].type = H264::NaluType::kSps;
|
||||
h264_header.nalus[1].type = H264::NaluType::kPps;
|
||||
h264_header.nalus[2].type = H264::NaluType::kIdr;
|
||||
h264_header.nalus_length = 3;
|
||||
|
||||
packet_buffer_->InsertPacket(&packet_);
|
||||
|
||||
|
||||
@ -98,8 +98,7 @@ TEST_F(TestVideoReceiver, PaddingOnlyFrames) {
|
||||
0, receiver_->RegisterPacketRequestCallback(&packet_request_callback_));
|
||||
const size_t kPaddingSize = 220;
|
||||
const uint8_t payload[kPaddingSize] = {0};
|
||||
WebRtcRTPHeader header;
|
||||
memset(&header, 0, sizeof(header));
|
||||
WebRtcRTPHeader header = {};
|
||||
header.frameType = kEmptyFrame;
|
||||
header.header.markerBit = false;
|
||||
header.header.paddingLength = kPaddingSize;
|
||||
@ -122,8 +121,7 @@ TEST_F(TestVideoReceiver, PaddingOnlyFramesWithLosses) {
|
||||
const size_t kFrameSize = 1200;
|
||||
const size_t kPaddingSize = 220;
|
||||
const uint8_t payload[kFrameSize] = {0};
|
||||
WebRtcRTPHeader header;
|
||||
memset(&header, 0, sizeof(header));
|
||||
WebRtcRTPHeader header = {};
|
||||
header.frameType = kEmptyFrame;
|
||||
header.header.markerBit = false;
|
||||
header.header.paddingLength = kPaddingSize;
|
||||
@ -173,8 +171,7 @@ TEST_F(TestVideoReceiver, PaddingOnlyAndVideo) {
|
||||
const size_t kFrameSize = 1200;
|
||||
const size_t kPaddingSize = 220;
|
||||
const uint8_t payload[kFrameSize] = {0};
|
||||
WebRtcRTPHeader header;
|
||||
memset(&header, 0, sizeof(header));
|
||||
WebRtcRTPHeader header = {};
|
||||
header.frameType = kEmptyFrame;
|
||||
header.video_header().is_first_packet_in_frame = false;
|
||||
header.header.markerBit = false;
|
||||
|
||||
Reference in New Issue
Block a user