★ PROGRAMMER'S GUIDE ★ Branch playback library Figure 5.1 Example of branch playback scenario
#define BSTM_MAX 3 / * Total number of branch streams (BSTM1.MPG, BSTM2.MPG, BSTM3.MPG) * /
#define BRANCH_MAX 2 / * Total number of branches (number of arrows in Fig. 5.1) * /
#define KEY_MAX 2 / * Total number of stream key types * /
#define A_BTN 0 / * A button branch number * /
#define B_BTN 1 / * B button branch number * /
#define BR_NUM 2 / * Number of branches per stream * /
#define BSTM1_ID 0 / * BSTM1.MPG branch stream identifier * /
#define BSTM2_ID 1 / * BSTM2.MPG branch stream identifier * /
#define BSTM3_ID 2 / * BSTM3.MPG branch stream identifier * /
/ * Branch playback library work area * /
Sint32 work_bpl [BPL_WORK_SIZE (BSTM_MAX, BRANCH_MAX, KEY_MAX) / sizeof (Sint32)];
void setScenario (void)
{
StmKey key [KEY_MAX]; / * Area for setting stream key * /
Sint32 brtbl [BR_NUM]; / * Area for setting the branch destination * /
Sint32 fid; / * File identifier * /
/ * Initialization of branch playback * /
BPL_Init (BSTM_MAX, BRANCH_MAX, KEY_MAX, work_bpl);
/ * Branch stream information setting * /
STM_KEY_CN (key + 0) = STM_KEY_CIMSK (key + 0) = STM_KEY_NONE;
STM_KEY_CN (key + 1) = STM_KEY_CIMSK (key + 1) = STM_KEY_NONE;
STM_KEY_SMMSK (key + 0) = STM_KEY_SMVAL (key + 0) = STM_SM_VIDEO;
STM_KEY_SMMSK (key + 1) = STM_KEY_SMVAL (key + 1) = STM_SM_AUDIO;
fid = GFS_NameToId ("BSTM1.MPG");
BPL_SetStmInfo (BSTM1_ID, fid, KEY_MAX, key);
fid = GFS_NameToId ("BSTM2.MPG");
BPL_SetStmInfo (BSTM2_ID, fid, KEY_MAX, key);
fid = GFS_NameToId ("BSTM3.MPG");
BPL_SetStmInfo (BSTM3_ID, fid, KEY_MAX, key);
/ * Setting branch destination information * /
brtbl [A_BTN] = BSTM2_ID; / * Branch to BSTM2.MPG when A button is pressed * /
brtbl [B_BTN] = BSTM3_ID; / * Branch to BSTM3.MPG when the B button is pressed * /
BPL_SetBranchInfo (BSTM1_ID, BR_NUM, brtbl); / * BSTM1.MPG branch destination setting * /
}
Sint32 work_gfs [GFS_WORK_SIZE (BSTM_MAX * KEY_MAX) / sizeof (Sint32)];
Sint32 work_stm [STM_WORK_SIZE (GRP_MAX, BSTM_MAX * KEY_MAX) / sizeof (Sint32)];
Sint32 brno; / * branch number * /
StmHn stmtbl [KEY_MAX]; / * Stream handle table * /
Sint32 bpl_stat; / * Branch playback state * /
Sint32 decode_stat; / * Decoder operating status * /
DecodeHn dc_hn = NULL; / * Decoder handle * /
Bool chgsw = OFF; / * Branch execution switch * /
Bool endflag = FALSE;
Sint32 ret;
/ * Initialization of each library * /
GFS_Init (...); / * File system initialization * /
STM_Init (...); / * Stream system initialization * /
initDecoder (); / * Decoder initialization * /
setScenario (); / * Scenario settings (see 5.1) * /
/ * Branch playback * /
BPL_SetStart (BSTM1_ID); / * Specify playback start stream * /
BPL_GetCurStm (KEY_MAX, stmtbl); / * Get first branch stream * /
dc_hn = createDecodeHn (stmtbl); / * Create decoder handle * /
while (endflag == FALSE) {
bpl_stat = BPL_ExecServer (chgsw); / * Run branch playback server * /
chgsw = OFF;
STM_ExecServer (); / * Run stream server * /
decode_stat = execDecoder (dc_hn); / * Execution of decoder server function * /
switch (bpl_stat) {
case BPL_SVR_COMPLETED: / * Branch playback end state * /
endflag = TRUE;
break;
case BPL_SVR_WAITSEL: / * Waiting for branch destination selection * /
/ * Get pad input (0: A button, 1: B button, negative: no input * /
brno = getPadEvent ();
if (brno> = 0) {
BPL_SelectBranch (brno); / * Select branch destination * /
}
break;
case BPL_SVR_SELECT: / * Branch destination decision state * /
case BPL_SVR_NOBRN: / * No branch destination * /
if (decode_stat! = COMPLETED) {/ * Check decoding completion * /
break;
}
chgsw = ON; / * Branch execution switch ON * /
ret = BPL_GetNextStm (KEY_MAX, stmtbl); / * Get the branch destination stream * /
if (ret> = 0) {/ * If there is a branch destination * /
destroyDecodeHn (dc_hn); / * Erase the handle of the decoder * /
dc_hn = createDecodeHn (stmtbl); / * Create decoder handle * /
}
break;
}
}
destroyDecodeHn (dc_hn); / * Erase the handle of the decoder * /
★ PROGRAMMER'S GUIDE ★ Branch playback library