]> mj.ucw.cz Git - misc.git/blob - oggtest.c
Ursary: Better client matching logic
[misc.git] / oggtest.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <ogg/ogg.h>
5
6 int main(void)
7 {
8   ogg_sync_state osy;
9
10   ogg_sync_init(&osy);
11   for (;;)
12     {
13       char *buf = ogg_sync_buffer(&osy, 4096);
14       int len = read(0, buf, 4096);
15       if (len < 0)
16         {
17           fprintf(stderr, "read error: %m\n");
18           return 1;
19         }
20       if (!len)
21         break;
22       ogg_sync_wrote(&osy, len);
23
24       int ok;
25       ogg_page opg;
26       while (ok = ogg_sync_pageout(&osy, &opg))
27         {
28           if (ok < 0)
29             fprintf(stderr, "Skipping...\n");
30           else
31             {
32               fprintf(stderr, "Page (v=%d, stream=%x, bos=%d, eos=%d, pos=%Ld, pgno=%d)\n",
33                       ogg_page_version(&opg),
34                       ogg_page_serialno(&opg),
35                       ogg_page_bos(&opg),
36                       ogg_page_eos(&opg),
37                       (unsigned long long) ogg_page_granulepos(&opg),
38                       (unsigned int) ogg_page_pageno(&opg));
39             }
40         }
41     }
42   fprintf(stderr, "Done.\n");
43
44   return 0;
45 }