[ogg-dev] More trival questions
Neil Leathers
neil.leathers at rogers.com
Mon Apr 28 20:52:18 PDT 2008
> > do {
> > if (ogg_sync_pageout(&the_ogg_sync_state, &the_ogg_page) == 1) {
> > printf("Decode Page\n");
> > send_to_my_decoder( the_ogg_page.body, the_ogg_page.body_len );
> >
> > ogg_stream_pagein(&the_ogg_stream_state, &the_ogg_page);
> >
> > ogg_stream_packetout(&the_ogg_stream_state, &the_ogg_packet);
> >
> > printf("Decode Packet\n");
> > send_to_my_decoder( the_ogg_packet.packet, the_ogg_packet.bytes );
> > }
>
> you need to loop on the call to ogg_stream_packetout(), because a page
> may contain any number (0, 1, 2, ...) of completed packets.
I also lacked the serial numbers on the streams.
if (ogg_sync_pageout(&the_ogg_sync_state, &the_ogg_page) == 1) {
key = ogg_page_serialno( &the_ogg_page);
the_ogg_stream_state = get(&hash_table, key);
if (the_ogg_stream_state == NULL) {
the_ogg_stream_state = malloc( sizeof(ogg_stream_state) );
ogg_stream_init(the_ogg_stream_state, key);
insert(&hash_table, key, the_ogg_stream_state);
}
ogg_stream_pagein(the_ogg_stream_state, &the_ogg_page);
while (ogg_stream_packetout(the_ogg_stream_state, &the_ogg_packet) != 0) {
send_to_my_decoder( key, the_ogg_packet.packet, the_ogg_packet.bytes );
}
}
Everything seems to be working now. Thanks,
Neil
More information about the ogg-dev
mailing list