GenericClip.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:10k
- /****************************************************************************************
- * Copyright (c) 2002 ZORAN Corporation, All Rights Reserved
- * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
- *
- * File: $Workfile: GenericClip.c $
- *
- * Description:
- * ============
- *
- *
- * Log:
- * ====
- * $Revision: 16 $
- * Last Modified by $Author: Nmaurer $ at $Modtime: 1/25/04 8:05 $
- ****************************************************************************************
- * Updates:
- ****************************************************************************************
- * $Log: /I76/I76_Common/I76_Reference/Playcore/Nav_Clips/GenericClip.c $
- *
- * 16 1/25/04 8:20 Nmaurer
- * Add drv_ prefix to Drive routines
- *
- * 15 11/28/03 7:24p Leslie
- * Change order of DEC_SetDiskType() and DEC_Prepare_to_decode()
- *
- * 11 03-08-29 0:04 Leslie
- * Add support for DVD-ROM Clips Discs
- *
- * 10 7/05/03 7:25a Stephaneh
- * Fixed SPDIF output at startup when Digital setting is Off
- *
- * 9 03-05-29 18:02 Jerryc
- * support flash card.
- *
- * 8 03-05-19 13:42 Leslie
- * Add drive Play Mode
- *
- * 7 03-03-06 19:12 Jerryc
- * jerryc, fix function getPrevItemInPrevFolder().
- *
- * 6 03-03-04 11:34 Jerryc
- * jerry cai, merge new nav clips lib
- *
- * 5 03-02-08 0:34 Leslie
- * Add MANUAL_DIRECTORY_EXPLORER
- *
- * 4 03-02-06 14:22 Leslie
- * Recoder Clip Number when recorder Marker
- *
- * 3 03-01-10 12:21 Leslie
- * Add wide-character strings support
- *
- * 2 03-01-09 12:30 Leslie
- *
- * 1 10/30/02 18:05 Rond
- *
- * 1 11/09/02 15:48 Atai
- *
- * 6 16/08/02 14:52 Nirm
- * - Code cleanup.
- *
- * 5 13/08/02 13:47 Nirm
- * - Clip_isFinished() replaced by Clip_getStatus().
- *
- * 4 4/08/02 17:12 Nirm
- * - Disabled Caching for Generic Clips.
- *
- * 3 2/08/02 19:47 Nirm
- * - Added Caching capability.
- *
- * 2 1/08/02 23:58 Nirm
- * - Integrated Byte-precision playback of Clips.
- *
- * 1 30/07/02 18:39 Nirm
- ****************************************************************************************/
- #include "Config.h" // Global Configuration - do not remove!
- #ifdef _DEBUG
- #undef IFTRACE
- #define IFTRACE if (gTraceNavigator)
- #include "DebugDbgMain.h"
- #endif
- #include "IncludeSysDefs.h"
- #include "Includemath-macro.h"
- #include "DecoderDecoder.h"
- #include "Drivedrv_api.h"
- #include "Drivedrv_defs.h"
- #include "PlaycoreCoremainCoreGDef.h"
- #include "PlaycoreNav_ClipsGenericClip.h"
- #include "PlaycoreNav_ClipsPE_Clips.h"
- #include "PlaycoreFileSysFileSystem_Impl.h"
- #ifdef SUPPORT_FLASH_CARD
- #include "DriveFE_Manager.h"
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // Const Factory
- DECLARE_CLIP_CONST_ATTR(Generic,
- DECLARE_CLIP_VTABLE(GenericClip_getExtendedInfo,
- GenericClip_play,
- GenericClip_pause,
- GenericClip_getStatus,
- GenericClip_abort,
- GenericClip_recordMarker,
- GenericClip_refresh,
- GenericClip_getTime,
- GenericClip_digest,
- GenericClip_scan
- ),
- eClipType_None,
- 0xFF, 0xFF, DEC_DISC_TYPE_NO_DISK,
- eCA_None,
- NULL
- )
- /////////////////////////////////////////////////////////////////////////////
- // Public Services
- BOOL GenericClip_isKindOf(LPCWSTR i_pszFilename, const LPCWSTR *i_aValidExtensions)
- {
- UINT8 uCurrExt;
- LPCWSTR pszExtension;
- // Locate the Filename-Extension
- pszExtension= wcsrchr(i_pszFilename, '.');
- if (NULL == pszExtension)
- return FALSE;
- // Isolate the Extension only (excluding the delimiter)
- pszExtension++;
- // Iterate over the Valid Extensions, and look for a match
- uCurrExt= 0;
- while (NULL != i_aValidExtensions[uCurrExt]) {
- if (0 == wcscmpi(pszExtension, i_aValidExtensions[uCurrExt]))
- return TRUE;
- uCurrExt++;
- }
- return FALSE;
- }
- void GenericClip_constructDefault(Clip *i_pThis)
- {
- // Set the Constant-Clip implementation only
- i_pThis->m_pConstAttr= &CLIP_CONST_ATTR(Generic);
- return;
- }
- void GenericClip_construct(Clip *o_pThis, const FindData *i_pFileInfo)
- {
- LPWSTR pszDelim;
- // Set the Constant-Clip implementation
- o_pThis->m_pConstAttr= &CLIP_CONST_ATTR(Generic);
- // Fill-in the ClipFileInfo:
- //AngieHe_0909_2004:Fix the wrong structure type.
- memset(&o_pThis->m_cfiInfo, 0, sizeof(ClipFileInfo));
- // Copy the Filename (not including the Extension)
- pszDelim= wcsrchr(i_pFileInfo->szFileID, '.');
- if (NULL == pszDelim) {
- dbg_printf(("INFO: GenericClip_construct(): No file-extension provided.n"));
- pszDelim= (LPWSTR)(i_pFileInfo->szFileID + CLIPS_MAX_FILENAME_LEN);
- }
- if (0 == wcsncmp(i_pFileInfo->szFileID, L"..", CLIPS_MAX_DIRNAME_LEN))
- wcsncpy((o_pThis->m_cfiInfo).szFilename, i_pFileInfo->szFileID,
- CLIPS_MAX_FILENAME_LEN);
- else
- wcsncpy((o_pThis->m_cfiInfo).szFilename, i_pFileInfo->szFileID,
- MIN(CLIPS_MAX_FILENAME_LEN, (int)(pszDelim - i_pFileInfo->szFileID)));
- // Copy the Directory-Name
- {
- WCHAR currPath[MAX_PATH];
- FileSys_getCurrentPath(currPath);
- pszDelim= wcsrchr(currPath, FileSys_getPathDelimiter());
- if (NULL != pszDelim)
- pszDelim++;
- else
- pszDelim= currPath;//(LPWSTR)FileSys_getCurrentPath();
- }
- wcsncpy((o_pThis->m_cfiInfo).szDirectoryName, pszDelim, CLIPS_MAX_DIRNAME_LEN);
- // Copy the File-Location and Size
- (o_pThis->m_cfiInfo).dwFileLocation= i_pFileInfo->dwStartAddr;
- (o_pThis->m_cfiInfo).cbFileSize= i_pFileInfo->cbFileSizeLow;
- // Set the Presentation Information
- (o_pThis->m_presentationInfo).eImageOrientation= eCIO_Original;
- (o_pThis->m_presentationInfo).eTransitionEffect= eCTE_None;
- (o_pThis->m_presentationInfo).ucUserData= 0x00;
- (o_pThis->m_presentationInfo).bModified= FALSE;
- return;
- }
- #pragma argsused
- BOOL GenericClip_getExtendedInfo(const Clip *i_pThis, WORD i_pExtInfo_sc_handle)
- {
- dbg_printf(("GenericClip_getExtendedInfo()n"));
- return FALSE;
- }
- #pragma argsused
- BOOL GenericClip_play(Clip *i_pThis, const ClipMarker *i_pResumeMarker,
- BOOL bCacheOnly)
- {
- DWORD dwStartLBA;
- ULONG ulBlocksCnt, cbPlaybackLength;
- dbg_printf(("GenericClip_play()n"));
- // Cached-playback is unsupported by default
- if (bCacheOnly)
- return FALSE;
- // Kill any existing Zoom
- DEC_SetZoomScale(NO_ZOOM);
- // Configure the Decoder to the appropriate Bitstream Type
- DEC_Stop_DVP_ADP_cmd((UINT8)0);
- DEC_SetDiskType((i_pThis->m_pConstAttr)->m_eBitstreamType);
- // Prepare for decoding
- DEC_prepare_to_decode();
- DEC_SetSID(DEC_SID_TYPE_AUDIO, (i_pThis->m_pConstAttr)->m_eAudioSID);
- DEC_SetSID(DEC_SID_TYPE_VIDEO, (i_pThis->m_pConstAttr)->m_eVideoSID);
- // Select the appropriate Clock
- PE_Clips_SelectClock(eCT_Decoder);
- // Calculate the Playback Start-Address
- if (NULL == i_pResumeMarker) {
- // Start at the beginning
- dwStartLBA= (i_pThis->m_cfiInfo).dwFileLocation;
- }
- else {
- // Playback is being resumed
- dwStartLBA= i_pResumeMarker->dwAddress;
- }
- // Calculate the Playback Length (in Bytes)
- cbPlaybackLength= ( (i_pThis->m_cfiInfo).cbFileSize -
- (LOGICAL_BLOCK_SIZE * (dwStartLBA - (i_pThis->m_cfiInfo).dwFileLocation)) );
- ulBlocksCnt= ((cbPlaybackLength + LOGICAL_BLOCK_SIZE - 1) / LOGICAL_BLOCK_SIZE);
- // Inform the Decoder of the Playback-Range
- PE_Clips_SetPlaybackRange(dwStartLBA, ulBlocksCnt, UNLIMITED_FILE_SIZE);//Leslie_0823_2003_A
- // Invoke playback of the Decoder & Drive
- // NOTE: The order of invocation is important, and must not be changed!
- DEC_PlaybackCommand(DEC_PLAYBACK_CMD_PLAY, NULL);
- //LX051703: Add AV Data mode for Play CD
- if ( !PE_Clips_Playback_Sectors(DRVCF_CDSPEED_1X | DRVF_PLAY_CD_AV_DATA, dwStartLBA, ulBlocksCnt)){//Leslie_0823_2003_A
- dbg_printf(("WARNING: GenericClip_play() Failed [1]n"));
- return FALSE;
- }
- // Restart the Clock
- PE_Clips_EnableClock(TRUE, TRUE,
- (NULL != i_pResumeMarker) ? i_pResumeMarker->uTime : 0);
- return TRUE;
- }
- #pragma argsused
- void GenericClip_pause(Clip *i_pThis, BOOL bEnable)
- {
- dbg_printf(("GenericClip_pause(%d)n", bEnable));
- if (bEnable) {
- // Pause the Clock
- PE_Clips_EnableClock(FALSE, FALSE, 0);
- // Pause the Decoder
- DEC_PlaybackCommand(DEC_PLAYBACK_CMD_PAUSE, NULL);
- }
- else {
- // Resume the Clock
- PE_Clips_EnableClock(TRUE, FALSE, 0);
- // Resume the Decoder
- DEC_PlaybackCommand(DEC_PLAYBACK_CMD_RESUME, NULL);
- }
- return;
- }
- #pragma argsused
- enClipStatus GenericClip_getStatus(const Clip *i_pThis)
- {
- if (drv_is_play_done() && DEC_IsPlaybackFinished(FALSE))
- return eCS_Finished;
- return eCS_Busy;
- }
- #pragma argsused
- void GenericClip_abort(Clip *i_pThis, BOOL bMaintainStandby)
- {
- dbg_printf(("GenericClip_abort(%d)n", bMaintainStandby));
- // Stop the Clock
- PE_Clips_EnableClock(FALSE, !bMaintainStandby, 0);
- drv_abort_play();
- DEC_PlaybackCommand(DEC_PLAYBACK_CMD_STOP, 0);
- if (! bMaintainStandby)
- drv_spindown();
- return;
- }
- void GenericClip_recordMarker(const Clip *i_pThis, ClipMarker *o_pMarker)
- {
- UINT8 wMin, wSec, wFrm;
- dbg_printf(("GenericClip_recordMarker()n"));
- #ifdef SUPPORT_FLASH_CARD
- if (IS_PLAYING_CARD)
- {
- //get physical address.
- o_pMarker->dwAddress = PE_Clips_GetCurrLocation();
- }
- else
- #endif
- {
- drv_get_msf(&wMin, &wSec, &wFrm);
-
- o_pMarker->dwAddress= drv_msf2lbn(wMin, wSec, wFrm);
- o_pMarker->uTime= GenericClip_getTime(i_pThis);
- o_pMarker->uClipNumer = gns.clips.uCurrentClipNumber;
- }
- return;
- }
- #pragma argsused
- void GenericClip_refresh(Clip *i_pThis)
- {
- }
- #pragma argsused
- UINT16 GenericClip_getTime(const Clip *i_pThis)
- {
- return PE_Clips_GetClock();
- }
- #pragma argsused
- void GenericClip_digest(Clip *i_pThis)
- {
- dbg_printf(("GenericClip_digest()n"));
- return;
- }
- #pragma argsused
- void GenericClip_scan(Clip *i_pThis, int iScanSpeed)
- {
- dbg_printf(("GenericClip_Scan()n"));
- return;
- }