📄 bdrom_app.cpp
字号:
/*****************************************************************************
******************************************************************************
** **
** Copyright (c) 2005-2006 Videon Central, Inc. **
** All rights reserved. **
** **
** The computer program contained herein contains proprietary information **
** which is the property of Videon Central, Inc. The program may be used **
** and/or copied only with the written permission of Videon Central, Inc. **
** or in accordance with the terms and conditions stipulated in the **
** agreement/contract under which the programs have been supplied. **
** **
******************************************************************************
*****************************************************************************/
/**
* @file bdrom_app.cpp
*
* Public API to the BDROM navigator.
*
* $Id: bdrom_app.cpp,v 1.66 2007/01/26 22:41:08 rbehe Exp $
*/
#include "vdvd_types.h"
#include "osapi.h"
#include "loader_app.h"
#include "dr_app.h"
#include "pe_app.h"
#include "dbgprint.h"
#include "bdrom_app.h"
#include "indexdb.h"
#include "mvobjdb.h"
#include "mvplaylistdb.h"
#include "sounddb.h"
#include "modmgr.h"
#include "playctrl.h"
#include "pbc_register.h"
#include "clpinfodb.h"
#include "usrapi.h"
#ifdef DMALLOC
#include "dmalloc.h"
#endif
/* Debug macros */
#define BDROMAPP_DEBUG DBG_ERROR
#define DBG_ON(x) (BDROMAPP_DEBUG >= x)
/**
* Local variables
*/
static BOOLEAN fBDROMAppInit = FALSE;
/**
* Local functions
*/
static OS_STATUS bdromappLoadPlayerCapabilities(PE_HANDLE pe);
static int bdromappMapLanguageCode(UCHAR ucLangCode);
/**
* BDROMAppInitialize -- Initialize the BDROM navigator
*
* @param
* loader - handle to the loader
* dr - handle to the dr
* pe - handle to the pe
*
* @retval
* BDAPP_STATUS
*/
BDAPP_STATUS BDROMAppInitialize(LOADER_HANDLE loader, DR_HANDLE dr, PE_HANDLE pe)
{
if (fBDROMAppInit == TRUE)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppInitialize: BDROM app already initialized\n"));
return (BDAPP_FAILURE);
}
if ( (loader == NULL) || (dr == NULL) || (pe == NULL) )
{
DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppInitialize: NULL PARAMETER\n"));
return (BDAPP_NULL_PTR);
}
/* Create the BD-ROM index table database */
if (IndexCreate(loader) != INDEX_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppInitialize: Failed to create index database\n"));
goto error_out;
}
/* Create the BD-ROM movie object database */
if (MvObjCreate(loader) != MVOBJ_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppInitialize: Failed to create mobj database\n"));
goto error_out;
}
/* Create the BD-ROM sound database */
if (SOUNDDBCreate(loader) != SOUNDDB_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppInitialize: Failed to create sound database\n"));
/* if sounds fail, don't die completely */
}
/* Create the BD-ROM movie playlist database */
if (MPLSCreate(loader) != MPLS_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppInitialize: Failed to create mpls database\n"));
goto error_out;
}
/* Create the BD-ROM clip info database */
if (ClpInfoMgrCreate(loader) != CLPINFO_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppInitialize: Failed to create clip info database\n"));
goto error_out;
}
/* Create the BD-ROM Module Manager */
if (ModMgrCreate(dr, pe) != MODMGR_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppInitialize: Failed to create mod mgr\n"));
goto error_out;
}
/* Load player capabilities */
if (bdromappLoadPlayerCapabilities(pe) != OS_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppInitialize: Failed to load player capabilities\n"));
goto error_out;
}
#ifdef DRM_BDPLUS_SUPPORT
/*
* TODO: check for BD+ disc and init the BD+ module if necessary
*/
DbgPrint(("%s:%d - NO DRM_BDPLUS_SUPPORT\n", __FILE__, __LINE__));
#endif
/* Set initialization flag */
fBDROMAppInit = TRUE;
return (BDAPP_SUCCESS);
error_out:
#ifdef DRM_BDPLUS_SUPPORT
/*
* TODO: If BD+ is running then shut it down now
*/
DbgPrint(("%s:%d - NO DRM_BDPLUS_SUPPORT\n", __FILE__, __LINE__));
#endif
/* delete module manager */
ModMgrDelete();
/* delete clip info database */
ClpInfoMgrDelete();
/* delete movie playlist database */
MPLSDelete();
/* delete sound database */
SOUNDDBDelete();
/* delete movie object database */
MvObjDelete();
/* delete index table database */
IndexDelete();
return (BDAPP_FAILURE);
}
/**
* BDROMAppUnInitialize -- Uninitialize the BDROM navigator
*
* @param
* none
*
* @retval
* BDAPP_STATUS
*/
BDAPP_STATUS BDROMAppUnInitialize(void)
{
if (fBDROMAppInit == FALSE)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppUnInitialize: BDROM app not initialized\n"));
return (BDAPP_FAILURE);
}
/* Clear flag */
fBDROMAppInit = FALSE;
/* Delete the BD-ROM Module Manager */
ModMgrDelete();
/* delete clip info database */
ClpInfoMgrDelete();
/* delete movie playlist database */
MPLSDelete();
/* delete sound database */
SOUNDDBDelete();
/* delete movie object database */
MvObjDelete();
/* delete index table database */
IndexDelete();
#ifdef DRM_BDPLUS_SUPPORT
/*
* TODO: If BD+ is running then shut it down now
*/
DbgPrint(("%s:%d - NO DRM_BDPLUS_SUPPORT\n", __FILE__, __LINE__));
#endif
return (BDAPP_SUCCESS);
}
/**
* BDROMAppStartNav -- Starts the BDROM navigator.
*
* @param
* none
*
* @retval
* BDAPP_STATUS
*/
BDAPP_STATUS BDROMAppStartNav(void)
{
if (fBDROMAppInit == FALSE)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppStartNav: BDROM app not initialized\n"));
return (BDAPP_FAILURE);
}
/*
* Send a PLAY event to the BD-ROM Module Manager to initiate
* a first play.
*/
if (ModMgrAddUserEvent(MODMGR_PLAY, 0) != MODMGR_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppStartNav: Failed to send user event to mod mgr\n"));
return (BDAPP_FAILURE);
}
return (BDAPP_SUCCESS);
}
/**
* BDROMAppCommandHandler -- Give command to BDROM nav to process.
*
* @param
* ulCommand -- Command to be processed
* ulInfo -- Information specific to the command
*
* @retval
* BDAPP_STATUS
*/
BDAPP_STATUS BDROMAppCommandHandler(ULONG ulCommand, ULONG ulInfo)
{
BOOLEAN fSendUserEvent = TRUE;
MODMGR_COMMAND tUserEvent = MODMGR_INVALID_COMMAND;
if (fBDROMAppInit == FALSE)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppCommandHandler: BDROM nav not running\n"));
return (BDAPP_FAILURE);
}
/*
* Map VDVD command type to an BDROM User Event
*/
switch (ulCommand)
{
case VDVD_COMMAND_PLAY:
tUserEvent = MODMGR_PLAY;
break;
case VDVD_COMMAND_PLAY_LOCATION:
tUserEvent = MODMGR_PLAYLOCATION;
break;
case VDVD_COMMAND_STOP:
tUserEvent = MODMGR_STOP;
break;
case VDVD_COMMAND_GOTO_TITLE:
tUserEvent = MODMGR_TITLESEARCH;
break;
case VDVD_COMMAND_MENU:
tUserEvent = MODMGR_MENUCALL;
break;
case VDVD_COMMAND_STILL_OFF:
tUserEvent = MODMGR_STILLOFF;
break;
case VDVD_COMMAND_FWD_PLAY:
tUserEvent = MODMGR_FORWARDPLAY;
break;
case VDVD_COMMAND_BWD_PLAY:
tUserEvent = MODMGR_BACKWARDPLAY;
break;
case VDVD_COMMAND_PAUSE_ON:
tUserEvent = MODMGR_PAUSEON;
break;
case VDVD_COMMAND_PAUSE_OFF:
tUserEvent = MODMGR_PAUSEOFF;
break;
case VDVD_COMMAND_STEP_FWD:
tUserEvent = MODMGR_FORWARDPLAY;
ulInfo = 1;
break;
case VDVD_COMMAND_AUDIO_SELECT:
tUserEvent = MODMGR_AUDIOCHANGE;
break;
case VDVD_COMMAND_ANGLE:
tUserEvent = MODMGR_ANGLECHANGE;
break;
case VDVD_COMMAND_GOTO_CHAPTER:
tUserEvent = MODMGR_CHAPTERSEARCH;
break;
case VDVD_COMMAND_NEXT_CHAPTER:
tUserEvent = MODMGR_SKIPTONEXTPOINT;
break;
case VDVD_COMMAND_PREV_CHAPTER:
tUserEvent = MODMGR_SKIPTOPREVPOINT;
break;
case VDVD_COMMAND_RESTART_CHAPTER:
tUserEvent = MODMGR_RESTARTPOINT;
break;
case VDVD_COMMAND_GOTO_TIME:
tUserEvent = MODMGR_TIMESEARCH;
break;
case VDVD_COMMAND_UP:
tUserEvent = MODMGR_MOVEUPSELECTEDBUTTON;
break;
case VDVD_COMMAND_DOWN:
tUserEvent = MODMGR_MOVEDOWNSELECTEDBUTTON;
break;
case VDVD_COMMAND_LEFT:
tUserEvent = MODMGR_MOVELEFTSELECTEDBUTTON;
break;
case VDVD_COMMAND_RIGHT:
tUserEvent = MODMGR_MOVERIGHTSELECTEDBUTTON;
break;
case VDVD_COMMAND_UP_RELEASE:
tUserEvent = MODMGR_MOVEUPSELECTEDBUTTON_RELEASE;
break;
case VDVD_COMMAND_DOWN_RELEASE:
tUserEvent = MODMGR_MOVEDOWNSELECTEDBUTTON_RELEASE;
break;
case VDVD_COMMAND_LEFT_RELEASE:
tUserEvent = MODMGR_MOVELEFTSELECTEDBUTTON_RELEASE;
break;
case VDVD_COMMAND_RIGHT_RELEASE:
tUserEvent = MODMGR_MOVERIGHTSELECTEDBUTTON_RELEASE;
break;
case VDVD_COMMAND_NUMERIC_BUTTON_SELECT:
tUserEvent = MODMGR_SELECTANDACTIVATEBUTTON;
break;
case VDVD_COMMAND_ENTER:
tUserEvent = MODMGR_ACTIVATEBUTTON;
break;
case VDVD_COMMAND_SUBTITLE_ON_OFF:
tUserEvent = MODMGR_PGANDSTENABLE;
break;
case VDVD_COMMAND_SUBTITLE_SELECT:
tUserEvent = MODMGR_PGANDSTCHANGE;
break;
case VDVD_COMMAND_RETURN:
tUserEvent = MODMGR_RESUME;
break;
case VDVD_COMMAND_POPUP_ON_OFF:
if (ulInfo == 0)
{
tUserEvent = MODMGR_POPUPOFF;
}
else
{
tUserEvent = MODMGR_POPUPON;
}
break;
case VDVD_COMMAND_SUBTITLE_USER_STYLE:
tUserEvent = MODMGR_TEXTSUBTITLESTYLECHANGE;
break;
case VDVD_COMMAND_REPEAT:
tUserEvent = MODMGR_REPEAT;
break;
case VDVD_COMMAND_COLOR_KEY:
tUserEvent = MODMGR_COLOR_KEY;
break;
default:
fSendUserEvent = FALSE;
DBGPRINT(DBG_ON(DBG_TRACE), ("BDROMAppCommandHandler: Command not supported\n"));
break;
}
if (fSendUserEvent == TRUE)
{
/* Send user event to Module Manager */
if (ModMgrAddUserEvent(tUserEvent, ulInfo) != MODMGR_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppCommandHandler: Failed to send user event to mod mgr\n"));
return (BDAPP_FAILURE);
}
}
else
{
/* notifiy unsupported command */
UsrSendProhibitedEvent(VDVD_INFO_PROH_CMD_NOT_SUPPORTED, ulCommand);
}
return (BDAPP_SUCCESS);
}
/**
* BDROMAppSetMenuLanguage -- Set the default menu language
*
* @param
* ucLangCode - language code for dvd menu
*
* @retval
* none.
*/
void BDROMAppSetMenuLanguage(UCHAR ucLangCode)
{
/* Set Menu language */
if (ModMgrConfigMenuLanguage(bdromappMapLanguageCode(ucLangCode) ) != MODMGR_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppSetMenuLanguage: failed to set menu language\n"));
}
}
/**
* BDROMAppSetAudioLanguage -- Set the default audio language
*
* @param
* ucLangCode - language code for audio
*
* @retval
* none.
*/
void BDROMAppSetAudioLanguage(UCHAR ucLangCode)
{
/* Set Audio language */
if (ModMgrConfigAudioLanguage(bdromappMapLanguageCode(ucLangCode) ) != MODMGR_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppSetAudioLanguage: failed to set audio language\n"));
}
}
/**
* BDROMAppSetSubtitleLanguage -- Set the default subtitle language
*
* @param
* ucLangCode - language code for subtitles
*
* @retval
* none.
*/
void BDROMAppSetSubtitleLanguage(UCHAR ucLangCode)
{
/* Set Subtitle language */
if (ModMgrConfigPGandSTLanguage(bdromappMapLanguageCode(ucLangCode) ) != MODMGR_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppSetSubtitleLanguage: failed to set subtitle language\n"));
}
}
/**
* BDROMAppSetParentalLevel -- Set the parental level
*
* @param
* ucLevel - parental level (1 - 8); 0 = off
*
* @retval
* none.
*/
void BDROMAppSetParentalLevel(UCHAR ucLevel)
{
int age;
/* Map parental level (1-8) to an age. */
switch (ucLevel)
{
case 1:
age = 5;
break;
case 2:
age = 8;
break;
case 3:
age = 10;
break;
case 4:
age = 13;
break;
case 5:
age = 15;
break;
case 6:
age = 17;
break;
case 7:
age = 17;
break;
case 8:
age = 18;
break;
case 0:
default:
age = 255;
}
/* Set parental level */
if (ModMgrConfigParentalLevel(age) != MODMGR_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppSetParentalLevel: failed to set parental level\n"));
}
}
/**
* BDROMAppSetCountryCode -- Set the country code
*
* @param
* ucCountryCode - country code
*
* @retval
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -