From 7f984e1492b6a62837f751b2893995e17de1f4ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Mangano?= Date: Wed, 2 Mar 2016 16:08:13 +0100 Subject: [PATCH] ogg: test multi-stream Ogg files the sample is generated with this command: ffmpeg -i mystery.ogg -i beep.ogg -c copy -map 0:0 -map 1:0 -map 0:0 -shortest mystery-beep.ogg it should be added into the CMakeLists.txt --- tests/ogg_test.cc | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/tests/ogg_test.cc b/tests/ogg_test.cc index bc2da04..b20476a 100644 --- a/tests/ogg_test.cc +++ b/tests/ogg_test.cc @@ -40,7 +40,45 @@ TEST_CASE("decoding an Ogg Vorbis file", "[ogg]") REQUIRE(s->type == ogg::UNKNOWN_STREAM); } -// TODO decoding a multi-stream file +TEST_CASE("decoding a multi-stream file", "[ogg]") +{ + std::ifstream src("../tests/samples/mystery-beep.ogg"); + ogg::Decoder dec(src); + std::shared_ptr first, second, third, s; + + s = dec.read_page(); + first = s; + REQUIRE(s != nullptr); + REQUIRE(s->state == ogg::HEADER_READY); + REQUIRE(s->type == ogg::OPUS_STREAM); + + s = dec.read_page(); + second = s; + REQUIRE(s != nullptr); + REQUIRE(s != first); + REQUIRE(s->state == ogg::RAW_READY); + REQUIRE(s->type == ogg::UNKNOWN_STREAM); + + s = dec.read_page(); + third = s; + REQUIRE(s != nullptr); + REQUIRE(s != first); + REQUIRE(s != second); + REQUIRE(s->state == ogg::HEADER_READY); + REQUIRE(s->type == ogg::OPUS_STREAM); + + s = dec.read_page(); + REQUIRE(s == first); + REQUIRE(s->state == ogg::TAGS_READY); + + s = dec.read_page(); + REQUIRE(s == second); + REQUIRE(s->state == ogg::RAW_READY); + + s = dec.read_page(); + REQUIRE(s == third); + REQUIRE(s->state == ogg::TAGS_READY); +} // Encoding is trickier, and might as well be done in actions_test.cc, given // opustags::edit_tags covers all of Encoder's regular code.