Skip to content

Commit

Permalink
cont.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmillan committed Jul 4, 2024
1 parent e028f7b commit deeda2c
Showing 1 changed file with 28 additions and 48 deletions.
76 changes: 28 additions & 48 deletions worker/test/src/RTC/TestRtpPacketH264Svc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SCENARIO("parse RTP packets with H264 SVC", "[parser][rtp]")
FAIL("cannot open file");
}

RtpPacket* packet = RtpPacket::Parse(buffer, len);
std::unique_ptr<RtpPacket> packet{ RtpPacket::Parse(buffer, len) };

if (!packet)
{
Expand Down Expand Up @@ -59,8 +59,9 @@ SCENARIO("parse RTP packets with H264 SVC", "[parser][rtp]")
// Read frame-marking.
packet->ReadFrameMarking(&frameMarking, frameMarkingLen);

const auto* payloadDescriptor =
Codecs::H264_SVC::Parse(payload, sizeof(payload), frameMarking, frameMarkingLen);
std::unique_ptr<RTC::Codecs::H264_SVC::PayloadDescriptor> payloadDescriptor{
Codecs::H264_SVC::Parse(payload, sizeof(payload), frameMarking, frameMarkingLen)
};

REQUIRE(payloadDescriptor);

Expand All @@ -73,10 +74,6 @@ SCENARIO("parse RTP packets with H264 SVC", "[parser][rtp]")
REQUIRE(payloadDescriptor->tlIndex == 0);
REQUIRE(payloadDescriptor->hasSlIndex == false);
REQUIRE(payloadDescriptor->isKeyFrame == true);

delete payloadDescriptor;

delete packet;
}

SECTION("parse I0-8.bin")
Expand All @@ -90,7 +87,7 @@ SCENARIO("parse RTP packets with H264 SVC", "[parser][rtp]")
FAIL("cannot open file");
}

RtpPacket* packet = RtpPacket::Parse(buffer, len);
std::unique_ptr<RtpPacket> packet{ RtpPacket::Parse(buffer, len) };

if (!packet)
{
Expand Down Expand Up @@ -123,8 +120,9 @@ SCENARIO("parse RTP packets with H264 SVC", "[parser][rtp]")
// Read frame-marking.
packet->ReadFrameMarking(&frameMarking, frameMarkingLen);

const auto* payloadDescriptor =
Codecs::H264_SVC::Parse(payload, sizeof(payload), frameMarking, frameMarkingLen);
std::unique_ptr<RTC::Codecs::H264_SVC::PayloadDescriptor> payloadDescriptor{
Codecs::H264_SVC::Parse(payload, sizeof(payload), frameMarking, frameMarkingLen)
};

REQUIRE(payloadDescriptor);

Expand All @@ -137,10 +135,6 @@ SCENARIO("parse RTP packets with H264 SVC", "[parser][rtp]")
REQUIRE(payloadDescriptor->tlIndex == 0);
REQUIRE(payloadDescriptor->hasSlIndex == false);
REQUIRE(payloadDescriptor->isKeyFrame == false);

delete payloadDescriptor;

delete packet;
}

SECTION("parse I0-5.bin")
Expand All @@ -154,7 +148,7 @@ SCENARIO("parse RTP packets with H264 SVC", "[parser][rtp]")
FAIL("cannot open file");
}

RtpPacket* packet = RtpPacket::Parse(buffer, len);
std::unique_ptr<RtpPacket> packet{ RtpPacket::Parse(buffer, len) };

if (!packet)
{
Expand Down Expand Up @@ -187,8 +181,9 @@ SCENARIO("parse RTP packets with H264 SVC", "[parser][rtp]")
// Read frame-marking.
packet->ReadFrameMarking(&frameMarking, frameMarkingLen);

const auto* payloadDescriptor =
Codecs::H264_SVC::Parse(payload, sizeof(payload), frameMarking, frameMarkingLen);
std::unique_ptr<RTC::Codecs::H264_SVC::PayloadDescriptor> payloadDescriptor{
Codecs::H264_SVC::Parse(payload, sizeof(payload), frameMarking, frameMarkingLen)
};

REQUIRE(payloadDescriptor);

Expand All @@ -200,10 +195,6 @@ SCENARIO("parse RTP packets with H264 SVC", "[parser][rtp]")
REQUIRE(payloadDescriptor->isKeyFrame == true);
REQUIRE(payloadDescriptor->hasSlIndex == false);
REQUIRE(payloadDescriptor->hasTlIndex == false);

delete payloadDescriptor;

delete packet;
}

SECTION("parse I1-15.bin")
Expand All @@ -217,7 +208,7 @@ SCENARIO("parse RTP packets with H264 SVC", "[parser][rtp]")
FAIL("cannot open file");
}

RtpPacket* packet = RtpPacket::Parse(buffer, len);
std::unique_ptr<RtpPacket> packet{ RtpPacket::Parse(buffer, len) };

if (!packet)
{
Expand Down Expand Up @@ -250,8 +241,9 @@ SCENARIO("parse RTP packets with H264 SVC", "[parser][rtp]")
// Read frame-marking.
packet->ReadFrameMarking(&frameMarking, frameMarkingLen);

const auto* payloadDescriptor =
Codecs::H264_SVC::Parse(payload, sizeof(payload), frameMarking, frameMarkingLen);
std::unique_ptr<RTC::Codecs::H264_SVC::PayloadDescriptor> payloadDescriptor{
Codecs::H264_SVC::Parse(payload, sizeof(payload), frameMarking, frameMarkingLen)
};

REQUIRE(payloadDescriptor);

Expand All @@ -264,10 +256,6 @@ SCENARIO("parse RTP packets with H264 SVC", "[parser][rtp]")
REQUIRE(payloadDescriptor->tlIndex == 0);
REQUIRE(payloadDescriptor->hasSlIndex == false);
REQUIRE(payloadDescriptor->isKeyFrame == false);

delete payloadDescriptor;

delete packet;
}

SECTION("parse I0-14.bin")
Expand All @@ -281,7 +269,7 @@ SCENARIO("parse RTP packets with H264 SVC", "[parser][rtp]")
FAIL("cannot open file");
}

RtpPacket* packet = RtpPacket::Parse(buffer, len);
std::unique_ptr<RtpPacket> packet{ RtpPacket::Parse(buffer, len) };

if (!packet)
{
Expand Down Expand Up @@ -314,8 +302,9 @@ SCENARIO("parse RTP packets with H264 SVC", "[parser][rtp]")
// Read frame-marking.
packet->ReadFrameMarking(&frameMarking, frameMarkingLen);

const auto* payloadDescriptor =
Codecs::H264_SVC::Parse(payload, sizeof(payload), frameMarking, frameMarkingLen);
std::unique_ptr<RTC::Codecs::H264_SVC::PayloadDescriptor> payloadDescriptor{
Codecs::H264_SVC::Parse(payload, sizeof(payload), frameMarking, frameMarkingLen)
};

REQUIRE(payloadDescriptor);

Expand All @@ -328,10 +317,6 @@ SCENARIO("parse RTP packets with H264 SVC", "[parser][rtp]")
REQUIRE(payloadDescriptor->tlIndex == 0);
REQUIRE(payloadDescriptor->hasSlIndex == false);
REQUIRE(payloadDescriptor->isKeyFrame == true);

delete payloadDescriptor;

delete packet;
}

SECTION("parse 2SL-I14.bin")
Expand All @@ -345,7 +330,7 @@ SCENARIO("parse RTP packets with H264 SVC", "[parser][rtp]")
FAIL("cannot open file");
}

RtpPacket* packet = RtpPacket::Parse(buffer, len);
std::unique_ptr<RtpPacket> packet{ RtpPacket::Parse(buffer, len) };

if (!packet)
{
Expand Down Expand Up @@ -378,8 +363,9 @@ SCENARIO("parse RTP packets with H264 SVC", "[parser][rtp]")
// Read frame-marking.
packet->ReadFrameMarking(&frameMarking, frameMarkingLen);

const auto* payloadDescriptor =
Codecs::H264_SVC::Parse(payload, sizeof(payload), frameMarking, frameMarkingLen);
std::unique_ptr<RTC::Codecs::H264_SVC::PayloadDescriptor> payloadDescriptor{
Codecs::H264_SVC::Parse(payload, sizeof(payload), frameMarking, frameMarkingLen)
};

REQUIRE(payloadDescriptor);

Expand All @@ -393,10 +379,6 @@ SCENARIO("parse RTP packets with H264 SVC", "[parser][rtp]")
REQUIRE(payloadDescriptor->hasSlIndex);
REQUIRE(payloadDescriptor->slIndex == 0);
REQUIRE(payloadDescriptor->isKeyFrame == true);

delete payloadDescriptor;

delete packet;
}

SECTION("create and test RTP files")
Expand Down Expand Up @@ -453,7 +435,7 @@ SCENARIO("parse RTP packets with H264 SVC", "[parser][rtp]")
FAIL("Failed to write RTP packet!\n");
}

RtpPacket* packet = RtpPacket::Parse(buffer2, len);
std::unique_ptr<RtpPacket> packet{ RtpPacket::Parse(buffer2, len) };

if (!packet)
{
Expand All @@ -469,18 +451,16 @@ SCENARIO("parse RTP packets with H264 SVC", "[parser][rtp]")
// Read frame-marking.
packet->ReadFrameMarking(&frameMarking, frameMarkingLen);

const auto* payloadDescriptor = Codecs::H264_SVC::Parse(
payload, packet->GetPayloadLength(), frameMarking, frameMarkingLen);
std::unique_ptr<RTC::Codecs::H264_SVC::PayloadDescriptor> payloadDescriptor{
Codecs::H264_SVC::Parse(payload, packet->GetPayloadLength(), frameMarking, frameMarkingLen)
};

REQUIRE(payloadDescriptor);

// payloadDescriptor->Dump();

pos += bytes;
rows++;

delete payloadDescriptor;
delete packet;
}

nf.close();
Expand Down

0 comments on commit deeda2c

Please sign in to comment.