[Vorbis-dev] ogg encoding

Stephen Whiters-Ridley s7ephen at gmail.com
Wed Jun 7 22:08:36 PDT 2006


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 (sa7ori at kenshoto.com) the
organizers of the Capture The Flag games at a convention called Defcon (
www.defcon.org). 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".

On 6/8/06, Ralph Giles <giles at xiph.org> wrote:
>
> On Wed, Jun 07, 2006 at 09:43:12PM -0400, Stephen Whiters-Ridley wrote:
>
> > ok, I know its faux pas to post code snippets but will pseudo code be
> ok?
>
> Is it? We often find there's no other way to give useful advice. :-)
>
> > while (amtread = fread(readbuf, file)){
> >  ogg_packet.bytes = amtread
> >  if first_read_from_file then
> >    ogg_packet.b_o_s = 1
> >  if amtread < PACKETSIZE then
> >    ogg_packet.e_o_s = 1
> >  ogg_packet.packet = readbuf
> >  ogg_stream_packetin()
> >  if (ogg_stream_pageout()) then
> >    write_page_to_file()
> >  elseif (amtread < PACKETSIZE) then
> >    ogg_stream_flush() and write_page_to_file()
> > }
>
> So that should be:
>
>   ...
>   while (ogg_stream_pageout()) {
>     write_page_to_file()
>   }
>   if (amtread < PACKETSIZE) {
>     while (ogg_stream_flush() {
>       write_page_to_file()
>   }
> }
>
> Otherwise you can easily (depending on the size of PACKETSIZE) have
> some fraction of your file buffered inside libogg and so the first
> ogg_stream_flush() doesn't actually return the last page. That remains
> my best guess why you're not seeing your eos.
>
> You also probably want to update the sequence number and granulepos
> fields for each packet.
>
> Just out of curiousity, what kind of data is this you're encapsulating?
>
> -r
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/vorbis-dev/attachments/20060608/19d97adb/attachment.html


More information about the Vorbis-dev mailing list