Loader

Implements an elementary stream file loader. Typical usage (MPEG2, no error checking):. More...

Data Structures

struct  Loader_Attrs
 Attributes used to create a Loader. More...

Typedefs

typedef struct Loader_Object * Loader_Handle
 Handle through which to reference a Loader.

Functions

Loader_Handle Loader_create (Char *fileName, Loader_Attrs *attrs)
 Creates a Loader.
Int Loader_prime (Loader_Handle hLoader, Buffer_Handle *hBufPtr)
 Prime the loader and obtain the first frame.
Int Loader_readData (Loader_Handle hLoader)
 Read more data in to the ring buffer. This call should be used when the Loader module works in asynchronous mode (.
Int Loader_getFrame (Loader_Handle hLoader, Buffer_Handle hBuf)
 Load the next frame.
Int Loader_flush (Loader_Handle hLoader)
 Tells the thread calling Loader_readData that it should quit. If the Loader is not used in async mode this call has no effect.
Int Loader_delete (Loader_Handle hLoader)
 Deletes a Loader.

Variables

const Loader_Attrs Loader_Attrs_DEFAULT
 Default attributes for a Loader.

Detailed Description

Implements an elementary stream file loader. Typical usage (MPEG2, no error checking):.

   #include <xdc/std.h>
   #include <ti/sdo/dmai/Dmai.h>
   #include <ti/sdo/dmai/Buffer.h>
   #include <ti/sdo/dmai/Loader.h>
   Loader_Attrs lAttrs = Loader_Attrs_DEFAULT;
   Loader_Handle hLoader;
   Buffer_Handle hBuf;

   Dmai_init();
   hLoader = Loader_create("myfile.m2v", &lAttrs);
   Loader_prime(hLoader, &hBuf);
   while (1) {
       // Call Vdec or Vdec2 to decode the elementary stream.
       Loader_getFrame(hLoader, hBuf);

       if (Buffer_getUserPtr(hBuf) == NULL) {
           // There is no more data to read, terminate.
           break;
       }
   }
   Loader_delete(hLoader);

Typedef Documentation

typedef struct Loader_Object* Loader_Handle

Handle through which to reference a Loader.


Function Documentation

Loader_Handle Loader_create ( Char *  fileName,
Loader_Attrs attrs 
)

Creates a Loader.

Parameters:
[in] fileName Name of the file to load data from.
[in] attrs Loader_Attrs to use for creating the Loader.
Return values:
Handle for use in subsequent operations (see Loader_Attrs).
NULL for failure.

Int Loader_prime ( Loader_Handle  hLoader,
Buffer_Handle hBufPtr 
)

Prime the loader and obtain the first frame.

Parameters:
[in] hLoader The Loader_Handle to prime.
[out] hBufPtr The buffer containing an encoded frame will be returned in this Buffer_Handle.
Return values:
Dmai_EOK for success.
Negative value for failure, see Dmai.h.
Remarks:
Loader_create must be called before this function.

Int Loader_readData ( Loader_Handle  hLoader  ) 

Read more data in to the ring buffer. This call should be used when the Loader module works in asynchronous mode (.

See also:
Loader_Attrs.async). In synchronous mode this call should not be used, it's called internally by Loader_getFrame for this configuration.
Parameters:
[in] hLoader The Loader_Handle to read data for.
Return values:
Dmai_EOK for success.
Dmai_EEOF if end of file was encountered.
Negative value for failure, see Dmai.h.
Remarks:
Loader_create must be called before this function.

This function should not be used in synchronous mode (see Loader_Attrs.async).

Int Loader_getFrame ( Loader_Handle  hLoader,
Buffer_Handle  hBuf 
)

Load the next frame.

Parameters:
[in] hLoader The Loader_Handle to load from.
[in] hBuf The Buffer_Handle of the buffer previously returned by Loader_prime. The bytes used set by Buffer_setNumBytesUsed and obtained using Buffer_getNumBytesUsed should be previously updated by the decoder, e.g. using a Vdec2_process call. When no more data is available (end of file) the Buffer_getUserPtr call will return NULL for this buffer and the function will return Dmai_EEOF.
Return values:
Dmai_EOK for success.
Dmai_EEOF if end of file was encountered.
Negative value for failure, see Dmai.h.
Remarks:
Loader_create must be called before this function.

Loader_prime must be called before this function.

Int Loader_flush ( Loader_Handle  hLoader  ) 

Tells the thread calling Loader_readData that it should quit. If the Loader is not used in async mode this call has no effect.

Parameters:
[in] hLoader The Loader_Handle to force.
Return values:
Dmai_EOK for success.
Negative value for failure, see Dmai.h.
Remarks:
Loader_create must be called before this function.

Loader_delete should be called after this function, the Loader instance cannot be used with other API calls after this.

This function should be called from the thread calling Loader_getFrame and not the thread calling Loader_readData.

Int Loader_delete ( Loader_Handle  hLoader  ) 

Deletes a Loader.

Parameters:
[in] hLoader The Loader_Handle to delete.
Return values:
Dmai_EOK for success.
Negative value for failure, see Dmai.h.
Remarks:
Loader_create must be called before this function.


Variable Documentation

Default attributes for a Loader.

     readBufSize      = 3 * 1024 * 1024,
     readSize         = 720 * 576 * 2
     readAhead        = 0
     vBufSize         = 0
     async            = FALSE


Copyright 2011, Texas Instruments Incorporated