Debian Codegraph @

t/oggdump.cc

raw symbols SCIP
1 /**
2 * \file t/oggdump.cc
3 *
4 * Dump brief information about the pages containted in an Ogg file.
5 *
6 * This tool is not build by default or installed, and is mainly meant to help understand how Ogg
7 * files are built, and to debug.
8 */
9
10 #include <opustags.h>
11
12 #include <iostream>
13 #include <string.h>
14
15 int main(int argc, char** argv)
16 {
17 if (argc != 2) {
18 std::cerr << "Usage: oggdump FILE\n";
19 return 1;
20 }
21 ot::file input = fopen(argv[1], "r");
22 if (input == nullptr) {
23 std::cerr << "Error opening '" << argv[1] << "': " << strerror(errno) << "\n";
24 return 1;
25 }
26 ot::ogg_reader reader(input.get());
27 ot::status rc;
28 while ((rc = reader.read_page()) == ot::st::ok) {
29 std::cout << "Stream " << ogg_page_serialno(&reader.page) << ", "
30 "page #" << ogg_page_pageno(&reader.page) << ", "
31 << ogg_page_packets(&reader.page) << " packet(s)";
32 if (ogg_page_bos(&reader.page)) std::cout << ", BoS";
33 if (ogg_page_eos(&reader.page)) std::cout << ", EoS";
34 if (ogg_page_continued(&reader.page)) std::cout << ", continued";
35 std::cout << "\n";
36 }
37 if (rc != ot::st::ok && rc != ot::st::end_of_stream) {
38 std::cerr << "error: " << rc.message << "\n";
39 return 1;
40 }
41 return 0;
42 }