LibMedia: Add ogg/vorbis support

Technically this supports any ogg/* audio stream, but it was at least
tested successfully on ogg/vorbis :^)
This commit is contained in:
Jelle Raaijmakers 2024-09-11 12:43:56 +02:00 committed by Andreas Kling
commit d29797f118
Notes: github-actions[bot] 2024-09-12 08:02:15 +00:00
9 changed files with 363 additions and 17 deletions

View file

@ -0,0 +1,29 @@
/*
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibMedia/Audio/Loader.h>
#include <LibTest/TestCase.h>
static void run_test(StringView file_name, int const num_samples, int const channels, u32 const rate)
{
constexpr auto format = "Ogg Vorbis (.ogg)";
constexpr int bits = 32;
ByteString in_path = ByteString::formatted("vorbis/{}", file_name);
auto loader = TRY_OR_FAIL(Audio::Loader::create(in_path));
EXPECT_EQ(loader->format_name(), format);
EXPECT_EQ(loader->sample_rate(), rate);
EXPECT_EQ(loader->num_channels(), channels);
EXPECT_EQ(loader->bits_per_sample(), bits);
EXPECT_EQ(loader->total_samples(), num_samples);
}
TEST_CASE(44_1Khz_stereo)
{
run_test("44_1Khz_stereo.ogg"sv, 352800, 2, 44100);
}