📄 playctrl.cpp
字号:
}
}
DbgPrint(("PlayCtrlGetMarkInfo: Mark not found!\n"));
return (PLAYCTRL_FAILURE);
}
/**
* PlayCtrlGetPrimaryVideoAttributes -- Get the primary video stream attributes.
*
* @param
* usStreamNum - video stream number
* pAttributes - pointer to stream attributes struct that will receive the info
*
* @retval
* audio language code
*/
PLAYCTRL_STATUS PlayCtrlGetPrimaryVideoAttributes(uint16 uiStreamNum, STREAM_ATTRIBUTES *pAttributes)
{
PLAYITEM *pPlayitem = NULL;
uint32 uiPlayitemId;
if (hPBC == NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetPrimaryVideoAttributes: PBCE not created!\n"));
return (PLAYCTRL_FAILURE);
}
/* Get current playitem register value */
PbcRegGetPSR(PLAYCTRL_PSR_PLAYITEM, &uiPlayitemId);
/* Pull out playitem id from register value */
uiPlayitemId &= 0x0000ffff;
/* Get current playitem info */
if (MPLSGetPlayItem( (uint16)(uiPlayitemId), &pPlayitem) == MPLS_SUCCESS)
{
/* validate stream number */
if (uiStreamNum < pPlayitem->STN_table.number_of_primary_video_stream_entries)
{
memcpy( pAttributes, &pPlayitem->STN_table.primary_video_stream[uiStreamNum].stream_attributes,
sizeof(STREAM_ATTRIBUTES) );
}
}
return (PLAYCTRL_SUCCESS);
}
/**
* PlayCtrlGetPrimaryAudioAttributes -- Get the primary audio stream attributes.
*
* @param
* usStreamNum - audio stream number
* pAttributes - pointer to stream attributes struct that will receive the info
*
* @retval
* audio language code
*/
PLAYCTRL_STATUS PlayCtrlGetPrimaryAudioAttributes(uint16 uiStreamNum, STREAM_ATTRIBUTES *pAttributes)
{
PLAYITEM *pPlayitem = NULL;
uint32 uiPlayitemId;
if (hPBC == NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetPrimaryAudioAttributes: PBCE not created!\n"));
return (PLAYCTRL_FAILURE);
}
/* Get current playitem register value */
PbcRegGetPSR(PLAYCTRL_PSR_PLAYITEM, &uiPlayitemId);
/* Pull out playitem id from register value */
uiPlayitemId &= 0x0000ffff;
/* Get current playitem info */
if (MPLSGetPlayItem( (uint16)(uiPlayitemId), &pPlayitem) == MPLS_SUCCESS)
{
/* validate stream number */
if (uiStreamNum < pPlayitem->STN_table.number_of_primary_audio_stream_entries)
{
memcpy( pAttributes, &pPlayitem->STN_table.primary_audio_stream[uiStreamNum].stream_attributes,
sizeof(STREAM_ATTRIBUTES) );
}
}
return (PLAYCTRL_SUCCESS);
}
/**
* PlayCtrlGetSecondaryAudioAttributes -- Get the secondary stream attributes.
*
* @param
* usStreamNum - audio stream number
* pAttributes - pointer to stream attributes struct that will receive the info
*
* @retval
* audio language code
*/
PLAYCTRL_STATUS PlayCtrlGetSecondaryAudioAttributes(uint16 uiStreamNum, STREAM_ATTRIBUTES *pAttributes)
{
PLAYITEM *pPlayitem = NULL;
uint32 uiPlayitemId;
if (hPBC == NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetSecondaryAudioAttributes: PBCE not created!\n"));
return (PLAYCTRL_FAILURE);
}
/* Get current playitem register value */
PbcRegGetPSR(PLAYCTRL_PSR_PLAYITEM, &uiPlayitemId);
/* Pull out playitem id from register value */
uiPlayitemId &= 0x0000ffff;
/* Get current playitem info */
if (MPLSGetPlayItem( (uint16)(uiPlayitemId), &pPlayitem) == MPLS_SUCCESS)
{
/* validate stream number */
if (uiStreamNum < pPlayitem->STN_table.number_of_secondary_audio_stream_entries)
{
memcpy( pAttributes, &pPlayitem->STN_table.secondary_audio_stream[uiStreamNum].stream_attributes,
sizeof(STREAM_ATTRIBUTES) );
}
}
return (PLAYCTRL_SUCCESS);
}
/**
* PlayCtrlGetPGTextSTAttributes -- Get the PG/TextST stream attributes.
*
* @param
* usStreamNum - PG/ST stream number
* pAttributes - pointer to stream attributes struct that will receive the info
*
* @retval
* PG/ST language code
*/
PLAYCTRL_STATUS PlayCtrlGetPGTextSTAttributes(uint16 uiStreamNum, STREAM_ATTRIBUTES *pAttributes)
{
PLAYITEM *pPlayitem = NULL;
uint32 uiPlayitemId;
if (hPBC == NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetPGTextSTAttributes: playback control engine not created!\n"));
return (PLAYCTRL_FAILURE);
}
/* Get current playitem register value */
PbcRegGetPSR(PLAYCTRL_PSR_PLAYITEM, &uiPlayitemId);
/* Pull out playitem id from register value */
uiPlayitemId &= 0x0000ffff;
/* Get current playitem info */
if (MPLSGetPlayItem( (uint16)(uiPlayitemId), &pPlayitem) == MPLS_SUCCESS)
{
/* validate stream number */
if (uiStreamNum < pPlayitem->STN_table.number_of_PG_textST_stream_entries)
{
memcpy( pAttributes, &pPlayitem->STN_table.PG_textST_stream[uiStreamNum].stream_attributes,
sizeof(STREAM_ATTRIBUTES) );
}
}
return (PLAYCTRL_SUCCESS);
}
/**
* PlayCtrlGetIGAttributes -- Get the IG stream attributes.
*
* @param
* usStreamNum - PG/ST stream number
* pAttributes - pointer to stream attributes struct that will receive the info
*
* @retval
* PG/ST language code
*/
PLAYCTRL_STATUS PlayCtrlGetIGAttributes(uint16 uiStreamNum, STREAM_ATTRIBUTES *pAttributes)
{
PLAYITEM *pPlayitem = NULL;
uint32 uiPlayitemId;
if (hPBC == NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetIGAttributes: playback control engine not created!\n"));
return (PLAYCTRL_FAILURE);
}
/* Get current playitem register value */
PbcRegGetPSR(PLAYCTRL_PSR_PLAYITEM, &uiPlayitemId);
/* Pull out playitem id from register value */
uiPlayitemId &= 0x0000ffff;
/* Get current playitem info */
if (MPLSGetPlayItem( (uint16)(uiPlayitemId), &pPlayitem) == MPLS_SUCCESS)
{
/* validate stream number */
if (uiStreamNum < pPlayitem->STN_table.number_of_IG_stream_entries)
{
memcpy( pAttributes, &pPlayitem->STN_table.IG_stream[uiStreamNum].stream_attributes,
sizeof(STREAM_ATTRIBUTES) );
}
}
return (PLAYCTRL_SUCCESS);
}
/**
* PlayCtrlSetTitleType -- Set the title type of the current title.
*
* @param
* fInteractiveTitle -- TRUE = current title is interactive; FALSE = current title is movie
*
* @retval
*
*/
PLAYCTRL_STATUS PlayCtrlSetTitleType(BOOLEAN fInteractiveTitle)
{
if (hPBC == NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlSetTitleType: playback control engine not created!\n"));
return (PLAYCTRL_FAILURE);
}
/* Set flag for interactive title */
hPBC->fInteractiveTitle = fInteractiveTitle;
return (PLAYCTRL_SUCCESS);
}
/**
* PlayCtrlGetPlayListDuration -- Get the sum of all playitem durations for the current playlist.
*
* @param
* None
*
* @retval
* Total time of playlist (in units of 45khz clock)
*/
uint32 PlayCtrlGetPlayListDuration(void)
{
uint16 uiNumPlayItems;
PLAYITEM *pPlayitem = NULL;
uint32 time = 0;
if (hPBC == NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetPlayListDuration: playback control engine not created!\n"));
return (0);
}
/* Get number of playitems */
if (MPLSGetNumberOfPlayItems(&uiNumPlayItems) != MPLS_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetPlayListDuration: Failed to get number of playitems!\n"));
return (0);
}
/* Count total time */
for (uint16 i = 0; i < uiNumPlayItems; i++)
{
/* Get the playitem info */
if (MPLSGetPlayItem(i, &pPlayitem) != MPLS_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetPlayListDuration: Failed to get playitem info\n"));
time = 0;
break;
}
/* Add playitems time to total time */
time += (pPlayitem->OUT_time - pPlayitem->IN_time);
}
return (time);
}
/**
* PlayCtrlGetPlayItemDuration -- Get the time duration for the specified playitem in the current playlist.
*
* @param
* playitem - the target playitem
*
* @retval
* Total time of playitem (in units of 45khz clock)
*/
uint32 PlayCtrlGetPlayItemDuration(uint16 playitem)
{
PLAYITEM *pPlayitem = NULL;
if (hPBC == NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetPlayItemDuration: playback control engine not created!\n"));
return (0);
}
/* Get the playitem info */
if (MPLSGetPlayItem(playitem, &pPlayitem) != MPLS_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetPlayItemDuration: Failed to get playitem info\n"));
return (0);
}
/* Add playitems time to total time */
return (pPlayitem->OUT_time - pPlayitem->IN_time);
}
/**
* PlayCtrlGetCurrentPlayListTime -- Get the the current playback time in the playlist.
*
* @param
* None
*
* @retval
* Current playback time of playlist (in units of 45khz clock)
*/
uint32 PlayCtrlGetCurrentPlayListTime(void)
{
uint32 uiPlayItemID;
uint32 uiPlayItemTime;
PLAYITEM *pPlayitem = NULL;
uint32 time = 0;
if (hPBC == NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetCurrentPlayListTime: playback control engine not created!\n"));
return (0);
}
/* get the current playitem */
if (PbcRegGetPSR(PLAYCTRL_PSR_PLAYITEM, &uiPlayItemID) != PLAYCTRL_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetCurrentPlayListTime: Failed to get current playitem ID!\n"));
return (0);
}
/* pull playitem id out of register value */
uiPlayItemID &= 0x0000ffff;
/* Count total time up to the current playitem */
for (USHORT i = 0; i < uiPlayItemID; i++)
{
/* Get the playitem info */
if (MPLSGetPlayItem(i, &pPlayitem) != MPLS_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetCurrentPlayListTime: Failed to get playitem info\n"));
time = 0;
break;
}
/* Add playitems time to total time */
time += (pPlayitem->OUT_time - pPlayitem->IN_time);
}
/* Get the current playitem info */
if (MPLSGetPlayItem( (uint16)(uiPlayItemID), &pPlayitem) != MPLS_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetCurrentPlayListTime: Failed to get playitem info\n"));
return (0);
}
/* get the current playitem time register value */
if (PbcRegGetPSR(PLAYCTRL_PSR_PRES_TIME, &uiPlayItemTime) != PLAYCTRL_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetCurrentPlayListTime: Failed to get current playitem time!\n"));
return (0);
}
/* Zero out negative results caused by timing issues */
if (uiPlayItemTime < pPlayitem->IN_time)
{
return(0);
}
/* add the time into the current playitem to the total time */
time += (uiPlayItemTime - pPlayitem->IN_time);
return (time);
}
/**
* PlayCtrlTakeSemaphore -- Take playback control engine syncronization semaphore.
*
* @param
* none
*
* @retval
* PLAYCTRL_STATUS
*/
PLAYCTRL_STATUS PlayCtrlTakeSemaphore(void)
{
if (hPBC == NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlTakeSemaphore: playback control engine not created!\n"));
return (PLAYCTRL_FAILURE);
}
/* Take semaphore */
if (OS_SemTake(hPBC->semSynch, OS_WAIT_FOREVER) != OS_OK)
{
return (PLAYCTRL_FAILURE);
}
else
{
return (PLAYCTRL_SUCCESS);
}
}
/**
* PlayCtrlGiveSemaphore -- Give playback control engine syncronization semaphore.
*
* @param
* none
*
* @retval
* PLAYCTRL_STATUS
*/
PLAYCTRL_STATUS PlayCtrlGiveSemaphore(void)
{
if (hPBC == NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGiveSemaphore: playback control engine not created!\n"));
return (PLAYCTRL_FAILURE);
}
/* Give semaphore */
if (OS_SemGive(hPBC->semSynch) != OS_OK)
{
return (PLAYCTRL_FAILURE);
}
else
{
return (PLAYCTRL_SUCCESS);
}
}
/**
* PlayCtrlPlayPLPlayItem -- Start playback of playlist at specified playitem.
*
* @param
* playlist_number -- playlist number
* playitem_number -- playitem number
*
* @retval
* PLAYCTRL_STATUS
*/
PLAYCTRL_STATUS PlayCtrlPlayPLPlayItem(uint32 playlist_number, uint32 playitem_number)
{
if (hPBC == NULL)
{
DbgPrint(("PlayCtrlPlayPLPlayItem: playback control engine not created!\n"));
return (PLAYCTRL_FAILURE);
}
/*
* Process the command in the pbc engine task.
* This should be a synchronous operation.
*/
if (PbcEngineProcessCmd(hPBC, PLAYCTRL_PLAYPLPLAYITEM, playlist_number, playitem_number, 0, TRUE) != PLAYCTRL_SUCCESS)
{
DbgPrint(("PlayCtrlPlayPLPlayItem: pbc engine failed to process command!\n"));
return (PLAYCTRL_FAILURE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -