| 699 | const std::string kBframeVideo = "pj_scene2D/testdata/test_1080p_bframes.mp4"; |
| 700 | |
| 701 | TEST(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 | |
| 747 | TEST(StreamingVideoDecoderBframeTest, LiveStreamWithDts) { |
| 748 | if (!std::filesystem::exists(kBframeVideo)) { |
nothing calls this directly
no test coverage detected