DVDDetection.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:7k
- /****************************************************************************************
- * Copyright (c) 2002 ZORAN Corporation, All Rights Reserved
- * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
- *
- * File: $Workfile: DVDDetection.c $
- *
- * Description:
- * ============
- *
- *
- * Log:
- * ====
- * $Revision: 8 $
- * Last Modified by $Author: Leslie $ at $Modtime: 04-03-03 17:02 $
- ****************************************************************************************
- * Updates:
- ****************************************************************************************
- * $Log: /I76/I76_Common/I76_Reference/Playcore/MediaDetection/DVDDetection.c $
- *
- * 8 04-03-03 17:43 Leslie
- * Fix wrong disc identification after eject try during disc loading
- *
- * 7 10/28/03 8:56a Leslie
- * remove the useless code
- *
- * 6 10/27/03 8:07a Leslie
- * add header
- *
- ****************************************************************************************/
- #include "Config.h" // Global Configuration - do not remove!
- #ifdef _DEBUG
- #define IFTRACE if (gTraceNavigator)
- #include "DebugDbgMain.h"
- #endif
- #include "IncludeSysDefs.h"
- #include "Includestring_ex.h"
- #include "Decoderdecoder.h"
- #include "Drivedrv_API.h"
- #include "PlaycoreDataStructuresArray.h"
- #include "PlaycoreAuxCacheAuxCache.h"
- #include "PlaycoreExceptionException.h"
- #include "PlaycoreFileSysFileSystem.h"
- #include "PlaycoreMediaDetectionDVDDetection.h"
- #include "PlaycorePlayModePlayMode.h"
- #include "PlaycoreNav_DVDHeadernvgadefs.h"
- #ifdef MACESTROLINK_SUPPORT
- #include "drivefe_manager.h"
- #endif
- /////////////////////////////////////////////////////////////////
- //global Variables Definition
- ////////////////////////////////////////////////////////////////
- // Private Services
- DWORD get_ifobase(LPCWSTR prefix, BOOL bIsBackupfile);
- static DWORD get_sapbase(void);
- static DWORD get_sapbase(void)
- {
- DWORD dwSAPBase= 0;
- int repeatcnt = 1;
- while (0 != repeatcnt--)
- {
- if (! FileSys_selectType(eAny)) {
- dbg_printf(("WARNING: get_sapbase() Failed [1]n", repeatcnt ));
- continue;
- }
- // Initialize the File-System
- if (! FileSys_initialize(FALSE)) {
- dbg_printf(("WARNING: get_sapbase() Failed [2]n"));
- continue;
- }
- // Try to enter the requested Directory
- if (! FileSys_changeDir(L"AUDIO_TS")) {
- dbg_printf(("WARNING: get_sapbase() Failed [3]n"));
- continue;
- }
- // Acquire the Address of the file
- if (FileSys_getFileLocation(L"AUDIO_PP.IFO", &dwSAPBase))
- break;
- dbg_printf(("WARNING: get_sapbase() Failed [4]n"));
- }
- return dwSAPBase;
- }
- DWORD get_ifobase(LPCWSTR prefix, BOOL bIsBackupfile)
- {
- DWORD dwIFOBase= 0;
- int repeatcnt = 2;
- WCHAR szFilename[16];
- dbg_printf(("get_ifobase(%s) calling.n", prefix));
- while (0 != repeatcnt--)
- {
- // Select any type of File-System that resides on the Medium
- if (! FileSys_selectType(eAny)) {
- dbg_printf(("WARNING: get_ifobase() Failed [1]n", repeatcnt ));
- continue;
- }
- // Initialize the File-System
- if (! FileSys_initialize(FALSE)) {
- dbg_printf(("WARNING: get_ifobase() Failed [2]n"));
- continue;
- }
- // Construct directory name
- wcscpy(szFilename, prefix);
- wcscat(szFilename, L"_TS");
- // Try to enter the requested Directory
- if (! FileSys_changeDir(szFilename)) {
- //<<<LX082202: Temporary patch for DVD discs whose VIDEO_TS don't locate in the root directory. Eventually we need to search the
- //path table to get the location of video_ts.ifo file
- if(wcscmp(szFilename, L"VIDEO_TS") == 0)//Leon.He_20050326: This patch should be only for DVD_Video, but this function is for DVD Audio also
- {
- LPCWSTR pszNewDir = L"DVDVolume";
- LPCWSTR pszNewDir1 = L"VIDEO_TS";
- dbg_printf(("WARNING: get_ifobase() Failed [3]n"));
- if ( !FileSys_changeDir(pszNewDir)){
- dbg_printf(("WARNING: get_ifobase() Failed [n]n"));
- continue;
- }
- if ( !FileSys_changeDir(pszNewDir1)){
- dbg_printf(("WARNING: get_ifobase() Failed [n+1]n"));
- continue;
- }
- }
- //LX082202>>>
- }
- // Locate the IFO file
- wcscpy(szFilename, prefix);
- if(bIsBackupfile)
- wcscat(szFilename, L"_TS.BUP");
- else
- wcscat(szFilename, L"_TS.IFO");
- // Acquire the Address of the file
- if (FileSys_getFileLocation((LPCWSTR)szFilename, &dwIFOBase))
- return dwIFOBase;
-
- dbg_printf(("WARNING: get_ifobase() Failed [4]n"));
- }
- if (0 == dwIFOBase) {
- tr_printf(("FATAL: Can't get IFO Base...Bad Disk!n"));
- }
- return dwIFOBase;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // DEC_DISC_TYPE DVD_DetermineDiscType() -
- // A sub-media identification service.
- //
- // Input:
- // None.
- //
- // Output:
- // The appropriate type of Disc for the Decoding process, or DEC_DISC_TYPE_NO_DISK if the
- // sub-media type couldn't be determined.
- //
- // Remarks: None
- int DVD_DetermineDiscType(void)
- {
- int iDVDDiscType = DVD_TYPE_NO_DISC;
-
- /* parse file system to find out what kind of DVD it is */
- /* DVD-Video, DVD-Audio/Video mixed, DVD-Audio only and DVD-ROM */
- #ifdef MACESTROLINK_SUPPORT
- if(IS_PLAYING_MLNK)
- DEC_SetDiskType( DEC_DISC_TYPE_MLNK);
- Logo_display(); //Hansen_2004_12_29
- #endif
- /* Check if it is DVD Video Disc First */
- if (0 != (gns.dvd.dw_vmg_ifobase= get_ifobase(L"VIDEO", FALSE)))
- {
- iDVDDiscType |= DVD_TYPE_VMG;
- }
- if (0 != (gns.dvd.dw_amg_ifobase= get_ifobase(L"AUDIO", FALSE)))
- {
- iDVDDiscType |= DVD_TYPE_AMG;
- }
- #ifdef DVD_VR_SUPPORT
- {//detect DVD-VR disc
- #ifdef D_ONLY_ONE_SESSION_4VCD
- enFileSysType eFS= FileSys_determineType(FALSE);
- #else
- enFileSysType eFS= FileSys_determineType();
- #endif
- if( eUDF_200 == eFS )
- {
- if( FileSys_selectType(eFS) && FileSys_initialize(TRUE) )
- {
- if (FileSys_goToRootDir() && FileSys_changeDir(L"DVD_RTAV") )
- iDVDDiscType |= DVD_TYPE_VR_VMG;
- }
- }
- }
- #endif//DVD_VR_SUPPORT
- /*if (0 != (gns.dvd.dw_sap_ifobase= get_sapbase()))
- {
- iDVDDiscType |= DVD_TYPE_SAP;
- }*/
- dbg_printf(("DVD type: %dn", iDVDDiscType));
- dbg_printf(("vmg_ifobase:%ldn", gns.dvd.dw_vmg_ifobase));
- dbg_printf(("amg_ifobase:%ldn", gns.dvd.dw_amg_ifobase));
- dbg_printf(("sap_ifobase:%ldn", gns.dvd.dw_sap_ifobase));
- /* Check if it is DVD-Audio disc */
- #ifdef DVD_AUDIO_SUPPORT
- if (!gps->dvd_a_v_preference && (iDVDDiscType & DVD_TYPE_VMG))
- {
- /* means priority contents is DVD-Video and VMG exists */
- iDVDDiscType &= ~DVD_TYPE_AMG;
- }
-
- if (iDVDDiscType & DVD_TYPE_AMG)
- {
- return DVD_TYPE_AMG;
- }
- #endif
- if (iDVDDiscType & DVD_TYPE_VMG)
- {
- return DVD_TYPE_VMG;
- }
- #ifdef DVD_VR_SUPPORT
- if(iDVDDiscType & DVD_TYPE_VR_VMG)
- return DVD_TYPE_VR_VMG;
- #endif
- #ifdef DVD_ROM_CLIPS_SUPPORT
- /* Neither DVD-Video nor DVD-Audio, check if it is DVD-ROM Disc
- * By default, we now assume it is DVD-ROM disc
- */
- if ( Exception_catchAndRethrow( EXCEPTION_MEDIUM_EJECTED ) )
- return DVD_TYPE_NO_DISC;
- else
- return DVD_TYPE_DVD_ROM;
- #else
- return DVD_TYPE_NO_DISC;
- #endif /* DVD_ROM_CLIPS_SUPPORT */
- }