nav_clips.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:200k
- // Update the current Playback-Mode
- g_pClipsNav->m_uCurrPlaybackMode= PM_GetPlaybackMode();
- return;
- }
- /////////////////////////////////////////////////////////////////////////////
- // OnNextItem()
- //
- // Description: A handler for the IE_CORE_NEXT_CHAPTER Event.
- //
- // Input: None
- // Output: None
- // In/Out: None
- // Return: None
- //
- // Remarks:
- // The handler schedules the next Item on the Playlist for playback, unless
- // the current Item is already the last one on the Playlist.
- static void OnNextItem()
- {
- BOOL bToAbortPlayback = 1;
-
- dbg_printf(("OnNext()n"));
- #ifdef USE_AUX_SUBTITLES
- // undisplay auxiliary subtitles, if exist.
- if ((SI_IS_CURRENT_MPEG4_CLIP && (FALSE != areAuxSubtitlePresent())) ||
- SI_CLIPS_MP4_INTERNAL_SUBTITLE_ON)
- stopDisplayAuxSubtitles();
- #endif
- if (PST_STOP == gcs.pstate) {
- dbg_printf(("Next is invalid in Stop state.n"));
- core_report_error( IE_UI_REPORT_ERROR, (void *) CLIPSNAV_ERR_PROHIBITED_UOP );
- return;
- }
- if((eWINDOWS_EXPLORER_STYLE == SHARED_INFO.eWindowsExplorerStyleBrowser)
- && eSingleItem == SHARED_INFO.uExplorerStyleBrowserPlayMode)
- {
- core_report_error( IE_UI_REPORT_ERROR, (void *) CLIPSNAV_ERR_PROHIBITED_UOP );
- return;
- }
-
- if(PM_IsPlaybackRandom(PM_GetPlaybackMode()))
- {
- PM_ShuffleProgramList(FALSE, 0);
- SHARED_INFO.uCurrPlaylistItem = 0;
- }
- if (0 == computePlaylistItem(SHARED_INFO.uCurrPlaylistItem, TRUE))
- {
- if(FALSE == IsGotoNextChapterAllowed())
- return;
- else
- if(PM_IsRepeatFolder())
- SHARED_INFO.uCurrPlaylistItem= 0;
- else
- {
- if( eWINDOWS_EXPLORER_STYLE == SHARED_INFO.eWindowsExplorerStyleBrowser)
- {
-
- if (PST_STOP != gcs.pstate)
- {
- // Stop the current playback, and re-invoke playback at the previous item
- UINT16 hClipInstance= ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1);
- Clip_abortPlayback(hClipInstance, TRUE);
- bToAbortPlayback = 0;
- }
-
- #ifdef MANUAL_DIRECTORY_EXPLORER
- if( 0 == getFirstItemInSubFoldersOrNextFolders())
- {
- if(!PM_IsRepeatAll())
- {
- // Cancel Intro Play Mode if Stop
- SHARED_INFO.bIsIntroPlayMode = FALSE;
- gcs.pstate= PST_STOP;
- return;
- }
- else
- if(0 == computePlaylistItem(0, TRUE))
- getFirstItemInSubFoldersOrNextFolders();
- }
- #endif
- }
-
- SHARED_INFO.uCurrPlaylistItem= 0;
- }
- }
- //if there is already a timer running, we disable it first
- timer_service_disable(g_pClipsNav->m_hPresentationTimer);
- // Advance to the next Item
- SHARED_INFO.uCurrPlaylistItem= computePlaylistItem(SHARED_INFO.uCurrPlaylistItem, TRUE);
- cancelRepeatModes(PM_REPEAT_AB_MASK);
-
- // Clear any Resume Marker
- (g_pClipsNav->m_cmResumeMarker).dwAddress= (ULONG)-1;
- if (PST_STOP != gcs.pstate) {
- if(bToAbortPlayback)
- {
- // Abort the current playback, if any
- UINT16 hClipInstance= ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1);
- Clip_abortPlayback(hClipInstance, TRUE);
- }
- // <<< Robin_0903_2004
- #ifdef DIVX_SUPPORT_MULTI_SUBTITLE_MODE0
- bNeedWaitForUI = TRUE;
- #endif
- // >>> Robin_0903_2004
- // Invoke playback of the next item
- if (! invokePlayback(FALSE)) {
- tr_printf(("FATAL: Failed to invoke playbackn"));
- gcs.pstate= PST_STOP;
- }
- }
- return;
- }
- /////////////////////////////////////////////////////////////////////////////
- // OnPreviousItem()
- //
- // Description: A handler for the IE_CORE_PREVIOUS_CHAPTER Event.
- //
- // Input: None
- // Output: None
- // In/Out: None
- // Return: None
- //
- // Remarks:
- // The handler schedules the previous Item on the Playlist for playback, unless
- // the current Item is already the first one on the Playlist.
- static void OnPreviousItem()
- {
- BOOL bToAbortPlayback = 1;
- dbg_printf(("OnPrevious()n"));
- #ifdef USE_AUX_SUBTITLES
- // undisplay auxiliary subtitles, if exist.
- if ((SI_IS_CURRENT_MPEG4_CLIP && (FALSE != areAuxSubtitlePresent())) ||
- SI_CLIPS_MP4_INTERNAL_SUBTITLE_ON)
- stopDisplayAuxSubtitles();
- #endif
- if (PST_STOP == gcs.pstate) {
- dbg_printf(("Previous invalid in Stop state.n"));
- core_report_error( IE_UI_REPORT_ERROR, (void *) CLIPSNAV_ERR_PROHIBITED_UOP );
- return;
- }
- if((eWINDOWS_EXPLORER_STYLE == SHARED_INFO.eWindowsExplorerStyleBrowser)
- && eSingleItem == SHARED_INFO.uExplorerStyleBrowserPlayMode)
- {
- core_report_error( IE_UI_REPORT_ERROR, (void *) CLIPSNAV_ERR_PROHIBITED_UOP );
- return;
- }
-
- //if there is already a timer running, we disable it first
- timer_service_disable(g_pClipsNav->m_hPresentationTimer);
- // Cancel Intro Play Mode if Stop
- SHARED_INFO.bIsIntroPlayMode = FALSE;
- #ifdef D_USE_VARIABLE_FOR_LIB
- if (SHARED_INFO.iCurrentTime <= clips_skip_back_threshold)
- #else
- if (SHARED_INFO.iCurrentTime <= CLIPS_SKIP_BACK_THRESHOLD)
- #endif
- {
- if(PM_IsPlaybackRandom(PM_GetPlaybackMode()))
- {
- PM_ShuffleProgramList(FALSE, 0);
- SHARED_INFO.uCurrPlaylistItem = PM_GetProgramSize();
- }
- if (0 == computePlaylistItem(SHARED_INFO.uCurrPlaylistItem, FALSE))
- {
- if (FALSE == IsGotoPreviousChapterAllowed())
- return;
- if( eSingle_LIST_STYLE == SHARED_INFO.eWindowsExplorerStyleBrowser ||
- ((eWINDOWS_EXPLORER_STYLE == SHARED_INFO.eWindowsExplorerStyleBrowser) &&
- (eWholeDisc != SHARED_INFO.uExplorerStyleBrowserPlayMode)) )
- {
-
- #ifdef CLIPS_WRAP_AROUND_ON_PROGRAM_EDGES
- // Set the Current Item to one past the Last item on the Play-List (i.e.
- // wrap-around is performed).
- SHARED_INFO.uCurrPlaylistItem= computePlaylistItem(PM_GetProgramSize(), FALSE);
- #else
- // Wrap-around if Repeat-All is on
- if(PM_IsRepeatFolder())
- {
- // Set the Current Item to one past the Last item on the Play-List (i.e.
- // wrap-around is performed).
- SHARED_INFO.uCurrPlaylistItem= computePlaylistItem(PM_GetProgramSize(), FALSE);
- }
- #endif //CLIPS_WRAP_AROUND_ON_PROGRAM_EDGES
- }
- #ifdef MANUAL_DIRECTORY_EXPLORER
- else
- if( eWINDOWS_EXPLORER_STYLE == SHARED_INFO.eWindowsExplorerStyleBrowser)
- {
- if (PST_STOP != gcs.pstate)
- {
- // Stop the current playback, and re-invoke playback at the previous item
- UINT16 hClipInstance= ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1);
- Clip_abortPlayback(hClipInstance, TRUE);
- bToAbortPlayback = 0;
- }
- SHARED_INFO.uCurrPlaylistItem = getLastItemInPrevFolders();
- if(0 == SHARED_INFO.uCurrPlaylistItem)
- {
- gcs.pstate= PST_STOP;
- return;
- }
- }
- #endif
- }
- else
- {
- // Move back to the previous Item
- SHARED_INFO.uCurrPlaylistItem= computePlaylistItem(SHARED_INFO.uCurrPlaylistItem, FALSE);
- }
- }
- cancelRepeatModes(PM_REPEAT_AB_MASK);
-
- // Clear any Resume Marker
- (g_pClipsNav->m_cmResumeMarker).dwAddress= (ULONG)-1;
- if (PST_STOP != gcs.pstate) {
- if(bToAbortPlayback)
- {
- // Stop the current playback, and re-invoke playback at the previous item
- UINT16 hClipInstance= ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1);
- Clip_abortPlayback(hClipInstance, TRUE);
- }
- // <<< Robin_0903_2004
- #ifdef DIVX_SUPPORT_MULTI_SUBTITLE_MODE0
- bNeedWaitForUI = TRUE;
- #endif
- // >>> Robin_0903_2004
- // Invoke playback of the previous item
- if (! invokePlayback(FALSE)) {
- tr_printf(("FATAL: Failed to invoke playbackn"));
- gcs.pstate= PST_STOP;
- }
- }
- return;
- }
- /////////////////////////////////////////////////////////////////////////////
- // OnNumericSelection()
- //
- // Description: A handler for the IE_CORE_MENU_NUMERICAL_SELECTION or
- // IE_CORE_GOTO_ENTRY Events.
- //
- // Input: iSelection - An index of the Playlist Item to select.
- // Output: None
- // In/Out: None
- // Return: None
- //
- // Remarks:
- // The handler sets the current Playlist Item to the one which resides
- // inside the Playlist at the specified index.
- static void OnNumericSelection(UINT16 iSelection)
- {
- UINT16 hClipInstance;
-
- UINT8 ucWhichWindow;
- BOOL bEntryIsDIR;
- // Robin_0715_2004, merge changelist #23919
- if ( PM_IsPlaybackShuffle(PM_GetPlaybackMode())
- #ifndef CLIPS_ONNUMERICSELECTION_DONT_CANCEL_PROGRAM
- ||PM_IsPlaybackProgram(PM_GetPlaybackMode())
- #endif
- ) {
- PM_SetPlaybackMode(PM_PLAYBACK_NORMAL);
- OnModeChange();
- Clips_SetExplorerStyleBrowserDiscScanMode(FALSE);
- Clips_SetExplorerStyleBrowserPlayMode(eSingleFolder);
- PM_ClearRepeat();
- }
- ucWhichWindow = iSelection >> 13;//to support to 5000 clips in one folder
- iSelection &= 0x1fff;
- // Verify that the selected number is legal
- if(eLEFT_WINDOW == ucWhichWindow)
- {
- UINT16 usMaxEntries;
- usMaxEntries = PEER_DIR_ARRAY_SIZE;
- if ((0 == iSelection) || (iSelection > usMaxEntries))
- {
- tr_printf(("Illegal Selection Number. Ignored.n"));
- return;
- }
- }
- else// Verify that the selected number is legal
- {
- UINT16 uProgramSize= PM_GetProgramSize();
- if(0 == uProgramSize)
- uProgramSize = SUB_DIR_ARRAY_SIZE;
- else
- uProgramSize = uProgramSize - 1 + SUB_DIR_ARRAY_SIZE;
- if ((0 == iSelection)
- || (iSelection > uProgramSize)) {
- tr_printf(("Illegal Selection Number. Ignored.n"));
- return;
- }
- }
- //check if the entry is a dir.
- bEntryIsDIR = 0;
- if(eRIGHT_WINDOW == ucWhichWindow || eSingle_WINDOW == ucWhichWindow)
- {
- #ifdef CLIPS_JPEG_DIGEST_SUPPORT
- if (g_pClipsNav->m_bDigestMode) {
- UINT16 uClipIndex;
- // Extract the correct Play-List Item corresponding to the Digest-selection
- if (!Array_getAt(g_pClipsNav->m_hDigestUnits, (iSelection-1), (BYTE*)&uClipIndex)) {
- tr_printf(("Cannot retrieve the selected Clip-Index.n"));
- return;
- }
- iSelection= (1 + (int)uClipIndex);
- _terminateDigestMode();
- }
- else
- #endif //CLIPS_JPEG_DIGEST_SUPPORT
- #ifdef MANUAL_DIRECTORY_EXPLORER
- if(iSelection <= SUB_DIR_ARRAY_SIZE)
- {
- Browser_OpenFolder( ucWhichWindow, iSelection, TRUE);
- return;
- }
- else
- #endif
- {
- iSelection -= SUB_DIR_ARRAY_SIZE;
- // Establish the validity of the selected Clip given the Playback-Filter
- hClipInstance= ClipsRepository_getInstanceAt(PM_GetProgramListEntry((UINT16)iSelection)-1);
- if (NULL == hClipInstance)
- {
- tr_printf(("Numeric-Selection rejected, due to no valid instancen"));
- return;
- }
- else
- if ((0 == (Clip_getType(hClipInstance) & g_uPlaybackFilter)))
- {
- tr_printf(("Numeric-Selection rejected, due to Playback-Filter conflict.n"));
- return;
- }
- }
- }
- #ifdef MANUAL_DIRECTORY_EXPLORER
- else
- if(eLEFT_WINDOW == ucWhichWindow)
- {
- Browser_OpenFolder( ucWhichWindow, iSelection, TRUE);
- return;
- }
- #endif
- if(eWINDOWS_EXPLORER_STYLE != SHARED_INFO.eWindowsExplorerStyleBrowser)
- {
- if (! PM_IsPlaybackNormal(PM_GetPlaybackMode())) {
- // Return to Normal Playback
- PM_SetPlaybackMode(PM_PLAYBACK_NORMAL);
- OnModeChange();
- }
- }
- // Disable the Presentation Timer
- timer_service_disable(g_pClipsNav->m_hPresentationTimer);
- // Cancel Intro Play Mode if Stop
- SHARED_INFO.bIsIntroPlayMode = FALSE;
- // Abort any ongoing playback
- if (!((0 == SHARED_INFO.uCurrentClipNumber) || (SHARED_INFO.uCurrentClipNumber > (PM_GetProgramSize() - 1))))
- {
- if (PST_STOP != gcs.pstate)
- {
- hClipInstance= ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1);
- Clip_abortPlayback(hClipInstance, TRUE);
- }
- }
- // Cancel any current Repeat-Modes, except Folder
- if(eWINDOWS_EXPLORER_STYLE != SHARED_INFO.eWindowsExplorerStyleBrowser)
- cancelRepeatModes(PM_REPEAT_SINGLE | PM_REPEAT_ALL | PM_REPEAT_AB_MASK);
- // Clear any Resume Marker
- (g_pClipsNav->m_cmResumeMarker).dwAddress= (ULONG)-1;
- SHARED_INFO.uCurrPlaylistItem= (UINT16)iSelection;
- gcs.pstate= PST_PLAY;
- // <<< Robin_0903_2004
- #ifdef DIVX_SUPPORT_MULTI_SUBTITLE_MODE0
- bNeedWaitForUI = TRUE;
- #endif
- // >>> Robin_0903_2004
- if (! invokePlayback(TRUE)) {
- tr_printf(("FATAL: Failed to invoke playback of a Playlist Item.n"));
- gcs.pstate= PST_STOP;
- }
- return;
- }
- #ifdef CLIPS_JPEG_SUPPORT
- /////////////////////////////////////////////////////////////////////////////
- // OnAngleSelection()
- //
- // Description: Handles Angle selection
- //
- // Input: i_eAngle - The selected Angle to apply
- // Output: None
- // In/Out: None
- // Return: None
- //
- // Remarks: None
- static void OnAngleSelection(enClipImageOrientation i_eAngle)
- {
- UINT16 hClipInstance;
- dbg_printf(("OnAngleSelection(%d)n", i_eAngle));
- // Retrieve the Clip-Information for the current Clip
- hClipInstance= ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1);
- if (NULL == hClipInstance) {
- tr_printf(("FATAL: OnAngleSelection() Failed [1]: Cannot retrieve info for the Current-Clip.n"));
- return;
- }
- // Set the selected Orientation
- Clip_setOrientation(hClipInstance, i_eAngle);
- // Disable the Presentation-Timer
- if(timer_service_is_active(g_pClipsNav->m_hPresentationTimer))
- timer_service_disable(g_pClipsNav->m_hPresentationTimer);
- // Clear any Resume Marker
- (g_pClipsNav->m_cmResumeMarker).dwAddress= (ULONG)-1;
- // <<< Robin_0903_2004
- #ifdef DIVX_SUPPORT_MULTI_SUBTITLE_MODE0
- bNeedWaitForUI = FALSE;
- #endif
- // >>> Robin_0903_2004
- // Re-invoke playback of the current Clip, to apply the new Angle
- if (!invokePlayback(FALSE)) {
- tr_printf(("FATAL: OnAngleSelection() Failed [2]: Cannot re-invoke playback.n"));
- gcs.pstate= PST_STOP;
- }
- return;
- }
- /////////////////////////////////////////////////////////////////////////////
- // OnTransitionSelection()
- //
- // Description: Handles Transition-Effect selection
- //
- // Input: i_eTransition - The selected Transition-Effect to apply
- // Output: None
- // In/Out: None
- // Return: None
- //
- // Remarks:
- // Transition-Effect is only applied if the current Clip hasn't finished
- // presenting, and is using some kind of Transition-Effect.
- static void OnTransitionSelection(enClipTransitionEffect i_eTransition)
- {
- dbg_printf(("OnTransitionSelection(%d)n", i_eTransition));
- if (PST_STOP != gcs.pstate) {
- UINT16 hClipInstance= ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1);
- if ((eCS_Finished != Clip_getStatus(hClipInstance)) &&
- (eCTE_None != Clip_getTransitionEffect(hClipInstance)))
- {
- Clip_setTransitionEffect(hClipInstance, i_eTransition);
- }
- }
- SHARED_INFO.eCurrentTransition= (UINT8)i_eTransition;
- return;
- }
- #ifdef CLIPS_JPEG_DIGEST_SUPPORT
- /////////////////////////////////////////////////////////////////////////////
- // _handleDigestUnit()
- //
- // Description: A Callback function supplied to the Digest mechanism
- //
- // Input: uUnitIndex - The Index of the Play-Item to Digest
- // eQuery - The requested Query
- // Output: None
- // In/Out: None
- // Return: None
- //
- // Remarks: None
- static BOOL _handleDigestUnit(UINT16 uUnitIndex, enDigestQuery eQuery)
- {
- UINT16 uClipIndex;
- UINT16 hClipInstance;
- dbg_printf(("_handleDigestUnit(%d, %d)n", uUnitIndex, (UINT16)eQuery));
- if (!Array_getAt(g_pClipsNav->m_hDigestUnits, uUnitIndex, (BYTE*)&uClipIndex)) {
- dbg_printf(("Cannot retrieve Clip-Index to digest.n"));
- return FALSE;
- }
- hClipInstance= ClipsRepository_getInstanceAt(uClipIndex);
- if (NULL == hClipInstance) {
- tr_printf(("FATAL: _handleDigestUnit() Failed [1]n"));
- return FALSE;
- }
- switch (eQuery)
- {
- case eDigestQuery_Start:
- // Reset error recovery
- (g_pClipsNav->m_ErrorRecoveryInfo).uRetryCount= CLIPS_ERROR_RECOVERY_RETRY_COUNT;
- Clip_digest(hClipInstance);
- return TRUE;
- case eDigestQuery_Stop:
- Clip_abortPlayback(hClipInstance, TRUE);
- return TRUE;
- case eDigestQuery_IsFinished:
- if (eCS_Error_Decoding == Clip_getStatus(hClipInstance)) {
- if (0 < (g_pClipsNav->m_ErrorRecoveryInfo).uRetryCount) {
- (g_pClipsNav->m_ErrorRecoveryInfo).uRetryCount--;
- Clip_digest(hClipInstance);
- }
- }
- else
- return (eCS_Busy != Clip_getStatus(hClipInstance));
- }
- return FALSE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // OnDigest()
- //
- // Description: Handle invocation of Digest Mode
- //
- // Input: Param - The selected Digest-Mode to engage
- // Output: None
- // In/Out: None
- // Return: None
- //
- // Remarks: None
- static void OnDigest(UINT16 Param)
- {
- UINT16 uDigestIndex, uInitialDigestItem, uIndex;
- dbg_printf(("OnDigest() %02xn", Param));
- // If already on digest mode, ignore the request
- if (g_pClipsNav->m_bDigestMode) {
- dbg_printf(("Already on digest mode. Ignored.n"));
- return;
- }
- // Make sure that there's anything to Digest
- if ((0 == g_pClipsNav->m_uDigestableItemsCnt) ||
- (0 == (g_pClipsNav->m_uDigestableTypes & g_uPlaybackFilter)))
- {
- dbg_printf(("WARNING: OnDigest() Failed [1]: No suitable items.n"));
- return;
- }
- // Allocate the Digest-Units Array
- g_pClipsNav->m_hDigestUnits= Array_construct(g_pClipsNav->m_uDigestableItemsCnt,
- sizeof(UINT16), NULL);
- if (NULL == g_pClipsNav->m_hDigestUnits) {
- tr_printf(("FATAL: OnDigest() Failed [2]: Cannot allocate digest items array!n"));
- return;
- }
- // Cancel Repeat Mode
- cancelRepeatModes(PM_REPEAT_AB_MASK);
-
- // Cancel Intro Play Mode if Stop
- SHARED_INFO.bIsIntroPlayMode = FALSE;
- // Fill the array only with appropriate Clips
- uInitialDigestItem= 0;
- uDigestIndex= 0;
- for (uIndex=0;
- (uIndex < SHARED_INFO.uClipsCnt) && (uDigestIndex < g_pClipsNav->m_uDigestableItemsCnt);
- uIndex++)
- {
- UINT16 hClipInstance= ClipsRepository_getInstanceAt(uIndex);
- if (NULL == hClipInstance) {
- dbg_printf(("WARNING: OnDigest() Failed [3]n"));
- continue;
- }
- if (Clip_hasAttribute(hClipInstance, eCA_Digestable)) {
- if (SHARED_INFO.uCurrentClipNumber == (1 + uIndex))
- uInitialDigestItem= uDigestIndex;
- if (!Array_setAt(g_pClipsNav->m_hDigestUnits, uDigestIndex++,
- (const BYTE*)&uIndex))
- {
- dbg_printf(("WARNING: OnDigest() Failed [4]n"));
- }
- }
- }
- // Disable the Presentation-Timer
- timer_service_disable(g_pClipsNav->m_hPresentationTimer);
- // Abort any ongoing playback
- if (PST_STOP != gcs.pstate) {
- UINT16 hClipInstance= ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1);
- Clip_abortPlayback(hClipInstance, TRUE);
- }
- if (NULL != g_pClipsNav->m_hCachedClip)
- Clip_abortPlayback(g_pClipsNav->m_hCachedClip, TRUE);
- // Enable Digest-Mode
- PE_Clips_EnableDigestMode(TRUE, eClipType_JPEG);
- // Move to Still State, and Presentation mode
- gcs.pstate= PST_STILL;
- // Initialize the Digest mechanism
- if (! Digest_init(_handleDigestUnit, uDigestIndex, eDiscView, 1)) {
- tr_printf(("FATAL: OnDigest() Failed [4]: Cannot initialize Digestn"));
- return;
- }
- // Move to Digest-Mode
- g_pClipsNav->m_bDigestMode= TRUE;
- // Record the current Operation-Mask, to be restored once Digest-Mode is terminated
- g_pClipsNav->m_ulCOP_Mask= COP_MASK;
- // Launch Digest
- #ifdef EXINO2 //ZKR JK0414 : always display from first picture
- Digest_start((uInitialDigestItem/6)*6);
- #else
- Digest_start(uInitialDigestItem);
- #endif
- // Set-up the relevant Operation-Mask
- CLEAR_COP_MASK(COP_PLAY | COP_PAUSE | COP_STEP | COP_SLOW | COP_SCAN |
- COP_SCAN_BACKWARD | COP_NEXT_CHAPTER | COP_PREVIOUS_CHAPTER);
- SET_COP_MASK(COP_STOP | COP_NEXT_CHAPTER | COP_PREVIOUS_CHAPTER);
- return;
- }
- /////////////////////////////////////////////////////////////////////////////
- // _terminateDigestMode()
- //
- // Description: Terminates the current Digest
- //
- // Input: None
- // Output: None
- // In/Out: None
- // Return: None
- //
- // Remarks: None
- static void _terminateDigestMode(void)
- {
- dbg_printf(("_terminateDigestModen"));
- #ifdef SUPPORT_FLASH_CARD
- drv_abort_play();
- #endif
- // Disable Digest-Mode
- PE_Clips_EnableDigestMode(FALSE, eClipType_JPEG);
- // Terminate the Digest mechanism
- Digest_terminate();
- // Restore the Operation-Mask
- SET_COP_MASK(g_pClipsNav->m_ulCOP_Mask);
- // Free the Digest-Units Array
- if (NULL != g_pClipsNav->m_hDigestUnits) {
- Array_destruct(g_pClipsNav->m_hDigestUnits);
- g_pClipsNav->m_hDigestUnits= NULL;
- }
- // Terminate Digest-Mode
- g_pClipsNav->m_bDigestMode= FALSE;
- return;
- }
- #endif //CLIPS_JPEG_DIGEST_SUPPORT
- #endif //CLIPS_JPEG_SUPPORT
- /////////////////////////////////////////////////////////////////////////////
- // PerformErrorRecovery()
- //
- // Description: Handles Error-Recovery
- //
- // Input: hClipInstance - The instance of the Clip to be recovered
- // eStatus - The current Status of the Clip specified in hClipInstance
- // Output: None
- // In/Out: None
- // Return: None
- //
- // Remarks: None
- static void PerformErrorRecovery(UINT16 hClipInstance, enClipStatus eStatus)
- {
- // Handle an Unsupported-Format Error
- if (eCS_Error_UnsupportedFormat == eStatus) {
- dbg_printf(("INFO: Unsupported Format encountered!n"));
- // Reflect the Error, for user's intervention
- (SHARED_INFO.cieCurrClip).eClipStatus= (UINT8)eStatus;
- // Unless pausing, continue to the next Item
- if (PST_PAUSE != gcs.pstate)
- OnPlaybackFinished();
- return;
- }
- // Handle a Decoding Error
- if (eCS_Error_Decoding == eStatus) {
- dbg_printf(("INFO: Decoding-Error found. Recovering...n"));
- if ((g_pClipsNav->m_ErrorRecoveryInfo).uRetryCount > 0) {
- (g_pClipsNav->m_ErrorRecoveryInfo).uRetryCount--;
- Clip_abortPlayback(hClipInstance, TRUE);
- // Repeat the current Clip
- if (Clip_hasAttribute(hClipInstance, eCA_Markable)) {
- ClipMarker cmRecovery;
- Clip_recordMarker(hClipInstance, &cmRecovery);
- // Increment the Address
- cmRecovery.dwAddress += CLIPS_LOCATION_TOLERANCE;
- Clip_startPlayback(hClipInstance, &cmRecovery, FALSE);
- }
- else {
- Clip_startPlayback(hClipInstance, NULL, FALSE);
- }
- }
- else {
- // Unrecoverable-Error
- dbg_printf(("INFO: Retries expired; abandoning current Clip.n"));
- // Reflect the Error, for user's intervention
- (SHARED_INFO.cieCurrClip).eClipStatus= (UINT8)eStatus;
- // Unless pausing, continue to the next Item
- if (PST_PAUSE != gcs.pstate)
- OnPlaybackFinished();
- }
- return;
- }
- // Nothing to do: just reflect the current Status
- (SHARED_INFO.cieCurrClip).eClipStatus= (UINT8)eStatus;
- }
- /////////////////////////////////////////////////////////////////////////////
- // OnScan(int iScanSpeed)
- //
- // Description: Handles Scan Request from UI
- //
- // Input: iScanSpeed: Scan Speed Requested
- // Output: None
- // In/Out: None
- // Return: None
- //
- // Remarks: None
- static void OnScan(int iScanSpeed)
- {
- UINT16 hClipInstance;
- // Start Scan
- dbg_printf(("On Scan()n"));
- hClipInstance= ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1);
- if ( ( NULL != hClipInstance) && ( PST_STOP != gcs.pstate ) && Clip_hasAttribute(hClipInstance, eCA_Scanable) ){
- // Cancel Intro Play Mode if Stop
- cancelRepeatModes(PM_REPEAT_AB_MASK);
- SHARED_INFO.bIsIntroPlayMode = FALSE;
-
- Clip_Scan(hClipInstance, iScanSpeed);
- }
- return;
- }
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : OnIntro
- //
- // Input Parameters : void
- //
- // Return Value : void
- //
- // Description : Begin to start intro playback or stop it.
- //////////////////////////////////////////////////////////////////////////////////
- static void OnIntro(void)
- {
- if (TRUE != SHARED_INFO.bIsIntroPlayMode)
- {
- if ( PST_STOP == gcs.pstate ){
- dbg_printf(("Cancel Playmode/Repeat moden"));
- PM_SetPlaybackMode(0);
- PM_ClearRepeat();
- SHARED_INFO.bIsIntroPlayMode = TRUE;
- SHARED_INFO.uCurrPlaylistItem= computePlaylistItem(SHARED_INFO.uCurrPlaylistItem, FALSE);
- OnPlay();
- }else
- dbg_printf(("Can't Activate Intro Mode in non-stop moden"));
- }else
- dbg_printf((" Already in intro mode, ignoren"));
- return;
- }
- ///////////////////////////////////////////////////////////////////////////////
- // Function Name: OnGotoTime(WORD Time)
- //
- // Input: Seek Time inside current playback Clip
- //
- // Return: None
- //
- // Description: We only support Track Time Search for MP3 Clips now
- ///////////////////////////////////////////////////////////////////////////////
- static void OnGotoTime(WORD wTime)
- {
- UINT16 hClipInstance;
- WORD wTrackTime;
- DWORD dwStartAddress, dwJumpOffset;
- dbg_printf(("On GotoTime at: %04xn", wTime));
- #ifdef USE_AUX_SUBTITLES
- if ((SI_IS_CURRENT_MPEG4_CLIP && (FALSE != areAuxSubtitlePresent())) ||
- SI_CLIPS_MP4_INTERNAL_SUBTITLE_ON)// Robin_0528_2004_A
- {
- // stop subtitle seeking
- setSubtitlesPlayMode(FALSE);
- stopDisplayAuxSubtitles();
- }
- #endif
- if ( ( PST_PLAY != gcs.pstate ) && ( PST_PAUSE != gcs.pstate ) ){
- dbg_printf(("Can't activate Clip Goto Time in non-play-pause moden"));
-
- return;
- }
-
- hClipInstance= ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1);
- if ( ( NULL == hClipInstance ) && ( eClipType_MP3 != Clip_getType(hClipInstance)) && ( eClipType_MPEG != Clip_getType(hClipInstance)) ){
- dbg_printf(("Can't find clip or current clip is not MP3 Clipn"));
- return;
- }
- // Calcuate jump location for different clips(MP3/MPEG)
- switch ( Clip_getType(hClipInstance) ){
- case eClipType_MP3:
- if ( gns.clips.uTotalPlaybackTime <= wTime ){
- dbg_printf(("Goto Time %04x is more than Total Track Time %04xn", wTime, wTrackTime));
- return;
- }
-
- dwStartAddress = MP3_Time_To_Address(wTime);
-
- break;
- case eClipType_MPEG:
- wTrackTime = (DWORD)((gns.clips.cieCurrClip.ciInfo.cbFileSize) >> 11)/(DWORD)CLIPS_MPEG_NUM_OF_SECTORES_PER_SECOND;
- if ( wTrackTime <= wTime ){
- dbg_printf(("Goto Time %04x is more than Total Track Time %04xn", wTime, wTrackTime));
- return;
- }
- dwJumpOffset = (DWORD)CLIPS_MPEG_NUM_OF_SECTORES_PER_SECOND * (DWORD)wTime;
- dwStartAddress = (gns.clips.cieCurrClip.ciInfo.dwFileLocation) + dwJumpOffset;
-
- break;
- case eClipType_AVI:
- #ifdef IS_ASF_CAPABLE
- case eClipType_ASF:
- #endif
- #ifdef IS_MP4_CAPABLE
- case eClipType_MP4:
- #endif
- if ( gns.clips.uTotalPlaybackTime <= wTime )
- {
- dbg_printf(("Goto time %04d is more than total clip time %04dn", wTime, gns.clips.uTotalPlaybackTime));
- return;
- }
- dbg_printf(("MPEG4 Goto Time: Time %04x Track Time %04xn", wTime, wTrackTime));
- dwStartAddress = gns.clips.cieCurrClip.ciInfo.dwFileLocation;
- break;
- default:
- dbg_printf(("Non supported format for time search, returnn"));
- return;
- }
-
- dbg_printf(("File Start Address is %08x, jump to start at %08xn", gns.clips.cieCurrClip.ciInfo.dwFileLocation,
- dwJumpOffset));
- Clip_abortPlayback(hClipInstance, TRUE);
- // gcs.pstate = PST_STILL;
- cancelRepeatModes(PM_REPEAT_AB_MASK);
- (g_pClipsNav->m_cmResumeMarker).dwAddress = dwStartAddress;
-
- (g_pClipsNav->m_cmResumeMarker).uTime = wTime;
- #ifdef USE_AUX_SUBTITLES
- if (SI_IS_CURRENT_MPEG4_CLIP && (FALSE != areAuxSubtitlePresent()))// Robin_0528_2004_A
- {
- // replace 0 with the updated time once it can be determined before
- // playback starts.
- subtitleGoToTime(0);
- setSubtitlesPlayMode(TRUE);
- }
- else if (SI_CLIPS_MP4_INTERNAL_SUBTITLE_ON)
- {
- setSubtitlesPlayMode(TRUE);
- }
- #endif
- // <<< Robin_0903_2004
- #ifdef DIVX_SUPPORT_MULTI_SUBTITLE_MODE0
- bNeedWaitForUI = FALSE;
- #endif
- // >>> Robin_0903_2004
- if (!invokePlayback(FALSE)) {
- tr_printf(("FATAL: Failed to invoke playbackn"));
- gcs.pstate= PST_STOP;
- }
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // Function Name: OnA2BRepeat(int Param)
- //
- // Input: A2B Action
- //
- // Return: None
- //
- // Description: Take the proper action for A2B according to "Param"
- /////////////////////////////////////////////////////////////////////////////////////////////////
- static void OnA2BRepeat(int Param)
- {
- UINT16 hClipInstance;
-
- dbg_printf(("On A2B Repeat Requrestn"));
- if ( PST_PLAY != gcs.pstate ){
- dbg_printf(("Can't activated A2B in non-play moden"));
- return;
- }
- hClipInstance= ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1);
- // if ( ( NULL == hClipInstance ) || ( eClipType_MP3 != Clip_getType(hClipInstance))
- // || ( eClipType_MPEG != Clip_getType(hClipInstance)) ){
- if ( !Clip_hasAttribute(hClipInstance, eCA_Markable)){
- dbg_printf(("Can't find clip or current clip is not MP3 Clipn"));
- return;
- }
-
- if (0 == (int)Param) {
- OnCancelABRepeat();
- return;
- }
- if (PM_GetRepeatAB() & PM_REPEAT_AB_B) {
- OnCancelABRepeat();
- PM_SetRepeatAB(0);
- }
- else {
- if ( 0 == PM_GetRepeatAB() ){ //) && ((g_pClipsNav->m_PositionA).iPlaylistItem < 0)) {
- OnSetMarkerA();
- PM_SetRepeatAB(PM_REPEAT_AB_A);
- if ( SI_IS_CURRENT_MPEG_CLIP ){
- if ( g_pClipsNav->m_PositionA.dwAddress > MPEG_SEARCH_ADDRESS_OFFSET )
- {
- #ifdef SUPPORT_FLASH_CARD
- if(!IS_PLAYING_CARD)
- #endif
- g_pClipsNav->m_PositionA.dwAddress -= MPEG_SEARCH_ADDRESS_OFFSET;
- }
- }
- }
- else {
- OnSetMarkerB();
- PM_SetRepeatAB(PM_REPEAT_AB_B);
- }
- }
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void SetMarker(ClipMarker eMarkerType, WORD uBookmarkNumber) -
- // Records the current playback position in the desired Marker.
- //
- // Input:
- // eMarkerType - Identifies which Marker is to be used for recording
- // uBookmarkNumber - If a Bookmark is being recorded, identifies the serial number
- // of the requested Bookmark within the list of available Bookmarks
- //
- // Output:
- // None. The requested Marker is recorded.
- //
- // Remarks:
- // If an attempt is made to record a non-existent Bookmark, the recording is aborted.
- static void SetMarker(enClip_MarkerType eMarkerType, WORD uBookmarkNumber)
- {
- UINT16 hClipInstance;
- ClipMarker *pMarker= NULL;
- hClipInstance= ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1);
- if ( NULL == hClipInstance )
- return;
-
- // Select the appropriate Marker to set
- switch (eMarkerType)
- {
- case eMarkerA: pMarker= &(g_pClipsNav->m_PositionA);
- break;
- case eMarkerB: pMarker= &(g_pClipsNav->m_PositionB);
- break;
- case eResumePlayback:
- pMarker= &(g_pClipsNav->m_cmResumeMarker);
- break;
- case eBookmark:
- if (uBookmarkNumber >= CLIPS_MAX_BOOKMARKER_NUM){
- dbg_printf(("UnSupported Bookmarker Numbern"));
- pMarker= NULL;
- }
- // else
- // pMarker= &(g_pClipsNav->m_Bookmarks[uBookmarkNumber]);
- dbg_printf(("Not supported Bookmarker Typen"));
- break;
- }
- Clip_recordMarker(hClipInstance, pMarker);
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void ClearMarker(enCDDA_MarkerType eMarkerType, WORD uBookmarkNumber) -
- // Clears the desired Marker.
- //
- // Input:
- // eMarkerType - Identifies which Marker is to be cleared
- // uBookmarkNumber - If a Bookmark is being cleared, identifies the serial number
- // of the requested Bookmark within the list of available Bookmarks
- //
- // Output:
- // None. The requested Marker is cleared.
- //
- // Remarks:
- // If an attempt is made to clear a non-existent Bookmark, the clearing is aborted.
- static void ClearMarker(enClip_MarkerType eMarkerType, WORD uBookmarkNumber)
- {
- ClipMarker *pMarker= NULL;
- // Select the appropriate Marker to set
- switch (eMarkerType)
- {
- case eMarkerA: pMarker= &(g_pClipsNav->m_PositionA);
- break;
- case eMarkerB: pMarker= &(g_pClipsNav->m_PositionB);
- break;
- case eResumePlayback:
- pMarker= &(g_pClipsNav->m_cmResumeMarker);
- break;
-
- case eBookmark:
- if (uBookmarkNumber >= CLIPS_MAX_BOOKMARKER_NUM){
- dbg_printf(("UnSupported Bookmarker Numbern"));
- pMarker= NULL;
- }
- // else
- // pMarker= &(g_pCDDANav->m_Bookmarks[uBookmarkNumber]);
- dbg_printf(("Not supported Bookmarker Typen"));
- break;
- //#endif
- }
- if (NULL != pMarker) {
- pMarker->uTime = -1;
- pMarker->dwAddress= -1;
- pMarker->uClipNumer = -1;
- }
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnSetMarkerA() -
- // Handles an event of setting the first Marker for an A->B Repeat sequence.
- //
- // Input:
- // None.
- // Output:
- // None.
- //
- // Remarks:
- // The method calls for the setting of the MarkerA Marker.
- static void OnSetMarkerA()
- {
- dbg_printf(("OnSetMarkAn"));
- SetMarker(eMarkerA, 0);
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnSetMarkerB() -
- // Handles an event of setting the second Marker for an A->B Repeat sequence.
- //
- // Input:
- // None.
- //
- // Output:
- // None.
- //
- // Remarks:
- // The method calls for the setting of the MarkerB Marker, and then it initiates the
- // REPEAT_AB Play-Mode.
- static void OnSetMarkerB()
- {
- dbg_printf(("OnSetMarkB()n"));
- // First, record the current position as MarkerB and stop playback
- SetMarker(eMarkerB, 0);
- // Prohibit an A-B Segment of less than 1 Second
- if (((g_pClipsNav->m_PositionB).uTime - (g_pClipsNav->m_PositionA).uTime) < CLIPS_A2B_MIN_GAP)
- {
- // Force a 5 Second gap between Point-A and Point-B
- (g_pClipsNav->m_PositionB).uTime= (g_pClipsNav->m_PositionA).uTime + CLIPS_A2B_MIN_GAP;
- }
- // Stop Playback
- PE_CD_AbortPlayback(TRUE);
- // Move the Current-Position to Point-A
- memcpy(&(g_pClipsNav->m_cmResumeMarker), &(g_pClipsNav->m_PositionA), sizeof(ClipMarker));
- // Invoke A-B Repeat, and start Playback
- PM_SetRepeatAB(PM_REPEAT_AB_B);
- // <<< Robin_0903_2004
- #ifdef DIVX_SUPPORT_MULTI_SUBTITLE_MODE0
- bNeedWaitForUI = FALSE;
- #endif
- // >>> Robin_0903_2004
- // Schedule a playback using the Markers just set
- if (! invokePlayback(FALSE)) {
- dbg_printf(("Error: Failed to invoke playbackn"));
- gcs.pstate= PST_STOP;
- }
- ie_send(IE_UI_STATE_CHANGE);
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnCancelABRepeat() -
- // Handles an event of cancelling the current REPEAT_AB Play-Mode.
- //
- // Input:
- // None.
- //
- // Output:
- // None.
- //
- // Remarks:
- // The method aborts the current Play-Mode by clearing both MarkerA and MarkerB, and
- // removing the REPEAT_AB Bit from the Play-Mode mask.
- // In addition, the method will re-sechedule a Rendezvous-Point, if needed,
- // in order to assure correct playback of the following items.
- static void OnCancelABRepeat()
- {
- dbg_printf(("OnCancelABRepeat()n"));
- // Clear the current setting of both markers
- ClearMarker(eMarkerA, 0);
- ClearMarker(eMarkerB, 0);
- PM_SetRepeatAB(0);
- ie_send(IE_UI_STATE_CHANGE);
- return;
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnDrmInfoMsgArrived() -
- // Handles an IE_CORE_DRM_INFO_ARRIVED Event.
- //
- // Input:
- // None.
- //
- // Output:
- // None.
- //
- // Remarks:
- // None.
- //////////////////////////////////////////////////////////////////////////////////////////
- //usually only 64 words are used.
- #define MAX_ENCODED_BUFFER 100
- static void OnDrmInfoMsgArrived(void)
- {
- UINT16 uiStatus;
- UINT16 i;
- UINT16 uiWriteIteration;
- UINT16 uiNumOfWriteIterations;
- UINT32 uiFrameKeyIndex;
- UINT32 uiTemp1,uiTemp2;
- UINT16 wTimeOut;
-
- UINT16 a_chEncodedVideoChunckBuffer[MAX_ENCODED_BUFFER];
- UINT16 a_chDecodedVideoChunckBuffer[MAX_ENCODED_BUFFER];
- UINT32 uiInputBufferSize;
- UINT32 uiInputBufferSizeWords;
- UINT32 uiOutputBufferSize;
- uiStatus = inport(DS2CFIFO_STATUS_ADDR);
- // wait for at least first three words in the fifo
- // (buffer size and frame key index)
- if(!uiStatus)
- {
- tr_printf(("Nothing in FIFOn"));
- return;
- }
- uiTemp1 = inport(DS2CFIFO_DATA_ADDR);
- uiTemp2 = inport(DS2CFIFO_DATA_ADDR);
- uiInputBufferSize = (uiTemp1<<16)|(uiTemp2);
-
- if (uiInputBufferSize > (MAX_ENCODED_BUFFER*2) )
- {
- tr_printf(("Error - uiInputBufferSize larger then %d words!n",MAX_ENCODED_BUFFER*2));
- return;
- }
- // get Frame key index
- uiFrameKeyIndex = inport(DS2CFIFO_DATA_ADDR);
-
- // get encoded block offset
- uiInputBufferSizeWords = uiInputBufferSize/2;
- for (i=0;
- i<uiInputBufferSizeWords && i<MAX_ENCODED_BUFFER;
- i++)
- {
- int timeOut = 0;
- do {
- uiStatus = inport(DS2CFIFO_STATUS_ADDR);
- if (timeOut > 10000) // Robin_0609_2004_A, avoid system stick when select Failed DivX file (can't playback) during playbacking DivX-DRM file
- {
- dbg_printf(("WARNING: OnDrmInfoMsgArrived() Failed!n"));
- return;
- }
- timeOut++;
- } while ( uiStatus < 1 );
- a_chEncodedVideoChunckBuffer[i] = inport(DS2CFIFO_DATA_ADDR);
- }
- #ifdef AVI_DRM_SUPPORT
- HandleDrmMessage( uiFrameKeyIndex,
- (BYTE*)a_chEncodedVideoChunckBuffer,
- uiInputBufferSize,
- (BYTE*)a_chDecodedVideoChunckBuffer,
- &uiOutputBufferSize);
-
- #endif //AVI_DRM_SUPPORT
-
- // send the decrypted data through the shared memory
- uiNumOfWriteIterations = (UINT16)uiInputBufferSizeWords/DRM_DECRYPTED_SHARED_MEM_LENGTH;
- for (uiWriteIteration = 0; uiWriteIteration < uiNumOfWriteIterations; uiWriteIteration++)
- {
- wTimeOut = 1000;
- while (wTimeOut--)
- {
- if (FALSE == DEC_AVI_GetDemuxSharedBit(DRM_DECRYPTED_FLAG_OFFSET, DRM_DECRYPTED_FLAG_BIT))
- break;
- delay_us(1000UL);
- }
-
- if (TRUE == DEC_AVI_GetDemuxSharedBit(DRM_DECRYPTED_FLAG_OFFSET, DRM_DECRYPTED_FLAG_BIT))
- {
- tr_printf(("Time out in OnDrmInfoMsgArrived()!n"));
- return;
- }
-
- for (i = 0; i < DRM_DECRYPTED_SHARED_MEM_LENGTH; i++)
- {
- DVP_API_DR_Write(DVP_DS2C_FIFO_START_OFFSET+i, a_chDecodedVideoChunckBuffer[(uiWriteIteration*DRM_DECRYPTED_SHARED_MEM_LENGTH) + i ]);
- }
-
- DEC_AVI_SetDemuxSharedBit(DRM_DECRYPTED_FLAG_OFFSET, DRM_DECRYPTED_FLAG_BIT);
- }
- if ( uiInputBufferSizeWords % DRM_DECRYPTED_SHARED_MEM_LENGTH)
- {
- wTimeOut = 1000;
- while (wTimeOut--)
- {
- if (FALSE == DEC_AVI_GetDemuxSharedBit(DRM_DECRYPTED_FLAG_OFFSET, DRM_DECRYPTED_FLAG_BIT))
- break;
- delay_us(1000UL);
- }
-
- if (TRUE == DEC_AVI_GetDemuxSharedBit(DRM_DECRYPTED_FLAG_OFFSET, DRM_DECRYPTED_FLAG_BIT))
- {
- tr_printf(("Time out in OnDrmInfoMsgArrived()!n"));
- return;
- }
-
- for (i = 0; i < (uiInputBufferSizeWords % DRM_DECRYPTED_SHARED_MEM_LENGTH); i++)
- {
- DVP_API_DR_Write(DVP_DS2C_FIFO_START_OFFSET+i, a_chDecodedVideoChunckBuffer[(uiWriteIteration*DRM_DECRYPTED_SHARED_MEM_LENGTH) + i ]);
- }
- DEC_AVI_SetDemuxSharedBit(DRM_DECRYPTED_FLAG_OFFSET, DRM_DECRYPTED_FLAG_BIT);
- }
-
-
- return;
- }
- #ifdef AVI_AUDIO_CHANGE_ONSCAN //ZKR JK0413 : add for Divx audio change on-the-fly
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnAuioChanged() -
- // Handles an IE_CORE_AUDIO_CHANGE Event.
- //
- // Input:
- // None
- //
- // Output:
- // None.
- //
- // Remarks:
- static void OnAudioChanged(void)
- {
- UINT16 hClipInstance= ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1);
-
- tr_printf(("nav_clips : IDX(%d)n",_mpeg4AudioCurrentDispIdx));
-
- sc_GetBytes(SC_MPEG4_AUDIO_STREAM_INFO_ADDR,
- (_mpeg4AudioCurrentDispIdx * SIZE_OF_AUDIO_STREAM_INFO),
- SIZE_OF_AUDIO_STREAM_INFO,
- (BYTE*)&_mpeg4AudioStreamInfo
- );
-
- #ifdef EXINO2
- if ( gcs.pstate == PST_PLAY ) {
- gcs.pstate = PST_STOP;
- OnPlay();
- }
- #else //PATCH: For audio chagne on fly, use the index table of previous audio stream. Potential A/V sync problem exsits.
- if ( gcs.pstate == PST_PLAY )
- {
- Clip_recordMarker(hClipInstance, &g_pClipsNav->m_cmResumeMarker);
- PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
- // Clip_abortPlayback(hClipInstance, TRUE);
- // <<< Robin_0903_2004
- #ifdef DIVX_SUPPORT_MULTI_SUBTITLE_MODE0
- bNeedWaitForUI = FALSE;
- #endif
- // >>> Robin_0903_2004
- if (!invokePlayback(FALSE)) {
- dbg_printf(("Failed to play-back the current List.n"));
- gcs.pstate= PST_STOP;
- }
- }
- #endif
- }
- #endif //AVI_AUDIO_CHANGE_ONSCAN
- #ifdef IS_MP4_CAPABLE
- static void OnChapterChanged(void)
- {
- MPEG4ChapterEntry mpeg4ChapterEntry;
- DWORD dwDRAMAddr;
- // <<< Robin_1119_2004, fix the wrong chapter number calculation
- WORD wTimeStart;
- WORD wTimeEnd;
- dwDRAMAddr = _dwMP4ChapterDRAMStartAddr - ((SI_CLIPS_CHAPTER_CURRENT_DISP_IDX+1) * sizeof(MPEG4ChapterEntry)/2);
- if (_mpeg4ChapterCurrentDispIdx > 0)
- {
- wai_sem(SEM_DRAM_ID);
- I49_ReadDRAMData(dwDRAMAddr,(UINT16*)&mpeg4ChapterEntry, (sizeof(MPEG4ChapterEntry)/2));
- sig_sem(SEM_DRAM_ID);
- wTimeStart = mpeg4ChapterEntry.uiChapterTime;
- }
- else
- {
- wTimeStart = 0;
- }
- if (_mpeg4ChapterCurrentDispIdx < (_mpeg4ChapterAvailableNum -1))
- {
- dwDRAMAddr -= sizeof(MPEG4ChapterEntry)/2;
- wai_sem(SEM_DRAM_ID);
- I49_ReadDRAMData(dwDRAMAddr,(UINT16*)&mpeg4ChapterEntry, (sizeof(MPEG4ChapterEntry)/2));
- sig_sem(SEM_DRAM_ID);
- wTimeEnd = mpeg4ChapterEntry.uiChapterTime;
- }
- else
- {
- wTimeEnd = 0xFFFFU;
- }
- _uiMP4ChapterStartTime = wTimeStart;
- _uiMP4ChapterEndTime = wTimeEnd;
- OnGotoTime(wTimeStart);
- // >>> Robin_1119_2004
-
- }
- #endif
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnSubtitleChanged() -
- // Handles an IE_CORE_SUBTITLE_ARRIVED Event.
- //
- // Input:
- // None
- //
- // Output:
- // None.
- //
- // Remarks:
- // The handler is used for DivX playback only.
- // the routine is handling Subtitles arrived from the Demux task
- static void OnSubtitleChanged(void)
- {
- UINT16 hClipInstance= ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1);
- // <<< Robin_0903_2004
-
- MPEG4SubtitleStreamInfo mpeg4LastSubtitleStreamInfo;
- // printf("IDX:%dn",SI_CLIPS_SUB_CURRENT_DISP_IDX);
- sc_GetBytes(SC_MPEG4_SUBTITLE_STREAM_INFO_ADDR,
- (SI_CLIPS_SUB_CURRENT_DISP_IDX * SIZE_OF_SUBTITLE_STREAM_INFO),
- SIZE_OF_SUBTITLE_STREAM_INFO,
- (BYTE*)&_mpeg4SubtitleStreamInfo
- );
- if (SI_CLIPS_SUB_CURRENT_DISP_IDX == MAX_SUB_PER_CLIP)
- {
- sc_GetBytes(SC_MPEG4_SUBTITLE_STREAM_INFO_ADDR,
- ((SI_CLIPS_SUB_AVAILABLE_NUM-1) * SIZE_OF_SUBTITLE_STREAM_INFO),
- SIZE_OF_SUBTITLE_STREAM_INFO,
- (BYTE*)&mpeg4LastSubtitleStreamInfo
- );
- }
- else
- {
- sc_GetBytes(SC_MPEG4_SUBTITLE_STREAM_INFO_ADDR,
- ((SI_CLIPS_SUB_CURRENT_DISP_IDX-1) * SIZE_OF_SUBTITLE_STREAM_INFO),
- SIZE_OF_SUBTITLE_STREAM_INFO,
- (BYTE*)&mpeg4LastSubtitleStreamInfo
- );
- }
- if(SI_CLIPS_SUB_CURRENT_DISP_IDX == MAX_SUB_PER_CLIP)
- {
- DEC_AVI_ChangedSubtitle(0xFFFF);
- _mpeg4SubtitleStreamID = NO_STREAM;
- if(mpeg4LastSubtitleStreamInfo.type > INTERNAL_SUBT)
- {
- // Robin_0329_2005, stop to display the external subtitle
- setSubtitlesPlayMode(FALSE);
- stopDisplayAuxSubtitles();
- return;
- }
- }
- else
- {
- // Robin_0419_2005, fix the problem when change subtitle language in sami
- if (_mpeg4SubtitleCurrentDispIdx >= _mpeg4SubtitleInternalAvailableNum)
- {
- DEC_AVI_ChangedSubtitle(0xFFFF);
- // push the internal subtitle, TBD
- if ((_mpeg4SubtitleInternalAvailableNum == 0) && (_mpeg4SubtitleAvailableNum == 1)) // only one external subtitle
- {
- subtitleGoToTime(0);
- setSubtitlesPlayMode(TRUE);
- return;
- }
- }
- else
- {
- DEC_AVI_ChangedSubtitle(_mpeg4SubtitleStreamID);
- }
- }
- #ifdef AVI_SUBTITLE_CHANGE_ONSCAN
- #ifdef EXINO2 //ZKR JK0419 : not change subtitle
- if (PST_PLAY== gcs.pstate)
- {
- OnScan(0);
- gcs.pstate= PST_PLAY;
- }
- #else
- if ( gcs.pstate == PST_PLAY )
- {
- Clip_recordMarker(hClipInstance, &g_pClipsNav->m_cmResumeMarker);
- PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
- // Clip_abortPlayback(hClipInstance, TRUE);
- #ifdef DIVX_SUPPORT_MULTI_SUBTITLE_MODE0
- bNeedWaitForUI = FALSE;
- #endif
- // >>> Robin_0903_2004
- if (!invokePlayback(FALSE)) {
- dbg_printf(("Failed to play-back the current List.n"));
- gcs.pstate= PST_STOP;
- }
- }
- #endif
- #endif
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnSubtitleArrived() -
- // Handles an IE_CORE_SUBTITLE_ARRIVED Event.
- //
- // Input:
- // None
- //
- // Output:
- // None.
- //
- // Remarks:
- // The handler is used for DivX playback only.
- // the routine is handling Subtitles arrived from the Demux task
- static void OnSubtitleArrived(void)
- {
- char Duration[28];
- UINT8 index_duration;
- UINT16 Width,Height,Left,Top,Right,Bottom,FieldOffset,Temp,SP_DCSQT_SA,DCSQ0_SQ_NXT_DCSQ_SA,SPDSize;
- DWORD Chunck_Size,SPB_Pointer,Temp1,Temp2;
- RGB_S ClrBackGround,ClrPattern,ClrEmpasis1,ClrEmpasis2;
- YUV_S ClrBackGround_yuv,ClrPattern_yuv,ClrEmpasis1_yuv,ClrEmpasis2_yuv;
- UINT8 i;
- UINT32 UlPts,UlEndPts,UlTempPts,StDataSize,BmpSize,BmpStuffing;
- UINT16 buff_header[4], buff_command[15],t1,t2;
- UINT8 index=0,SPUStuffing,command_size;
- UINT16 status;
- // static UINT8 Count = 0;
- #if defined(SDRAM_2X16MBITS) && defined(NEW_2X16M_MAPPING)
- UINT16 uiACBStartAddressAVI,uiSPBStartAddressAVI, uiAPPStartAddressAVI;
- UINT32 SPBStartAddressAVI;
- UINT32 SPBEndAddressAVI;
- #endif
- UINT16 wWindwosWidth, wDiff;
-
- status = inport(DS2CFIFO_STATUS_ADDR);
- if(status != 31)
- {
- tr_printf(("not all message recievedn"));
- // asm int 3;
- }
- // get Chunck Size
- Temp1 = inport(DS2CFIFO_DATA_ADDR);
- Temp2 = inport(DS2CFIFO_DATA_ADDR);
- Chunck_Size = (Temp1<<16)|(Temp2);
- // get SPB Pointer
- Temp1 = inport(DS2CFIFO_DATA_ADDR);
- Temp2 = inport(DS2CFIFO_DATA_ADDR);
- SPB_Pointer = (Temp1<<16)|(Temp2);
- // printf("SPB_Pointer:%08lxn",SPB_Pointer);
- for(index_duration=0;index_duration<28;index_duration+=2)
- {
- Temp = inport(DS2CFIFO_DATA_ADDR);
- Duration[index_duration] = (char) (Temp & 0xff);
- Duration[index_duration+1] = (char) ((Temp & 0xff00)>>8);
- }
- Width = inport(DS2CFIFO_DATA_ADDR);
- Height = inport(DS2CFIFO_DATA_ADDR);
- Left = inport(DS2CFIFO_DATA_ADDR);
- Top = inport(DS2CFIFO_DATA_ADDR);
- Right = inport(DS2CFIFO_DATA_ADDR);
- Bottom = inport(DS2CFIFO_DATA_ADDR);
- // move the subpicture to the center
- wWindwosWidth = Right + Left;
- if (wWindwosWidth < 720)
- {
- wDiff = (720-wWindwosWidth)/2;
- Left += wDiff;
- Right += wDiff;
- }
- // a hardware bug in I76
- // When progressive and NTSC->PAL, if SPU start line is multiple of 10,
- // the line of two fields are flip.
- if (DEC_IsVideoPal())
- {
- if (0 == Top%10)
- {
- Top += 2;
- Bottom += 2;
- }
- }
-
- FieldOffset = inport(DS2CFIFO_DATA_ADDR);
-
- // if(Count==10)
- // {
- // printf("W:%x H:%x L:%x T:%x R:%x B:%x F:%xn",Width,Height,Left,Top,Right,Bottom,FieldOffset);
- // }
- Bottom -=2;
- Temp = inport(DS2CFIFO_DATA_ADDR);
- ClrBackGround.red = (char) (Temp & 0xff);
- ClrBackGround.green = (char) ((Temp & 0xff00)>>8);
- Temp = inport(DS2CFIFO_DATA_ADDR);
- ClrBackGround.blue = (char) (Temp & 0xff);
- ClrPattern.red = (char) ((Temp & 0xff00)>>8);
- Temp = inport(DS2CFIFO_DATA_ADDR);
- ClrPattern.green = (char) (Temp & 0xff);
- ClrPattern.blue = (char) ((Temp & 0xff00)>>8);
- Temp = inport(DS2CFIFO_DATA_ADDR);
- ClrEmpasis1.red = (char) (Temp & 0xff);
- ClrEmpasis1.green = (char) ((Temp & 0xff00)>>8);
- Temp = inport(DS2CFIFO_DATA_ADDR);
- ClrEmpasis1.blue = (char) (Temp & 0xff);
- ClrEmpasis2.red = (char) ((Temp & 0xff00)>>8);
- Temp = inport(DS2CFIFO_DATA_ADDR);
- ClrEmpasis2.green = (char) (Temp & 0xff);
- ClrEmpasis2.blue = (char) ((Temp & 0xff00)>>8);
-
- if(change_pallet)
- {
- /* SubPicture Reset */
- /* set the SP switch */
- outport(SPSWITCH_ADDR,0x5);
- /* set the SP Scale */
- // The feature subtitle window size is 640x480/720x480
- if (DEC_IsVideoPal())
- {
- I49_ParameterWrite(SPSCALE_ADDR, 0x02); // NTSC->PAL
- }
- else
- {
- I49_ParameterWrite(SPSCALE_ADDR, 0x00);
- }
- change_pallet = FALSE;
- t1 = RGB_2_Y(ClrBackGround.red,ClrBackGround.green,ClrBackGround.blue);//( ( 66 * ClrBackGround.red + 129 * ClrBackGround.green + 25 * ClrBackGround.blue + 128) >> 8) + 16;
- ClrBackGround_yuv.Y = t1;
- if(t1 > 235)
- ClrBackGround_yuv.Y = 235;
- if(t1 < 16)
- ClrBackGround_yuv.Y = 16;
- t1 = RGB_2_U(ClrBackGround.red,ClrBackGround.green,ClrBackGround.blue);//( ( -38 * ClrBackGround.red - 74 * ClrBackGround.green + 112 * ClrBackGround.blue + 128) >> 8) + 128;
- ClrBackGround_yuv.U = t1;
- if(t1 > 240)
- ClrBackGround_yuv.U = 240;
- if(t1 < 16)
- ClrBackGround_yuv.U = 16;
- t1 = RGB_2_V(ClrBackGround.red,ClrBackGround.green,ClrBackGround.blue);//( ( 112 * ClrBackGround.red - 94 * ClrBackGround.green - 18 * ClrBackGround.blue + 128) >> 8) + 128;
- ClrBackGround_yuv.V = t1;
- if(t1 > 240)
- ClrBackGround_yuv.V = 240;
- if(t1 < 16)
- ClrBackGround_yuv.V = 16;
- t1 = RGB_2_Y(ClrPattern.red,ClrPattern.green,ClrPattern.blue);
- ClrPattern_yuv.Y = t1;
- if(t1 > 235)
- ClrPattern_yuv.Y = 235;
- if(t1 < 16)
- ClrPattern_yuv.Y = 16;
- t1 = RGB_2_U(ClrPattern.red,ClrPattern.green,ClrPattern.blue);
- ClrPattern_yuv.U = t1;
- if(t1 > 240)
- ClrPattern_yuv.U = 240;
- if(t1 < 16)
- ClrPattern_yuv.U = 16;
- t1 = RGB_2_V(ClrPattern.red,ClrPattern.green,ClrPattern.blue);
- ClrPattern_yuv.V = t1;
- if(t1 > 240)
- ClrPattern_yuv.V = 240;
- if(t1 < 16)
- ClrPattern_yuv.V = 16;
- t1 = RGB_2_Y(ClrEmpasis1.red,ClrEmpasis1.green,ClrEmpasis1.blue);
- ClrEmpasis1_yuv.Y = t1;
- if(t1 > 235)
- ClrEmpasis1_yuv.Y = 235;
- if(t1 < 16)
- ClrEmpasis1_yuv.Y = 16;
- t1 = RGB_2_U(ClrEmpasis1.red,ClrEmpasis1.green,ClrEmpasis1.blue);
- ClrEmpasis1_yuv.U = t1;
- if(t1 > 240)
- ClrEmpasis1_yuv.U = 240;
- if(t1 < 16)
- ClrEmpasis1_yuv.U = 16;
- t1 = RGB_2_V(ClrEmpasis1.red,ClrEmpasis1.green,ClrEmpasis1.blue);
- ClrEmpasis1_yuv.V = t1;
- if(t1 > 240)
- ClrEmpasis1_yuv.V = 240;
- if(t1 < 16)
- ClrEmpasis1_yuv.V = 16;
-
- t1 = RGB_2_Y(ClrEmpasis2.red,ClrEmpasis2.green,ClrEmpasis2.blue);
- ClrEmpasis2_yuv.Y = t1;
- if(t1 > 235)
- ClrEmpasis2_yuv.Y = 235;
- if(t1 < 16)
- ClrEmpasis2_yuv.Y = 16;
- t1 = RGB_2_U(ClrEmpasis2.red,ClrEmpasis2.green,ClrEmpasis2.blue);
- ClrEmpasis2_yuv.U = t1;
- if(t1 > 240)
- ClrEmpasis2_yuv.U = 240;
- if(t1 < 16)
- ClrEmpasis2_yuv.U = 16;
- t1 = RGB_2_V(ClrEmpasis2.red,ClrEmpasis2.green,ClrEmpasis2.blue);
- ClrEmpasis2_yuv.V = t1;
- if(t1 > 240)
- ClrEmpasis2_yuv.V = 240;
- if(t1 < 16)
- ClrEmpasis2_yuv.V = 16;
-
- // printf("RGB => BG:%02x%02x%02x PT:%02x%02x%02x E1:%02x%02x%02x E2:%02x%02x%02xn",
- // ClrBackGround.red,ClrBackGround.green,ClrBackGround.blue,
- // ClrPattern.red,ClrPattern.green,ClrPattern.blue,
- // ClrEmpasis1.red,ClrEmpasis1.green,ClrEmpasis1.blue,
- // ClrEmpasis2.red,ClrEmpasis2.green,ClrEmpasis2.blue );
- //
- // printf("YUV => BG:%02x%02x%02x PT:%02x%02x%02x E1:%02x%02x%02x E2:%02x%02x%02xn",
- // ClrBackGround_yuv.Y,ClrBackGround_yuv.U,ClrBackGround_yuv.V,
- // ClrPattern_yuv.Y,ClrPattern_yuv.U,ClrPattern_yuv.V,
- // ClrEmpasis1_yuv.Y,ClrEmpasis1_yuv.U,ClrEmpasis1_yuv.V,
- // ClrEmpasis2_yuv.Y,ClrEmpasis2_yuv.U,ClrEmpasis2_yuv.V );
- // program the pallet
- outport(SPPALETTE_ADDR,(UINT16)ClrBackGround_yuv.Y);
- outport(SPPALETTE_ADDR,(UINT16)((ClrBackGround_yuv.V<<8) | ClrBackGround_yuv.U));
- outport(SPPALETTE_ADDR,(UINT16)ClrPattern_yuv.Y);
- outport(SPPALETTE_ADDR,(UINT16)((ClrPattern_yuv.V<<8) | ClrPattern_yuv.U));
- outport(SPPALETTE_ADDR,(UINT16)ClrEmpasis1_yuv.Y);
- outport(SPPALETTE_ADDR,(UINT16)((ClrEmpasis1_yuv.V<<8) | ClrEmpasis1_yuv.U));
- outport(SPPALETTE_ADDR,(UINT16)ClrEmpasis2_yuv.Y);
- outport(SPPALETTE_ADDR,(UINT16)((ClrEmpasis2_yuv.V<<8) | ClrEmpasis2_yuv.U));
- // printf("%x ",(UINT16)ClrBackGround_yuv.Y);
- // printf("%x ",(UINT16)ClrBackGround_yuv.Y);
- // empty the other 12
- for(i=0;i<12;i++)
- {
- outport(SPPALETTE_ADDR,0);
- outport(SPPALETTE_ADDR,0);
- }
- }
-
- FieldOffset += 4;
- // Calculate UlPts
- UlPts = ((((Duration[1] - '0')*10)+(Duration[2]-'0'))*3600);
- UlPts += ((((Duration[4] - '0')*10)+(Duration[5] - '0'))*60);
- UlPts += (((Duration[7] - '0')*10)+(Duration[8] - '0'));
- UlPts *= 90000;
- UlTempPts = (Duration[10] - '0')*100 + (Duration[11] - '0')*10 + (Duration[12] - '0');
- UlTempPts *= 90;
- UlPts += UlTempPts;
- StDataSize = Chunck_Size -/* FourCCSize - CkSizeSize -*/ DurationSize;
- BmpSize = StDataSize - STDHeaderSize;
- SPUStuffing = BmpSize&1;
- // BmpStuffing = DCSQTSize > (SPUHdrSize + BmpSize + DCSQTSize)/2 ? (DCSQTSize - SPUHdrSize - BmpSize + 1)/2:0;
- // Calculate SPDSize
- SPDSize = SPUHdrSize + BmpSize + /*(BmpStuffing*2) +*/ DCSQTSize + SPUStuffing;
- // Calculate SP_DCSQT_SA
- SP_DCSQT_SA = SPUHdrSize + BmpSize /* + (BmpStuffing*2)*/;
- DCSQ0_SQ_NXT_DCSQ_SA = SP_DCSQT_SA + DCSQ0Size;
- /*
- buff_header[1] = ((UlPts&0xff000000)>>24);
- buff_header[0] = ((UlPts&0x00ff0000)>>16);
- buff_header[3] = ((UlPts&0x0000ff00)>>8);
- buff_header[2] = ((UlPts&0x000000ff));
- //memcpy((void*) buff_header , (void*)(&UlPts), sizeof(UlPts) );
- buff_header[5] = (SPDSize>>8);
- buff_header[4] = (SPDSize&0xFF);
- buff_header[7] = (SP_DCSQT_SA>>8);
- buff_header[6] = (SP_DCSQT_SA&0xFF);
- */
- buff_header[0] = ((UlPts&0xffff0000)>>16);
- buff_header[1] = ((UlPts&0x0000ffff));
- buff_header[2] = SPDSize;
- buff_header[3] = SP_DCSQT_SA;
- if(SPUStuffing)
- {
- // printf("STUFn");
- buff_command[index++] = ((DCSQ0_SQ_NXT_DCSQ_SA&0xff00)>>8);
- buff_command[index++] = (((DCSQ0_SQ_NXT_DCSQ_SA&0xff)<<8)|0x03);
- buff_command[index++] = 0x3210;
- buff_command[index++] = 0x04FF;
- buff_command[index++] = 0xF005;
- t1 = ((Left&0x03ff)<<4);
- t2 = ((Right&0x300)>>8);
- buff_command[index++] = t1 | t2;//0x0a02;//(((Left&0x03ff)<<4) | ((Right&0x300)>>8));
- // printf("L:%04x R:%04x b:%04xn",t1,t2,buff_command[index-1]);
- // printf("L:%x R:%xn",((Left&0x03ff)<<4),((Right&0x300)>>8));
-
- buff_command[index++] = (((Right&0xff)<<8) | ((Top&0x3f0)>>4));
- buff_command[index++] = (((Top&0xe)<<12) | (Bottom&0x3ff));
- // if(Count==10)
- // {
- // printf("b1:%04x %04x %04x ",buff_command[index-3],buff_command[index-2],buff_command[index-1]);
- // }
- // if(!(Top&0x1))
- // {
- buff_command[index++] = 0x0600;
- buff_command[index++] = ((0x0400) | ((FieldOffset&0xff00)>>8));
- buff_command[index++] = ((FieldOffset&0xff)<<8);
- /* }
- else
- {
- buff_command[index++] = ((0x0600) |((FieldOffset&0xff00)>>8));
- buff_command[index++] = ((FieldOffset&0xff) | (0x00));
- buff_command[index++] = 0x0400;
- }
- */
- UlEndPts = ((((Duration[14] - '0')*10)+(Duration[15] - '0'))*3600);
- UlEndPts += ((((Duration[17] - '0')*10)+(Duration[18] - '0'))*60);
- UlEndPts += (((Duration[20] - '0')*10)+(Duration[21] - '0'));
- UlEndPts *= 90000;
- UlTempPts = (Duration[23] - '0')*100 + (Duration[24] - '0')*10 + (Duration[25] - '0');
- UlTempPts *= 90;
- UlEndPts += UlTempPts;
- UlTempPts = ((UlEndPts - UlPts)>>10);
- buff_command[index++] = ((0xFF00) | ((UlTempPts&0xff00)>>8));
- buff_command[index++] = (((UlTempPts&0x00ff)<<8)| ((DCSQ0_SQ_NXT_DCSQ_SA&0xFF00)>>8));
- buff_command[index++] = (((DCSQ0_SQ_NXT_DCSQ_SA&0x00FF)<<8) | (0x0002));
- buff_command[index++] = 0xFFFF;
- }
- else
- {
- // printf("STUF!!n");
- buff_command[index++] = 0x0000;
- buff_command[index++] = DCSQ0_SQ_NXT_DCSQ_SA;
- buff_command[index++] = 0x0332;
- buff_command[index++] = 0x1004;
- // Contrast
- buff_command[index++] = 0xFFF0;
- buff_command[index++] = ((0x0500) | ((Left&0x3f0)>>4));
- buff_command[index++] = (((Left&0xf)<<12) | (Right&0x3ff));
- buff_command[index++] = (((Top&0x3fe)<<4) | ((Bottom&0x300)>>8));
- buff_command[index++] = (((Bottom&0xff)<<8) | 0x0006) ;
- // if(Count==10)
- // {
- // printf("b1:%04x %04x %04x %04x",buff_command[index-4],buff_command[index-3],buff_command[index-2],buff_command[index-1]);
- // }
- // if(Top&0x1)
- // {
- buff_command[index++] = 0x0004;
- buff_command[index++] = FieldOffset;
- /* }
- else
- {
- buff_command[index++] = FieldOffset;
- buff_command[index++] = 0x0004;
- }
- */
- buff_command[index++] = 0x00FF;
- UlEndPts = ((((Duration[14] - '0')*10)+(Duration[15] - '0'))*3600);
- UlEndPts += ((((Duration[17] - '0')*10)+(Duration[18] - '0'))*60);
- UlEndPts += (((Duration[20] - '0')*10)+(Duration[21] - '0'));
- UlEndPts *= 90000;
- UlTempPts = (Duration[23] - '0')*100 + (Duration[24] - '0')*10 + (Duration[25] - '0');
- UlTempPts *= 90;
- UlEndPts += UlTempPts;
- UlTempPts = ((UlEndPts - UlPts)>>10);
- buff_command[index++] = (UlTempPts&0xFFFF);
- buff_command[index++] = DCSQ0_SQ_NXT_DCSQ_SA;
- buff_command[index++] = 0x02FF;
- }
- #if defined(SDRAM_2X16MBITS) && defined(NEW_2X16M_MAPPING)
- // MPEG4Clip_dynamic_malloc(&uiACBStartAddressAVI, &uiSPBStartAddressAVI, &uiAPPStartAddressAVI);
- UlTempPts = _mpeg4InternalSubtitleBufferStartAddr;
- SPBStartAddressAVI = _mpeg4InternalSubtitleBufferStartAddr * 512UL;
- SPBEndAddressAVI = (_mpeg4InternalSubtitleBufferStartAddr + SPB_SIZE_AVI) * 512UL;
- #else
- UlTempPts = (OSD_BUFFER_SIZE_AVI + VCB_SIZE_AVI + ACB_SIZE_AVI);
- #endif
- UlTempPts *= 512UL;
- UlTempPts += (SPB_Pointer/2);
- #if 0
- {
- int i;
- for(i=0;i<SPU_HEADER_LENGTH;i++)
- {
- printf("%04x ",buff_header[i]);
- }
- printf("n");
- for(i=0;i<SPU_COMMAND_LENGTH;i++)
- {
- printf("%04x ",buff_command[i]);
- }
- printf("n");
- }
- #endif
- // SRkeep = InterruptDisable();
-
- // semaphore_set(SEM_DRAM);
- // printf("SPB_Pointer:%08lx ",UlTempPts);
- #if defined(SDRAM_2X16MBITS) && defined(NEW_2X16M_MAPPING)
- CyclicWriteDRAMData(SPBStartAddressAVI,SPBEndAddressAVI,
- UlTempPts,(UINT16*)buff_header, SPU_HEADER_LENGTH);
- #else
- CyclicWriteDRAMData(SPB_START_AVI,SPB_END_AVI,
- UlTempPts,(UINT16*)buff_header, SPU_HEADER_LENGTH);
- #endif
- // I49_WriteDRAMDataNSW(UlTempPts,(UINT16*)buff_header, SPU_HEADER_LENGTH);
- if(SPUStuffing)
- {
- UlTempPts += (SPU_HEADER_LENGTH + ((BmpSize+1)/2));
- }
- else
- {
- UlTempPts += (SPU_HEADER_LENGTH + (BmpSize/2));
- }
- // printf("%08lx n",UlTempPts);
- #if (defined(SDRAM_2X16MBITS) && defined(NEW_2X16M_MAPPING))
- CyclicWriteDRAMData(SPBStartAddressAVI,SPBEndAddressAVI,
- UlTempPts,(UINT16*)buff_command, SPU_COMMAND_LENGTH);
- #else
- CyclicWriteDRAMData(SPB_START_AVI,SPB_END_AVI,
- UlTempPts,(UINT16*)buff_command, SPU_COMMAND_LENGTH);
- #endif
- // I49_WriteDRAMDataNSW(UlTempPts, (UINT16*)buff_command, SPU_COMMAND_LENGTH);
-
- // semaphore_clear(SEM_DRAM);
- // Count++;
- // printf("C:%d",Count++);
- outport(SPD_INCREMENT_ADDR,0x1);
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnDemuxFinished() -
- // Handles an IE_CORE_DEMUX_FINISHED Event.
- //
- // Input:
- // None
- //
- // Output:
- // None. The playback is skipped to the nex/previous I frame.
- //
- // Remarks:
- // The handler is used for DivX playback only.
- // In case the demux reached the end sector, the DivX navigator is notified and request the
- // next/previous I frame according to the index table.
- static void OnDemuxFinished(void)
- {
- const ClipInfoEx *pCurrClip = &(SHARED_INFO).cieCurrClip;
- /* Make sure we are in scanning mode */
- if ( ((PST_SCAN != gcs.pstate) || (0 == gns.clips.iScanSpeed))
- && (PST_SLOW != gcs.pstate) )
- {
- dbg_printf(("Scanning cancelled. Ignored.n"));
- return;
- }
- /* Make sure we are playing MPEG4 file */
- if ( ((enClipType)pCurrClip->ciInfo.eType != eClipType_AVI)
- #ifdef IS_ASF_CAPABLE
- && ((enClipType)pCurrClip->ciInfo.eType != eClipType_ASF)
- #endif
- #ifdef IS_MP4_CAPABLE
- && ((enClipType)pCurrClip->ciInfo.eType != eClipType_MP4)
- #endif
- )
- {
- return;
- }
-
- Clip_continueScanning();
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnIFrameDisplayed() -
- // Handles an IE_CORE_I_FRAME Event.
- //
- // Input:
- // None
- //
- // Output:
- // None. The playback is skipped forward/backwards in order to seek and present the next
- // I-Frame.
- //
- // Remarks:
- // The handler checks the direction of the current Scan.
- // In case of a forward scan, the current playback is halted and restarted from a position
- // further down the stream.
- // In the case of a backwards scan, the current playback is halted and restarted from a
- // position preceding the current one.
- // In both cases, if the next position is outside the boundaries of the current Playing-Segment,
- // the appropriate action is performed; i.e.: the next item (in forward scan) or the previous
- // item (in backwards scan) is invoked.
- static void OnIFrameDisplayed(void)
- {
- DWORD dwCurrLocation= -1;
- DWORD dwNextLocation;
- BOOL bLocationFromDriveValid;
- DWORD dwClipStartAddress, dwClipEndAddress;
- dbg_printf(("OnIFrameDisplayed()n"));
- SET_COP_MASK(COP_SCAN);
-
- // Make sure that Scanning is still active
- if ( ((PST_SCAN != gcs.pstate) || (0 == gns.clips.iScanSpeed))
- &&(PST_SLOW != gcs.pstate) )
- {
- dbg_printf(("Scanning cancelled. Ignored.n"));
- dwCurrLocation= -1; // Reset the Scan position
- return;
- }
- dwClipStartAddress = (DWORD)gns.clips.cieCurrClip.ciInfo.dwFileLocation;
- dwClipEndAddress = (DWORD)(gns.clips.cieCurrClip.ciInfo.cbFileSize >> 11) + 1 + dwClipStartAddress;
-
- if(gns.clips.iScanSpeed < 0)
- dwCurrLocation = CurrLocationBackup;
- else
- dwCurrLocation = PE_Clips_GetCurrLocation();
- // Abort the current Playback, without changing Decoder mode
- PE_CD_AbortPlayback(TRUE);
- // Calculate the Next target location; avoid slipping over the edge
- if (gns.clips.iScanSpeed != 0)
- {
- dwNextLocation= (dwCurrLocation + (gns.clips.iScanSpeed * CLIPS_MPEG_NUM_OF_SECTORES_PER_SECOND));
- }
- else if (gns.clips.iSlowSpeed != 0)
- {
- dwNextLocation= (dwCurrLocation + (gns.clips.iSlowSpeed * CLIPS_MPEG_NUM_OF_SECTORES_PER_SECOND));
- }
-
- if ((INT32)dwNextLocation < 0)
- dwNextLocation= 0;
- // Check the Scanning-direction, and act accordingly
- if (gns.clips.iScanSpeed > 0) {
- if (dwNextLocation < dwClipEndAddress ) {
- // The next sub-segment to skip to is within the boundaries of the current segment
- dwCurrLocation= dwNextLocation;
- }
- else {
- //<<<angieh_0412_2004:Don't reset the state it will be used when compute the next track.
- //gcs.pstate = PST_PLAY;
- //gns.clips.iScanSpeed = 0;
- //angieh_0412_2004>>>
- PE_CD_CancelNotification(IFrame);
- ie_send(IE_CORE_CDNAV_FINISHED);
- return;
- }
- }
- else if ( ( gns.clips.iScanSpeed < 0 ) || ( gns.clips.iSlowSpeed < 0 )){
- // Continue Scanning
- if (dwNextLocation > dwClipStartAddress ) {
- // The previous sub-segment to skip to is within the boundaries of the current segment
- dwCurrLocation= dwNextLocation;
- }
- else {
- //<<<angieh_0412_2004:Don't reset the state it will be used when compute the next track.
- //gcs.pstate = PST_PLAY;
- //gns.clips.iScanSpeed = 0;
- //gns.clips.iSlowSpeed = 0;
- //angieh_0412_2004>>>
- PE_CD_CancelNotification(IFrame);
- ie_send(IE_CORE_CDNAV_FINISHED);
- return;
- }
- }
- if (gns.clips.iScanSpeed != 0)
- gcs.pstate= PST_SCAN;
- else{
- if (gns.clips.iSlowSpeed != 0)
- gcs.pstate= PST_SLOW;
- }
- // Arrange for an additional I-Frame notification
- PE_CD_RequestNotification(IFrame);
- // Engage the Error-Recovery mehcanism for I-Frame Display Miss
- (g_pClipsNav->m_ErrorRecoveryInfo).uRetryCount= CLIPS_ERROR_RECOVERY_RETRY_COUNT;
-
- // Invoke playback of the next sub-segment within the current segment
- if ( (gns.clips.iScanSpeed != 0) || (gns.clips.iSlowSpeed != 0) ){
- // UINT16 uTime = PE_Clips_GetClock(); //SUPPORT_FLASH_CARD
- // DEC_SetDiskType(i_pThis->m_pConstAttr)->m_eBitstreamType);
-
- // Prepare for decoding
- DEC_prepare_to_decode();
- DEC_SetSID(DEC_SID_TYPE_AUDIO, NoAudio);
- DEC_SetSID(DEC_SID_TYPE_VIDEO, 0xE0);
- // Inform the Decoder of the Playback-Range
- PE_Clips_SetPlaybackRange(dwCurrLocation, dwClipEndAddress - dwCurrLocation, UNLIMITED_FILE_SIZE);
- if(gns.clips.iScanSpeed < 0)
- CurrLocationBackup = dwCurrLocation;
- else
- CurrLocationBackup = -1;
- // Invoke playback of the Decoder & Drive
- // NOTE: The order of invocation is important, and must not be changed!
- DEC_PlaybackCommand(DEC_PLAYBACK_CMD_REF_FRAME_ONLY, NULL);//jeanz_0319_2005 Reset right command
- //LX051703: Add AV Data mode for Play CD
- if (!PE_Clips_Playback_Sectors(DRVCF_CDSPEED_1X | DRVF_PLAY_CD_AV_DATA, dwCurrLocation, dwClipEndAddress - dwCurrLocation )) {
- dbg_printf(("WARNING: GenericClip_play() Failed [1]n"));
- return FALSE;
- }
- }
-
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnStep() -
- // Handels an IE_CORE_STEP Event.
- //
- // Input:
- // None
- //
- // Output:
- // The appropriate PE method is called to step forward.
- static void OnStep(void)
- {
- UINT16 hClipInstance;
- hClipInstance= ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1);
- if ( NULL == hClipInstance )
- return;
- dbg_printf(("OnStep()n"));
- if ( !Clip_hasAttribute(hClipInstance, eCA_Slowable)){
- dbg_printf(("Step Foward not supportedn"));
- }
- if (PST_PAUSE != gcs.pstate) {
- dbg_printf(("Step is illegal when not Pausing. Ignored.n"));
- return;
- }
- // Cancel Intro Playmode
- gns.clips.bIsIntroPlayMode = FALSE;
- PE_CD_Step();
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnDriveError(void) -
- // Handles an IE_CORE_DRIVE_READ_FAIL Event.
- //
- // Input:
- // None.
- //
- // Output:
- // None.
- //
- // Remarks:
- // The function is activated to perform error handling for the clip resulting from
- // drive errors. Currently only for DivX.
- static void OnDriveError(void)
- {
- UINT16 hClipInstance = ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1);
- Clip_performErrorHandling(hClipInstance);
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnDemuxError(void) -
- // Handles an IE_CORE_DEMUX_ERROR Event.
- //
- // Input:
- // None.
- //
- // Output:
- // None.
- //
- // Remarks:
- // The function is activated to perform error handling for the clip resulting from
- // DEMUX-CPU communication errors. Currently only for DivX.
- static void OnDemuxError(void)
- {
- UINT16 hClipInstance = ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1);
- Clip_performErrorHandling(hClipInstance);
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnSlow(int iSpeed) -
- // Handles an IE_CORE_SLOW Event.
- //
- // Input:
- // iSpeed - Holds the requested Slow-Motion speed.
- //
- // Output:
- // None. Slow forward is started, if possible.
- //
- // Remarks:
- // Requests a Slow-Motion from the PE.
- static void OnSlow(int iSpeed)
- {
- dbg_printf(("OnSlow(%d)n", iSpeed));
- if (PST_STOP == gcs.pstate) {
- dbg_printf(("Cannot slow forward during a stop. Ignored.n"));
- return;
- }
- // Cancel Intro Playmode
- gns.clips.bIsIntroPlayMode = FALSE;
- if (IS_CLIPS_TYPE_MPEG4)
- {
- if (PST_PAUSE == gcs.pstate)
- _bMPEG4PauseToSlow = TRUE;
- else
- _bMPEG4PauseToSlow = FALSE;
- }
-
- // Eliminate current Scanning
- if ( (PST_SCAN == gcs.pstate) || ( ( PST_SLOW == gcs.pstate) && ( gns.clips.iSlowSpeed < 0 ) ) )
- {
- OnScan(0);
- gcs.pstate= PST_PLAY;
- }
- // First of all, resume Normal-Playback, if in Stop or Pause (essential for Slow-Motion),
- // or if Scanning is being eliminated.
- if ((PST_STOP == gcs.pstate) || (PST_PAUSE == gcs.pstate) || (0 == iSpeed))
- PE_CD_SetSlowMotion(FALSE, 0);
- // Now actually invoke Slow-Motion, if necessary
- if (0 != iSpeed) {
- if (iSpeed > 0) {
- PE_CD_SetSlowMotion(TRUE, (UINT8)iSpeed);
- PE_CD_CancelNotification(IFrame);
- gcs.pstate= PST_SLOW;
- }
- else {
- iSpeed = ((int)(iSpeed) + 9)*(-1);
- //This routine is like OnScan, we separate it with OnScan is becasue we don't want the gcs.pstate to be confused
- PE_CD_RequestNotification(IFrame);
- //cancel Trigger Bit notification
- PE_CD_CancelNotification(TriggerBit);
- #ifdef SUPPORT_FLASH_CARD
- if(IS_PLAYING_CARD)
- drv_suspend_playback(TRUE);
- #endif
- PE_CD_SetScan(TRUE, NoAudio, iSpeed);
- #ifdef SUPPORT_FLASH_CARD
- if(IS_PLAYING_CARD)
- drv_suspend_playback(FALSE);
- #endif
- gcs.pstate = PST_SLOW;
- }
- }
- gns.clips.iSlowSpeed= iSpeed;
- if (IS_CLIPS_TYPE_MPEG4)
- {
- _bMPEG4PauseToSlow = FALSE;
- }
- return;
- }
- #ifdef _DEBUG
- static void OnStatusReport()
- {
- const ClipInfoEx *pCurrClip= &(SHARED_INFO).cieCurrClip;
- WCHAR szTempDirectoryName[SC_CLIPS_CURRENT_DIRECTORY_SZ*2];
- WCHAR szTempFilename[SC_CLIPS_CURRENT_FILENAME_SZ*2];
- tr_printf(("Status Report for Clips-Navigatorn"));
- tr_printf(("tTotal number of items on Playlist: %dn", (int)(PM_GetProgramSize()-1)));
- tr_printf(("tCurrent Playlist item: %dn", (int)SHARED_INFO.uCurrPlaylistItem));
- tr_printf(("tClip No. %d.n", SHARED_INFO.uCurrentClipNumber));
- // tr_printf(("tClip-Path: %sn", DBG_W2A(pCurrClip->ciInfo.szDirectoryName)));
- // tr_printf(("tClip-name: %sn", DBG_W2A(pCurrClip->ciInfo.szFilename)));
- sc_GetBytes(SC_CLIPS_CURRENT_DIRECTORY_ADDR, (WORD)0, (WORD)(SC_CLIPS_CURRENT_DIRECTORY_SZ*4), (BYTE*)szTempDirectoryName);
- sc_GetBytes(SC_CLIPS_CURRENT_FILENAME_ADDR, (WORD)0, (WORD)(SC_CLIPS_CURRENT_FILENAME_SZ*4), (BYTE*)szTempFilename);
- tr_printf(("tClip-Path: %sn", DBG_W2A(szTempDirectoryName)));
- tr_printf(("tClip-name: %sn", DBG_W2A(szTempFilename)));
- if (! (SHARED_INFO.cieCurrClip).bIsExtendedInfoAvailable) {
- tr_printf(("No Extended Information available.n"));
- return;
- }
- #ifdef CLIPS_ACQUIRE_EXTENDED_INFO
- // tr_printf(("tPlayback-Time: %d Seconds.n", pCurrClip->uPlaybackTime));
- switch ((enClipType)pCurrClip->ciInfo.eType)
- {
- case eClipType_MP3:
- {
- //Angie_0810_2004:Move the MP3 and WMA extend info from gns to SCPAD for I86 memory reducing.
- MP3_ID3v1Tag id3Tag;
- printf("tClip-Type: MP3n");
- #ifdef CLIPS_MP3_EXTRACT_ID3V1_TAG
- sc_GetBytes(gns.clips.cieCurrClip.ExtInfo_sc_handle, 0, sizeof(MP3_ID3v1Tag), (BYTE *)&id3Tag);
- printf("tTitle: %sn", DBG_W2A(id3Tag.szSongName));
- printf("tArtist: %sn", DBG_W2A(id3Tag.szArtist));
- printf("tAlbum: %sn", DBG_W2A(id3Tag.szAlbum));
- printf("tYear: %sn", DBG_W2A(id3Tag.szYear));
- printf("tGenre: %sn", DBG_W2A(id3Tag.pszGenre));
- printf("tTrack-Num: %dn", id3Tag.uTrackNum);
- printf("tComment: %sn", DBG_W2A(id3Tag.szComment));
- #endif //CLIPS_MP3_EXTRACT_ID3V1_TAG
- }
- break;
- case eClipType_WMA:
- {
- //Angie_0810_2004:Move the MP3 and WMA extend info from gns to SCPAD for I86 memory reducing.
- WMA_ExtendInfo wmaContentDesc;
- printf("tClip-Type: MP3n");
- #ifdef CLIPS_WMA_EXTRACT_CONTENT_DESC
- sc_GetBytes(gns.clips.cieCurrClip.ExtInfo_sc_handle, 0, sizeof(WMA_ExtendInfo), (BYTE *)&wmaContentDesc);
- printf("tTitle: %sn", DBG_W2A(wmaContentDesc.szTitle));
- printf("tAuthor: %sn", DBG_W2A(wmaContentDesc.szAuthor));
- printf("tCopyright: %sn", DBG_W2A(wmaContentDesc.szCopyright));
- printf("tDescription: %sn", DBG_W2A(wmaContentDesc.szDescription));
- #endif //CLIPS_WMA_EXTRACT_CONTENT_DESC
- }
- break;
- case eClipType_JPEG:
- {
- printf("tClips-Type: JPEGn");
- }
- break;
- default:
- break;
- }
- #endif //CLIPS_ACQUIRE_EXTENDED_INFO
- return;
- }
- #endif //_DEBUG
- static BOOL Browser_Construct(void)
- {
- UINT32 dwRepositoryAddress= (UINT32)SC_CLIPSDIR1_LIST_ADDRESS;
- // Dynamically allocate an Array for Peer Directories found
- SHARED_INFO.hDirsArray[0] = Array_constructEx(MAX_SUBDIRS_CNT, 2 * (1+MAX_DIRNAME_LEN), &dwRepositoryAddress); //jerry cai todo: should be 2 * (1+MAX_DIRNAME_LEN)
- if (NULL == SHARED_INFO.hDirsArray[0])
- {
- tr_printf(("FATAL: Clips_construct() Failed [3]: Low system resourcesn"));
- return FALSE;
- }
- #ifdef MANUAL_DIRECTORY_EXPLORER
- dwRepositoryAddress= (UINT32)SC_CLIPSDIR2_LIST_ADDRESS;
- // Dynamically allocate an Array for Sub-Directories found
- SHARED_INFO.hDirsArray[1] = Array_constructEx(MAX_SUBDIRS_CNT, 2 * (1+MAX_DIRNAME_LEN), &dwRepositoryAddress); //jerry cai todo: should be 2 * (1+MAX_DIRNAME_LEN)
- if (NULL == SHARED_INFO.hDirsArray[1])
- {
- tr_printf(("FATAL: Clips_construct() Failed [4]: Low system resourcesn"));
- return FALSE;
- }
- Browser_InitArrays();
- #endif
- return TRUE;
- }
- static void Browser_Destruct(void)
- {
- Array_clear(SHARED_INFO.hDirsArray[0]);
- Array_destruct(SHARED_INFO.hDirsArray[0]);
- #ifdef MANUAL_DIRECTORY_EXPLORER
- Array_clear(SHARED_INFO.hDirsArray[1]);
- Array_destruct(SHARED_INFO.hDirsArray[1]);
- #endif
- }
- #ifdef MANUAL_DIRECTORY_EXPLORER
- static void Browser_InitArrays(void)
- {
- CLIPS_PEER_ARRAY = 0;
- SHARED_INFO.uPeerDirCount= 0;
- SHARED_INFO.uSubDirCount= 0;
- }
- /*
- when go ing to sub directory, the old subDir becomes peerDir,
- The new subDir will be rebuilt.
- Out: previous SubDirArray is now PeerDirArray.
- SHARED_INFO.uPeerDirCount is updated also.
- */
- static void Browser_SwitchArrays(void)
- {
- CLIPS_PEER_ARRAY = 1 - CLIPS_PEER_ARRAY;
- SHARED_INFO.uPeerDirCount= PEER_DIR_ARRAY_SIZE;
- }
- /*
- remove the entries of the array
- */
- static void Browser_ResetPeerFoldersArray(void)
- {
- ArrayInitBound(SHARED_INFO.hDirsArray[CLIPS_PEER_ARRAY], 0);
- SHARED_INFO.uPeerDirCount= 0;
- }
- /*
- remove the entries of the array
- */
- static void Browser_ResetSubFoldersArray(void)
- {
- ArrayInitBound(SHARED_INFO.hDirsArray[CLIPS_SUB_ARRAY], 0);
- SHARED_INFO.uSubDirCount= 0;
- }
- /*
- Author: Jerry CAI
- Feb 24, 2003
-
- Desp: This function builds a list of the directories that are peers of the working folder.
- Caller: It's called when the smart navigator enters parent directory.
- In: Suppose the working folder is in the right window(this is the default state).
- Out:PeerDir list is updated.
- SHARED_INFO.uCurrentDir is updated also.
-
- */
- static BOOL Browser_BuildPeerFoldersList(UINT16 uMaxDirsToFind)
- {
- BOOL bSearchAborted;
- UINT16 hFindFile;
- FindData *pFileInfo;
- UINT16 hInstance;
- LPWSTR pszWorkingFolderName = NULL;
- SHARED_INFO.uCurrentDir = 1;
- // Allocate a FindData structure
- pFileInfo= (FindData*)malloc(sizeof(FindData));
- if (NULL == pFileInfo)
- {
- tr_printf(("FATAL: Browser_BuildPeerFoldersList() Failed [2]: Low system resourcesn"));
-
- return FALSE;
- }
- Browser_ResetPeerFoldersArray();
- //working folder is root
- if(TRUE == FileSys_InRootDir())
- {
-
- hInstance = 1;
-
- wcscpy(&pFileInfo->szFileID[0], L"ROOT");
- // Enqueue the Directory found
- if (! Array_setAt(SHARED_INFO.hDirsArray[CLIPS_PEER_ARRAY], hInstance - 1,
- (const BYTE*)pFileInfo->szFileID))
- {
- tr_printf(("WARNING: _findAndAddClips() Failed [3]n"));
- }
- SHARED_INFO.uPeerDirCount= 1;
- if(pFileInfo)
- free(pFileInfo);
-
- return;
- }
- pszWorkingFolderName = (LPWSTR)malloc((1 + MAX_DIRNAME_LEN) * sizeof(WCHAR));
- if (NULL == pszWorkingFolderName)
- {
- tr_printf(("FATAL: Browser_BuildPeerFoldersList() Failed [2]: Low system resources.n"));
- return FALSE;
- }
- //Get the working folder's name.
- {
- LPWSTR pszDelim;
- WCHAR currPath[MAX_PATH];
-
- // Copy the Directory-Name
- FileSys_getCurrentPath(currPath);
- pszDelim= wcsrchr(currPath, FileSys_getPathDelimiter());
- if (NULL != pszDelim)
- pszDelim++;
- else
- pszDelim= currPath;//(LPWSTR)FileSys_getCurrentPath();
- wcsncpy(pszWorkingFolderName, pszDelim, MAX_DIRNAME_LEN);
- }
- //Set the working folder to be in the left window.
- FileSys_goUp();
- // Start scanning the Current Directory
- hFindFile= FileSys_findFirstFile(FILESYS_WILDCARD_SEARCH, pFileInfo);
- if (NULL == hFindFile)
- {
- if(NULL != pszWorkingFolderName)
- free(pszWorkingFolderName);
- free(pFileInfo);
- return FALSE;
- }
- // Start scanning the Current-Directory
- bSearchAborted= FALSE;
- do {
- // If an Exception was thrown, abort the search
- if (Exception_catchAndRethrow(EXCEPTION_MEDIUM_EJECTED)) {
- tr_printf(("EXCEPTION: Browser_BuildPeerFoldersList() Aborting [2]n"));
- bSearchAborted= TRUE;
- break;
- }
- // Verify that there is vacancy in the Clips-Repository
- if (uMaxDirsToFind == PEER_DIR_ARRAY_SIZE)
- break;
- // Check the Type of File found
- if (FILETYPE_VOLUME == pFileInfo->uFileType)
- {
- //do nothing.
- }
- else
- if (FILETYPE_DIRECTORY == pFileInfo->uFileType)
- {
- hInstance= 1 + PEER_DIR_ARRAY_SIZE;
- // Skip the Current directories
- if (0x00 == pFileInfo->szFileID[0] || 0 == wcscmp(pFileInfo->szFileID, L"."))
- continue;
- //parent directory
- if( (0x01 == pFileInfo->szFileID[0]) || 0 == wcscmp(pFileInfo->szFileID, L".."))
- {
- WCHAR currPath[MAX_PATH];
- FileSys_getCurrentPath(currPath);
- if( currPath[0] == 0)
- wcscpy(&pFileInfo->szFileID[0], L"ROOT");
- else
- wcscpy(&pFileInfo->szFileID[0], L"..");
-
- }
- //update current dir.
- if (0 == wcsncmp(pFileInfo->szFileID, pszWorkingFolderName, MAX_DIRNAME_LEN))
- SHARED_INFO.uCurrentDir = hInstance;
- // Enqueue the Directory found, for later use
- if (! Array_setAt(SHARED_INFO.hDirsArray[CLIPS_PEER_ARRAY], hInstance - 1,
- (const BYTE*)pFileInfo->szFileID))
- {
- tr_printf(("WARNING: _findAndAddClips() Failed [3]n"));
- break;
- }
- }
- } while (FileSys_findNextFile(hFindFile, pFileInfo));
- // Terminate the search
- FileSys_findClose(hFindFile);
- //set the working folder to right window by default.
- if (! FileSys_changeDir(pszWorkingFolderName))
- {
- tr_printf(("WARNING: FileSys_changeDir() Failed [7]n"));
- bSearchAborted= TRUE;
-
- }
- SHARED_INFO.uPeerDirCount= PEER_DIR_ARRAY_SIZE;
-
- if(NULL != pszWorkingFolderName)
- free(pszWorkingFolderName);
-
- if(NULL != pFileInfo)
- free(pFileInfo);
- return (! bSearchAborted);
- }
- /*
- Browser_BuildFolderContentList
- Desc: Find all the items either file or subdir in the working directory. Create
- a clip object for each of the item and save the clip in ClipsRepository, which
- is an array based on SDRAM scratch pad. For a subdir item, its fileId is saved
- in another array SHARED_INFO.hDirsArray[CLIPS_SUB_ARRAY]. This is because a clip
- object doesn't have a entry like fileId, though entry szFilename seems to have
- the same value.
- Out: SHARED_INFO.uCurrentClipNumber = 0, this means no item is on playing.
-
- should be called after Browser_BuildPeerFoldersList.
- */
- static BOOL Browser_BuildFolderContentList(UINT16 uMaxClipsToFind)
- {
- BOOL bSearchAborted;
- UINT16 hFindFile;
- FindData *pFileInfo;
- UINT16 hInstance;
- SHARED_INFO.uCurrentClipNumber = 0;
- Browser_ResetSubFoldersArray();
- ClipsRepository_clear();
-
- // Allocate a FindData structure
- pFileInfo= (FindData*)malloc(sizeof(FindData));
- if (NULL == pFileInfo)
- {
- tr_printf(("FATAL: Browser_BuildFolderContentList() Failed [2]: Low system resourcesn"));
- return FALSE;
- }
- // Start scanning the Current Directory
- hFindFile= FileSys_findFirstFile(FILESYS_WILDCARD_SEARCH, pFileInfo);
- if (NULL == hFindFile) {
- free(pFileInfo);
- return FALSE;
- }
- // Start scanning the Current-Directory
- bSearchAborted= FALSE;
- do {
- // If an Exception was thrown, abort the search
- if (Exception_catchAndRethrow(EXCEPTION_MEDIUM_EJECTED)) {
- tr_printf(("EXCEPTION: Browser_BuildFolderContentList() Aborting [2]n"));
- bSearchAborted= TRUE;
- break;
- }
- // Verify that there is vacancy in the Clips-Repository
- if (uMaxClipsToFind == ClipsRepository_getSize())
- break;
- // Check the Type of File found
- if (FILETYPE_VOLUME == pFileInfo->uFileType)
- {
- //do nothing.
- }
- else
- if (FILETYPE_DIRECTORY == pFileInfo->uFileType)
- {
-
- hInstance= 1 + SUB_DIR_ARRAY_SIZE;
-
- // Skip the Current directories
- if (0x00 == pFileInfo->szFileID[0] || 0 == wcscmp(pFileInfo->szFileID, L"."))
- continue;
- //parent directory
- if( (0x01 == pFileInfo->szFileID[0]) || 0 == wcscmp(pFileInfo->szFileID, L".."))
- {
- WCHAR currPath[MAX_PATH];
- FileSys_getCurrentPath(currPath);
- if(currPath[0] == 0)
- wcscpy(&pFileInfo->szFileID[0], L"ROOT");
- else
- wcscpy(&pFileInfo->szFileID[0], L"..");
-
- }
- // Enqueue the Directory found, for later use
- if (! Array_setAt(SHARED_INFO.hDirsArray[CLIPS_SUB_ARRAY], hInstance - 1,
- (const BYTE*)pFileInfo->szFileID))
- {
- tr_printf(("WARNING: _findAndAddClips() Failed [3]n"));
- break;
- }
- }
- else // it's a file
- {
- UINT16 hClipInstance= ClipsRepository_addClip(pFileInfo);
- if (NULL == hClipInstance) {
- dbg_printf(("WARNING: Browser_BuildFolderContentList() Failed [4]: %s rejected.n", DBG_W2A(pFileInfo->szFileID)));
- continue;
- }
- // Update the Available-Types
- g_uAvailableClipTypes |= (UINT16)Clip_getType(hClipInstance);
- #ifdef CLIPS_JPEG_DIGEST_SUPPORT
- // Update the number of Digestable Items
- if (Clip_hasAttribute(hClipInstance, eCA_Digestable)) {
- g_pClipsNav->m_uDigestableTypes |= (UINT16)Clip_getType(hClipInstance);
- g_pClipsNav->m_uDigestableItemsCnt++;
- }
- #endif //CLIPS_JPEG_DIGEST_SUPPORT
- dbg_printf(("%d. %sn", ClipsRepository_getSize(), DBG_W2A(pFileInfo->szFileID)));
- }
- } while (FileSys_findNextFile(hFindFile, pFileInfo));
- // Terminate the search
- FileSys_findClose(hFindFile);
- SHARED_INFO.uSubDirCount= SUB_DIR_ARRAY_SIZE;
-
- free(pFileInfo);
- return (! bSearchAborted);
- }
- /*
- When the browser is already opened, USER click on a dir entry to open it.
- */
- static void Browser_OpenFolder(UINT8 ucWhichWindow, int iWhichEntry, BOOL bNotifyUI)
- {
- FindData *pFileInfo;
- // Allocate a FindData structure
- pFileInfo= (FindData*)malloc(sizeof(FindData));
- if (NULL == pFileInfo)
- {
- tr_printf(("FATAL: Browser_OpenFolder() Failed [1]: Low system resourcesn"));
- return FALSE;
- }
- if(eLEFT_WINDOW == ucWhichWindow) //It's a peer directory in the left window
- Array_getAt(SHARED_INFO.hDirsArray[CLIPS_PEER_ARRAY],iWhichEntry - 1,(const BYTE*)pFileInfo->szFileID);
- else
- if(eRIGHT_WINDOW == ucWhichWindow) //It's a sub directory in the right window
- Array_getAt(SHARED_INFO.hDirsArray[CLIPS_SUB_ARRAY],(iWhichEntry - 1),(const BYTE*)pFileInfo->szFileID);
-
- //go up to parent directory.
- if(0 == wcscmp(pFileInfo->szFileID, L"..") || 0 == wcscmp(pFileInfo->szFileID, L"ROOT"))
- {
- if(FALSE == FileSys_InRootDir())
- {
- FileSys_goUp();
- Browser_Build(eBuildAll, bNotifyUI);
- }
- else
- notifyUIOnBrowserContentChange(eCLIPS_UPDATE_NONE, eCLIPS_UPDATE_NONE);
- }
- else
- if(eLEFT_WINDOW == ucWhichWindow && iWhichEntry != SHARED_INFO.uCurrentDir) //It's a peer directory in the left window
- {
- // go to the new working directory.
- FileSys_goUp();
- if (! FileSys_changeDir(pFileInfo->szFileID))
- {
- tr_printf(("WARNING: go to subDir() Failed [7]n"));
- free(pFileInfo);
- return;
- }
- SHARED_INFO.uCurrentDir = iWhichEntry;
- Browser_Build(eBuildFileListOnly, bNotifyUI);
- }
- else
- if(eRIGHT_WINDOW == ucWhichWindow) //It's a sub directory in the right window
- {
- SHARED_INFO.uCurrentDir = iWhichEntry;
- if (! FileSys_changeDir(pFileInfo->szFileID))
- {
- tr_printf(("WARNING: go to subDir() Failed [7]n"));
- free(pFileInfo);
- return;
- }
- Browser_Build(eBuildPeerDirListBasedOnSubDirList, bNotifyUI);
- }
- else
- notifyUIOnBrowserContentChange(eCLIPS_UPDATE_NONE, eCLIPS_UPDATE_NONE);
-
- free(pFileInfo);
- return;
- }
- /*
- -Build the list of the content of the working directory and the list of
- the working directory's peers.
- -Initialize the program list and start play the
- content of the working directory.
- In:
- eBuildAll, true when need to build everything from scratch.
- eBuildFileListOnly, true when the peer dir doesn't need to change when going to a peer dir.
-
- eBuildPeerDirListBasedOnSubDirList, true when SubDir exists and can be used as PeerDir
- when going to a lower level directory.
-
- Out:g_pClipsNav->m_eClipsListStatus is firstly set to be eCLS_Building and finally
- eCLS_Finalized. At this point UI is supposed to refresh it's browser.
-
- notify UI to refresh it's browser.
-
- */
- static void Browser_Build(enBuildBrowser eBuildBrowserType, BOOL bNotifyUI)
- {
- UINT32 Param;
-
- BYTE ucUpdatePeerDirListWindow = eCLIPS_UPDATE_ALL;
-
- #ifdef CLIPS_JPEG_DIGEST_SUPPORT
- g_pClipsNav->m_bDigestMode= FALSE;
- g_pClipsNav->m_uDigestableTypes= (UINT16)eClipType_None;
- g_pClipsNav->m_uDigestableItemsCnt= 0;
- #endif //CLIPS_JPEG_DIGEST_SUPPORT
-
- // Reset the Available Types
- g_uAvailableClipTypes= (UINT16)eClipType_None;
- // Invoke the search
- g_pClipsNav->m_eClipsListStatus= (UINT8)eCLS_Building;
- //build peer DIR.
- if(eBuildPeerDirListBasedOnSubDirList == eBuildBrowserType)
- Browser_SwitchArrays();
- else
- if(eBuildAll == eBuildBrowserType)
- Browser_BuildPeerFoldersList(MAX_SUBDIRS_CNT);
- else
- if(eBuildFileListOnly == eBuildBrowserType)
- {
- ucUpdatePeerDirListWindow = eCLIPS_UPDATE_INDEX;
- }
-
- //build file list.
- Browser_BuildFolderContentList(CLIPS_MAX_PROGRAM_SIZE);
-
- //build the program list and play the first item.
- Clips_finalizeClipsList();
- if(TRUE == bNotifyUI)
- notifyUIOnBrowserContentChange(ucUpdatePeerDirListWindow, eCLIPS_UPDATE_ALL);
- return;
- }
- void Browser_GetPeerFolderInfo(UINT16 uDirNum,ClipInfo *o_pInfo)
- {
- Browser_GetFolderInfo(uDirNum, o_pInfo, eLEFT_WINDOW);
- }
- static void Browser_GetFolderInfo(UINT16 uDirNum,ClipInfo *o_pInfo, enWINDOWTYPE eWin)
- {
- FindData *pFileInfo;
- BYTE ucDirArray;
- if(eLEFT_WINDOW == eWin)
- {
- ucDirArray = CLIPS_PEER_ARRAY;
- }
- else
- {
- ucDirArray = CLIPS_SUB_ARRAY;
- }
-
- // Allocate a FindData structure
- pFileInfo= (FindData*)malloc(sizeof(FindData));
- if (NULL == pFileInfo)
- {
- tr_printf(("FATAL: Browser_GetFolderInfo() Failed [1]: Low system resourcesn"));
- return;
- }
- //uDirNum is 1 based.
- if(0 == uDirNum || uDirNum > Array_getSize(SHARED_INFO.hDirsArray[ucDirArray]))
- {
- tr_printf(("WARNING: Browser_GetFolderInfo() try to get non exist item."));
- free(pFileInfo);
- return;
- }
-
- Array_getAt(SHARED_INFO.hDirsArray[ucDirArray],uDirNum - 1,(const BYTE*)pFileInfo->szFileID);
- //Get the working folder's name.
- {
- LPWSTR pszDelim;
-
- // Copy the Directory-Name
- pszDelim= wcsrchr(pFileInfo->szFileID, FileSys_getPathDelimiter());
- if (NULL != pszDelim)
- pszDelim++;
- else
- pszDelim= (LPWSTR)pFileInfo->szFileID;
- wcsncpy(&(o_pInfo->szFilename), pszDelim, CLIPS_MAX_DIRNAME_LEN);
- }
- o_pInfo->eType = eClipType_DIR;
- free(pFileInfo);
- return;
- }
- /*
- Desc: get a playable item in the 1st sub folder of the current working folder.
- if such a item is not available. Go to next folder and repeat the process.
- In: none.
- Out: Current working folder is changed to the sub or next folder that contains a
- playable item.
- SHARED_INFO.uCurrPlaylistItem is updated to be the 1st playable item in the
- working folder.
- An event is sent to UI to notify the change of working folder.
- */
- static UINT16 getFirstItemInSubFoldersOrNextFolders(void)
- {
- UINT16 uNextItem = 0;
- BOOL bWholeDiscFinished = 0;
- BOOL is_need_update_all = 0;
-
- // <<< SEC CH.KO040204:Only normal play can access next folder
- #ifdef EXINO2
- if(PM_IsPlaybackShuffle(PM_GetPlaybackMode()))
- return 0;
- #endif
- // SEC CH.KO040204 >>>
- //<<<BillTang_0714_2004: moved here from below while(1){} to avoid
- //calling DEC_Stop_DVP_cmd() without dec_CacheInit() around causing
- //discGetBytes() failed in case of some sectors already cached!
- #ifdef CLIPS_DISPLAY_BACKGROUND
- PE_Clips_DisplayBackground();
- #else
- PE_Clips_DisplayLogo();
- #endif //CLIPS_DISPLAY_BACKGROUND
- //BillTang_0714_2004>>>
- while(1)
- {
- if(0 == uNextItem)
- {
- UINT16 dirNo = 0;
- int i;
-
- //play 1st sub dir is the working folder
-
- if(1 < SUB_DIR_ARRAY_SIZE)//has sub dir, go check is there is anything to play.
- {
- Browser_OpenFolder( eRIGHT_WINDOW, 2, FALSE);
- uNextItem = computePlaylistItem(0, TRUE);
- continue;
- }
- else // no sub dir
- {
- while(1)
- {
- if(SHARED_INFO.uCurrentDir < Array_getSize(SHARED_INFO.hDirsArray[CLIPS_PEER_ARRAY] )) // has peer folder after him
- {
- //got peer dirs to play.
- Browser_OpenFolder( eLEFT_WINDOW, SHARED_INFO.uCurrentDir+1, FALSE);
- uNextItem = computePlaylistItem(0, TRUE);
- break;
- }
- else //no peer folder following him.
- {
- is_need_update_all = TRUE;
- if(TRUE == FileSys_InRootDir())//have reached to root, no more items to play.
- {
- bWholeDiscFinished++;
- if (PM_IsRepeatAll())
- {
- while (1 < SUB_DIR_ARRAY_SIZE )
- Browser_OpenFolder( eRIGHT_WINDOW, 2, FALSE);
- uNextItem = computePlaylistItem(0, TRUE);
- }
- break;
-
- }
- else // go 1 level up and repeat the process.
- {
- Browser_OpenFolder( eLEFT_WINDOW, 1, FALSE);
- continue; //go check if it has peer sub dir follows him.
- }
- }
- }
- if((1 == bWholeDiscFinished && (!PM_IsRepeatAll())) || 1 < bWholeDiscFinished)
- break;
- continue;//go check if there is anything to play.
- }
-
- }
- else
- break;
-
- }
- if(is_need_update_all)
- notifyUIOnBrowserContentChange(eCLIPS_UPDATE_ALL, eCLIPS_UPDATE_ALL);
- else
- notifyUIOnBrowserContentChange(eCLIPS_UPDATE_INDEX, eCLIPS_UPDATE_ALL);
- return uNextItem;
- }
- /*
- Desc: get a playable item in the prev folder of the current working folder.
- if such a item is not available. Go to prev folder's last sub folder
- and repeat the process.
- In: none.
- Out: Current working folder is changed to the prev that contains a
- playable item.
- SHARED_INFO.uCurrPlaylistItem is updated to be the last playable item in the
- working folder.
- An event is sent to UI to notify the change of working folder.
- */
- static UINT16 getLastItemInPrevFolders(void)
- {
- BOOL bWholeDiscFinished = 0;
- UINT16 uPrevItem = 0;
- BOOL is_need_update_all = 0;
- while(1)
- {
- if(0 == uPrevItem)
- {
- int i;
-
-
- while(1)
- {
- if(SHARED_INFO.uCurrentDir > 2) // has peer folder before him
- {
- //got peer dirs to play.
- Browser_OpenFolder( eLEFT_WINDOW, SHARED_INFO.uCurrentDir - 1, FALSE);
- while(1)
- {
- UINT16 dirNo = 0;
-
- if(1 < SUB_DIR_ARRAY_SIZE) // a sub dir is found
- {
- Browser_OpenFolder( eRIGHT_WINDOW, SUB_DIR_ARRAY_SIZE, FALSE);
- continue;
- }
- else
- break;
-
- }
- uPrevItem = computePlaylistItem(ClipsRepository_getSize() + 1, FALSE);
- break;
- }
- else //no peer folder before him.
- {
- is_need_update_all = TRUE;
- if(TRUE == FileSys_InRootDir())//have reached to root, no more items to play.
- {
- bWholeDiscFinished++;
- if (PM_IsRepeatAll())
- {
- while (1 < SUB_DIR_ARRAY_SIZE )
- Browser_OpenFolder( eRIGHT_WINDOW, SUB_DIR_ARRAY_SIZE, FALSE);
- uPrevItem = computePlaylistItem(ClipsRepository_getSize() + 1, FALSE);
- }
- break;
-
- }
- else // go 1 level up and repeat the process.
- {
- Browser_OpenFolder( eLEFT_WINDOW, 1, FALSE);
- continue; //go check if it has peer sub dir follows him.
- }
- }
- }
- if((1 == bWholeDiscFinished && (!PM_IsRepeatAll())) || 1 < bWholeDiscFinished)
- break;
- continue;//go check if there is anything to play.
-
- }
- else
- break;
-
- }
- #ifdef CLIPS_DISPLAY_BACKGROUND
- PE_Clips_DisplayBackground();
- #else
- PE_Clips_DisplayLogo();
- #endif //CLIPS_DISPLAY_BACKGROUND
- if(is_need_update_all)
- notifyUIOnBrowserContentChange(eCLIPS_UPDATE_ALL, eCLIPS_UPDATE_ALL);
- else
- notifyUIOnBrowserContentChange(eCLIPS_UPDATE_INDEX, eCLIPS_UPDATE_ALL);
-
- return uPrevItem;
- }
- /*
- Desc: Notify UI when the content of the PeerDirList or the FileList changes, or when the current playing
- item no. changes, or when the current Dir No. changes.
-
- In: ucUpdatePeerDirListWindow - what has changed in PeerDirList window.
- ucUpdateFileListWindow - what has changed in FileList window.
- Out:a IE_UI_CLIPS_UPDATE message is sent to UI.
- */
- static void notifyUIOnBrowserContentChange(BYTE ucUpdatePeerDirListWindow, BYTE ucUpdateFileListWindow)
- {
- UINT32 Param=0;
- //if(eWINDOWS_EXPLORER_STYLE == SHARED_INFO.eWindowsExplorerStyleBrowser)
- {
- Param = (((UINT32)ucUpdatePeerDirListWindow)<<16)|ucUpdateFileListWindow;
- ie_send_ex(IE_UI_CLIPS_UPDATE, (void *)(Param));
- }
- #ifdef MANUAL_DIRECTORY_EXPLORER
- SHARED_INFO.uSubDirArraySize = SUB_DIR_ARRAY_SIZE;//ERICM_4JUN25K
- #endif
- return;
- }
- #endif
- /*
- FileSys_InRootDir
- Desc: check if the working folder is root directory.
- In: None
- Out: None
- Return: TRUE - yes it's root directory.
- FALSE - no it's not
- */
- static BOOL FileSys_InRootDir(void)
- {
- WCHAR currPath[MAX_PATH];
- FileSys_getCurrentPath(currPath);
- return (0 == currPath[0]);
- }
- static void SetBrowserStyle(enClipsBrowserStyle eBrowserStyle)
- {
- SHARED_INFO.eWindowsExplorerStyleBrowser = eBrowserStyle;
- #ifdef MANUAL_DIRECTORY_EXPLORER
- if(eSingle_LIST_STYLE == SHARED_INFO.eWindowsExplorerStyleBrowser)
- SHARED_INFO.bDisplayLogoWhenPlayAudioOnlySteam = 0;
- else
- SHARED_INFO.bDisplayLogoWhenPlayAudioOnlySteam = 1;
- #endif
- }
- BOOL Clips_getPlayListItemInfoAt(UINT16 uPlayListItem, ClipInfo *o_pClipFileInfo)
- {
- return Clips_getClipFileInfoAt(PM_GetProgramListEntry((UINT16)uPlayListItem), o_pClipFileInfo);
- }
- static BOOL IsGotoNextChapterAllowed()
- {
- #ifdef EXINO2
- // <<< SEC CH.KO040204: Only normal play can access next folder
- // <<< SEC CH.KO050804: if subfolder not existed, kodak picture cd mulfunc problem fixed
- if((PM_IsPlaybackNormal(PM_GetPlaybackMode()))&& (g_disc_type !=DEC_DISC_TYPE_PICTURE_CD))
- #else
- if(PM_IsPlaybackRandom(PM_GetPlaybackMode()))
- #endif
- {
- return TRUE;
- }
- if (0 == computePlaylistItem(SHARED_INFO.uCurrPlaylistItem, TRUE))
- {
- if(eWholeDisc != SHARED_INFO.uExplorerStyleBrowserPlayMode)
- {
- #ifdef CLIPS_WRAP_AROUND_ON_PROGRAM_EDGES
- #else
- // Wrap-around if Repeat-All is on
- if (PM_IsRepeatAll() || PM_IsRepeatFolder()) {
- }
- else {
- return FALSE;
- }
- #endif //CLIPS_WRAP_AROUND_ON_PROGRAM_EDGES
-
-
- }
- #ifdef EXINO2
- // <<< SEC CH.KO040204:Only normal play can access next folder
- else if(PM_IsPlaybackRandom(PM_GetPlaybackMode())|| PM_IsPlaybackShuffle(PM_GetPlaybackMode()))
- return FALSE;
- // SEC CH.KO040204 >>>
- #endif
- }
- return TRUE;
-
- }
- static BOOL IsGotoPreviousChapterAllowed()
- {
- if(PM_IsPlaybackRandom(PM_GetPlaybackMode()))
- {
- return TRUE;
- }
- if (0 == computePlaylistItem(SHARED_INFO.uCurrPlaylistItem, FALSE))
- {
- if(eWholeDisc != SHARED_INFO.uExplorerStyleBrowserPlayMode)
- {
- #ifdef CLIPS_WRAP_AROUND_ON_PROGRAM_EDGES
- #else
- // Wrap-around if Repeat-All is on
- if (PM_IsRepeatAll() || PM_IsRepeatFolder()) {
- }
- else {
- return FALSE;
- }
- #endif //CLIPS_WRAP_AROUND_ON_PROGRAM_EDGES
-
-
- }
- }
- return TRUE;
-
- }
- #define min(a,b) (((a) < (b)) ? (a) : (b))
- void
- CyclicWriteDRAMData(const INT32 uiBufferStart,const INT32 uiBufferEnd,
- UINT32 uiAddress, UINT16* puiTarget, UINT32 uiLength )
- {
- /* we assume that uiAddress <= uiBufferEnd */
- /* first write is from uiAdress, length is min(uiLength, uiBufferEnd-uiAddress) */
- /* scond write is for the remaining - which is uiBufferEnd-uiAddress */
- UINT32 uiWriteLengthFirstCall;
- UINT32 uiWriteLengthSecondCall;
- //UINT32 kk;
- // printf("start:%lx end:%lx ",uiBufferStart,uiBufferEnd);
- while(uiAddress >= uiBufferEnd)
- {
- // uiAddress -= (SPB_SIZE_AVI*512UL);
- uiAddress -= (uiBufferEnd - uiBufferStart);
- }
- uiWriteLengthFirstCall = min(uiLength, uiBufferEnd - uiAddress);
- uiWriteLengthSecondCall = uiLength - uiWriteLengthFirstCall ;
- wai_sem(SEM_DRAM_ID);
- I49_WriteDRAMDataNSW(uiAddress, (UINT16*)puiTarget, uiWriteLengthFirstCall);
- // printf("addr:%lxn",uiAddress);
- if ( uiWriteLengthFirstCall != uiLength )
- {
- // printf("BUG!!!n");
- I49_WriteDRAMDataNSW(uiBufferStart,
- (UINT16*)(puiTarget + uiWriteLengthFirstCall ),
- uiWriteLengthSecondCall );
- }
- sig_sem(SEM_DRAM_ID);
- return;
- }
- #ifdef EXINO2 //ZKR JK0413 : change the macro
- UINT16 Clips_getTotalDigestNum(void)
- {
- return g_pClipsNav->m_uDigestableItemsCnt;
- }
- #endif
- #ifdef SUPPORT_FLASH_CARD
- UINT32 Clips_GetCurrClipSize(void)
- {
- return (gns.clips.cieCurrClip.ciInfo.cbFileSize);
- }
- UINT32 Clips_GetCurrClipSartAddr(void)
- {
- return (gns.clips.cieCurrClip.ciInfo.dwFileLocation);
- }
- //JERRYC_2004_Oct_21
- BOOL Clips_IsAddrWithinCurrClip(UINT32 lsn)
- {
- if(lsn < (gns.clips.cieCurrClip.ciInfo.dwFileLocation))
- return FALSE;
- else
- lsn -= gns.clips.cieCurrClip.ciInfo.dwFileLocation;
- if((lsn*LOGICAL_BLOCK_SIZE) >= Clips_GetCurrClipSize())
- return FALSE;
- return TRUE;
- }
- //JERRYC_FEB19
- /*
- Desc: translate a logical address of a clips into a physical address address on flash card.
- */
- UINT32 Clips_GetPSNOnFlashCardAndOffset(UINT32 lsn, UINT32* pOffset)
- {
- STRUCT_FILE file;
- UINT32 psn;
- UINT32 offset = lsn - gns.clips.cieCurrClip.ciInfo.dwFileLocation;
- UINT16 blocksPerCluster;
-
- //in digest mode, gns.clips.cieCurrClip doesn't refer to the clip to play.
- if (g_pClipsNav->m_bDigestMode || (FALSE == Clips_IsAddrWithinCurrClip(lsn))){
- *pOffset = 0;
- return lsn;
- }
- //open file
- FileSys_FileOpen(&file, gns.clips.cieCurrClip.ciInfo.dwFileLocation, 0, gns.clips.cieCurrClip.ciInfo.cbFileSize);
- FileSys_FileSeek(&file, 0, (LOGICAL_BLOCK_SIZE * offset));
- psn = file.fx_file_current_physical_cluster;
-
- dbg_printf(("get psn on card, lsn:%lx, psn:%lx.n", lsn, psn));
- blocksPerCluster = (file.fx_file_media_ptr->fx_media_sectors_per_cluster)/4;
- if(blocksPerCluster > 0){
- *pOffset = (offset % blocksPerCluster)*LOGICAL_BLOCK_SIZE;
- }
- else
- *pOffset = 0;
-
- FileSys_FileClose(&file);
- return psn;
- }
- //JERRYC_FEB19
- /*
- Desc: translate a logical address of a clips into a physical address address on flash card.
- */
- UINT32 Clips_GetPSNOnFlashCard(UINT32 lsn)
- {
- STRUCT_FILE file;
- UINT32 psn;
- UINT32 offset = lsn - gns.clips.cieCurrClip.ciInfo.dwFileLocation;
- //in digest mode, gns.clips.cieCurrClip doesn't refer to the clip to play.
- if (g_pClipsNav->m_bDigestMode || (FALSE == Clips_IsAddrWithinCurrClip(lsn)))
- return lsn;
- //open file
- FileSys_FileOpen(&file, gns.clips.cieCurrClip.ciInfo.dwFileLocation, 0, gns.clips.cieCurrClip.ciInfo.cbFileSize);
- FileSys_FileSeek(&file, 0, (LOGICAL_BLOCK_SIZE * offset));
- psn = file.fx_file_current_physical_cluster;
- FileSys_FileClose(&file);
- dbg_printf(("get psn on card, lsn:%lx, psn:%lx.n", lsn, psn));
- return psn;
- }
- #endif