📄 dvd_app.cpp
字号:
{
return (sprm[SPRM_PTTN_ONE_SEQ_PGC]);
}
else
{
DBGPRINT(DBG_ON(DBG_ERROR), ("DvdAppGetCurrentChapter: dvd nav not running!\n"));
return (0);
}
}
/**
* DvdAppGetPlayTime -- Get current play time
*
* @param
* bTimeMode - time mode (0 = Chapter, 1 = Chapter remain, 2 = Title, 3 = Title Remain)
*
* @retval
* Play time in seconds
*/
ULONG DvdAppGetPlayTime(BYTE bTimeMode)
{
if (fDVDAppStarted == TRUE)
{
BYTE currentTimeMode = time_info->display_mode;
ULONG ulTime;
/*
* Determine time mode we want to get
*/
switch (bTimeMode)
{
case 0:
time_info->display_mode = CHAP_UP;
break;
case 1:
time_info->display_mode = CHAP_DOWN;
break;
case 2:
time_info->display_mode = TITLE_UP;
break;
case 3:
time_info->display_mode = TITLE_DOWN;
break;
default:
DBGPRINT(DBG_ON(DBG_ERROR), ("DvdAppGetPlayTime: invalid time mode!\n"));
time_info->display_mode = TITLE_UP;
break;
}
/*
* The time info structure is filled in whenever each navpack is received, so we
* do not need to fill in the time info structure here unless we are changing the
* time mode
*/
/* Update time values for the new time mode with the current time from navpack */
/* If the nav_task isn't processing any new nav packs, keep processing the old time */
if ((nv_pck_ready == 0) || (nav_pack_abort == 1) || (wait_first_nvpck == 1) || (during_search == 1) || (adjust_nv_tmr == 1) || (nav_pack_suspend == 1))
{
/* Use the previous good navpack time during search and skip conditions */
update_timedisp(prev_eltm);
}
else if (currentTimeMode != bTimeMode)
{
/* Capture the previous good navpack time for later search and skip conditions */
prev_eltm = nvpck[CURRENT].pci_gi.c_eltm;
/* Update time values for the new time mode with the current time from navpack */
update_timedisp(prev_eltm);
}
/* Get time in hour, min, seconds and convert to time in seconds. */
ulTime = 60 * 60 * time_info->hour;
ulTime += 60 * time_info->min;
ulTime += time_info->sec;
return (ulTime);
}
else
{
DBGPRINT(DBG_ON(DBG_ERROR), ("DvdAppGetPlayTime: dvd nav not running!\n"));
return (0);
}
}
/**
* DvdAppGetNumberOfSubtitles -- Get number of subtitles currently available
*
* @param
* none
*
* @retval
* Number of currently available subtitles
*/
USHORT DvdAppGetNumberOfSubtitles(void)
{
if (fDVDAppStarted == TRUE)
{
USHORT usNumSubtitles = (vtsi_mat.vts_spst_n[1] & 0x3f);
USHORT usNumAvailableSubtitles = 0;
for (USHORT i = 0; i < usNumSubtitles; i++)
{
if (pgc_gi.pgc_spst_ctlt[i][0] & 0x80)
{
usNumAvailableSubtitles++;
}
}
return (usNumAvailableSubtitles);
}
else
{
DBGPRINT(DBG_ON(DBG_ERROR), ("DvdAppGetNumberOfSubtitles: dvd nav not running!\n"));
return (0);
}
}
/**
* DvdAppGetSubtitleState -- Determine if subtitles are allowed
*
* @param
* none
*
* @retval
* TRUE if navigator is in a state that subtitles are allowed.
*/
BOOLEAN DvdAppGetSubtitleState(void)
{
if (fDVDAppStarted == TRUE)
{
NAV_STATE state = get_nav_state();
BOOLEAN fGoodState = TRUE;
UBYTE temp_spu_num;
/*
* Can only turn on subtitles during normal play or pause
*/
if ( (state != NORMAL_PLAYING) && (state != PAUSED) )
{
fGoodState = FALSE;
}
if ( (pgc_domain != TT_PGC) || ( (vtsi_mat.vts_spst_n[1] & 0x3f) == 0) )
{
fGoodState = FALSE;
}
/*
* Check that there are subtitles available
*/
temp_spu_num = (vtsi_mat.vts_spst_n[1] & 0x3f);
for (int i = 0; i < (vtsi_mat.vts_spst_n[1] & 0x3f); i ++)
{
if (!(pgc_gi.pgc_spst_ctlt[i][0] & 0x80) ||
(2 == (vtsi_mat.vts_spst_atrt[i].flags & 0x03)) ||
(3 == (vtsi_mat.vts_spst_atrt[i].flags & 0x03)))
{
temp_spu_num--;
}
}
if (!temp_spu_num)
{
fGoodState = FALSE;
}
return (fGoodState);
}
else
{
DBGPRINT(DBG_ON(DBG_ERROR), ("DvdAppGetSubtitleState: dvd nav not running!\n"));
return (FALSE);
}
}
/**
* DvdAppIsSubtitleOn -- Get state of subtitles
*
* @param
* none
*
* @retval
* If there is a subtitle stream that is on, return TRUE
*/
BOOLEAN DvdAppIsSubtitleOn(void)
{
if (fDVDAppStarted == TRUE)
{
if (get_spu_on_off_state() != 1)
{
return (FALSE);
}
else
{
return (TRUE);
}
}
else
{
DBGPRINT(DBG_ON(DBG_ERROR), ("DvdAppIsSubtitleOn: dvd nav not running!\n"));
return (0);
}
}
/**
* DvdAppGetCurrentSubtitleStream -- Get currently active subtitle stream
*
* @param
* none
*
* @retval
* Subtitle stream number of the currently selected subtitle
*/
USHORT DvdAppGetCurrentSubtitleStream(void)
{
if (fDVDAppStarted == TRUE)
{
return ( (USHORT)get_current_subtitle_stream() );
}
else
{
DBGPRINT(DBG_ON(DBG_ERROR), ("DvdAppGetCurrentSubtitleStream: dvd nav not running!\n"));
return (0);
}
}
/**
* DvdAppGetSubtitleLanguage -- Get language of subtitle stream
*
* @param
* usStreamNum - stream number of subtitle
*
* @retval
* Language code of subtitle with stream number = usStreamNum
*/
ULONG DvdAppGetSubtitleLanguage(USHORT usStreamNum)
{
if (fDVDAppStarted == TRUE)
{
USHORT specific_code;
ULONG lang_code;
USHORT usEnabledCount = 0;
/*
* Ths specified stream number is the stream number in the list of *enabled* streams.
* We need to determine which stream number this is in the list of *all* streams.
*/
for (USHORT i = 0; i < (vtsi_mat.vts_spst_n[1] & 0x3f); i++)
{
/* If this subtitle stream is enabled, increase count */
if (pgc_gi.pgc_spst_ctlt[i][0] & 0x80)
{
usEnabledCount++;
}
/* If we've reached the specified stream number, we're done */
if (usEnabledCount == (usStreamNum + 1))
{
usStreamNum = i;
break;
}
}
specific_code = (USHORT)(vtsi_mat.vts_spst_atrt[usStreamNum].specific_code);
lang_code = MapLanguageCode( (UCHAR)(get_language_code(specific_code)) );
return(lang_code);
}
else
{
DBGPRINT(DBG_ON(DBG_ERROR), ("DvdAppGetSubtitleLanguage: dvd nav not running!\n"));
return (0);
}
}
/**
* DvdAppGetNumberOfAngles -- Get number of angles in current title
*
* @param
* none
*
* @retval
* Number of angles
*/
USHORT DvdAppGetNumberOfAngles(void)
{
if (fDVDAppStarted == TRUE)
{
return (tt_srp[get_sprm(SPRM_TTN_TT_DOM) - 1].agl_n);
}
else
{
DBGPRINT(DBG_ON(DBG_ERROR), ("DvdAppGetNumberOfAngles: dvd nav not running!\n"));
return (0);
}
}
/**
* DvdAppGetNumberOfAvailableAngles -- Get number of angles currently available
*
* @param
* none
*
* @retval
* Number of angles
*/
USHORT DvdAppGetNumberOfAvailableAngles(void)
{
if (fDVDAppStarted == TRUE)
{
/*
* If we are currently playing a valid cell and the cell is in an angle block,
* then return the number of angles in the angle block. Otherwise, since we are
* not in an angle block, return 1.
*/
if ( ( (1 <= next_cell) && ( next_cell <= pgc_gi.pgc_cnt[3]) ) && /* valid cell */
( 0x10 == (c_pbi[next_cell - 1].c_cat[0] & 0x30 ) ) ) /* angle block */
{
/* Number of angles in each angle block in title is the same */
return (tt_srp[get_sprm(SPRM_TTN_TT_DOM) - 1].agl_n);
}
else
{
return (1);
}
}
else
{
DBGPRINT(DBG_ON(DBG_ERROR), ("DvdAppGetNumberOfAvailableAngles: dvd nav not running!\n"));
return (0);
}
}
/**
* DvdAppGetCurrentAngle -- Get currently selected angle
*
* @param
* none
*
* @retval
* Angle number
*/
USHORT DvdAppGetCurrentAngle(void)
{
if (fDVDAppStarted == TRUE)
{
return (sprm[SPRM_AGLN_TT_DOM]);
}
else
{
DBGPRINT(DBG_ON(DBG_ERROR), ("DvdAppGetCurrentAngle: dvd nav not running!\n"));
return (0);
}
}
/**
* DvdAppGetNumberOfAudio -- Get number of available audio streams
*
* @param
* none
*
* @retval
* Number of audio streams
*/
USHORT DvdAppGetNumberOfAudio(void)
{
if (fDVDAppStarted == TRUE)
{
USHORT usNumAudio = (vtsi_mat.vts_ast_n[1] & 0x3f);
USHORT usNumAvailableAudio = 0;
for (USHORT i = 0; i < usNumAudio; i++)
{
if (pgc_gi.pgc_ast_ctlt[i][0] & 0x80)
{
usNumAvailableAudio++;
}
}
return (usNumAvailableAudio);
}
else
{
DBGPRINT(DBG_ON(DBG_ERROR), ("DvdAppGetNumberOfAudio: dvd nav not running!\n"));
return (0);
}
}
/**
* DvdAppGetCurrentAudio -- Get currently selected audio stream
*
* @param
* none
*
* @retval
* audio stream number
*/
USHORT DvdAppGetCurrentAudio(void)
{
if (fDVDAppStarted == TRUE)
{
USHORT usAudioStn = 0;
OS_SemTake(prm_sem, OS_WAIT_FOREVER);
/* Calculate the audio stream number in the list of *enabled* audio streams */
for (USHORT i = 0; i <= sprm[SPRM_ASTN_TT_DOM]; i++)
{
/* If this audio stream is enabled, increase count */
if (pgc_gi.pgc_ast_ctlt[i][0] & 0x80)
{
usAudioStn++;
}
}
OS_SemGive(prm_sem);
return (usAudioStn);
}
else
{
DBGPRINT(DBG_ON(DBG_ERROR), ("DvdAppGetCurrentAudio: dvd nav not running!\n"));
return (0);
}
}
/**
* DvdAppGetAudioLanguage -- Get language of audio stream
*
* @param
* usStreamNum - audio stream number
*
* @retval
* Language code of audio stream with stream number = usStreamNum
*/
ULONG DvdAppGetAudioLanguage(USHORT usStreamNum)
{
if (fDVDAppStarted == TRUE)
{
USHORT specific_code;
ULONG lang_code;
USHORT usEnabledCount = 0;
/*
* Ths specified stream number is the stream number in the list of *enabled* streams.
* We need to determine which stream number this is in the list of *all* streams.
*/
for (USHORT i = 0; i < (vtsi_mat.vts_ast_n[1] & 0x3f); i++)
{
/* If this audio stream is enabled, increase count */
if (pgc_gi.pgc_ast_ctlt[i][0] & 0x80)
{
usEnabledCount++;
}
/* If we've reached the specified stream number, we're done */
if (usEnabledCount == (usStreamNum + 1))
{
usStreamNum = i;
break;
}
}
specific_code = (USHORT)(vtsi_mat.vts_ast_atrt[usStreamNum].specific_code);
lang_code = MapLanguageCode( (UCHAR)(get_language_code(specific_code)) );
return(lang_code);
}
else
{
DBGPRINT(DBG_ON(DBG_ERROR), ("DvdAppGetAudioLanguage: dvd nav not running!\n"));
return (0);
}
}
/**
* DvdAppGetRepeatMode -- Return the repeat mode
*
* @param
* None
*
* @retval
* VDVD_INFO_REPEAT repeat mode
*/
USHORT DvdAppGetRepeatMode(void)
{
USHORT usVdvdRepeatMode = VDVD_INFO_REPEAT_OFF;
/* map dvd repeat_mode to vdvd type */
switch (repeat_mode)
{
case REPEAT_OFF:
usVdvdRepeatMode = VDVD_INFO_REPEAT_OFF;
break;
case REPEAT_TT:
usVdvdRepeatMode = VDVD_INFO_REPEAT_TITLE;
break;
case REPEAT_PTT:
usVdvdRepeatMode = VDVD_INFO_REPEAT_CHAPTER;
break;
case REPEAT_A_B:
/* map ab count to vdvd repeat a-b type */
if (A_B_count == 1)
{
usVdvdRepeatMode = VDVD_INFO_REPEAT_A;
}
else
{
usVdvdRepeatMode = VDVD_INFO_REPEAT_AB;
}
break;
default:
break;
}
return (usVdvdRepeatMode);
}
/*
* PRIVATE FUNCTIONS
*****************************************************************************/
/**
* Receives event callbacks from the PE.
*
* @param event - enumerated event code (see pe_app.h)
*/
static PE_STATUS dvdPEEventCallback(PVOID pContext, PE_EVENT_CODE event, PVOID pEventInfo)
{
ULONG msg[4];
PE_STATUS pe_status = PE_SUCCESS;
if (event >= PE_EVENT_CODE_INVALID)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("%s, %d: PE_EVENT_INVALID\n", __FILE__, __LINE__));
return (PE_FAILURE);
}
if (fKillNavTasks == TRUE)
{
return (PE_SUCCESS);
}
switch (event)
{
case PE_EVENT_BEG_OF_STREAM:
DBGPRINT(DBG_ON(DBG_TRACE), ("dvdPEEventCallback(): Send NAV_BEG_STREAM\n"));
/* send message to nav to be processed */
msg[0] = NAV_BEG_STREAM;
if (OS_MsgQSend(queue_nav, (char *)&msg[0], NAV_MSG_SIZE, OS_WAIT_FOREVER, OS_MSG_PRI_NORMAL) == OS_OK)
{
/* Tell the pe to go idle
* The nav will resume the PE once it processes this event */
pe_status = PE_EVNT_IDLE;
}
break;
case PE_EVENT_END_OF_STREAM:
DBGPRINT(DBG_ON(DBG_TRACE), ("dvdPEEventCallback(): PE_EVENT_END_OF_STREAM\n"));
/* send message to nav to be processed */
msg[0] = NAV_END_STREAM;
msg[1] = (ULONG)((PE_END_OF_STREAM_EVENT_INFO *)pEventInfo)->pContext;
if (OS_MsgQSend(queue_nav, (char *)&msg[0], NAV_MSG_SIZE, OS_WAIT_FOREVER, OS_MSG_PRI_NORMAL) != OS_OK)
{
DbgPrint(("\nOS_MsgQSend FAILURE, %s, %d\n\n", __FILE__, __LINE__));
}
break;
case PE_EVENT_DISCONTINUITY:
DBGPRINT(DBG_ON(DBG_TRACE), ("dvdPEEventCallback(): PE_EVENT_DISCONTINUITY\n"));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -