2.3. Communication with RTP : Audio Queue Module

The Capturing and Playing Module must communicate with the RTP module. Recording thread sends encoded frames to the transmitting RTP, and the playing thread receives frames from the receiving RTP module. The module that allows this communication is the Audio Queue module. This module is optimized to store blocks of audio data (samples or audio frames). The queue, when initiated, is located between receiving/transmitting RTP thread and recorder/player thread. There may be many queues created, depending on how many audio engine threads are active. Recording thread and transmitting RTP must get the same queue pointer to work properly, and the same to playing thread and receiving RTP.

The queue contains two sets of buffers: free and used. Free buffers are those that are empty and can be filled with digital audio data. Used buffers are those containing digital audio data.

The main data structure is the frame_queue structure. This is a structure describing all features of the queue. A pointer to this structure (typedefed as fqp) is commonly used by all functions working with this queue. This pointer is also passed to the playing/recording thread and the RTP thread. There is no need of know the internals of this structure to use it properly.

The buf_struct structure describes a buffer (a single node of the queue).

struct buf_struct{

	char *payload;		/* digital audio data (payload) */	
	timestp timestamp;	/* timestamp */

	bsp next;		/* For internal use only */
};
The pointer to this structure is typedefed as bsp and it is returned by the get_buffer() and reserve_buffer() functions (described later).

All queue-functions are multi-thread safe, the data is protected by critical sections. These mechanisms are run with no user's effort, they are placed inside the routines described below.