MHEG  17.9.0
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Pages
Macros | Functions
stmr_queue.c File Reference

IC Streamer queue manager. More...

#include <string.h>
#include "stb_os.h"
#include "glue_memory.h"
#include "glue_debug.h"
#include "mh5profile.h"
#include "stmr_queue.h"
#include "stmr_common.h"
#include "stmr_task.h"
#include "stmr_dl.h"

Macros

#define QDBG_CHECK
 
#define QDBG_ALLOC(x)
 
#define QDBG_FREE(x)
 
#define QDBG_FUNC_START(x)
 
#define QDBG_FUNC_END(x)
 
#define QUEUE_CHECK()   QueueCheck()
 
#define QUEUE_PRINT()
 
#define PDBG(x)   TRACE(TICS, x)
 
#define DBG(x)
 
#define MIN_THRESHOLD_SIZE   1048576
 

Functions

void SendSignalToTask (void)
 
E_MhegErr MHEG5QueueInit (U8BIT *buffer, U32BIT bufferSize)
 Initialise queue manager. More...
 
MHEG5QueueItemMHEG5QueueAllocItem (U32BIT requestId, U32BIT len)
 Allocate a new queue item and initialise with request ID and block length. More...
 
void MHEG5QueueInsertItem (MHEG5QueueItem *item)
 Insert a queue item into the queue. More...
 
MHEG5QueueItemMHEG5QueueGetHeadItem (void)
 Return the item at the head of the queue (the next item to consume). The function returns an "invalid" item if streaming is disabled. It returns NULL if the queue is empty. Task : STREAMING. More...
 
BOOLEAN MHEG5QueueIsValidItem (MHEG5QueueItem *item)
 Tell whether the item returned by MHEG5QueueGetHeadItem is valid. If the item is invalid, then streaming is disabled. More...
 
void MHEG5QueueUpdateItem (MHEG5QueueItem *item, U32BIT processed)
 Update the number of bytes processed in a queue item. The same item will be returned by the next call to MHEG5QueueGetHeadItem. If the item is no longer in the queue (because the queue has been cleared), the item is freed and no changes are made to the queue or to the item. More...
 
void MHEG5QueueReleaseItem (MHEG5QueueItem *item)
 Release an item from the queue. If the item is no longer in the queue (because the queue has been cleared), the item is freed and no changes are made to the queue. More...
 
U32BIT MHEG5QueueGetBufferedBytes (void)
 Return number of buffered bytes in the queue (regardless of request) More...
 
void MHEG5QueueEnableStreaming (U32BIT requestId)
 Allow streaming data from the queue. More...
 
void MHEG5QueueDisableStreaming (void)
 Do not allow streaming data from the queue. More...
 
BOOLEAN MHEG5QueueIsStreamingEnabled (void)
 Tell whether streaming is enabled. More...
 
void MHEG5QueueReleaseRequestItems (U32BIT requestId)
 Release all queue items that are related to a given request. More...
 
void MHEG5QueueReleaseItems (U32BIT requestId, U64BIT marker)
 Release queue items that are related to a given request up to a marker. More...
 
void MHEG5QueueReleaseAllItems (void)
 Release all queue items - clear the queue completely. More...
 
void MHEG5QueueRegisterInsertCallback (void(*callback)(U32BIT downloadId, U64BIT base, U64BIT position, U32BIT len, BOOLEAN last))
 Register notification callback for item insertion event. If a callback is already registered for the event, it will be replaced. More...
 
void MHEG5QueueRegisterReleaseCallback (void(*callback)(U32BIT requestId, U64BIT base, U64BIT position, U32BIT len, BOOLEAN last))
 Register notification callback for item release events. If a callback is already registered for the event, it will be replaced. More...
 
void MHEG5QueueTerm (void)
 Terminate queue manager. More...
 

Detailed Description

IC Streamer queue manager.

Date
21/10/2010
Author
Omri Barel

Function Documentation

MHEG5QueueItem* MHEG5QueueAllocItem ( U32BIT  requestId,
U32BIT  len 
)

Allocate a new queue item and initialise with request ID and block length.

Parameters
requestIdRequest ID
lenSize of stream data block in bytes
Returns
Newly allocated item, or NULL if cannot be allocated
void MHEG5QueueDisableStreaming ( void  )

Do not allow streaming data from the queue.

Returns
Nothing
void MHEG5QueueEnableStreaming ( U32BIT  requestId)

Allow streaming data from the queue.

Parameters
requestIdRequest for which streaming is enabled
Returns
Nothing
U32BIT MHEG5QueueGetBufferedBytes ( void  )

Return number of buffered bytes in the queue (regardless of request)

Returns
Number of buffered bytes
MHEG5QueueItem* MHEG5QueueGetHeadItem ( void  )

Return the item at the head of the queue (the next item to consume). The function returns an "invalid" item if streaming is disabled. It returns NULL if the queue is empty. Task : STREAMING.

Return the item at the head of the queue (the next item to consume). The function returns an "invalid" item if streaming is disabled. It returns NULL if the queue is empty.

Returns
Pointer to item, or NULL if queue is empty
E_MhegErr MHEG5QueueInit ( U8BIT *  buffer,
U32BIT  bufferSize 
)

Initialise queue manager.

Parameters
bufferBuffer to use for queue items
bufferSizeSize of buffer in bytes
Returns
Nothing
void MHEG5QueueInsertItem ( MHEG5QueueItem item)

Insert a queue item into the queue.

Parameters
itemItem to be inserted (allocated using QueueAllocItem)
Returns
Nothing
BOOLEAN MHEG5QueueIsStreamingEnabled ( void  )

Tell whether streaming is enabled.

Returns
TRUE if streaming is enabled, FALSE otherwise
BOOLEAN MHEG5QueueIsValidItem ( MHEG5QueueItem item)

Tell whether the item returned by MHEG5QueueGetHeadItem is valid. If the item is invalid, then streaming is disabled.

Parameters
itemQueue item to check
Returns
TRUE if item is valid, FALSE otherwise
void MHEG5QueueRegisterInsertCallback ( void(*)(U32BIT downloadId, U64BIT base, U64BIT position, U32BIT len, BOOLEAN last)  callback)

Register notification callback for item insertion event. If a callback is already registered for the event, it will be replaced.

Parameters
callbackItem insertion callback
Returns
Nothing
void MHEG5QueueRegisterReleaseCallback ( void(*)(U32BIT requestId, U64BIT base, U64BIT position, U32BIT len, BOOLEAN last)  callback)

Register notification callback for item release events. If a callback is already registered for the event, it will be replaced.

Parameters
callbackItem release callback
Returns
Nothing
void MHEG5QueueReleaseAllItems ( void  )

Release all queue items - clear the queue completely.

Returns
Nothing
void MHEG5QueueReleaseItem ( MHEG5QueueItem item)

Release an item from the queue. If the item is no longer in the queue (because the queue has been cleared), the item is freed and no changes are made to the queue.

Parameters
itemQueue item to release
Returns
Nothing
void MHEG5QueueReleaseItems ( U32BIT  requestId,
U64BIT  marker 
)

Release queue items that are related to a given request up to a marker.

Parameters
requestIdRequest ID
markernew position
Returns
Nothing
void MHEG5QueueReleaseRequestItems ( U32BIT  requestId)

Release all queue items that are related to a given request.

Parameters
requestIdRequest ID
Returns
Nothing
void MHEG5QueueTerm ( void  )

Terminate queue manager.

Returns
Nothing
void MHEG5QueueUpdateItem ( MHEG5QueueItem item,
U32BIT  processed 
)

Update the number of bytes processed in a queue item. The same item will be returned by the next call to MHEG5QueueGetHeadItem. If the item is no longer in the queue (because the queue has been cleared), the item is freed and no changes are made to the queue or to the item.

Parameters
itemQueue item to update
processedNumber of bytes processed
Returns
Nothing