Revert "Remove Lua 5.1 support"
[lsnes.git] / src / util / lsnes-dumpogg.cpp
blobac6a7c276492dafdcc1c198bb7c6eda0652514b3
1 #include "library/ogg.hpp"
2 #include <iostream>
3 #include <fstream>
5 int main(int argc, char** argv)
7 if(argc != 2) {
8 std::cerr << "Filename needed." << std::endl;
9 return 1;
11 std::ifstream s(argv[1], std::ios_base::binary);
12 if(!s) {
13 std::cerr << "Can't open '" << argv[1] << "'" << std::endl;
14 return 2;
16 ogg::stream_reader_iostreams r(s);
17 ogg::page p;
18 while(r.get_page(p)) {
19 std::cout << "Ogg page: Stream " << p.get_stream() << " sequence " << p.get_sequence()
20 << " Flags: " << (p.get_continue() ? "CONTINUE " : "")
21 << (p.get_bos() ? "BOS " : "") << (p.get_eos() ? "EOS " : "")
22 << "granulepos=" << p.get_granulepos() << std::endl;
23 size_t pc = p.get_packet_count();
24 for(size_t i = 0; i < pc; i++) {
25 auto pp = p.get_packet(i);
26 std::cout << "Packet #" << i << ": " << pp.second << " bytes";
27 if(i == 0 && p.get_continue())
28 std::cout << " <continued>";
29 if(i + 1 == pc && p.get_last_packet_incomplete())
30 std::cout << " <incomplete>";
31 std::cout << std::endl;
34 std::cout << "End of Ogg stream." << std::endl;
35 return 0;