chunkbuffer.h File Reference

This is the chunk buffer of the peer. More...

Go to the source code of this file.

Typedefs

typedef struct chunk_buffer ChunkBuffer

Functions

struct chunk_buffer * cb_init (const char *config)
int cb_add_chunk (struct chunk_buffer *cb, const struct chunk *c)
struct chunkcb_get_chunks (const struct chunk_buffer *cb, int *n)
int cb_clear (struct chunk_buffer *cb)
void cb_destroy (struct chunk_buffer *cb)
struct chunkcb_get_chunk (const struct chunk_buffer *cb, int id)

Detailed Description

This is the chunk buffer of the peer.

The chunks buffer is responsible for storing the chunks received by a peer. Each chunk is stored until the chunk buffer decides to discard it (for example, when some kind of playout delay is expired), then it is removed from the buffer. The buffer makes its chunks available to the output module and to the scheduler, in form of an ordered list (chunks are ordered by timestamp). Since every chunk has a timestamp and a sequence number (the chunk ID), the chunk buffer's clients (scheduler and output module) can easily check if there are gaps in the list.


Typedef Documentation

typedef struct chunk_buffer ChunkBuffer

Structure describing a chunk buffer. This is an opaque type.


Function Documentation

int cb_add_chunk ( struct chunk_buffer *  cb,
const struct chunk c 
)

Add a chunk to a buffer.

Insert a chunk in the given buffer. One or more chunks can be removed from the buffer (if necessary, and according to the internal logic of the chunk buffer) to create space for the new one.

Parameters:
cb a pointer to the chunk buffer
c a pointer to the descriptor of the chunk to be inserted in the buffer
Returns:
>=0 in case of success, < 0 in case of failure
int cb_clear ( struct chunk_buffer *  cb  ) 

Clear a chunk buffer

Remove all the chunks from the specified chunk buffer.

Parameters:
cb a pointer to the chunk buffer
Returns:
>= 0 in case of success, < 0 in case of error.
void cb_destroy ( struct chunk_buffer *  cb  ) 

Destroy a chunk buffer

Remove all the chunks from the specified chunk buffer, and free all the memory dynamically allocated to it.

Parameters:
cb a pointer to the chunk buffer
struct chunk* cb_get_chunk ( const struct chunk_buffer *  cb,
int  id 
) [read]

Get a specific chunk from a buffer

Provide one single chunk from the specified chunkbuffer, with the requested identifier.

Parameters:
cb a pointer to the chunk buffer
id the identifier of the chunk to be returned
Returns:
a pointer to the requested chunk
struct chunk* cb_get_chunks ( const struct chunk_buffer *  cb,
int *  n 
) [read]

Get the chunks from a buffer.

Provide an (ordered) list of the chunks which are currently stored in the specified chunk buffer. Such list is stored in a C arrary (so, after calling chunks_array = cb_get_chunks(cb), chunks_array[i] contains the i^th chunk).

Parameters:
cb a pointer to the chunks buffer
n a pointer to an integer variable where number of chunks will be stored
Returns:
the chunks array if there are no failures and the buffer is not empty, NULL if the buffer is empty or in case of error (in case of error, n < 0; if the buffer is empty, n = 0).
struct chunk_buffer* cb_init ( const char *  config  )  [read]

Allocate a chunk buffer.

Allocate and initialise a chunk buffer structure, and return a pointer to it.

Parameters:
config a text string containing some configuration parameters for the buffer, such as the playout delay and maybe some additional parameters (estimated size of the buffer, etc...)
Returns:
a pointer to the allocated chunk buffer in case of success, NULL otherwise
Generated on Mon Jul 12 16:16:52 2010 for GRAPES by  doxygen 1.6.3