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}
This commit is contained in:
@ -72,13 +72,11 @@ void CopyCodecSpecific(const CodecSpecificInfo* info, RTPVideoHeader* rtp) {
|
||||
rtp->vp9().end_of_picture = info->codecSpecific.VP9.end_of_picture;
|
||||
return;
|
||||
}
|
||||
case kVideoCodecH264: {
|
||||
auto& h264_header = rtp->video_type_header.emplace<RTPVideoHeaderH264>();
|
||||
h264_header.packetization_mode =
|
||||
case kVideoCodecH264:
|
||||
rtp->h264().packetization_mode =
|
||||
info->codecSpecific.H264.packetization_mode;
|
||||
rtp->simulcastIdx = info->codecSpecific.H264.simulcast_idx;
|
||||
return;
|
||||
}
|
||||
case kVideoCodecMultiplex:
|
||||
case kVideoCodecGeneric:
|
||||
rtp->codec = kVideoCodecGeneric;
|
||||
|
@ -445,10 +445,8 @@ TEST(PayloadRouterTest, InfoMappedToRtpVideoHeader_H264) {
|
||||
Unused, const RTPVideoHeader* header, Unused) {
|
||||
EXPECT_EQ(0, header->simulcastIdx);
|
||||
EXPECT_EQ(kVideoCodecH264, header->codec);
|
||||
const auto& h264 =
|
||||
absl::get<RTPVideoHeaderH264>(header->video_type_header);
|
||||
EXPECT_EQ(H264PacketizationMode::SingleNalUnit,
|
||||
h264.packetization_mode);
|
||||
header->h264().packetization_mode);
|
||||
return true;
|
||||
}));
|
||||
|
||||
|
@ -23,18 +23,17 @@ RtpPacketizer* RtpPacketizer::Create(VideoCodecType type,
|
||||
size_t last_packet_reduction_len,
|
||||
const RTPVideoHeader* rtp_video_header,
|
||||
FrameType frame_type) {
|
||||
RTC_CHECK(type == kVideoCodecGeneric || rtp_video_header);
|
||||
switch (type) {
|
||||
case kVideoCodecH264: {
|
||||
const auto& h264 =
|
||||
absl::get<RTPVideoHeaderH264>(rtp_video_header->video_type_header);
|
||||
case kVideoCodecH264:
|
||||
RTC_CHECK(rtp_video_header);
|
||||
return new RtpPacketizerH264(max_payload_len, last_packet_reduction_len,
|
||||
h264.packetization_mode);
|
||||
}
|
||||
rtp_video_header->h264().packetization_mode);
|
||||
case kVideoCodecVP8:
|
||||
RTC_CHECK(rtp_video_header);
|
||||
return new RtpPacketizerVp8(rtp_video_header->vp8(), max_payload_len,
|
||||
last_packet_reduction_len);
|
||||
case kVideoCodecVP9:
|
||||
RTC_CHECK(rtp_video_header);
|
||||
return new RtpPacketizerVp9(rtp_video_header->vp9(), max_payload_len,
|
||||
last_packet_reduction_len);
|
||||
case kVideoCodecGeneric:
|
||||
|
@ -429,8 +429,7 @@ bool RtpDepacketizerH264::Parse(ParsedPayload* parsed_payload,
|
||||
modified_buffer_.reset();
|
||||
|
||||
uint8_t nal_type = payload_data[0] & kTypeMask;
|
||||
parsed_payload->video_header()
|
||||
.video_type_header.emplace<RTPVideoHeaderH264>();
|
||||
parsed_payload->video_header().h264().nalus_length = 0;
|
||||
if (nal_type == H264::NaluType::kFuA) {
|
||||
// Fragmented NAL units (FU-A).
|
||||
if (!ParseFuaNalu(parsed_payload, payload_data))
|
||||
@ -459,8 +458,7 @@ bool RtpDepacketizerH264::ProcessStapAOrSingleNalu(
|
||||
parsed_payload->video_header().codec = kVideoCodecH264;
|
||||
parsed_payload->video_header().simulcastIdx = 0;
|
||||
parsed_payload->video_header().is_first_packet_in_frame = true;
|
||||
auto& h264_header = absl::get<RTPVideoHeaderH264>(
|
||||
parsed_payload->video_header().video_type_header);
|
||||
RTPVideoHeaderH264* h264_header = &parsed_payload->video_header().h264();
|
||||
|
||||
const uint8_t* nalu_start = payload_data + kNalHeaderSize;
|
||||
const size_t nalu_length = length_ - kNalHeaderSize;
|
||||
@ -478,13 +476,13 @@ bool RtpDepacketizerH264::ProcessStapAOrSingleNalu(
|
||||
return false;
|
||||
}
|
||||
|
||||
h264_header.packetization_type = kH264StapA;
|
||||
h264_header->packetization_type = kH264StapA;
|
||||
nal_type = payload_data[kStapAHeaderSize] & kTypeMask;
|
||||
} else {
|
||||
h264_header.packetization_type = kH264SingleNalu;
|
||||
h264_header->packetization_type = kH264SingleNalu;
|
||||
nalu_start_offsets.push_back(0);
|
||||
}
|
||||
h264_header.nalu_type = nal_type;
|
||||
h264_header->nalu_type = nal_type;
|
||||
parsed_payload->frame_type = kVideoFrameDelta;
|
||||
|
||||
nalu_start_offsets.push_back(length_ + kLengthFieldSize); // End offset.
|
||||
@ -530,7 +528,7 @@ bool RtpDepacketizerH264::ProcessStapAOrSingleNalu(
|
||||
}
|
||||
|
||||
// Rewrite length field to new SPS size.
|
||||
if (h264_header.packetization_type == kH264StapA) {
|
||||
if (h264_header->packetization_type == kH264StapA) {
|
||||
size_t length_field_offset =
|
||||
start_offset - (H264::kNaluTypeSize + kLengthFieldSize);
|
||||
// Stap-A Length includes payload data and type header.
|
||||
@ -619,13 +617,13 @@ bool RtpDepacketizerH264::ProcessStapAOrSingleNalu(
|
||||
RTC_LOG(LS_WARNING) << "Unexpected STAP-A or FU-A received.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (h264_header.nalus_length == kMaxNalusPerPacket) {
|
||||
RTPVideoHeaderH264* h264 = &parsed_payload->video_header().h264();
|
||||
if (h264->nalus_length == kMaxNalusPerPacket) {
|
||||
RTC_LOG(LS_WARNING)
|
||||
<< "Received packet containing more than " << kMaxNalusPerPacket
|
||||
<< " NAL units. Will not keep track sps and pps ids for all of them.";
|
||||
} else {
|
||||
h264_header.nalus[h264_header.nalus_length++] = nalu;
|
||||
h264->nalus[h264->nalus_length++] = nalu;
|
||||
}
|
||||
}
|
||||
|
||||
@ -678,13 +676,12 @@ bool RtpDepacketizerH264::ParseFuaNalu(
|
||||
parsed_payload->video_header().codec = kVideoCodecH264;
|
||||
parsed_payload->video_header().simulcastIdx = 0;
|
||||
parsed_payload->video_header().is_first_packet_in_frame = first_fragment;
|
||||
auto& h264_header = absl::get<RTPVideoHeaderH264>(
|
||||
parsed_payload->video_header().video_type_header);
|
||||
h264_header.packetization_type = kH264FuA;
|
||||
h264_header.nalu_type = original_nal_type;
|
||||
RTPVideoHeaderH264* h264 = &parsed_payload->video_header().h264();
|
||||
h264->packetization_type = kH264FuA;
|
||||
h264->nalu_type = original_nal_type;
|
||||
if (first_fragment) {
|
||||
h264_header.nalus[h264_header.nalus_length] = nalu;
|
||||
h264_header.nalus_length = 1;
|
||||
h264->nalus[h264->nalus_length] = nalu;
|
||||
h264->nalus_length = 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -26,12 +26,6 @@ namespace {
|
||||
|
||||
using ::testing::ElementsAreArray;
|
||||
|
||||
struct H264ParsedPayload : public RtpDepacketizer::ParsedPayload {
|
||||
RTPVideoHeaderH264& h264() {
|
||||
return absl::get<RTPVideoHeaderH264>(video.video_type_header);
|
||||
}
|
||||
};
|
||||
|
||||
constexpr RtpPacketToSend::ExtensionManager* kNoExtensions = nullptr;
|
||||
const size_t kMaxPayloadSize = 1200;
|
||||
const size_t kLengthFieldLength = 2;
|
||||
@ -72,8 +66,7 @@ RtpPacketizer* CreateH264Packetizer(H264PacketizationMode mode,
|
||||
size_t max_payload_size,
|
||||
size_t last_packet_reduction) {
|
||||
RTPVideoHeader header;
|
||||
header.video_type_header.emplace<RTPVideoHeaderH264>().packetization_mode =
|
||||
mode;
|
||||
header.h264().packetization_mode = mode;
|
||||
return RtpPacketizer::Create(kVideoCodecH264, max_payload_size,
|
||||
last_packet_reduction, &header, kEmptyFrame);
|
||||
}
|
||||
@ -586,7 +579,7 @@ class RtpDepacketizerH264Test : public ::testing::Test {
|
||||
RtpDepacketizerH264Test()
|
||||
: depacketizer_(RtpDepacketizer::Create(kVideoCodecH264)) {}
|
||||
|
||||
void ExpectPacket(H264ParsedPayload* parsed_payload,
|
||||
void ExpectPacket(RtpDepacketizer::ParsedPayload* parsed_payload,
|
||||
const uint8_t* data,
|
||||
size_t length) {
|
||||
ASSERT_TRUE(parsed_payload != NULL);
|
||||
@ -601,29 +594,29 @@ class RtpDepacketizerH264Test : public ::testing::Test {
|
||||
|
||||
TEST_F(RtpDepacketizerH264Test, TestSingleNalu) {
|
||||
uint8_t packet[2] = {0x05, 0xFF}; // F=0, NRI=0, Type=5 (IDR).
|
||||
H264ParsedPayload payload;
|
||||
RtpDepacketizer::ParsedPayload payload;
|
||||
|
||||
ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet)));
|
||||
ExpectPacket(&payload, packet, sizeof(packet));
|
||||
EXPECT_EQ(kVideoFrameKey, payload.frame_type);
|
||||
EXPECT_EQ(kVideoCodecH264, payload.video_header().codec);
|
||||
EXPECT_TRUE(payload.video_header().is_first_packet_in_frame);
|
||||
EXPECT_EQ(kH264SingleNalu, payload.h264().packetization_type);
|
||||
EXPECT_EQ(kIdr, payload.h264().nalu_type);
|
||||
EXPECT_EQ(kH264SingleNalu, payload.video_header().h264().packetization_type);
|
||||
EXPECT_EQ(kIdr, payload.video_header().h264().nalu_type);
|
||||
}
|
||||
|
||||
TEST_F(RtpDepacketizerH264Test, TestSingleNaluSpsWithResolution) {
|
||||
uint8_t packet[] = {kSps, 0x7A, 0x00, 0x1F, 0xBC, 0xD9, 0x40, 0x50,
|
||||
0x05, 0xBA, 0x10, 0x00, 0x00, 0x03, 0x00, 0xC0,
|
||||
0x00, 0x00, 0x03, 0x2A, 0xE0, 0xF1, 0x83, 0x25};
|
||||
H264ParsedPayload payload;
|
||||
RtpDepacketizer::ParsedPayload payload;
|
||||
|
||||
ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet)));
|
||||
ExpectPacket(&payload, packet, sizeof(packet));
|
||||
EXPECT_EQ(kVideoFrameKey, payload.frame_type);
|
||||
EXPECT_EQ(kVideoCodecH264, payload.video_header().codec);
|
||||
EXPECT_TRUE(payload.video_header().is_first_packet_in_frame);
|
||||
EXPECT_EQ(kH264SingleNalu, payload.h264().packetization_type);
|
||||
EXPECT_EQ(kH264SingleNalu, payload.video_header().h264().packetization_type);
|
||||
EXPECT_EQ(1280u, payload.video_header().width);
|
||||
EXPECT_EQ(720u, payload.video_header().height);
|
||||
}
|
||||
@ -646,13 +639,13 @@ TEST_F(RtpDepacketizerH264Test, TestStapAKey) {
|
||||
0x85, 0xB8, 0x0, 0x4, 0x0, 0x0, 0x13, 0x93, 0x12, 0x0};
|
||||
// clang-format on
|
||||
|
||||
H264ParsedPayload payload;
|
||||
RtpDepacketizer::ParsedPayload payload;
|
||||
ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet)));
|
||||
ExpectPacket(&payload, packet, sizeof(packet));
|
||||
EXPECT_EQ(kVideoFrameKey, payload.frame_type);
|
||||
EXPECT_EQ(kVideoCodecH264, payload.video_header().codec);
|
||||
EXPECT_TRUE(payload.video_header().is_first_packet_in_frame);
|
||||
const RTPVideoHeaderH264& h264 = payload.h264();
|
||||
const RTPVideoHeaderH264& h264 = payload.video_header().h264();
|
||||
EXPECT_EQ(kH264StapA, h264.packetization_type);
|
||||
// NALU type for aggregated packets is the type of the first packet only.
|
||||
EXPECT_EQ(kSps, h264.nalu_type);
|
||||
@ -676,14 +669,14 @@ TEST_F(RtpDepacketizerH264Test, TestStapANaluSpsWithResolution) {
|
||||
0x00, 0x03, kIdr, 0xFF, 0x00, 0x00, 0x04, kIdr, 0xFF,
|
||||
0x00, 0x11};
|
||||
|
||||
H264ParsedPayload payload;
|
||||
RtpDepacketizer::ParsedPayload payload;
|
||||
|
||||
ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet)));
|
||||
ExpectPacket(&payload, packet, sizeof(packet));
|
||||
EXPECT_EQ(kVideoFrameKey, payload.frame_type);
|
||||
EXPECT_EQ(kVideoCodecH264, payload.video_header().codec);
|
||||
EXPECT_TRUE(payload.video_header().is_first_packet_in_frame);
|
||||
EXPECT_EQ(kH264StapA, payload.h264().packetization_type);
|
||||
EXPECT_EQ(kH264StapA, payload.video_header().h264().packetization_type);
|
||||
EXPECT_EQ(1280u, payload.video_header().width);
|
||||
EXPECT_EQ(720u, payload.video_header().height);
|
||||
}
|
||||
@ -700,7 +693,7 @@ TEST_F(RtpDepacketizerH264Test, TestEmptyStapARejected) {
|
||||
uint8_t trailing_empty_packet[] = {kStapA, 0x00, 0x03, kIdr,
|
||||
0xFF, 0x00, 0x00, 0x00};
|
||||
|
||||
H264ParsedPayload payload;
|
||||
RtpDepacketizer::ParsedPayload payload;
|
||||
|
||||
EXPECT_FALSE(depacketizer_->Parse(&payload, lone_empty_packet,
|
||||
sizeof(lone_empty_packet)));
|
||||
@ -739,7 +732,7 @@ TEST_F(RtpDepacketizerH264Test, DepacketizeWithRewriting) {
|
||||
out_buffer.AppendData(kHeader, 2);
|
||||
out_buffer.AppendData(kIdrTwo);
|
||||
|
||||
H264ParsedPayload payload;
|
||||
RtpDepacketizer::ParsedPayload payload;
|
||||
EXPECT_TRUE(
|
||||
depacketizer_->Parse(&payload, in_buffer.data(), in_buffer.size()));
|
||||
|
||||
@ -786,7 +779,7 @@ TEST_F(RtpDepacketizerH264Test, DepacketizeWithDoubleRewriting) {
|
||||
out_buffer.AppendData(kHeader, 2);
|
||||
out_buffer.AppendData(kIdrTwo);
|
||||
|
||||
H264ParsedPayload payload;
|
||||
RtpDepacketizer::ParsedPayload payload;
|
||||
EXPECT_TRUE(
|
||||
depacketizer_->Parse(&payload, in_buffer.data(), in_buffer.size()));
|
||||
|
||||
@ -803,16 +796,16 @@ TEST_F(RtpDepacketizerH264Test, TestStapADelta) {
|
||||
// Length, nal header, payload.
|
||||
0, 0x02, kSlice, 0xFF, 0, 0x03, kSlice, 0xFF, 0x00, 0,
|
||||
0x04, kSlice, 0xFF, 0x00, 0x11};
|
||||
H264ParsedPayload payload;
|
||||
RtpDepacketizer::ParsedPayload payload;
|
||||
|
||||
ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet)));
|
||||
ExpectPacket(&payload, packet, sizeof(packet));
|
||||
EXPECT_EQ(kVideoFrameDelta, payload.frame_type);
|
||||
EXPECT_EQ(kVideoCodecH264, payload.video_header().codec);
|
||||
EXPECT_TRUE(payload.video_header().is_first_packet_in_frame);
|
||||
EXPECT_EQ(kH264StapA, payload.h264().packetization_type);
|
||||
EXPECT_EQ(kH264StapA, payload.video_header().h264().packetization_type);
|
||||
// NALU type for aggregated packets is the type of the first packet only.
|
||||
EXPECT_EQ(kSlice, payload.h264().nalu_type);
|
||||
EXPECT_EQ(kSlice, payload.video_header().h264().nalu_type);
|
||||
}
|
||||
|
||||
TEST_F(RtpDepacketizerH264Test, TestFuA) {
|
||||
@ -840,7 +833,7 @@ TEST_F(RtpDepacketizerH264Test, TestFuA) {
|
||||
};
|
||||
const uint8_t kExpected3[] = {0x03};
|
||||
|
||||
H264ParsedPayload payload;
|
||||
RtpDepacketizer::ParsedPayload payload;
|
||||
|
||||
// We expect that the first packet is one byte shorter since the FU-A header
|
||||
// has been replaced by the original nal header.
|
||||
@ -849,7 +842,7 @@ TEST_F(RtpDepacketizerH264Test, TestFuA) {
|
||||
EXPECT_EQ(kVideoFrameKey, payload.frame_type);
|
||||
EXPECT_EQ(kVideoCodecH264, payload.video_header().codec);
|
||||
EXPECT_TRUE(payload.video_header().is_first_packet_in_frame);
|
||||
const RTPVideoHeaderH264& h264 = payload.h264();
|
||||
const RTPVideoHeaderH264& h264 = payload.video_header().h264();
|
||||
EXPECT_EQ(kH264FuA, h264.packetization_type);
|
||||
EXPECT_EQ(kIdr, h264.nalu_type);
|
||||
ASSERT_EQ(1u, h264.nalus_length);
|
||||
@ -859,28 +852,28 @@ TEST_F(RtpDepacketizerH264Test, TestFuA) {
|
||||
|
||||
// Following packets will be 2 bytes shorter since they will only be appended
|
||||
// onto the first packet.
|
||||
payload = H264ParsedPayload();
|
||||
payload = RtpDepacketizer::ParsedPayload();
|
||||
ASSERT_TRUE(depacketizer_->Parse(&payload, packet2, sizeof(packet2)));
|
||||
ExpectPacket(&payload, kExpected2, sizeof(kExpected2));
|
||||
EXPECT_EQ(kVideoFrameKey, payload.frame_type);
|
||||
EXPECT_EQ(kVideoCodecH264, payload.video_header().codec);
|
||||
EXPECT_FALSE(payload.video_header().is_first_packet_in_frame);
|
||||
{
|
||||
const RTPVideoHeaderH264& h264 = payload.h264();
|
||||
const RTPVideoHeaderH264& h264 = payload.video_header().h264();
|
||||
EXPECT_EQ(kH264FuA, h264.packetization_type);
|
||||
EXPECT_EQ(kIdr, h264.nalu_type);
|
||||
// NALU info is only expected for the first FU-A packet.
|
||||
EXPECT_EQ(0u, h264.nalus_length);
|
||||
}
|
||||
|
||||
payload = H264ParsedPayload();
|
||||
payload = RtpDepacketizer::ParsedPayload();
|
||||
ASSERT_TRUE(depacketizer_->Parse(&payload, packet3, sizeof(packet3)));
|
||||
ExpectPacket(&payload, kExpected3, sizeof(kExpected3));
|
||||
EXPECT_EQ(kVideoFrameKey, payload.frame_type);
|
||||
EXPECT_EQ(kVideoCodecH264, payload.video_header().codec);
|
||||
EXPECT_FALSE(payload.video_header().is_first_packet_in_frame);
|
||||
{
|
||||
const RTPVideoHeaderH264& h264 = payload.h264();
|
||||
const RTPVideoHeaderH264& h264 = payload.video_header().h264();
|
||||
EXPECT_EQ(kH264FuA, h264.packetization_type);
|
||||
EXPECT_EQ(kIdr, h264.nalu_type);
|
||||
// NALU info is only expected for the first FU-A packet.
|
||||
@ -891,37 +884,37 @@ TEST_F(RtpDepacketizerH264Test, TestFuA) {
|
||||
TEST_F(RtpDepacketizerH264Test, TestEmptyPayload) {
|
||||
// Using a wild pointer to crash on accesses from inside the depacketizer.
|
||||
uint8_t* garbage_ptr = reinterpret_cast<uint8_t*>(0x4711);
|
||||
H264ParsedPayload payload;
|
||||
RtpDepacketizer::ParsedPayload payload;
|
||||
EXPECT_FALSE(depacketizer_->Parse(&payload, garbage_ptr, 0));
|
||||
}
|
||||
|
||||
TEST_F(RtpDepacketizerH264Test, TestTruncatedFuaNalu) {
|
||||
const uint8_t kPayload[] = {0x9c};
|
||||
H264ParsedPayload payload;
|
||||
RtpDepacketizer::ParsedPayload payload;
|
||||
EXPECT_FALSE(depacketizer_->Parse(&payload, kPayload, sizeof(kPayload)));
|
||||
}
|
||||
|
||||
TEST_F(RtpDepacketizerH264Test, TestTruncatedSingleStapANalu) {
|
||||
const uint8_t kPayload[] = {0xd8, 0x27};
|
||||
H264ParsedPayload payload;
|
||||
RtpDepacketizer::ParsedPayload payload;
|
||||
EXPECT_FALSE(depacketizer_->Parse(&payload, kPayload, sizeof(kPayload)));
|
||||
}
|
||||
|
||||
TEST_F(RtpDepacketizerH264Test, TestStapAPacketWithTruncatedNalUnits) {
|
||||
const uint8_t kPayload[] = {0x58, 0xCB, 0xED, 0xDF};
|
||||
H264ParsedPayload payload;
|
||||
RtpDepacketizer::ParsedPayload payload;
|
||||
EXPECT_FALSE(depacketizer_->Parse(&payload, kPayload, sizeof(kPayload)));
|
||||
}
|
||||
|
||||
TEST_F(RtpDepacketizerH264Test, TestTruncationJustAfterSingleStapANalu) {
|
||||
const uint8_t kPayload[] = {0x38, 0x27, 0x27};
|
||||
H264ParsedPayload payload;
|
||||
RtpDepacketizer::ParsedPayload payload;
|
||||
EXPECT_FALSE(depacketizer_->Parse(&payload, kPayload, sizeof(kPayload)));
|
||||
}
|
||||
|
||||
TEST_F(RtpDepacketizerH264Test, TestShortSpsPacket) {
|
||||
const uint8_t kPayload[] = {0x27, 0x80, 0x00};
|
||||
H264ParsedPayload payload;
|
||||
RtpDepacketizer::ParsedPayload payload;
|
||||
EXPECT_TRUE(depacketizer_->Parse(&payload, kPayload, sizeof(kPayload)));
|
||||
}
|
||||
|
||||
@ -930,9 +923,9 @@ TEST_F(RtpDepacketizerH264Test, TestSeiPacket) {
|
||||
kSei, // F=0, NRI=0, Type=6.
|
||||
0x03, 0x03, 0x03, 0x03 // Payload.
|
||||
};
|
||||
H264ParsedPayload payload;
|
||||
RtpDepacketizer::ParsedPayload payload;
|
||||
ASSERT_TRUE(depacketizer_->Parse(&payload, kPayload, sizeof(kPayload)));
|
||||
const RTPVideoHeaderH264& h264 = payload.h264();
|
||||
const RTPVideoHeaderH264& h264 = payload.video_header().h264();
|
||||
EXPECT_EQ(kVideoFrameDelta, payload.frame_type);
|
||||
EXPECT_EQ(kH264SingleNalu, h264.packetization_type);
|
||||
EXPECT_EQ(kSei, h264.nalu_type);
|
||||
|
@ -1102,6 +1102,7 @@ TEST_P(RtpSenderTest, NoFlexfecForTimingFrames) {
|
||||
EXPECT_EQ(0, rtp_sender_->RegisterPayload(payload_name, kPayloadType, 90000,
|
||||
0, 1500));
|
||||
RTPVideoHeader video_header;
|
||||
memset(&video_header, 0, sizeof(RTPVideoHeader));
|
||||
video_header.video_timing.flags = VideoSendTiming::kTriggeredByTimer;
|
||||
EXPECT_TRUE(rtp_sender_->SendOutgoingData(
|
||||
kVideoFrameKey, kPayloadType, kTimestamp, kCaptureTimeMs, kPayloadData,
|
||||
@ -1809,9 +1810,8 @@ TEST_P(RtpSenderVideoTest, RetransmissionTypesGeneric) {
|
||||
|
||||
TEST_P(RtpSenderVideoTest, RetransmissionTypesH264) {
|
||||
RTPVideoHeader header;
|
||||
header.video_type_header.emplace<RTPVideoHeaderH264>().packetization_mode =
|
||||
H264PacketizationMode::NonInterleaved;
|
||||
header.codec = kVideoCodecH264;
|
||||
header.h264().packetization_mode = H264PacketizationMode::NonInterleaved;
|
||||
|
||||
EXPECT_EQ(kDontRetransmit,
|
||||
rtp_sender_video_->GetStorageType(
|
||||
|
@ -55,6 +55,20 @@ struct RTPVideoHeader {
|
||||
|
||||
return absl::get<RTPVideoHeaderVP9>(video_type_header);
|
||||
}
|
||||
// TODO(philipel): Remove when downstream projects have been updated.
|
||||
RTPVideoHeaderH264& h264() {
|
||||
if (!absl::holds_alternative<RTPVideoHeaderH264>(video_type_header))
|
||||
video_type_header.emplace<RTPVideoHeaderH264>();
|
||||
|
||||
return absl::get<RTPVideoHeaderH264>(video_type_header);
|
||||
}
|
||||
// TODO(philipel): Remove when downstream projects have been updated.
|
||||
const RTPVideoHeaderH264& h264() const {
|
||||
if (!absl::holds_alternative<RTPVideoHeaderH264>(video_type_header))
|
||||
video_type_header.emplace<RTPVideoHeaderH264>();
|
||||
|
||||
return absl::get<RTPVideoHeaderH264>(video_type_header);
|
||||
}
|
||||
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
|
@ -36,15 +36,14 @@ H264SpsPpsTracker::PacketAction H264SpsPpsTracker::CopyAndFixBitstream(
|
||||
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 @@ H264SpsPpsTracker::PacketAction H264SpsPpsTracker::CopyAndFixBitstream(
|
||||
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 @@ H264SpsPpsTracker::PacketAction H264SpsPpsTracker::CopyAndFixBitstream(
|
||||
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 @@ H264SpsPpsTracker::PacketAction H264SpsPpsTracker::CopyAndFixBitstream(
|
||||
}
|
||||
|
||||
// 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));
|
||||
|
@ -46,29 +46,21 @@ 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:
|
||||
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 @@ class TestH264SpsPpsTracker : public ::testing::Test {
|
||||
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 @@ class TestH264SpsPpsTracker : public ::testing::Test {
|
||||
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 @@ class TestH264SpsPpsTracker : public ::testing::Test {
|
||||
|
||||
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, NoNalus) {
|
||||
|
||||
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, FuAFirstPacket) {
|
||||
|
||||
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, StapAIncorrectSegmentLength) {
|
||||
|
||||
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, NoNalusFirstPacket) {
|
||||
|
||||
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, IdrNoSpsPpsInserted) {
|
||||
|
||||
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, IdrFirstPacketNoSpsPpsInserted) {
|
||||
|
||||
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, IdrFirstPacketNoPpsInserted) {
|
||||
|
||||
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, IdrFirstPacketNoSpsInserted) {
|
||||
|
||||
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 @@ TEST_F(TestH264SpsPpsTracker, SpsPpsPacketThenIdrFirstPacket) {
|
||||
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, SpsPpsPacketThenIdrFirstPacket) {
|
||||
|
||||
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 @@ TEST_F(TestH264SpsPpsTracker, SpsPpsOutOfBand) {
|
||||
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 @@ TEST_F(TestH264SpsPpsTracker, SpsPpsOutOfBandWrongNaluHeader) {
|
||||
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 @@ TEST_F(TestH264SpsPpsTracker, SpsPpsOutOfBandIncompleteNalu) {
|
||||
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 @@ TEST_F(TestH264SpsPpsTracker, SaveRestoreWidthHeight) {
|
||||
|
||||
// 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 @@ TEST_F(TestH264SpsPpsTracker, SaveRestoreWidthHeight) {
|
||||
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});
|
||||
|
@ -1155,19 +1155,17 @@ 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;
|
||||
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 @@ TEST_F(TestBasicJitterBuffer, SpsAndPpsHandling) {
|
||||
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 @@ TEST_F(TestBasicJitterBuffer, SpsAndPpsHandling) {
|
||||
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 @@ TEST_F(TestBasicJitterBuffer, SpsAndPpsHandling) {
|
||||
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));
|
||||
|
@ -303,17 +303,18 @@ std::vector<std::unique_ptr<RtpFrameObject>> PacketBuffer::FindFrames(
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -110,10 +110,8 @@ std::vector<NaluInfo> VCMSessionInfo::GetNaluInfos() const {
|
||||
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 @@ size_t VCMSessionInfo::InsertBuffer(uint8_t* frame_buffer,
|
||||
// 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) {
|
||||
|
@ -508,19 +508,17 @@ 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_) {
|
||||
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 @@ TEST_P(TestPacketBufferH264Parameterized, GetBitstreamBufferPadding) {
|
||||
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 @@ TEST_F(TestPacketBuffer, IncomingCodecChange) {
|
||||
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 @@ TEST_F(TestPacketBuffer, TooManyNalusInPacket) {
|
||||
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 @@ class TestPacketBufferH264IdrIsKeyframe
|
||||
};
|
||||
|
||||
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, IdrIsKeyframe) {
|
||||
}
|
||||
|
||||
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 @@ class TestPacketBufferH264SpsPpsIdrIsKeyframe
|
||||
};
|
||||
|
||||
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, IdrIsNotKeyframe) {
|
||||
}
|
||||
|
||||
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, SpsPpsIsNotKeyframe) {
|
||||
}
|
||||
|
||||
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_);
|
||||
|
||||
|
@ -98,7 +98,8 @@ TEST_F(TestVideoReceiver, PaddingOnlyFrames) {
|
||||
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 @@ TEST_F(TestVideoReceiver, PaddingOnlyFramesWithLosses) {
|
||||
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 @@ TEST_F(TestVideoReceiver, PaddingOnlyAndVideo) {
|
||||
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;
|
||||
|
@ -134,9 +134,9 @@ class RtpVideoStreamReceiverTest : public testing::Test {
|
||||
}
|
||||
|
||||
WebRtcRTPHeader GetDefaultPacket() {
|
||||
WebRtcRTPHeader packet = {};
|
||||
WebRtcRTPHeader packet;
|
||||
memset(&packet, 0, sizeof(packet));
|
||||
packet.video_header().codec = kVideoCodecH264;
|
||||
packet.video_header().video_type_header.emplace<RTPVideoHeaderH264>();
|
||||
return packet;
|
||||
}
|
||||
|
||||
@ -151,9 +151,9 @@ class RtpVideoStreamReceiverTest : public testing::Test {
|
||||
info.pps_id = -1;
|
||||
data->push_back(H264::NaluType::kSps);
|
||||
data->push_back(sps_id);
|
||||
auto& h264 =
|
||||
absl::get<RTPVideoHeaderH264>(packet->video_header().video_type_header);
|
||||
h264.nalus[h264.nalus_length++] = info;
|
||||
packet->video_header()
|
||||
.h264()
|
||||
.nalus[packet->video_header().h264().nalus_length++] = info;
|
||||
}
|
||||
|
||||
void AddPps(WebRtcRTPHeader* packet,
|
||||
@ -166,9 +166,9 @@ class RtpVideoStreamReceiverTest : public testing::Test {
|
||||
info.pps_id = pps_id;
|
||||
data->push_back(H264::NaluType::kPps);
|
||||
data->push_back(pps_id);
|
||||
auto& h264 =
|
||||
absl::get<RTPVideoHeaderH264>(packet->video_header().video_type_header);
|
||||
h264.nalus[h264.nalus_length++] = info;
|
||||
packet->video_header()
|
||||
.h264()
|
||||
.nalus[packet->video_header().h264().nalus_length++] = info;
|
||||
}
|
||||
|
||||
void AddIdr(WebRtcRTPHeader* packet, int pps_id) {
|
||||
@ -176,9 +176,9 @@ class RtpVideoStreamReceiverTest : public testing::Test {
|
||||
info.type = H264::NaluType::kIdr;
|
||||
info.sps_id = -1;
|
||||
info.pps_id = pps_id;
|
||||
auto& h264 =
|
||||
absl::get<RTPVideoHeaderH264>(packet->video_header().video_type_header);
|
||||
h264.nalus[h264.nalus_length++] = info;
|
||||
packet->video_header()
|
||||
.h264()
|
||||
.nalus[packet->video_header().h264().nalus_length++] = info;
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -202,8 +202,9 @@ class RtpVideoStreamReceiverTest : public testing::Test {
|
||||
};
|
||||
|
||||
TEST_F(RtpVideoStreamReceiverTest, GenericKeyFrame) {
|
||||
WebRtcRTPHeader rtp_header = {};
|
||||
WebRtcRTPHeader rtp_header;
|
||||
const std::vector<uint8_t> data({1, 2, 3, 4});
|
||||
memset(&rtp_header, 0, sizeof(rtp_header));
|
||||
rtp_header.header.sequenceNumber = 1;
|
||||
rtp_header.header.markerBit = 1;
|
||||
rtp_header.video_header().is_first_packet_in_frame = true;
|
||||
@ -259,8 +260,9 @@ TEST_F(RtpVideoStreamReceiverTest,
|
||||
}
|
||||
|
||||
TEST_F(RtpVideoStreamReceiverTest, GenericKeyFrameBitstreamError) {
|
||||
WebRtcRTPHeader rtp_header = {};
|
||||
WebRtcRTPHeader rtp_header;
|
||||
const std::vector<uint8_t> data({1, 2, 3, 4});
|
||||
memset(&rtp_header, 0, sizeof(rtp_header));
|
||||
rtp_header.header.sequenceNumber = 1;
|
||||
rtp_header.header.markerBit = 1;
|
||||
rtp_header.video_header().is_first_packet_in_frame = true;
|
||||
@ -407,8 +409,9 @@ TEST_F(RtpVideoStreamReceiverTest, PaddingInMediaStream) {
|
||||
}
|
||||
|
||||
TEST_F(RtpVideoStreamReceiverTest, RequestKeyframeIfFirstFrameIsDelta) {
|
||||
WebRtcRTPHeader rtp_header = {};
|
||||
WebRtcRTPHeader rtp_header;
|
||||
const std::vector<uint8_t> data({1, 2, 3, 4});
|
||||
memset(&rtp_header, 0, sizeof(rtp_header));
|
||||
rtp_header.header.sequenceNumber = 1;
|
||||
rtp_header.header.markerBit = 1;
|
||||
rtp_header.video_header().is_first_packet_in_frame = true;
|
||||
|
Reference in New Issue
Block a user