pjbtoc

Name

pjbtoc -- High-level PJB operations

Synopsis



#define     TT_MODIFIED_SDK
void        SetJukeboxName                  (PJBTOC *t,
                                             LPCTSTR text);
int         PJBTOC_OpenPjb                  (int idx,
                                             PJBTOC **tptr,
                                             int readtoc);
void        PJBTOC_Close                    (PJBTOC *t);
int         PJBTOC_WalkTree                 (PJBTOC *t,
                                             int (*func) (PJBTOC *t,JNode n,void *arg),
                                             void *arg);
int         PJBTOC_DeleteNode               (PJBTOC *t,
                                             JNode node);
int         PJBTOC_DeleteSubtree            (PJBTOC *t,
                                             JNode node,
                                             int (*func) (PJBTOC *t,JNode n,void *arg),
                                             void *arg);
int         PJBTOC_FreeTrackData            (PJBTOC *t,
                                             JNode n);
JNode       PJBTOC_CreateSet                (PJBTOC *t,
                                             JInsertPt *ins,
                                             char *text);
JNode       PJBTOC_CreateDisc               (PJBTOC *t,
                                             JInsertPt *ins,
                                             char *text);
int         PJBTOC_WriteTrack               (PJBTOC *t,
                                             JNode n,
                                             JInsertPt *ins,
                                             int (*readfunc) (PJBTOC *t,u8 *buffer,long len,long *numread,void *arg),
                                             void *arg,
                                             char *id3Tag);
int         PJBTOC_WriteTrackSetStart       (PJBTOC *t,
                                             PTSState **_state);
int         PJBTOC_WriteTrackSetStep        (PTSState *state,
                                             JNode n,
                                             JInsertPt *ins,
                                             int (*readfunc) (PJBTOC *t,u8 *buffer,long len,long *numread,void *arg),
                                             void *arg,
                                             char *id3Tag);
int         PJBTOC_WriteTrackSetEnd         (PTSState *state);
int         PJBTOC_WriteDisc                (PJBTOC *t,
                                             long *offsets,
                                             JNode *array,
                                             int array_len,
                                             int (*readfunc) (PJBTOC *t,u8 *buffer,long len,long *numread,void *arg),
                                             void *arg,
                                             char *id3Tag);
int         PJBTOC_ReadTrack                (PJBTOC *t,
                                             JNode node,
                                             int (*writefunc) (PJBTOC *t, u8 *buffer, long len,void *arg),
                                             void *arg);
JNode       PJBTOC_FindJNode                (PJBTOC *t,
                                             JNode parent,
                                             char *text);
JNode       PJBTOC_FindDisc                 (PJBTOC *t,
                                             JNode setnode,
                                             char *text,
                                             int create);
JNode       PJBTOC_FindSet                  (PJBTOC *t,
                                             char *text,
                                             int create);
int         PJBTOC_FlushJukebox             (PJBTOC *t);
int         PJBTOC_UpdateFlash              (PJBTOC *t,
                                             char *filename,
                                             int execute);
int         PJBTOC_Reboot                   (PJBTOC *t,
                                             int maincode);
int         PJBTOC_ReadRawTOCFromFile       (PJBTOC *realtoc,
                                             char *filename,
                                             PJBTOC **toc_return);
int         PJBTOC_SetTOC                   (PJBTOC *t,
                                             PJBTOC *newTOC);
int         PJBTOC_WalkSubtree              (PJBTOC *t,
                                             JNode n,
                                             int (*func) (PJBTOC *t,JNode n,void *arg),
                                             void *arg);
JNode       PJBTOC_CopySubtree              (PJBTOC *t,
                                             JNode node);
int         PJBTOC_FlushJukebox_norebuild   (PJBTOC *t);
char*       PJBTOC_DumpTOC                  (PJBTOC *t);
unsigned int PJBTOC_CountTrackSize          (PJBTOC *t,
                                             JNode track);
int         PJBTOC_ReadAllocBlock           (PJBTOC *t,
                                             u8 *buffer,
                                             AllocMap_Block blkno);
int         PJBTOC_WriteAllocBlock          (PJBTOC *t,
                                             u8 *buffer,
                                             AllocMap_Block blkno);
int         PJBTOC_ReadLastClick            (PJBTOC *t,
                                             u8 *buffer,
                                             AllocMap_Block blkno);
void        PJBAssert                       (int expr,
                                             const char *srcFile,
                                             long srcLine,
                                             const char *msg,
                                             ...);
#define     PJB_ASSERT                      ( x, msg )
#define     PJB_ASSERT1                     ( x, msg, arg1 )
#define     PJB_ASSERT2                     ( x, msg, arg1, arg2 )
#define     PJB_ASSERT3                     ( x, msg, arg1, arg2, arg3 )
void        PJBMessage                      (const char *msg,
                                             ...);

Description

This is the high level interface to the PJB. From this library, you can manipulate a PJB's TOC, add files to the PJB, delete files, etc.

Details

TT_MODIFIED_SDK

#define TT_MODIFIED_SDK


SetJukeboxName ()

void        SetJukeboxName                  (PJBTOC *t,
                                             LPCTSTR text);

Used to safely set the name of the jukebox in the TOC

t : PJBTOC structure
text : new name


PJBTOC_OpenPjb ()

int         PJBTOC_OpenPjb                  (int idx,
                                             PJBTOC **tptr,
                                             int readtoc);

Open a PJB and read its table of contents. This routine is used to create a PJBTOC structure and read and parse the TOC. Once this is called, you can manipulate the data on a PJB.

idx : index of which PJB to open (0 opens the first PJB, 1 opens the second, ...)
tptr : pointer to a pointer to a PJBTOC to be returned
readtoc : if FALSE, does not read the TOC. This can be useful to connect to a PJB for flash update operations only, where reading the TOC might not be possible.
Returns : 0 if ok, else error


PJBTOC_Close ()

void        PJBTOC_Close                    (PJBTOC *t);

Close an open PJBTOC structure, freeing allocated memory.

t : PJBTOC structure pointer


PJBTOC_WalkTree ()

int         PJBTOC_WalkTree                 (PJBTOC *t,
                                             int (*func) (PJBTOC *t,JNode n,void *arg),
                                             void *arg);

Walk the entire tree, starting at the root. This is the main API call for performing an operation over the entire tree.

t : PJBTOC structure
func : function to call for each node in the tree
arg : passed to the function for context info
Returns : 0 if all nodes were walked, !=0 if we stopped somewhere


PJBTOC_DeleteNode ()

int         PJBTOC_DeleteNode               (PJBTOC *t,
                                             JNode node);

Delete the specified node from the tree. XXX should this also delete the children?

t : PJBTOC structure
node : JNode to be deleted
Returns : 0 if ok, else error


PJBTOC_DeleteSubtree ()

int         PJBTOC_DeleteSubtree            (PJBTOC *t,
                                             JNode node,
                                             int (*func) (PJBTOC *t,JNode n,void *arg),
                                             void *arg);

Delete whole subtree staring with given node.

t : PJBTOC structure
node : JNode to be deleted
func : Function to be called
arg : args
Returns : 0 if ok, else error


PJBTOC_FreeTrackData ()

int         PJBTOC_FreeTrackData            (PJBTOC *t,
                                             JNode n);

t : 
n : 
Returns : 


PJBTOC_CreateSet ()

JNode       PJBTOC_CreateSet                (PJBTOC *t,
                                             JInsertPt *ins,
                                             char *text);

Create a new set in the TOC. The new Disc is inserted in the tree. This function assumes the set does not already exist.

t : PJBTOC structure
ins : insert point - the parent is assumed to be the root
text : name of new set
Returns : JNode of set we created or NULL if we could not create one


PJBTOC_CreateDisc ()

JNode       PJBTOC_CreateDisc               (PJBTOC *t,
                                             JInsertPt *ins,
                                             char *text);

Create a new Disc in the TOC. The new Disc is inserted in the tree. This function assumes the Disc does not already exist.

t : PJBTOC structure
ins : insert point - the parent should be a Set.
text : name of new Disc
Returns : JNode of disc we created or NULL if we could not create one


PJBTOC_WriteTrack ()

int         PJBTOC_WriteTrack               (PJBTOC *t,
                                             JNode n,
                                             JInsertPt *ins,
                                             int (*readfunc) (PJBTOC *t,u8 *buffer,long len,long *numread,void *arg),
                                             void *arg,
                                             char *id3Tag);

Write an MP3 file to the PJB.

t : PJBTOC structure
n : new JNode, must be a TRACK node
ins : insert point, identifies place in the tree for the new node (should be a DISC node) if null, the node is not inserted to TOC.
readfunc : passed to the function for context info
arg : context arg to pass t readfunc
id3Tag : ID3V2 (128byte) string of tag information
Returns : 0 if ok, else error


PJBTOC_WriteTrackSetStart ()

int         PJBTOC_WriteTrackSetStart       (PJBTOC *t,
                                             PTSState **_state);

???

t : PJBTOC structure
_state : State
Returns : 0 if OK, -1 otherwise


PJBTOC_WriteTrackSetStep ()

int         PJBTOC_WriteTrackSetStep        (PTSState *state,
                                             JNode n,
                                             JInsertPt *ins,
                                             int (*readfunc) (PJBTOC *t,u8 *buffer,long len,long *numread,void *arg),
                                             void *arg,
                                             char *id3Tag);

???

state : State
n : Node
ins : Insert point
readfunc : Read callback function
arg : Arguments
id3Tag : ID3V2 tag string
Returns : 0 always


PJBTOC_WriteTrackSetEnd ()

int         PJBTOC_WriteTrackSetEnd         (PTSState *state);

???

state : State
Returns : 0 always


PJBTOC_WriteDisc ()

int         PJBTOC_WriteDisc                (PJBTOC *t,
                                             long *offsets,
                                             JNode *array,
                                             int array_len,
                                             int (*readfunc) (PJBTOC *t,u8 *buffer,long len,long *numread,void *arg),
                                             void *arg,
                                             char *id3Tag);

Write an MP3 file to the PJB. Instead of one single track, an array of tracks is used. Each track node is expected to contain valid bit rate field and a time field which is used to indicate the length of that track.

t : PJBTOC structure
offsets : array of byte offsets for tracks
array : array of new track JNodes
array_len : number of JNodes in narray
readfunc : callback for reading MP3 data
arg : context arg to pass t readfunc
id3Tag : ID3V2 (128byte) string of tag information
Returns : 0 if ok, else error


PJBTOC_ReadTrack ()

int         PJBTOC_ReadTrack                (PJBTOC *t,
                                             JNode node,
                                             int (*writefunc) (PJBTOC *t, u8 *buffer, long len,void *arg),
                                             void *arg);

Read single track from the PJB. Data is passed to 'writefunc'.

t : PJBTOC structure
node : Node to be read
writefunc : callback for writing MP3 data
arg : context arg to pass t readfunc
Returns : 0 if ok, else error


PJBTOC_FindJNode ()

JNode       PJBTOC_FindJNode                (PJBTOC *t,
                                             JNode parent,
                                             char *text);

find a JNode by text

t : PJBTOC structure
parent : starting place in the tree
text : text to find
Returns : JNode of found node or NULL if we could not find one


PJBTOC_FindDisc ()

JNode       PJBTOC_FindDisc                 (PJBTOC *t,
                                             JNode setnode,
                                             char *text,
                                             int create);

Locate a Disc in the TOC

t : PJBTOC structure
setnode : JNode of the set to search in
text : Disc to find
create : create the Disc if it does not exist
Returns : 0 if ok, else error code


PJBTOC_FindSet ()

JNode       PJBTOC_FindSet                  (PJBTOC *t,
                                             char *text,
                                             int create);

Locate a Set in the TOC

t : PJBTOC structure
text : Disc to find
create : create the Set if it does not exist
Returns : JNode of set we found (or created)


PJBTOC_FlushJukebox ()

int         PJBTOC_FlushJukebox             (PJBTOC *t);

Flush the modified TOC to the PJB and recompute the map. This is the call you should make after adding data to a PJB.

t : PJBTOC structure
Returns : 0 if ok, else error


PJBTOC_UpdateFlash ()

int         PJBTOC_UpdateFlash              (PJBTOC *t,
                                             char *filename,
                                             int execute);

Update the program file in the PJB's flash Note: the PJB must be in flash update mode already

t : PJBTOC structure
filename : name of flash image file to write
execute : if TRUE, run the program without writing to flash
Returns : 0 if ok, else error code


PJBTOC_Reboot ()

int         PJBTOC_Reboot                   (PJBTOC *t,
                                             int maincode);

Reboot the PJB to the main program or to flash update mode

t : PJBTOC structure
maincode :if FALSE, go to flash update mode.if TRUE, go to the main player program
Returns : 0 if ok, else error code


PJBTOC_ReadRawTOCFromFile ()

int         PJBTOC_ReadRawTOCFromFile       (PJBTOC *realtoc,
                                             char *filename,
                                             PJBTOC **toc_return);

Read alternative toc from file in 'raw' format (PJB native format, as writen by 'pjb ls -raw' command) and return it in 'toc_return'. This toc can be 'merged' into real toc with PJBTOC_SetTOC function.

realtoc : 
filename : 
toc_return : 
Returns : 0 if ok, else error


PJBTOC_SetTOC ()

int         PJBTOC_SetTOC                   (PJBTOC *t,
                                             PJBTOC *newTOC);

Set the actual TOC from 'new' to 't' and update allocation map in 't'. Used to merge a toc read from file into actual toc. This function also frees the 'new'.

t : PJBTOC structure pointer
newTOC : ??
Returns : 0 if ok, else error


PJBTOC_WalkSubtree ()

int         PJBTOC_WalkSubtree              (PJBTOC *t,
                                             JNode n,
                                             int (*func) (PJBTOC *t,JNode n,void *arg),
                                             void *arg);

Walks subtree, starting at node. This is the main API call for performing an operation over a specific subtree.

t : PJBTOC structure
n : Node to start at (If node is NULL, start with root)
func : function to call for each node in the tree
arg : passed to the function for context info
Returns : 0 if all nodes were walked, !=0 if we stopped somewhere


PJBTOC_CopySubtree ()

JNode       PJBTOC_CopySubtree              (PJBTOC *t,
                                             JNode node);

Copies the toc and returns pointer to root of copied subtree.

t : PJBTOC structure
node : JNode to be copied
Returns : Pointer to root of copied subtree


PJBTOC_FlushJukebox_norebuild ()

int         PJBTOC_FlushJukebox_norebuild   (PJBTOC *t);

Flush the modified TOC to the PJB and do NOT recompute the map.

t : PJBTOC structure
Returns : 0 if ok, else error


PJBTOC_DumpTOC ()

char*       PJBTOC_DumpTOC                  (PJBTOC *t);

t : PJBTOC structure
Returns : ??


PJBTOC_CountTrackSize ()

unsigned int PJBTOC_CountTrackSize          (PJBTOC *t,
                                             JNode track);

Counts the size of the 'track' in bytes. Zero is returned if an error occured

t : PJBTOC structure
track : Track node to be examined
Returns : Number of bytes if ok, else 0, if an error has occured


PJBTOC_ReadAllocBlock ()

int         PJBTOC_ReadAllocBlock           (PJBTOC *t,
                                             u8 *buffer,
                                             AllocMap_Block blkno);

See internal function ReadAllocBlock() for details

t : PJBTOC structure pointer
buffer : ??
blkno : ??
Returns : ??


PJBTOC_WriteAllocBlock ()

int         PJBTOC_WriteAllocBlock          (PJBTOC *t,
                                             u8 *buffer,
                                             AllocMap_Block blkno);

Write 128Kbytes of data to a PJB

t : PJBTOC structure pointer
buffer : address of 128KB block
blkno : block # to write on the PJB
Returns : Read count


PJBTOC_ReadLastClick ()

int         PJBTOC_ReadLastClick            (PJBTOC *t,
                                             u8 *buffer,
                                             AllocMap_Block blkno);

Reads the last click from a PJB the click is placed at the end of the 128K buffer

t : PJBTOC structure
buffer : address of 128KB block
blkno : block # to write on the PJB
Returns : Read count


PJBAssert ()

void        PJBAssert                       (int expr,
                                             const char *srcFile,
                                             long srcLine,
                                             const char *msg,
                                             ...);

expr : 
srcFile : 
Param3 : 
msg : 
... : 


PJB_ASSERT()

#define     PJB_ASSERT( x, msg )

x : 
msg : 


PJB_ASSERT1()

#define     PJB_ASSERT1( x, msg, arg1 )

x : 
msg : 
arg1 : 


PJB_ASSERT2()

#define     PJB_ASSERT2( x, msg, arg1, arg2 )

x : 
msg : 
arg1 : 
arg2 : 


PJB_ASSERT3()

#define     PJB_ASSERT3( x, msg, arg1, arg2, arg3 )

x : 
msg : 
arg1 : 
arg2 : 
arg3 : 


PJBMessage ()

void        PJBMessage                      (const char *msg,
                                             ...);

msg : 
... :