GenericClip.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:10k
源码类别:

DVD

开发平台:

Others

  1. /****************************************************************************************
  2.  *  Copyright (c) 2002 ZORAN Corporation, All Rights Reserved
  3.  *  THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
  4.  *
  5.  *  File: $Workfile: GenericClip.c $             
  6.  *
  7.  * Description: 
  8.  * ============
  9.  * 
  10.  * 
  11.  * Log:
  12.  * ====
  13.  * $Revision: 16 $
  14.  * Last Modified by $Author: Nmaurer $ at $Modtime: 1/25/04 8:05 $ 
  15.  ****************************************************************************************
  16.  * Updates:
  17.  ****************************************************************************************
  18.  * $Log: /I76/I76_Common/I76_Reference/Playcore/Nav_Clips/GenericClip.c $
  19.  * 
  20.  * 16    1/25/04 8:20 Nmaurer
  21.  * Add drv_ prefix to Drive routines
  22.  * 
  23.  * 15    11/28/03 7:24p Leslie
  24.  * Change order of DEC_SetDiskType() and DEC_Prepare_to_decode()
  25.  * 
  26.  * 11    03-08-29 0:04 Leslie
  27.  * Add support for DVD-ROM Clips Discs
  28.  * 
  29.  * 10    7/05/03 7:25a Stephaneh
  30.  * Fixed SPDIF output at startup when Digital setting is Off
  31.  * 
  32.  * 9     03-05-29 18:02 Jerryc
  33.  * support flash card.
  34.  * 
  35.  * 8     03-05-19 13:42 Leslie
  36.  * Add drive Play Mode
  37.  * 
  38.  * 7     03-03-06 19:12 Jerryc
  39.  * jerryc, fix function getPrevItemInPrevFolder().
  40.  * 
  41.  * 6     03-03-04 11:34 Jerryc
  42.  * jerry cai, merge new nav clips lib 
  43.  * 
  44.  * 5     03-02-08 0:34 Leslie
  45.  * Add MANUAL_DIRECTORY_EXPLORER
  46.  * 
  47.  * 4     03-02-06 14:22 Leslie
  48.  * Recoder Clip Number when recorder Marker
  49.  * 
  50.  * 3     03-01-10 12:21 Leslie
  51.  * Add wide-character strings support
  52.  * 
  53.  * 2     03-01-09 12:30 Leslie
  54.  * 
  55.  * 1     10/30/02 18:05 Rond
  56.  * 
  57.  * 1     11/09/02 15:48 Atai
  58.  * 
  59.  * 6     16/08/02 14:52 Nirm
  60.  * - Code cleanup.
  61.  * 
  62.  * 5     13/08/02 13:47 Nirm
  63.  * - Clip_isFinished() replaced by Clip_getStatus().
  64.  * 
  65.  * 4     4/08/02 17:12 Nirm
  66.  * - Disabled Caching for Generic Clips.
  67.  * 
  68.  * 3     2/08/02 19:47 Nirm
  69.  * - Added Caching capability.
  70.  * 
  71.  * 2     1/08/02 23:58 Nirm
  72.  * - Integrated Byte-precision playback of Clips.
  73.  * 
  74.  * 1     30/07/02 18:39 Nirm
  75.  ****************************************************************************************/
  76. #include "Config.h" // Global Configuration - do not remove!
  77. #ifdef _DEBUG
  78. #undef IFTRACE
  79. #define IFTRACE if (gTraceNavigator)
  80. #include "DebugDbgMain.h"
  81. #endif
  82. #include "IncludeSysDefs.h"
  83. #include "Includemath-macro.h"
  84. #include "DecoderDecoder.h"
  85. #include "Drivedrv_api.h"
  86. #include "Drivedrv_defs.h"
  87. #include "PlaycoreCoremainCoreGDef.h"
  88. #include "PlaycoreNav_ClipsGenericClip.h"
  89. #include "PlaycoreNav_ClipsPE_Clips.h"
  90. #include "PlaycoreFileSysFileSystem_Impl.h"
  91. #ifdef SUPPORT_FLASH_CARD
  92. #include "DriveFE_Manager.h"
  93. #endif
  94. /////////////////////////////////////////////////////////////////////////////
  95. // Const Factory
  96. DECLARE_CLIP_CONST_ATTR(Generic,
  97. DECLARE_CLIP_VTABLE(GenericClip_getExtendedInfo,
  98. GenericClip_play,
  99. GenericClip_pause,
  100. GenericClip_getStatus,
  101. GenericClip_abort,
  102. GenericClip_recordMarker,
  103. GenericClip_refresh,
  104. GenericClip_getTime,
  105. GenericClip_digest,
  106. GenericClip_scan
  107. ),
  108. eClipType_None,
  109. 0xFF, 0xFF, DEC_DISC_TYPE_NO_DISK,
  110. eCA_None,
  111. NULL
  112. )
  113. /////////////////////////////////////////////////////////////////////////////
  114. // Public Services
  115. BOOL GenericClip_isKindOf(LPCWSTR i_pszFilename, const LPCWSTR *i_aValidExtensions)
  116. {
  117. UINT8 uCurrExt;
  118. LPCWSTR pszExtension;
  119. // Locate the Filename-Extension
  120. pszExtension= wcsrchr(i_pszFilename, '.');
  121. if (NULL == pszExtension)
  122. return FALSE;
  123. // Isolate the Extension only (excluding the delimiter)
  124. pszExtension++;
  125. // Iterate over the Valid Extensions, and look for a match
  126. uCurrExt= 0;
  127. while (NULL != i_aValidExtensions[uCurrExt]) {
  128. if (0 == wcscmpi(pszExtension, i_aValidExtensions[uCurrExt]))
  129. return TRUE;
  130. uCurrExt++;
  131. }
  132. return FALSE;
  133. }
  134. void GenericClip_constructDefault(Clip *i_pThis)
  135. {
  136. // Set the Constant-Clip implementation only
  137. i_pThis->m_pConstAttr= &CLIP_CONST_ATTR(Generic);
  138. return;
  139. }
  140. void GenericClip_construct(Clip *o_pThis, const FindData *i_pFileInfo)
  141. {
  142. LPWSTR pszDelim;
  143. // Set the Constant-Clip implementation
  144. o_pThis->m_pConstAttr= &CLIP_CONST_ATTR(Generic);
  145. // Fill-in the ClipFileInfo:
  146. //AngieHe_0909_2004:Fix the wrong structure type.
  147. memset(&o_pThis->m_cfiInfo, 0, sizeof(ClipFileInfo));
  148. // Copy the Filename (not including the Extension)
  149. pszDelim= wcsrchr(i_pFileInfo->szFileID, '.');
  150. if (NULL == pszDelim) {
  151. dbg_printf(("INFO: GenericClip_construct(): No file-extension provided.n"));
  152. pszDelim= (LPWSTR)(i_pFileInfo->szFileID + CLIPS_MAX_FILENAME_LEN);
  153. }
  154. if (0 == wcsncmp(i_pFileInfo->szFileID, L"..", CLIPS_MAX_DIRNAME_LEN))
  155. wcsncpy((o_pThis->m_cfiInfo).szFilename, i_pFileInfo->szFileID,
  156. CLIPS_MAX_FILENAME_LEN);
  157. else
  158. wcsncpy((o_pThis->m_cfiInfo).szFilename, i_pFileInfo->szFileID,
  159. MIN(CLIPS_MAX_FILENAME_LEN, (int)(pszDelim - i_pFileInfo->szFileID)));
  160. // Copy the Directory-Name
  161. {
  162. WCHAR currPath[MAX_PATH];
  163. FileSys_getCurrentPath(currPath);
  164. pszDelim= wcsrchr(currPath, FileSys_getPathDelimiter());
  165. if (NULL != pszDelim)
  166. pszDelim++;
  167. else
  168. pszDelim= currPath;//(LPWSTR)FileSys_getCurrentPath();
  169. }
  170. wcsncpy((o_pThis->m_cfiInfo).szDirectoryName, pszDelim, CLIPS_MAX_DIRNAME_LEN);
  171. // Copy the File-Location and Size
  172. (o_pThis->m_cfiInfo).dwFileLocation= i_pFileInfo->dwStartAddr;
  173. (o_pThis->m_cfiInfo).cbFileSize= i_pFileInfo->cbFileSizeLow;
  174. // Set the Presentation Information
  175. (o_pThis->m_presentationInfo).eImageOrientation= eCIO_Original;
  176. (o_pThis->m_presentationInfo).eTransitionEffect= eCTE_None;
  177. (o_pThis->m_presentationInfo).ucUserData= 0x00;
  178. (o_pThis->m_presentationInfo).bModified= FALSE;
  179. return;
  180. }
  181. #pragma argsused
  182. BOOL GenericClip_getExtendedInfo(const Clip *i_pThis, WORD i_pExtInfo_sc_handle)
  183. {
  184. dbg_printf(("GenericClip_getExtendedInfo()n"));
  185. return FALSE;
  186. }
  187. #pragma argsused
  188. BOOL GenericClip_play(Clip *i_pThis, const ClipMarker *i_pResumeMarker,
  189.   BOOL bCacheOnly)
  190. {
  191. DWORD dwStartLBA;
  192. ULONG ulBlocksCnt, cbPlaybackLength;
  193. dbg_printf(("GenericClip_play()n"));
  194. // Cached-playback is unsupported by default
  195. if (bCacheOnly)
  196. return FALSE;
  197. // Kill any existing Zoom
  198. DEC_SetZoomScale(NO_ZOOM);
  199. // Configure the Decoder to the appropriate Bitstream Type
  200. DEC_Stop_DVP_ADP_cmd((UINT8)0);
  201. DEC_SetDiskType((i_pThis->m_pConstAttr)->m_eBitstreamType);
  202. // Prepare for decoding
  203. DEC_prepare_to_decode();
  204. DEC_SetSID(DEC_SID_TYPE_AUDIO, (i_pThis->m_pConstAttr)->m_eAudioSID);
  205. DEC_SetSID(DEC_SID_TYPE_VIDEO, (i_pThis->m_pConstAttr)->m_eVideoSID);
  206. // Select the appropriate Clock
  207. PE_Clips_SelectClock(eCT_Decoder);
  208. // Calculate the Playback Start-Address
  209. if (NULL == i_pResumeMarker) {
  210. // Start at the beginning
  211. dwStartLBA= (i_pThis->m_cfiInfo).dwFileLocation;
  212. }
  213. else {
  214. // Playback is being resumed
  215. dwStartLBA= i_pResumeMarker->dwAddress;
  216. }
  217. // Calculate the Playback Length (in Bytes)
  218. cbPlaybackLength= ( (i_pThis->m_cfiInfo).cbFileSize - 
  219. (LOGICAL_BLOCK_SIZE * (dwStartLBA - (i_pThis->m_cfiInfo).dwFileLocation)) );
  220. ulBlocksCnt= ((cbPlaybackLength + LOGICAL_BLOCK_SIZE - 1) / LOGICAL_BLOCK_SIZE);
  221. // Inform the Decoder of the Playback-Range
  222. PE_Clips_SetPlaybackRange(dwStartLBA, ulBlocksCnt, UNLIMITED_FILE_SIZE);//Leslie_0823_2003_A
  223. // Invoke playback of the Decoder & Drive
  224. // NOTE: The order of invocation is important, and must not be changed!
  225. DEC_PlaybackCommand(DEC_PLAYBACK_CMD_PLAY, NULL);
  226. //LX051703: Add AV Data mode for Play CD
  227. if ( !PE_Clips_Playback_Sectors(DRVCF_CDSPEED_1X | DRVF_PLAY_CD_AV_DATA, dwStartLBA, ulBlocksCnt)){//Leslie_0823_2003_A
  228. dbg_printf(("WARNING: GenericClip_play() Failed [1]n"));
  229. return FALSE;
  230. }
  231. // Restart the Clock
  232. PE_Clips_EnableClock(TRUE, TRUE,
  233.  (NULL != i_pResumeMarker) ? i_pResumeMarker->uTime : 0);
  234. return TRUE;
  235. }
  236. #pragma argsused
  237. void GenericClip_pause(Clip *i_pThis, BOOL bEnable)
  238. {
  239. dbg_printf(("GenericClip_pause(%d)n", bEnable));
  240. if (bEnable) {
  241. // Pause the Clock
  242. PE_Clips_EnableClock(FALSE, FALSE, 0);
  243. // Pause the Decoder
  244. DEC_PlaybackCommand(DEC_PLAYBACK_CMD_PAUSE, NULL);
  245. }
  246. else {
  247. // Resume the Clock
  248. PE_Clips_EnableClock(TRUE, FALSE, 0);
  249. // Resume the Decoder
  250. DEC_PlaybackCommand(DEC_PLAYBACK_CMD_RESUME, NULL);
  251. }
  252. return;
  253. }
  254. #pragma argsused
  255. enClipStatus GenericClip_getStatus(const Clip *i_pThis)
  256. {
  257. if (drv_is_play_done() && DEC_IsPlaybackFinished(FALSE))
  258. return eCS_Finished;
  259. return eCS_Busy;
  260. }
  261. #pragma argsused
  262. void GenericClip_abort(Clip *i_pThis, BOOL bMaintainStandby)
  263. {
  264. dbg_printf(("GenericClip_abort(%d)n", bMaintainStandby));
  265. // Stop the Clock
  266. PE_Clips_EnableClock(FALSE, !bMaintainStandby, 0);
  267. drv_abort_play();
  268. DEC_PlaybackCommand(DEC_PLAYBACK_CMD_STOP, 0);
  269. if (! bMaintainStandby)
  270. drv_spindown();
  271. return;
  272. }
  273. void GenericClip_recordMarker(const Clip *i_pThis, ClipMarker *o_pMarker)
  274. {
  275. UINT8 wMin, wSec, wFrm;
  276. dbg_printf(("GenericClip_recordMarker()n"));
  277. #ifdef SUPPORT_FLASH_CARD 
  278. if (IS_PLAYING_CARD)
  279.    {
  280.     //get physical address.
  281.     o_pMarker->dwAddress = PE_Clips_GetCurrLocation();
  282. }
  283.    else
  284. #endif
  285. {
  286. drv_get_msf(&wMin, &wSec, &wFrm);
  287. o_pMarker->dwAddress= drv_msf2lbn(wMin, wSec, wFrm);
  288. o_pMarker->uTime= GenericClip_getTime(i_pThis);
  289. o_pMarker->uClipNumer = gns.clips.uCurrentClipNumber;
  290. }
  291. return;
  292. }
  293. #pragma argsused
  294. void GenericClip_refresh(Clip *i_pThis)
  295. {
  296. }
  297. #pragma argsused
  298. UINT16 GenericClip_getTime(const Clip *i_pThis)
  299. {
  300. return PE_Clips_GetClock();
  301. }
  302. #pragma argsused
  303. void GenericClip_digest(Clip *i_pThis)
  304. {
  305. dbg_printf(("GenericClip_digest()n"));
  306. return;
  307. }
  308. #pragma argsused
  309. void GenericClip_scan(Clip *i_pThis, int iScanSpeed)
  310. {
  311. dbg_printf(("GenericClip_Scan()n"));
  312. return;
  313. }