Revert "Remove RTPVideoHeader::h264() accessors."
This reverts commit dfbced6504720d2c0807d7b92798eb80ba3f8be9.
Reason for revert: Crashes when making a video call.
#9 0x00000001043dd8d8 in webrtc::RTPVideoHeaderH264& absl::variant_internal::TypedThrowBadVariantAccess<webrtc::RTPVideoHeaderH264&>() at /third_party/absl/types/internal/variant.h:315
#10 0x00000001043dd8ac in absl::variant_internal::VariantAccessResultImpl<2ul, absl::variant<webrtc::RTPVideoHeaderVP8, webrtc::RTPVideoHeaderVP9, webrtc::RTPVideoHeaderH264>&&&>::type absl::variant_internal::VariantCoreAccess::CheckedAccess<2ul, absl::variant<webrtc::RTPVideoHeaderVP8, webrtc::RTPVideoHeaderVP9, webrtc::RTPVideoHeaderH264>&>(absl::variant<webrtc::RTPVideoHeaderVP8, webrtc::RTPVideoHeaderVP9, webrtc::RTPVideoHeaderH264>&&&) at /third_party/absl/types/internal/variant.h:597
#11 0x00000001043db778 in webrtc::RTPVideoHeaderH264& absl::get<webrtc::RTPVideoHeaderH264, webrtc::RTPVideoHeaderVP8, webrtc::RTPVideoHeaderVP9, webrtc::RTPVideoHeaderH264>(absl::variant<webrtc::RTPVideoHeaderVP8, webrtc::RTPVideoHeaderVP9, webrtc::RTPVideoHeaderH264>&) at /third_party/absl/types/variant.h:299
#12 0x0000000104558bcc in webrtc::RtpPacketizer::Create(webrtc::VideoCodecType, unsigned long, unsigned long, webrtc::RTPVideoHeader const*, webrtc::FrameType) at webrtc/modules/rtp_rtcp/source/rtp_format.cc:30
Original change's description:
> Remove RTPVideoHeader::h264() accessors.
>
> Bug: none
> Change-Id: I043bcaf358575688b223bc3631506e148b47fd58
> Reviewed-on: https://webrtc-review.googlesource.com/88220
> Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
> Commit-Queue: Philip Eliasson <philipel@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#23971}
TBR=danilchap@webrtc.org,stefan@webrtc.org,philipel@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: none
Change-Id: If99bcabdfe3cae7094f24e407bbe2f47233e46e3
Reviewed-on: https://webrtc-review.googlesource.com/88820
Commit-Queue: JT Teh <jtteh@webrtc.org>
Reviewed-by: Zeke Chin <tkchin@webrtc.org>
Reviewed-by: JT Teh <jtteh@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23993}
diff --git a/modules/video_coding/h264_sps_pps_tracker.cc b/modules/video_coding/h264_sps_pps_tracker.cc
index d67d827..51931f8 100644
--- a/modules/video_coding/h264_sps_pps_tracker.cc
+++ b/modules/video_coding/h264_sps_pps_tracker.cc
@@ -36,15 +36,14 @@
const uint8_t* data = packet->dataPtr;
const size_t data_size = packet->sizeBytes;
const RTPVideoHeader& video_header = packet->video_header;
- auto& h264_header =
- absl::get<RTPVideoHeaderH264>(packet->video_header.video_type_header);
+ RTPVideoHeaderH264* codec_header = &packet->video_header.h264();
bool append_sps_pps = false;
auto sps = sps_data_.end();
auto pps = pps_data_.end();
- for (size_t i = 0; i < h264_header.nalus_length; ++i) {
- const NaluInfo& nalu = h264_header.nalus[i];
+ for (size_t i = 0; i < codec_header->nalus_length; ++i) {
+ const NaluInfo& nalu = codec_header->nalus[i];
switch (nalu.type) {
case H264::NaluType::kSps: {
sps_data_[nalu.sps_id].width = packet->width;
@@ -111,7 +110,7 @@
required_size += pps->second.size + sizeof(start_code_h264);
}
- if (h264_header.packetization_type == kH264StapA) {
+ if (codec_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);
@@ -156,9 +155,9 @@
pps_info.type = H264::NaluType::kPps;
pps_info.sps_id = sps->first;
pps_info.pps_id = pps->first;
- 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;
+ 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;
} else {
RTC_LOG(LS_WARNING) << "Not enough space in H.264 codec header to insert "
"SPS/PPS provided out-of-band.";
@@ -166,7 +165,7 @@
}
// Copy the rest of the bitstream and insert start codes.
- if (h264_header.packetization_type == kH264StapA) {
+ if (codec_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));
diff --git a/modules/video_coding/h264_sps_pps_tracker_unittest.cc b/modules/video_coding/h264_sps_pps_tracker_unittest.cc
index dad8294..4b43955 100644
--- a/modules/video_coding/h264_sps_pps_tracker_unittest.cc
+++ b/modules/video_coding/h264_sps_pps_tracker_unittest.cc
@@ -46,29 +46,21 @@
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:
- void AddSps(H264VcmPacket* packet,
- uint8_t sps_id,
- std::vector<uint8_t>* data) {
+ 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) {
NaluInfo info;
info.type = H264::NaluType::kSps;
info.sps_id = sps_id;
@@ -76,10 +68,11 @@
data->push_back(H264::NaluType::kSps);
data->push_back(sps_id); // The sps data, just a single byte.
- packet->h264().nalus[packet->h264().nalus_length++] = info;
+ packet->video_header.h264()
+ .nalus[packet->video_header.h264().nalus_length++] = info;
}
- void AddPps(H264VcmPacket* packet,
+ void AddPps(VCMPacket* packet,
uint8_t sps_id,
uint8_t pps_id,
std::vector<uint8_t>* data) {
@@ -90,16 +83,18 @@
data->push_back(H264::NaluType::kPps);
data->push_back(pps_id); // The pps data, just a single byte.
- packet->h264().nalus[packet->h264().nalus_length++] = info;
+ packet->video_header.h264()
+ .nalus[packet->video_header.h264().nalus_length++] = info;
}
- void AddIdr(H264VcmPacket* packet, int pps_id) {
+ void AddIdr(VCMPacket* packet, int pps_id) {
NaluInfo info;
info.type = H264::NaluType::kIdr;
info.sps_id = -1;
info.pps_id = pps_id;
- packet->h264().nalus[packet->h264().nalus_length++] = info;
+ packet->video_header.h264()
+ .nalus[packet->video_header.h264().nalus_length++] = info;
}
protected:
@@ -108,8 +103,8 @@
TEST_F(TestH264SpsPpsTracker, NoNalus) {
uint8_t data[] = {1, 2, 3};
- H264VcmPacket packet;
- packet.h264().packetization_type = kH264FuA;
+ VCMPacket packet = GetDefaultPacket();
+ packet.video_header.h264().packetization_type = kH264FuA;
packet.dataPtr = data;
packet.sizeBytes = sizeof(data);
@@ -120,8 +115,8 @@
TEST_F(TestH264SpsPpsTracker, FuAFirstPacket) {
uint8_t data[] = {1, 2, 3};
- H264VcmPacket packet;
- packet.h264().packetization_type = kH264FuA;
+ VCMPacket packet = GetDefaultPacket();
+ packet.video_header.h264().packetization_type = kH264FuA;
packet.video_header.is_first_packet_in_frame = true;
packet.dataPtr = data;
packet.sizeBytes = sizeof(data);
@@ -136,8 +131,8 @@
TEST_F(TestH264SpsPpsTracker, StapAIncorrectSegmentLength) {
uint8_t data[] = {0, 0, 2, 0};
- H264VcmPacket packet;
- packet.h264().packetization_type = kH264StapA;
+ VCMPacket packet = GetDefaultPacket();
+ packet.video_header.h264().packetization_type = kH264StapA;
packet.video_header.is_first_packet_in_frame = true;
packet.dataPtr = data;
packet.sizeBytes = sizeof(data);
@@ -147,7 +142,7 @@
TEST_F(TestH264SpsPpsTracker, NoNalusFirstPacket) {
uint8_t data[] = {1, 2, 3};
- H264VcmPacket packet;
+ VCMPacket packet = GetDefaultPacket();
packet.video_header.is_first_packet_in_frame = true;
packet.dataPtr = data;
packet.sizeBytes = sizeof(data);
@@ -162,8 +157,8 @@
TEST_F(TestH264SpsPpsTracker, IdrNoSpsPpsInserted) {
std::vector<uint8_t> data = {1, 2, 3};
- H264VcmPacket packet;
- packet.h264().packetization_type = kH264FuA;
+ VCMPacket packet = GetDefaultPacket();
+ packet.video_header.h264().packetization_type = kH264FuA;
AddIdr(&packet, 0);
packet.dataPtr = data.data();
@@ -176,7 +171,7 @@
TEST_F(TestH264SpsPpsTracker, IdrFirstPacketNoSpsPpsInserted) {
std::vector<uint8_t> data = {1, 2, 3};
- H264VcmPacket packet;
+ VCMPacket packet = GetDefaultPacket();
packet.video_header.is_first_packet_in_frame = true;
AddIdr(&packet, 0);
@@ -189,7 +184,7 @@
TEST_F(TestH264SpsPpsTracker, IdrFirstPacketNoPpsInserted) {
std::vector<uint8_t> data = {1, 2, 3};
- H264VcmPacket packet;
+ VCMPacket packet = GetDefaultPacket();
packet.video_header.is_first_packet_in_frame = true;
AddSps(&packet, 0, &data);
@@ -203,7 +198,7 @@
TEST_F(TestH264SpsPpsTracker, IdrFirstPacketNoSpsInserted) {
std::vector<uint8_t> data = {1, 2, 3};
- H264VcmPacket packet;
+ VCMPacket packet = GetDefaultPacket();
packet.video_header.is_first_packet_in_frame = true;
AddPps(&packet, 0, 0, &data);
@@ -217,7 +212,7 @@
TEST_F(TestH264SpsPpsTracker, SpsPpsPacketThenIdrFirstPacket) {
std::vector<uint8_t> data;
- H264VcmPacket sps_pps_packet;
+ VCMPacket sps_pps_packet = GetDefaultPacket();
// Insert SPS/PPS
AddSps(&sps_pps_packet, 0, &data);
@@ -230,7 +225,7 @@
data.clear();
// Insert first packet of the IDR
- H264VcmPacket idr_packet;
+ VCMPacket idr_packet = GetDefaultPacket();
idr_packet.video_header.is_first_packet_in_frame = true;
AddIdr(&idr_packet, 1);
data.insert(data.end(), {1, 2, 3});
@@ -248,8 +243,8 @@
TEST_F(TestH264SpsPpsTracker, SpsPpsIdrInStapA) {
std::vector<uint8_t> data;
- H264VcmPacket packet;
- packet.h264().packetization_type = kH264StapA;
+ VCMPacket packet = GetDefaultPacket();
+ packet.video_header.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
@@ -289,18 +284,18 @@
tracker_.InsertSpsPpsNalus(sps, pps);
// Insert first packet of the IDR.
- H264VcmPacket idr_packet;
+ VCMPacket idr_packet = GetDefaultPacket();
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.h264().nalus_length);
+ EXPECT_EQ(1u, idr_packet.video_header.h264().nalus_length);
EXPECT_EQ(H264SpsPpsTracker::kInsert,
tracker_.CopyAndFixBitstream(&idr_packet));
- EXPECT_EQ(3u, idr_packet.h264().nalus_length);
+ EXPECT_EQ(3u, idr_packet.video_header.h264().nalus_length);
EXPECT_EQ(320, idr_packet.width);
EXPECT_EQ(240, idr_packet.height);
- ExpectSpsPpsIdr(idr_packet.h264(), 0, 0);
+ ExpectSpsPpsIdr(idr_packet.video_header.h264(), 0, 0);
if (idr_packet.dataPtr != kData) {
// In case CopyAndFixBitStream() prepends SPS/PPS nalus to the packet, it
@@ -322,7 +317,7 @@
tracker_.InsertSpsPpsNalus(sps, pps);
// Insert first packet of the IDR.
- H264VcmPacket idr_packet;
+ VCMPacket idr_packet = GetDefaultPacket();
idr_packet.video_header.is_first_packet_in_frame = true;
AddIdr(&idr_packet, 0);
idr_packet.dataPtr = kData;
@@ -341,7 +336,7 @@
tracker_.InsertSpsPpsNalus(sps, pps);
// Insert first packet of the IDR.
- H264VcmPacket idr_packet;
+ VCMPacket idr_packet = GetDefaultPacket();
idr_packet.video_header.is_first_packet_in_frame = true;
AddIdr(&idr_packet, 0);
idr_packet.dataPtr = kData;
@@ -355,7 +350,7 @@
// Insert an SPS/PPS packet with width/height and make sure
// that information is set on the first IDR packet.
- H264VcmPacket sps_pps_packet;
+ VCMPacket sps_pps_packet = GetDefaultPacket();
AddSps(&sps_pps_packet, 0, &data);
AddPps(&sps_pps_packet, 0, 1, &data);
sps_pps_packet.dataPtr = data.data();
@@ -366,7 +361,7 @@
tracker_.CopyAndFixBitstream(&sps_pps_packet));
delete[] sps_pps_packet.dataPtr;
- H264VcmPacket idr_packet;
+ VCMPacket idr_packet = GetDefaultPacket();
idr_packet.video_header.is_first_packet_in_frame = true;
AddIdr(&idr_packet, 1);
data.insert(data.end(), {1, 2, 3});
diff --git a/modules/video_coding/jitter_buffer_unittest.cc b/modules/video_coding/jitter_buffer_unittest.cc
index 756dc52..adb495d 100644
--- a/modules/video_coding/jitter_buffer_unittest.cc
+++ b/modules/video_coding/jitter_buffer_unittest.cc
@@ -1155,19 +1155,17 @@
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;
- 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;
+ 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;
bool retransmitted = false;
EXPECT_EQ(kCompleteSession,
jitter_buffer_->InsertPacket(*packet_, &retransmitted));
@@ -1183,14 +1181,14 @@
packet_->markerBit = false;
packet_->codec = kVideoCodecH264;
packet_->video_header.codec = kVideoCodecH264;
- 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;
+ 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;
// Not complete since the marker bit hasn't been received.
EXPECT_EQ(kIncomplete,
jitter_buffer_->InsertPacket(*packet_, &retransmitted));
@@ -1202,11 +1200,11 @@
packet_->markerBit = true;
packet_->codec = kVideoCodecH264;
packet_->video_header.codec = kVideoCodecH264;
- 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;
+ 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;
// Complete and decodable since the pps and sps are received in the first
// packet of this frame.
EXPECT_EQ(kCompleteSession,
@@ -1224,11 +1222,11 @@
packet_->markerBit = true;
packet_->codec = kVideoCodecH264;
packet_->video_header.codec = kVideoCodecH264;
- 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;
+ 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;
// Complete and decodable since sps, pps and key frame has been received.
EXPECT_EQ(kCompleteSession,
jitter_buffer_->InsertPacket(*packet_, &retransmitted));
diff --git a/modules/video_coding/packet_buffer.cc b/modules/video_coding/packet_buffer.cc
index e1172b3..28ade46 100644
--- a/modules/video_coding/packet_buffer.cc
+++ b/modules/video_coding/packet_buffer.cc
@@ -303,17 +303,18 @@
break;
if (is_h264 && !is_h264_keyframe) {
- 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)
+ const RTPVideoHeaderH264& header =
+ data_buffer_[start_index].video_header.h264();
+
+ if (header.nalus_length >= kMaxNalusPerPacket)
return found_frames;
- for (size_t j = 0; j < h264_header->nalus_length; ++j) {
- if (h264_header->nalus[j].type == H264::NaluType::kSps) {
+ for (size_t j = 0; j < header.nalus_length; ++j) {
+ if (header.nalus[j].type == H264::NaluType::kSps) {
has_h264_sps = true;
- } else if (h264_header->nalus[j].type == H264::NaluType::kPps) {
+ } else if (header.nalus[j].type == H264::NaluType::kPps) {
has_h264_pps = true;
- } else if (h264_header->nalus[j].type == H264::NaluType::kIdr) {
+ } else if (header.nalus[j].type == H264::NaluType::kIdr) {
has_h264_idr = true;
}
}
diff --git a/modules/video_coding/session_info.cc b/modules/video_coding/session_info.cc
index 93a1d53..1b6f732 100644
--- a/modules/video_coding/session_info.cc
+++ b/modules/video_coding/session_info.cc
@@ -110,10 +110,8 @@
return std::vector<NaluInfo>();
std::vector<NaluInfo> nalu_infos;
for (const VCMPacket& packet : packets_) {
- 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]);
+ for (size_t i = 0; i < packet.video_header.h264().nalus_length; ++i) {
+ nalu_infos.push_back(packet.video_header.h264().nalus[i]);
}
}
return nalu_infos;
@@ -177,9 +175,8 @@
// header supplied by the H264 depacketizer.
const size_t kH264NALHeaderLengthInBytes = 1;
const size_t kLengthFieldLength = 2;
- const auto* h264 =
- absl::get_if<RTPVideoHeaderH264>(&packet.video_header.video_type_header);
- if (h264 && h264->packetization_type == kH264StapA) {
+ if (packet.video_header.codec == kVideoCodecH264 &&
+ packet.video_header.h264().packetization_type == kH264StapA) {
size_t required_length = 0;
const uint8_t* nalu_ptr = packet_buffer + kH264NALHeaderLengthInBytes;
while (nalu_ptr < packet_buffer + packet.sizeBytes) {
diff --git a/modules/video_coding/video_packet_buffer_unittest.cc b/modules/video_coding/video_packet_buffer_unittest.cc
index f588026..58611ff 100644
--- a/modules/video_coding/video_packet_buffer_unittest.cc
+++ b/modules/video_coding/video_packet_buffer_unittest.cc
@@ -508,19 +508,17 @@
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_) {
- 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.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;
} else {
- h264_header.nalus[0].type = H264::NaluType::kIdr;
- h264_header.nalus_length = 1;
+ packet.video_header.h264().nalus[0].type = H264::NaluType::kIdr;
+ packet.video_header.h264().nalus_length = 1;
}
}
packet.is_first_packet_in_frame = first == kFirst;
@@ -594,14 +592,12 @@
new uint8_t[sizeof(data_data) + EncodedImage::kBufferPaddingBytesH264]);
VCMPacket packet;
- 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.video_header.h264().nalus_length = 1;
+ packet.video_header.h264().nalus[0].type = H264::NaluType::kIdr;
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;
@@ -759,9 +755,7 @@
EXPECT_TRUE(packet_buffer_->InsertPacket(&packet));
packet.codec = kVideoCodecH264;
- auto& h264_header =
- packet.video_header.video_type_header.emplace<RTPVideoHeaderH264>();
- h264_header.nalus_length = 1;
+ packet.video_header.h264().nalus_length = 1;
packet.timestamp = 3;
packet.seqNum = 3;
EXPECT_TRUE(packet_buffer_->InsertPacket(&packet));
@@ -784,9 +778,7 @@
packet.frameType = kVideoFrameKey;
packet.is_first_packet_in_frame = true;
packet.markerBit = true;
- auto& h264_header =
- packet.video_header.video_type_header.emplace<RTPVideoHeaderH264>();
- h264_header.nalus_length = kMaxNalusPerPacket;
+ packet.video_header.h264().nalus_length = kMaxNalusPerPacket;
packet.sizeBytes = 0;
packet.dataPtr = nullptr;
EXPECT_TRUE(packet_buffer_->InsertPacket(&packet));
@@ -881,10 +873,9 @@
};
TEST_F(TestPacketBufferH264IdrIsKeyframe, IdrIsKeyframe) {
- 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_.video_header.h264().nalus[0].type = H264::NaluType::kIdr;
+ packet_.video_header.h264().nalus_length = 1;
+
packet_buffer_->InsertPacket(&packet_);
ASSERT_EQ(1u, frames_from_callback_.size());
@@ -892,12 +883,10 @@
}
TEST_F(TestPacketBufferH264IdrIsKeyframe, SpsPpsIdrIsKeyframe) {
- 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_.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;
packet_buffer_->InsertPacket(&packet_);
@@ -913,10 +902,8 @@
};
TEST_F(TestPacketBufferH264SpsPpsIdrIsKeyframe, IdrIsNotKeyframe) {
- 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_.video_header.h264().nalus[0].type = H264::NaluType::kIdr;
+ packet_.video_header.h264().nalus_length = 1;
packet_buffer_->InsertPacket(&packet_);
@@ -925,11 +912,9 @@
}
TEST_F(TestPacketBufferH264SpsPpsIdrIsKeyframe, SpsPpsIsNotKeyframe) {
- 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_.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;
packet_buffer_->InsertPacket(&packet_);
@@ -938,12 +923,10 @@
}
TEST_F(TestPacketBufferH264SpsPpsIdrIsKeyframe, SpsPpsIdrIsKeyframe) {
- 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_.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;
packet_buffer_->InsertPacket(&packet_);
diff --git a/modules/video_coding/video_receiver_unittest.cc b/modules/video_coding/video_receiver_unittest.cc
index a4778e8..8b64e77 100644
--- a/modules/video_coding/video_receiver_unittest.cc
+++ b/modules/video_coding/video_receiver_unittest.cc
@@ -98,7 +98,8 @@
0, receiver_->RegisterPacketRequestCallback(&packet_request_callback_));
const size_t kPaddingSize = 220;
const uint8_t payload[kPaddingSize] = {0};
- WebRtcRTPHeader header = {};
+ WebRtcRTPHeader header;
+ memset(&header, 0, sizeof(header));
header.frameType = kEmptyFrame;
header.header.markerBit = false;
header.header.paddingLength = kPaddingSize;
@@ -121,7 +122,8 @@
const size_t kFrameSize = 1200;
const size_t kPaddingSize = 220;
const uint8_t payload[kFrameSize] = {0};
- WebRtcRTPHeader header = {};
+ WebRtcRTPHeader header;
+ memset(&header, 0, sizeof(header));
header.frameType = kEmptyFrame;
header.header.markerBit = false;
header.header.paddingLength = kPaddingSize;
@@ -171,7 +173,8 @@
const size_t kFrameSize = 1200;
const size_t kPaddingSize = 220;
const uint8_t payload[kFrameSize] = {0};
- WebRtcRTPHeader header = {};
+ WebRtcRTPHeader header;
+ memset(&header, 0, sizeof(header));
header.frameType = kEmptyFrame;
header.video_header().is_first_packet_in_frame = false;
header.header.markerBit = false;