[ogg-dev] Using ogg
Neil Leathers
neil.leathers at rogers.com
Sun Apr 27 15:45:52 PDT 2008
I'm try to use libogg and wanted to confirm I'm reading the documentation correctly. Is the following the (psuedo code) loop to follow:
#define BUF_SIZE 4096
ogg_sync_state the_ogg_sync_state;
ogg_page the_ogg_page;
char* buffer;
size_t bytes_actually_read;
<<open data source>>
ogg_sync_init(&the_ogg_sync_state);
<<while there is more data...>> {
while (ogg_sync_pageout(&the_ogg_sync_state, &the_ogg_page) != 1) {
buffer = ogg_sync_buffer(&the_ogg_sync_state, BUF_SIZE);
bytes_actually_read = fread(buffer, 1, BUF_SIZE, source);
if (ogg_sync_wrote(&the_ogg_sync_state, bytes_actually_read) == -1 ) {
<<return error>>
}
}
send_to_my_decoder( the_ogg_page.body, the_ogg_page.body_len );
}
ogg_sync_destroy( &the_ogg_sync_state );
In the function "send_to_my_decoder" I just check to see if the body data is the format I am interested in and skip it if it isn't my format.
Neil Leathers
More information about the ogg-dev
mailing list