toc

Name

toc -- Implementation of the TOC class

Synopsis



#define     LPCTSTR
#define     TC_ENC_MP3
#define     TC_ENC_PCM
#define     TC_ENC_AAC
#define     TC_MAJ_VERSION
#define     TC_MIN_VERSION
#define     TC_Version
#define     TC_Root
#define     TC_Set
#define     TC_Disk
#define     TC_Track
#define     TC_Block
#define     TC_ID
#define     TC_EndSegment
#define     TC_AllocMap
#define     TC_UidMap
#define     TC_Origin_CD
#define     TC_Origin_ID3
#define     TC_Origin_Unk
#define     TC_BR_32
#define     TC_BR_64
#define     TC_BR_96
#define     TC_BR_128
#define     TC_BR_ESCAPE
#define     MAX_TOC_STR
#define     MAX_NODE_STR
#define     DEFAULT_NEW_JUKEBOX_NAME
#define     DEFAULT_NEW_SET_NAME
#define     DEFAULT_NEW_DISK_NAME
#define     TC_VERSION_FORMAT
#define     TC_PJB_TRACKADDR_FORMAT
#define     TC_TRACK_ID_FORMAT
#define     TC_OLD_TRACK_FORMAT
#define     TC_AM_FORMAT
#define     FRAMES_PER_SEC
#define     FRAMES_TO_SECS                  (x)
typedef     JNodeType;
struct      pjb;
struct      repo;
#define     MAX_FORMAT_ADDR
#define     JNODE_TYPE_NULL
#define     JNODE_TYPE_ROOT
#define     JNODE_TYPE_SET
#define     JNODE_TYPE_DISK
#define     JNODE_TYPE_TRACK
#define     MAX_TOC_DEPTH
#define     JNODE_FIRST
#define     JNODE_LAST
struct      JNodeRec;
#define     TOC_TYPE_PJB
#define     TOC_ERROR_VERSION
#define     TOC_ERROR_FORMAT
#define     TOC_ERROR_ALLOCMAP
TOC_Ctx*    MakeTocCtx                      (int tocType);
void        FreeTocCtx                      (TOC_Ctx *ctx);
void        InitIOBuf                       (TOC_IOBuf *bf,
                                             LPCTSTR s);
void        OutputTocLine                   (TOC_IOBuf *bf,
                                             char c,
                                             LPCTSTR t);
int         InputTocLine                    (TOC_IOBuf *bf,
                                             char *pc,
                                             char *ss);
void        OutputToc                       (TOC_Ctx *ctx,
                                             TOC_IOBuf *bf);
int         InputToc                        (TOC_Ctx *ctx,
                                             TOC_IOBuf *bf);
JNode       MakeNode                        (JNodeType type,
                                             LPCTSTR text);
JNode       CopyNode                        (JNode node);
JNode       CopyChildren                    (JNode node,
                                             JNode parent);
void        UnlinkNode                      (JNode node);
void        FreeNode                        (JNode node);
void        SetNodeText                     (JNode node,
                                             LPCTSTR text);
int         IndexFromCdUID                  (TOC_Ctx *ctx,
                                             LPCTSTR uid);
LPCTSTR     CdUIDFromIndex                  (TOC_Ctx *ctx,
                                             int i);
void        FormatTrackAddr                 (char *str,
                                             TOC_Ctx *ctx,
                                             JNode n);
void        InsertNode                      (JNode jSrc,
                                             JInsertPt *pIns,
                                             int bReplace,
                                             int bCopy);
int         DeleteNode                      (JNode node);
long        CountNodeChildren               (JNode jnParent);

Description

This module contains routines to manipulate the table-of-contents of the Personal Jukebox

Details

LPCTSTR

#define LPCTSTR		char const *


TC_ENC_MP3

#define TC_ENC_MP3		1		// MP3 encoding


TC_ENC_PCM

#define TC_ENC_PCM		2		// raw audio


TC_ENC_AAC

#define TC_ENC_AAC		3		// AAC encoding (NOT SUPPORTED)


TC_MAJ_VERSION

#define TC_MAJ_VERSION	2		// current major version


TC_MIN_VERSION

#define TC_MIN_VERSION	0		// current minor version


TC_Version

#define TC_Version		'V'		

Version number string follows


TC_Root

#define TC_Root			'R'		

Jukebox root name follows


TC_Set

#define TC_Set			'S'	

Set name follows


TC_Disk

#define	TC_Disk			'D'	

Disk name follows


TC_Track

#define	TC_Track		'T'		// Track name follows


TC_Block

#define	TC_Block		'B'


TC_ID

#define	TC_ID			'I'	


TC_EndSegment

#define	TC_EndSegment	'.'		// End of directory or alloc map


TC_AllocMap

#define	TC_AllocMap		'+'		// Alloc map entry


TC_UidMap

#define	TC_UidMap		'U'		// CD UID map entry


TC_Origin_CD

#define TC_Origin_CD	(0)		// audio CD capture


TC_Origin_ID3

#define TC_Origin_ID3	(1)     // ID3 tagged MP3 file


TC_Origin_Unk

#define TC_Origin_Unk	(2)     // untagged MP3 file


TC_BR_32

#define TC_BR_32		4


TC_BR_64

#define TC_BR_64		8


TC_BR_96

#define TC_BR_96		12


TC_BR_128

#define TC_BR_128       16      // bit rate <= 1024 are in 8000 bits/sec


TC_BR_ESCAPE

#define TC_BR_ESCAPE	1024    // bit rates > 1024 are in bits/sec


MAX_TOC_STR

#define MAX_TOC_STR	  1024		// Maximum TOC line


MAX_NODE_STR

#define MAX_NODE_STR  1000		// Maximum node name, minus uniquifiers


DEFAULT_NEW_JUKEBOX_NAME

#define DEFAULT_NEW_JUKEBOX_NAME	"New Personal Jukebox"


DEFAULT_NEW_SET_NAME

#define DEFAULT_NEW_SET_NAME		"New Set"


DEFAULT_NEW_DISK_NAME

#define DEFAULT_NEW_DISK_NAME		"New Disc"


TC_VERSION_FORMAT

#define TC_VERSION_FORMAT	"%d.%d"


TC_PJB_TRACKADDR_FORMAT

#define TC_PJB_TRACKADDR_FORMAT	"%d %ld.%ld %ld.%ld"


TC_TRACK_ID_FORMAT

#define TC_TRACK_ID_FORMAT	"%d.%d.%ld %ld"


TC_OLD_TRACK_FORMAT

#define TC_OLD_TRACK_FORMAT	"%d.%d.%ld"


TC_AM_FORMAT

#define TC_AM_FORMAT  "%d.%d.%d"


FRAMES_PER_SEC

#define FRAMES_PER_SEC	 (75)


FRAMES_TO_SECS()

 #define FRAMES_TO_SECS(x)  ((x + (FRAMES_PER_SEC/2))/FRAMES_PER_SEC)

Get the number of seconds, from frames

x : Number of frames


JNodeType

typedef int JNodeType;


struct pjb

struct pjb {
		long start_block;
		int	start_block_offset;
		long end_block;
		int end_block_bytes;
	} pjb;


struct repo

struct repo {
		long fileid;
	} repo;


MAX_FORMAT_ADDR

#define MAX_FORMAT_ADDR		100


JNODE_TYPE_NULL

#define	JNODE_TYPE_NULL		0


JNODE_TYPE_ROOT

#define	JNODE_TYPE_ROOT		1


JNODE_TYPE_SET

#define JNODE_TYPE_SET		2


JNODE_TYPE_DISK

#define JNODE_TYPE_DISK		3


JNODE_TYPE_TRACK

#define JNODE_TYPE_TRACK	4


MAX_TOC_DEPTH

#define MAX_TOC_DEPTH           4


JNODE_FIRST

#define JNODE_FIRST		(JNode) NULL


JNODE_LAST

#define JNODE_LAST		(JNode) 0xFFFFFFFF


struct JNodeRec

struct JNodeRec {
	JNodeType			type;
	LPCTSTR				text;
	JNode				parent;
	JNode				child;
	JNode				sibling;
	/* following elements are valid only for type == JNODE_TYPE_TRACK */
	TrackAddress		trackAddr;
	int					iCdUID;				/* identifies CD (-1 iff not from CD) */
	int					iTrack;				/* track in original CD (-1 iff not from CD) */
	long				time;				/* playing time in 75'ths of sec */
	int					enc_type;			/* encoding type */
	int					bit_rate;			/* encoding bit rate (bits/sec) */
};


TOC_TYPE_PJB

#define TOC_TYPE_PJB		1


TOC_ERROR_VERSION

#define TOC_ERROR_VERSION	1


TOC_ERROR_FORMAT

#define TOC_ERROR_FORMAT	2


TOC_ERROR_ALLOCMAP

#define TOC_ERROR_ALLOCMAP	3


MakeTocCtx ()

TOC_Ctx*    MakeTocCtx                      (int tocType);

???

tocType : Type of TOC to create context for
Returns : Context structure


FreeTocCtx ()

void        FreeTocCtx                      (TOC_Ctx *ctx);

Frees the context structure

ctx : Context


InitIOBuf ()

void        InitIOBuf                       (TOC_IOBuf *bf,
                                             LPCTSTR s);

???

bf : 
s : 


OutputTocLine ()

void        OutputTocLine                   (TOC_IOBuf *bf,
                                             char c,
                                             LPCTSTR t);

Outputs a TOC line

bf : Buffer
c : Character
t : Input buffer containing the TOC line


InputTocLine ()

int         InputTocLine                    (TOC_IOBuf *bf,
                                             char *pc,
                                             char *ss);

???

bf : Input buffer
pc : ??
ss : ??
Returns : 1 if OK, error number otherwise


OutputToc ()

void        OutputToc                       (TOC_Ctx *ctx,
                                             TOC_IOBuf *bf);

Outputs the TOC structure

ctx : Context
bf : Output buffer


InputToc ()

int         InputToc                        (TOC_Ctx *ctx,
                                             TOC_IOBuf *bf);

???

ctx : Context
bf : Buffer
Returns : 0 if OK, error number otherwise


MakeNode ()

JNode       MakeNode                        (JNodeType type,
                                             LPCTSTR text);

Makes a new node

type : Node type
text :Text to use
Returns : Newly created node


CopyNode ()

JNode       CopyNode                        (JNode node);

Copies the node

node : Node to copy
Returns : Copy of node


CopyChildren ()

JNode       CopyChildren                    (JNode node,
                                             JNode parent);

Copies the children of a node

node : Node
parent : Parent node
Returns : New subtree containing the copies child nodes.


UnlinkNode ()

void        UnlinkNode                      (JNode node);

Unlinks the node from the TOC

node : Node to be unlinked


FreeNode ()

void        FreeNode                        (JNode node);

Frees up the node and any subtree associated with it.

node : Node to be freed


SetNodeText ()

void        SetNodeText                     (JNode node,
                                             LPCTSTR text);

Sets the text of node to new value

node : Node to be changed
text : New text


IndexFromCdUID ()

int         IndexFromCdUID                  (TOC_Ctx *ctx,
                                             LPCTSTR uid);

Given the CDUID, return the index

ctx : Context
uid : CD ID to use
Returns : CDUID found


CdUIDFromIndex ()

LPCTSTR     CdUIDFromIndex                  (TOC_Ctx *ctx,
                                             int i);

Gets the CdUID from given index

ctx : Context
i : Index
Returns : CDUID string


FormatTrackAddr ()

void        FormatTrackAddr                 (char *str,
                                             TOC_Ctx *ctx,
                                             JNode n);

Formats the Track Addr for output.

str : output buffer
ctx : Context
n : Node


InsertNode ()

void        InsertNode                      (JNode jSrc,
                                             JInsertPt *pIns,
                                             int bReplace,
                                             int bCopy);

Inserts a node into the TOC

jSrc : Node to be inserted
pIns : Insert point
bReplace : Replace?
bCopy : Copy?


DeleteNode ()

int         DeleteNode                      (JNode node);

Deletes a node from the TOC. Note: after calling DeleteNode the map must be rebuilt!

node : Node to be deleted
Returns : 0


CountNodeChildren ()

long        CountNodeChildren               (JNode jnParent);

Called to count the children of a provided JNode

jnParent : Node to count child entries for
Returns : Number of children of given node