MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / TEST

Function TEST

pj_scene2D/tests/streaming_video_decoder_test.cpp:701–745  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

699const std::string kBframeVideo = "pj_scene2D/testdata/test_1080p_bframes.mp4";
700
701TEST(StreamingVideoDecoderBframeTest, PushWithDtsAndDecode) {
702 if (!std::filesystem::exists(kBframeVideo)) {
703 GTEST_SKIP() << "test_1080p_bframes.mp4 not found";
704 }
705 auto packets = test::extractAnnexBPackets(kBframeVideo);
706 ASSERT_GT(packets.size(), 10u);
707
708 // Verify this video actually has non-monotonic PTS (B-frames)
709 bool has_non_monotonic_pts = false;
710 for (size_t i = 1; i < packets.size(); ++i) {
711 if (packets[i].timestamp < packets[i - 1].timestamp) {
712 has_non_monotonic_pts = true;
713 break;
714 }
715 }
716 ASSERT_TRUE(has_non_monotonic_pts) << "test video should have B-frames with non-monotonic PTS";
717
718 // Verify DTS IS monotonic
719 for (size_t i = 1; i < packets.size(); ++i) {
720 ASSERT_GE(packets[i].dts, packets[i - 1].dts) << "DTS should be monotonic at i=" << i;
721 }
722
723 // Push using DTS as ObjectStore timestamp
724 ObjectStore store;
725 auto topic_result = store.registerTopic({0, "video/bframes", R"({"media_class":"video","encoding":"h264"})"});
726 auto topic = topic_result.value();
727
728 for (const auto& pkt : packets) {
729 auto result = store.pushOwned(topic, pkt.dts, pkt.data);
730 ASSERT_TRUE(result.has_value()) << "push failed at dts=" << pkt.dts << ": " << result.error();
731 }
732
733 EXPECT_EQ(store.entryCount(topic), packets.size());
734
735 // Decode via StreamingVideoDecoder
736 StreamingVideoDecoder decoder;
737 decoder.attach(&store, topic);
738
739 auto range = store.timeRange(topic);
740 auto result = decoder.decodeAt(range.second);
741 ASSERT_TRUE(result.has_value()) << result.error();
742 EXPECT_FALSE(result->isNull());
743 EXPECT_EQ(result->width, 1920);
744 EXPECT_EQ(result->height, 1080);
745}
746
747TEST(StreamingVideoDecoderBframeTest, LiveStreamWithDts) {
748 if (!std::filesystem::exists(kBframeVideo)) {

Callers

nothing calls this directly

Calls 15

extractAnnexBPacketsFunction · 0.85
mp4VideoFormatFunction · 0.85
formatExtractorFunction · 0.85
sampledBenchVideoFunction · 0.85
pushOwnedMethod · 0.80
entryCountMethod · 0.80
reserveMethod · 0.80
keyframeTimestampsMethod · 0.80
decodeSampledMethod · 0.80
sizeMethod · 0.45
registerTopicMethod · 0.45

Tested by

no test coverage detected