mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-02 15:46:33 +00:00
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:
parent
1b267abf36
commit
d29797f118
Notes:
github-actions[bot]
2024-09-12 08:02:15 +00:00
Author: https://github.com/gmta
Commit: d29797f118
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1369
9 changed files with 363 additions and 17 deletions
29
Tests/LibMedia/TestVorbisDecode.cpp
Normal file
29
Tests/LibMedia/TestVorbisDecode.cpp
Normal 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue