Buffer Management
The data reorganization described in the previous paragraph
allows the server to stream the AVI file sequentially, from
the beginning to the end. On the client side, subsequently
care must be taken that the codec accesses the correct data.
Recall that we did not alter any index values within the AVI
file. Therefore, the buffer manager must correctly translate
any file system calls (read and seek) attempted by the
codec to the relevant locations in the client playout buffer.
Figure 2 shows the initial organization of the client buffer
when data starts to arrive. Two number values are transmitted
at the very beginning of the data stream: (1) the file size:
fileSize, and (2) the byte offset where the frame table starts:
offsetOfFrameTable.
QRead(): This function retrieves a specific amount
of data from the current seek position in the buffer.
The currentSeekOffset is then adjusted to reflect the
next unread byte. Error checks ensure that data is not
read beyond the current buffer end. If this condition
were to occur, the function would wait for more data
to arrive and then return. In that case, the buffer
sizes and/or the streaming rate are