1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright The Music Player Daemon Project
#include "lib/xiph/OggSyncState.hxx"
#include "lib/xiph/OggStreamState.hxx"
#include "config/Data.hxx"
#include "input/Init.hxx"
#include "input/InputStream.hxx"
#include "input/Reader.hxx"
#include "event/Thread.hxx"
#include "util/PrintException.hxx"
#include <fmt/core.h>
int
main(int argc, char **argv) noexcept
try {
if (argc != 2) {
fmt::print(stderr, "Usage: DumpOgg FILE\n");
return EXIT_FAILURE;
}
const char *path = argv[1];
EventThread io_thread;
io_thread.Start();
const ScopeInputPluginsInit input_plugins_init(ConfigData(),
io_thread.GetEventLoop());
Mutex mutex;
auto is = InputStream::OpenReady(path, mutex);
InputStreamReader reader{*is};
OggSyncState sync{reader};
while (true) {
ogg_page page;
if (!sync.ExpectPage(page))
break;
fmt::print("page offset={} serial={}\n",
sync.GetStartOffset(), ogg_page_serialno(&page));
}
return EXIT_SUCCESS;
} catch (...) {
PrintException(std::current_exception());
return EXIT_FAILURE;
}
|