Thanks! So ogg_stream_pageout() and ogg_stream_flush() *do* "fill in" the contents of the ogg_page structure, and its only valid to access the ogg_page structure's contents (like in the file writing routines) after you have either flush()ed or pageout()ed. As for what this is used for, I am implementing a network daemon that runs single socket, and has to support muxing/demuxing all within the same connection, instead of reinvent the wheel I decided to go with ogg. BUT to get acquinted with the format for that project, I am actually a member of Kenshoto (
<a href="mailto:sa7ori@kenshoto.com">sa7ori@kenshoto.com</a>) the organizers of the Capture The Flag games at a convention called Defcon (<a href="http://www.defcon.org">www.defcon.org</a>). I procrastinated, and am hurrying to finish the last of the development for the qualification rounds. This particular use of ogg, is for the "Forensics" challenge portion. The idea being that someone is smuggling data in an ogg file, and the challenge is to write a parser, and decrypt the obfuscated contents to obtain "the flag".
<br><br><div><span class="gmail_quote">On 6/8/06, <b class="gmail_sendername">Ralph Giles</b> <<a href="mailto:giles@xiph.org">giles@xiph.org</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Wed, Jun 07, 2006 at 09:43:12PM -0400, Stephen Whiters-Ridley wrote:<br><br>> ok, I know its faux pas to post code snippets but will pseudo code be ok?<br><br>Is it? We often find there's no other way to give useful advice. :-)
<br><br>> while (amtread = fread(readbuf, file)){<br>> ogg_packet.bytes = amtread<br>> if first_read_from_file then<br>> ogg_packet.b_o_s = 1<br>> if amtread < PACKETSIZE then<br>> ogg_packet.e_o_s = 1
<br>> ogg_packet.packet = readbuf<br>> ogg_stream_packetin()<br>> if (ogg_stream_pageout()) then<br>> write_page_to_file()<br>> elseif (amtread < PACKETSIZE) then<br>> ogg_stream_flush() and write_page_to_file()
<br>> }<br><br>So that should be:<br><br> ...<br> while (ogg_stream_pageout()) {<br> write_page_to_file()<br> }<br> if (amtread < PACKETSIZE) {<br> while (ogg_stream_flush() {<br> write_page_to_file()
<br> }<br>}<br><br>Otherwise you can easily (depending on the size of PACKETSIZE) have<br>some fraction of your file buffered inside libogg and so the first<br>ogg_stream_flush() doesn't actually return the last page. That remains
<br>my best guess why you're not seeing your eos.<br><br>You also probably want to update the sequence number and granulepos<br>fields for each packet.<br><br>Just out of curiousity, what kind of data is this you're encapsulating?
<br><br> -r<br></blockquote></div><br>