nav_clips.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:200k
- /****************************************************************************************
- * Copyright (c) 2002 ZORAN Corporation, All Rights Reserved
- * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
- *
- * File: $Workfile: nav_clips.c $
- *
- * Description:
- * ============
- *
- *
- * Log:
- * ====
- * $Revision: 228 $
- * Last Modified by $Author: Leslie $ at $Modtime: 04-04-03 14:14 $
- ****************************************************************************************
- * Updates:
- ****************************************************************************************
- * $Log: /I76/I76_Common/I76_Reference/Playcore/Nav_Clips/nav_clips.c $
- *
- * 228 04-04-03 14:17 Leslie
- * Fix MPEG Clip A2B Repeat problem
- *
- * 227 04-04-01 19:19 Fwang
- * Fix AVI AB repeat goes to start of clip.
- *
- * 226 4/01/04 6:33p Terencet
- * cancel rotation when press play, force to auto playback
- *
- * 225 04-04-01 15:38 Aidenl
- * For D90NB, Flush logo due to mp3,jpeg R1 address is different with
- * others
- *
- * 224 3/30/04 5:54p Terencet
- * add SDJPEG_DISPLAY_BY_ADP switch
- *
- * 223 04-03-30 16:11 Williaml
- * set the play mode to normal from program, intro or shuffle after full
- * stop
- *
- * 222 3/27/04 6:09p Terencet
- * when rotation active will stop auto presentation and cache
- *
- * 221 04-03-26 11:52 Leonh
- *
- * 220 3/25/04 8:03p Robinj
- * Add "AVI_SUBTITLE_CHANGE_ONSCAN" for changing subtitle with short delay
- * but there is a break
- *
- * 219 3/25/04 7:58p Terencet
- * don't cache for JPEG digest mode
- *
- * 218 04-03-25 18:30 Chaol
- * fix FF time problem
- *
- * 217 04-03-25 17:08 Leslie
- * Set Default JEPG display buffer to be R1
- *
- * 216 04-03-24 18:37 Leonh
- * Prohibit continuously do the skipf and skpb for AVI playback
- *
- * 215 3/21/04 8:49p Lotan
- * merge 4 with certification DB
- *
- * 214 3/20/04 6:35p Terencet
- * clear subdir count in clips constructor to fix wrong clips num
- *
- * 213 04-03-16 11:50 Jerryc
- *
- * 212 3/10/04 4:26p Lotan
- * Merge with Divx Certification DB 3
- *
- * 210 3/04/04 10:22p Lotan
- * Second merge with Divx Certification DB,
- * including 2x16 SDram
- *
- * 209 04-03-04 15:38 Jerryc
- * add more macro MANUAL_DIRECTORY_EXPLORER to reduce sdram requirment in
- * case the macro is not defined.
- *
- * 208 3/01/04 6:29p Lotan
- * merge with Divx certification DB
- *
- * 207 04-02-25 16:21 Leslie
- * Fix HD-JPEG problem
- *
- * 206 2/20/04 6:13p Glenl
- * Merged S1 code
- *
- * 205 2/17/04 4:39p Rinata
- * malloc for Jpeg temp buffers
- *
- * 204 2/15/04 7:41p Lotan
- * update DRM message handling
- *
- * 203 2/13/04 5:16p Terencet
- * avoid massage pool full while skiping WMA unsupported rate
- *
- * 202 2/12/04 5:09p Rond
- * fixed YUV issue
- *
- * 201 2/12/04 4:15p Rond
- * fixed bottom subtitle issue
- *
- * 200 2/11/04 12:42a Lotan
- * new Divx DRM handling method.
- *
- * 199 2/10/04 8:42p Rond
- * subtitle issues
- *
- * 198 2/08/04 10:22a Eyalr
- * fix compile erro on subtitle
- *
- * 197 2/08/04 10:07a Eyalr
- * added changes for Subtitle
- *
- * 196 2/04/04 10:09a Leslie
- * Add JPEG Cache and Display Buffer Toggling
- *
- * 195 2/02/04 19:24 Eyalr
- * fixed subtitles bug
- *
- * 194 20/01/04 12:20 Lotan
- * add OnDrmInfoMsgArrived(void) declaration
- *
- * 193 20/01/04 12:13 Lotan
- * add Dec_Avi_Drm.h file inclusion
- *
- * 192 20/01/04 12:06 Lotan
- * add OnDrmInfoMsgArrived() function and switch-case
- *
- * 191 1/20/04 12:29p Chaol
- * patch for WMA stop resume, trick it as PAUSE
- *
- * 190 1/14/04 11:07a Chaol
- * check if JPEG new line ready to copy display
- *
- * 189 1/13/04 12:11 Hamadk
- * Merged with CES DB
- *
- * 188 12/26/03 12:28 Eyalr
- * Added first code for subtitle support
- *
- * 187 12/24/03 17:42 Hamadk
- * Added handling for demux finished event
- *
- * 186 12/22/03 4:00p Chaol
- * add JPEG copy to display buffer when new line ready
- *
- * 185 11/28/03 7:24p Leslie
- *
- * 184 11/25/03 6:13p Leslie
- * free scratch pad after searching clips
- * signature: MikeX_1125_2003
- *
- * 183 11/12/03 7:54a Leslie
- * The sub directory max counter was error.
- * MikeX_1112_2003
- *
- * 182 9/29/03 8:18 Hamadk
- *
- * 180 03-09-05 17:08 Angieh
- * Correct a careless error
- *
- * 179 9/04/03 11:52a Leonh
- * add the really define for uDirTreeLevel
- *
- * 178 03-08-22 13:55 Angieh
- * Override the Transition-Effect.
- *
- * 177 8/14/03 7:12p Leonh
- * solve jpeg flash problem in another way
- *
- * 176 03-08-06 18:33 Leonh
- * correct the state to play state when press play key after slowf and
- * slowr
- *
- * 175 03-08-04 21:04 Leonh
- * make mpeg ab repeat work ok
- *
- * 174 03-08-01 21:16 Leonh
- * correct the condition for timer enable
- *
- * 173 03-08-01 11:47 Leonh
- * JPEG zoom state, keep on the fly
- *
- * 172 7/30/03 11:18a Mikex
- * bug fix for screen blicker after pressed stop when play the jpeg disc
- * in NTSC mode.
- *
- * 171 03-07-28 17:02 Leslie
- * Check in changes for Task Force
- *
- * 170 03-07-24 12:00 Frankm
- * Adjust_jpeg_logo() for single track.
- *
- * 169 03-07-10 15:38 Frankm
- * Adjust logo "flash" in two cases.
- *
- * 168 03-07-10 14:50 Frankm
- * Adjust the logo "flash" bug on jpeg disc.
- *
- * 165 03-06-30 16:56 Leslie
- * Merge Alco Step A code
- *
- * 164 03-06-24 11:51 Ivany
- * Setting MODE to be "Shuffle", the MODE changes into "FOLDER NORMAL"
- * automatically after selecting a track, then the selected track can be
- * played normally.
- *
- * 163 03-06-23 18:33 Tonnyg
- * if one pic is in zoom, next one won't be called
- *
- * 162 03-06-23 12:03 Ivany
- * display logo when media type changes
- *
- * 161 03-06-16 17:04 Leonh
- * reset all parameter
- *
- * 160 03-06-13 15:47 Leonh
- * to support to 5000 clips
- *
- * 159 03-06-11 17:02 Frankm
- * Add support for 5000 clips.
- *
- * 158 03-06-10 12:12 Leonh
- *
- * 157 03-06-06 15:33 Frankm
- * Stop shouldn't cancel the intro mode.
- *
- * 156 03-06-06 11:33 Leonh
- * prohibit skipf or skipb when sing track
- *
- * 155 03-06-04 17:18 Leonh
- * allow change play mode on fly on old menu
- *
- * 154 03-06-03 18:23 Leonh
- * correct behavior when disc repeat
- *
- * 152 03-05-30 11:53 Jerryc
- * fix dead lock in Clips_getClipFileInfoAt().
- *
- * 151 03-05-29 18:02 Jerryc
- * support flash card.
- *
- * 150 03-05-28 13:57 Billt
- * Close Menu after the last clip playbacked
- *
- * 149 03-05-28 11:33 Leonh
- *
- * 148 03-05-27 14:19 Leonh
- *
- * 147 03-05-26 18:40 Leonh
- *
- * 146 03-05-23 18:40 Leonh
- *
- * 145 03-05-23 11:29 Janeg
- * Select action end program mode.
- *
- * 144 03-05-21 16:26 Jerryc
- * don't reset play mode on numeric selection.
- *
- * 143 03-05-19 13:43 Leslie
- * Add drive Play Mode
- *
- * 142 03-05-16 19:04 Jerryc
- * fix in folder repeat mode, skip next problem.
- *
- * 141 5/16/03 4:58p Tonnyg
- * to disable setup after a subdir of CD-ROM or PCD is entered by Vestel
- *
- * 140 03-05-16 15:40 Jerryc
- * fix disc repeat hanging pbe.
- *
- * 139 03-05-16 11:59 Jerryc
- * in single/repeat track mode, skip prev/next always go to the same
- * track.
- *
- * 138 03-05-16 11:13 Jerryc
- * fix single track mode problem.
- *
- * 137 03-04-30 10:35 Jerryc
- * clear program mode when changing folder.
- *
- * 136 03-04-28 14:33 Jerryc
- * clean up.
- *
- * 135 03-04-28 11:58 Jerryc
- * for no menu mode, UI sees no directory items.
- *
- * 134 03-04-25 17:27 Jerryc
- * folders are always list on the top.
- *
- * 133 03-04-24 16:40 Tonnyg
- *
- * 132 03-04-24 11:59 Jerryc
- * further fix random mode.
- *
- * 131 03-04-24 10:45 Jerryc
- * fix random mode.
- *
- * 130 03-04-23 11:55 Jerryc
- * fix pbe: mp3 play ->ffwd ->pause->play, behaviour is not as expected.
- *
- * 129 03-04-22 15:26 Jerryc
- * don't reset play mode to normal when finishing play back the playlist.
- *
- * 128 03-04-22 14:25 Jerryc
- * clean up.
- *
- * 127 03-04-22 9:51 Jerryc
- * define a macro for intro play time.
- *
- * 126 03-04-21 17:13 Jerryc
- * update cop_next_chapter on every tick.
- *
- * 125 03-04-21 11:22 Jerryc
- * fix random mode.
- *
- * 124 03-04-18 13:46 Jerryc
- * fix long dir name problem.
- *
- * 123 03-04-11 14:07 Janeg
- * JerryC: Pause/Play JPEG after displaying whole picture.
- *
- * 122 03-04-10 15:57 Janeg
- * Jerry Cai:
- * Maintain play mode after swithcing folder.
- * Disable scan after manual and natural stop.
- * Send IE_UI_CLIPS_UPDATE in no menu mode.
- *
- * 121 03-04-09 21:37 Janeg
- *
- * 120 4/09/03 11:11a Lyncolnc
- * Added event to clear UI messages like Q1..Q5 when the current clip
- * (JPG) finished its playback.
- *
- * 119 03-04-07 14:47 Billt
- * don't cancel repeat when play from stopresume
- *
- * 118 03-04-02 16:57 Jerryc
- * add function IsGotoNextChapterAllowed().
- *
- * 117 03-04-02 11:28 Janeg
- * Add error report to UI.
- *
- * 116 03-04-01 16:34 Jerryc
- * change some tr_printf to dbg_printf.
- *
- * 115 03-04-01 15:13 Jerryc
- * fix mp3 time search.
- *
- * 114 03-03-28 15:07 Jerryc
- * set play mode to normal when change folder.
- *
- * 113 03-03-27 15:08 Jerryc
- * notify UI on current clip number change.
- *
- * 112 03-03-24 17:00 Jerryc
- * allow change play mode from track repeat to folder nornal on the fly.
- *
- * 111 03-03-20 17:31 Billt
- * Fixed a compiler switch bug
- *
- * 110 03-03-20 11:48 Jerryc
- * change dir num from 100 to 300.
- *
- * 109 03-03-18 10:52 Jerryc
- * fix digest stop pbe
- *
- * 108 03-03-17 11:03 Jerryc
- * change repeat a->b min gap to be 1s.
- *
- * 107 03-03-14 18:15 Jerryc
- * Clips_getClipFileInfoAt is now implemented in a synchonous way to aoid
- * conflict between UI and core task.
- *
- * 106 03-03-14 14:50 Jerryc
- * display logo in constructor
- *
- * 105 03-03-13 14:02 Jerryc
- * clean up code
- *
- * 104 03-03-11 17:34 Jerryc
- * correct disc scan mode
- *
- * 103 03-03-11 15:48 Jerryc
- * notify UI when browser content is ready.
- *
- * 102 03-03-11 14:28 Jerryc
- * when MP3 FB finishes, play the current song in normal mode.
- *
- * 101 03-03-10 16:16 Jerryc
- * clean up.
- *
- * 100 03-03-10 15:28 Jerryc
- * clean up
- *
- * 99 03-03-10 13:53 Jerryc
- * clean up the browser object implementation.
- *
- * 98 03-03-07 19:10 Jerryc
- * jerryc, add support for random play mode
- *
- * 97 03-03-06 19:12 Jerryc
- * jerryc, fix function getPrevItemInPrevFolder().
- *
- * 96 03-03-06 16:13 Jerryc
- * jerryc, fix some play modes.
- *
- * 95 03-03-05 17:40 Jerryc
- * jerryc, fix some play modes.
- *
- * 94 03-03-05 10:41 Jerryc
- * jerryc, fix some playback mode pbe.
- *
- * 93 03-03-04 16:22 Jerryc
- * jerryc, clear program list before exit clip nav.
- *
- * 92 03-03-04 15:32 Jerryc
- * jerryc, fix compile errors.
- *
- * 91 03-03-04 15:16 Hannahh
- *
- * 90 03-03-04 15:01 Jerryc
- * jerryc, clean up
- *
- * 88 03-03-04 11:50 Jerryc
- * jerryc, add function Clips_SetBrowserStyle.
- *
- * 87 03-03-04 11:34 Jerryc
- * jerry cai, merge new nav clips lib
- *
- * 83 03-02-21 13:53 Leslie
- *
- * 82 03-02-20 18:04 Victorwu
- * Add disc and folder intro for Vestel
- *
- * 81 03-02-19 17:36 Victorwu
- * Fix bugs and add new features for Vestel
- *
- * 80 03-02-14 11:46 Victorwu
- * Fix bugs for VESTEL new filesearch.
- *
- * 78 03-02-11 17:33 Leslie
- * Change g_pClipsNav from Initialzied Data to Uninitialized data type
- *
- * 77 03-02-10 17:46 Leslie
- *
- * 76 03-02-10 17:33 Leslie
- * Add AUTO_REWIND_PLAYBACK_FOR_JPEG_DISCS
- *
- * 75 03-02-09 22:25 Leslie
- * Fix Clip not auto playback problem
- *
- * 74 03-02-08 0:36 Leslie
- * Add MANUAL_DIRECTORY_EXPLORER
- *
- * 73 03-02-06 18:31 Leslie
- * Support MPEG CLips Slow, STEP and Time Search
- *
- * 72 03-02-06 14:21 Leslie
- * Scan supporrted for MPEG Clips
- *
- * 71 03-02-03 18:05 Leslie
- * Use Clip_recordMarker for recording Book marker instead of direct
- * call/control
- *
- * 70 2/02/03 7:54p Adamw
- * //fix file search problem.
- * //double the array element cause of unicode implemented
- * //or else when search long name file many file will lost
- *
- * 69 03-01-30 0:11 Leslie
- * Fix MP3 Time Search problem
- * Support MP3 A2B inside track
- * Remove compiler warnning
- *
- * 68 03-01-28 18:43 Leslie
- * Support MP3 Time Search
- *
- * 67 03-01-27 23:58 Leslie
- * Remove compile warnning
- *
- * 66 03-01-24 20:31 Leslie
- * Support Clip Intro Play for MP3 clips
- *
- * 65 03-01-14 1:41 Leslie
- * MP3 Scan supported
- *
- * 64 03-01-10 12:21 Leslie
- * Add wide-character strings support
- *
- * 63 03-01-09 12:30 Leslie
- *
- * 62 10/30/02 17:49 Rond
- *
- * 4 11/09/02 15:49 Atai
- * Vaddis 5e production update
- *
- * 66 25/08/02 12:08 Nirm
- * - Fixed invokePlayback() to renew Pause only after all of the
- * Current-Clip's information has been updated, since OnStop() uses this
- * information.
- *
- * 65 22/08/02 11:08 Nirm
- * - Fixed a typo in _onPresentationFinished(): the next Play-List item
- * must be computed based on the current Item, instead of the current
- * Clip.
- *
- * 64 20/08/02 20:10 Nirm
- * - Upon setting the Playback-Filter during Stop, the playback is reset
- * to the first suitable Item on the Play-List.
- *
- * 63 20/08/02 18:04 Nirm
- * - Playback Filter is reset upon Program invocation.
- *
- * 62 20/08/02 13:33 Nirm
- * - Fixes to the Playback-Filter mechanism: take into account the
- * Digestable attribute.
- *
- * 61 19/08/02 22:27 Nirm
- * - Added Playback-Filter.
- *
- * 60 19/08/02 15:07 Nirm
- * - Code optimization.
- *
- * 59 19/08/02 14:46 Nirm
- * - Added Repeat-Folder support.
- *
- * 58 19/08/02 11:34 Nirm
- * - Added Directory Nesting-Level control.
- *
- * 57 18/08/02 14:02 Nirm
- * - Digest interface changes.
- *
- * 56 13/08/02 19:20 Nirm
- * - Upon encountering an Error, continue playback unless in Pause mode.
- *
- * 55 13/08/02 13:48 Nirm
- * - Clip_isFinished() replaced by Clip_getStatus();
- * - Error-Recovery re-introduced.
- *
- * 54 9/08/02 13:19 Nirm
- * - If selected, the Background is presented upon Play-List construction,
- * instead of in the constructor. This is needed in order to allow the
- * user to select the proper Background setting.
- *
- * 53 9/08/02 11:51 Nirm
- * - The Background is captured upon construction, to prevent undefined
- * background-color appearance.
- *
- * 52 9/08/02 10:46 Nirm
- * - Fixed Assertion problem when executing Stop on an empty play-list;
- * - Corrected cache-ahead to work as expected in Shuffle mode.
- *
- * 51 8/08/02 20:27 Nirm
- * - Enabled Numeric-Selection from Shuffle mode.
- *
- * 50 7/08/02 23:13 Nirm
- * - Extended Digest support to more than 256 items.
- *
- * 49 4/08/02 21:07 Nirm
- * - For still-images, the Background is cleared before playback.
- *
- * 48 4/08/02 17:27 Nirm
- * - Fixed OnPlaybackFinished() to use the Presentation-Time of the
- * current-clip, instead of the cached-clip.
- *
- * 47 4/08/02 14:11 Nirm
- * - Various fixes related to the Transition-Effect and Caching mechanism.
- *
- * 46 2/08/02 19:52 Nirm
- * - Added Cache-Ahead mechansim.
- *
- * 45 1/08/02 23:40 Nirm
- * - Enhanced Digest to support initial-item selection; the initial item
- * is always presented as the first item on a Page.
- *
- * 44 31/07/02 12:53 Nirm
- * - Enhanced the Transition-Override mechanism.
- *
- * 43 30/07/02 20:35 Nirm
- * - Integrated Multi-Standard support for Clips.
- *
- * 42 22/07/02 10:46 Nirm
- * - Reduced heap-memory consumption.
- *
- * 41 21/07/02 20:03 Nirm
- * - Switched to using an Extended-Addressing Array for 16mbit versions.
- *
- * 40 7/07/02 14:55 Nirm
- * - MAX_DIRNAME_LEN for file-searches was increased to 32; this is needed
- * to distinguish between directories with long names.
- *
- * 39 4/06/02 21:16 Nirm
- * - Code cleanup.
- *
- * 38 3/06/02 19:59 Nirm
- * - Moved SC_CLIPS_LIST_ADDRESS to ScPadAlloc.h
- *
- * 37 2/06/02 20:56 Nirm
- * - Added support of Full-Stop and Stop-Resume for MP3.
- *
- * 36 26/05/02 17:23 Ettim
- * Using the extended address mode and setting the file list size to 500
- * files.
- *
- * 35 23/05/02 14:08 Ettim
- * Some code preparations in order to work with an absolute 32 bit address
- * on the scratch pad.
- *
- * 34 16/05/02 12:37 Ettim
- * Enabled zoom in JPEG.
- * Keeping pause state while angle setting.
- *
- * 33 15/05/02 9:31 Ettim
- * Added UI support for L/R (Transition) and Angle buttons (no OSD yet).
- *
- * 32 10/05/02 16:55 Nirm
- * - Flie search is terminated once the Clips-List capacity has been
- * reached.
- *
- * 31 10/05/02 14:53 Nirm
- * - Cleanup of compilation-warnings.
- *
- * 30 29/04/02 12:25 Nirm
- * - Fixes for JPEG Digest.
- *
- * 29 23/04/02 9:32 Nirm
- * - Added dependency in "Config.h".
- *
- * 28 11/04/02 13:47 Ettim
- * Digest for JPEG updates
- *
- * 27 11/04/02 9:47 Ettim
- * Getting the parameters for the digest (digest mode & intro frames
- * count) from the UI.
- *
- * 26 10/04/02 12:29 Ettim
- * Added jpeg support.
- *
- * 25 3/27/02 13:18 Ettim
- * Replaced D_PICTURE_CD_ENABLED with CLIPS_JPEG_SUPPORT
- *
- * 24 27/03/02 9:19 Nirm
- * - Changed CLIPS_TICKS_PER_SECOND -> KER_TICKS_PER_SECOND;
- * - Moved some privately-used definitions from Nav_Clips.h
- *
- * 23 3/26/02 19:14 Ettim
- * Added new clips navigation support.
- *
- * 22 14/03/02 12:11 Nirm
- * - Optimized the implementation of _findAndAddClips().
- *
- * 21 3/12/02 3:20a Dingming
- * 12 digest for PCD supported
- *
- * 20 3/12/02 2:57a Dingming
- * PCD slide show supported
- *
- * 19 11/03/02 20:12 Nirm
- * - Removed unnecessary "extern";
- * - Documentation typo fixed.
- *
- * 18 3/09/02 3:51a Dingming
- * remove display logo for PCD digest stop
- *
- * 17 3/08/02 3:57a Dingming
- * PCD digest supporting
- *
- * 16 7/03/02 16:52 Nirm
- * Integrated Exceptioning mechanism.
- *
- * 15 3/07/02 4:07a Dingming
- * clean up jpg digest variable
- *
- * 14 3/06/02 4:07a Dingming
- * implement for PCD playback
- *
- * 13 3/05/02 5:51a Dingming
- * picture cd implement
- *
- * 12 3/05/02 1:26a Dingming
- * move JPG restore Angle to the common area
- *
- * 11 4/03/02 19:22 Nirm
- * Integrated support for Full-Stop.
- *
- * 10 2/28/02 2:52a Dingming
- * code porting for picture cd
- *
- * 9 21/02/02 16:54 Nirm
- * - Added support for Long/Short filenames;
- * - Added support for Wrap-Around on Program-Edges;
- * - Code cleanup.
- *
- * 8 20/02/02 17:38 Nirm
- * - Added Long-Filename support;
- * - Turned Clips_findClips() to fully asynchronous.
- *
- * 7 19/02/02 9:40 Nirm
- * Code Cleanup.
- *
- * 6 18/02/02 20:33 Nirm
- * Integrated MP3-ID3 extraction.
- *
- * 5 18/02/02 11:26 Nirm
- * Added MP3-ID3v1 support.
- *
- * 4 15/02/02 0:54 Nirm
- * - Collection of the Clips is temporarily done outside the constructor.
- *
- * 3 14/02/02 23:44 Nirm
- * - Fixed wrong copy of the FindFile info.
- *
- * 2 14/02/02 18:13 Nirm
- * Integration of the Clips Navigator.
- *
- * 1 7/02/02 7:49 Nirm
- ****************************************************************************************/
- #include "Config.h" // Global Configuration - do not remove!
- #ifdef _DEBUG
- #undef IFTRACE
- #define IFTRACE if (gTraceNavigator)
- #include "DebugDbgMain.h"
- #endif
- #include <embedded.h>
- #include "IncludeSysDefs.h"
- #include "Includestring_ex.h"
- #include "Includemath-macro.h"
- #include "KernelKer_API.h"
- #include "KernelEventDef.h"
- #include "PlaycoreCoremainCoreGDef.h"
- #include "PlaycoreDataStructuresArray.h"
- #include "PlaycoreExceptionException.h"
- #include "PlaycoreFileSysFileSystem.h"
- #include "PlaycoreNav_ClipsNav_Clips.h"
- #include "PlaycoreNav_ClipsPE_Clips.h"
- #include "PlaycoreNav_ClipsMP3.h"
- #include "PlaycorePlayModePlayMode.h"
- #include "PlaycoreScPadScPadAlloc.h"
- #include "PlaycoreTimingTiming.h"
- #include "Playcorenav_cddape_cd.h"
- #include "PlaycoreNav_ClipsClip_Impl.h"
- #include "PlaycoreNav_ClipsClip.h"
- #include "servicesinclude_heap.h"
- #include "PlaycoreNav_CDDAcdnav_err.h"
- #include "LogoLogo.h"
- #include "DecoderDec_Avi_Drm.h"
- #include "Decoderdecoder.h"
- #include "PlaycoreNav_ClipsAuxSubtitles.h"
- #ifdef CLIPS_JPEG_SUPPORT
- #include "PlaycoreNav_ClipsJPEG.h"
- #ifdef CLIPS_JPEG_DIGEST_SUPPORT
- #include "PlaycoreDigestdigest.h"
- #endif //CLIPS_JPEG_DIGEST_SUPPORT
- #endif //CLIPS_JPEG_SUPPORT
- #ifdef SUPPORT_FLASH_CARD
- #include "drivefe_manager.h"
- #include "mediacardsincluderegister.h"
- UINT32 Clips_GetCurrClipSize(void);
- UINT32 Clips_GetCurrClipSartAddr(void);
- extern BOOL drv_suspend_playback(BOOL bSuspend);
- #endif
- extern void sc_GetBytes(WORD i_hSourceAddress, WORD i_cbOffset, WORD i_cbSize, BYTE *o_pDestBuff);
- /////////////////////////////////////////////////////////////////////////////
- // Constants and Enumerations
- #define MPEG_SEARCH_ADDRESS_OFFSET 300L // 4 seconds
- #define CLIPS_LOCATION_TOLERANCE 30
- #define CLIPS_ERROR_RECOVERY_RETRY_COUNT 3
- #define CLIPS_A2B_MIN_GAP 1 // in seconds
- #define CLIPS_MAX_BOOKMARKER_NUM 3
- #define CLIPS_MPEG_NUM_OF_SECTORES_PER_SECOND 75L
- #define CLIPS_INTRO_PLAY_TIME 10 // in seconds
- #define RGB_2_Y(r,g,b) ( (( ( 66 * r) + (129 * g) + (25 * b) + 128) >> 8) + 16 )
- #define RGB_2_U(r,g,b) ( (( (-38 * r) - (74 * g) + (112 * b) + 128) >> 8) + 128 )
- #define RGB_2_V(r,g,b) ( (( (112 * r) - (94 * g) - (18 * b) + 128) >> 8) + 128 )
- typedef enum { ePause, eStopResume, eFullStop } enStopType;
- typedef enum { eFindClipRendezvous, eTimerRendezvous, ePositionA, ePositionB } enRendezvousType;
- typedef enum { eMarkerA, eMarkerB, eResumePlayback, eBookmark } enClip_MarkerType;
- typedef enum {
- eBuildAll,
- eBuildFileListOnly,
- eBuildPeerDirListBasedOnSubDirList,
- } enBuildBrowser;
- typedef enum {
- eUIToGetClipInfo,
- eClipInfoReadyForUI,
- eClipInfoNotAvailable,
- } enGetClipInfoStatus;
- /////////////////////////////////////////////////////////////////////////////
- // Macros
- #define SHARED_INFO (gns.clips)
- #define PEER_DIR_ARRAY_SIZE Array_getSize(SHARED_INFO.hDirsArray[CLIPS_PEER_ARRAY])
- #ifdef MANUAL_DIRECTORY_EXPLORER
- #define SUB_DIR_ARRAY_SIZE Array_getSize(SHARED_INFO.hDirsArray[CLIPS_SUB_ARRAY])
- #else
- #define SUB_DIR_ARRAY_SIZE 0
- #endif
- // <<< Robin_0903_2004
- #ifdef DIVX_SUPPORT_MULTI_SUBTITLE_MODE0
- static BOOL bNeedWaitForUI = FALSE;
- #endif
- // >>> Robin_0903_2004
- UINT16 g_uAvailableClipTypes;
- BOOL change_pallet;
- static UINT16 g_uPlaybackFilter;
- DWORD CurrLocationBackup = -1;
- // <<< SEC BK.LIM101303: Search first file if Root dose not have any file list to play.
- #ifdef EXINO2
- #ifdef MP3_SUBFOLDER_AUTOPLAY
- BOOL g_bClipsAutoplay;
- #endif
- #endif
- // SEC BK.LIM101303>>>
- // <<< Stivenz_0223_2005: If current chapter is unsupported then goto next.
- #ifdef D_MP4_SKIP_UNSUPPORTED_CHAPTER
- extern BOOL bMP4DRMDisable;
- #endif
- extern BOOL isFailedToReadMP3Head;//LeonHe_2005_0519: Failed to read the MP3 Head.
- typedef struct ClipsNavInfo_TAG
- {
- UINT8 m_eClipsListStatus;
- UINT8 m_uCurrPlaybackMode; // Stores the Current Playback-Mode
- // Presentation time
- UINT8 m_hPresentationTimer; // Holds the timer for the presentation time
- // Play-State related
- UINT8 m_bPresentationMode; // Indicates whether Presentation-Mode is active
- // Cached-Playback related
- UINT16 m_hCachedClip; // Holds a handle to a Cached Clip
- // Stop-Resume related
- ClipMarker m_cmResumeMarker;
- ClipMarker m_PositionA;
- ClipMarker m_PositionB;
- #ifdef CLIPS_JPEG_DIGEST_SUPPORT
- // Digest related
- UINT8 m_bDigestMode; // Indicates whether digest mode is active
- UINT16 m_uDigestableTypes; // Holds a mask of all Digestable Types
- UINT16 m_uDigestableItemsCnt; // Holds the number of Digestable Items
- UINT32 m_hDigestUnits; // Holds the Items indexes to be displayed on digest mode
- #endif //CLIPS_JPEG_DIGEST_SUPPORT
- // Error-Handling and Recovery
- struct Clips_ErrorRecoveryInfo_TAG {
- UINT8 uRetryCount; // Holds the play retry counter
- } m_ErrorRecoveryInfo;
- // Operation-Mask related
- ULONG m_ulCOP_Mask;
- } Clips_Nav_Info;
- static Clips_Nav_Info *g_pClipsNav = NULL;
- extern unsigned char time_display;
- #ifdef D_USE_VARIABLE_FOR_LIB
- extern WORD clips_skip_back_threshold;
- #endif
- #if defined(_DEBUG) || defined(D_RELEASE_TRACE_ENABLED) // ZKR GL051004
- #define DBG_W2A(szWString) _wcs2str(szWString, g_szDebugString, sizeof(g_szDebugString))
- static char g_szDebugString[64];
- #endif //_DEBUG
- BYTE ui_enter_pressed = 0;
- /////////////////////////////////////////////////////////////////////////////
- // Forward-Declarations of Private-Services
- static BOOL _findAndAddClips(UINT16 uMaxClipsToFind, BOOL bRootLevel);
- static void constructor(void);
- static void destructor(void);
- static BOOL invokePlayback(BOOL bOverrideTransition);
- static void PerformErrorRecovery(UINT16 hClipInstance, enClipStatus eStatus);
- static UINT16 computePlaylistItem(UINT16 uCurrItem, BOOL bNext);
- static void cancelRepeatModes(BYTE uModesMask);
- // Event Handlers
- static void OnFindClips(UINT16 uTypesToFind);
- static void OnTick(void);
- static void OnPlay(void);
- static void OnPlaybackFinished(void);
- static void OnStop(enStopType eType);
- static void OnRendezvous(void *Param);
- static void _onPresentationFinished(void);
- #ifdef CLIPS_JPEG_SUPPORT
- static void OnAngleSelection(enClipImageOrientation i_eOrientation);
- static void OnTransitionSelection(enClipTransitionEffect i_eTransition);
- #ifdef CLIPS_JPEG_DIGEST_SUPPORT
- static BOOL _handleDigestUnit(UINT16 uUnitIndex, enDigestQuery eQuery);
- static void OnDigest(UINT16 Param);
- static void _terminateDigestMode(void);
- #endif //CLIPS_JPEG_DIGEST_SUPPORT
- #endif //CLIPS_JPEG_SUPPORT
- static void OnModeChange(void);
- static void OnNextItem(void);
- static void OnPreviousItem(void);
- static void OnNumericSelection(UINT16 uSelection);
- // Presentation timer callback function
- static void OnPresentationTimeExpired(UINT8 hTimer);
- static void OnStatusReport(void);
- static void OnScan(int iScanSpeed);
- static void OnIntro(void);
- static void OnGotoTime(WORD wTime);
- static void OnSetMarkerA(void);
- static void OnSetMarkerB(void);
- static void OnCancelABRepeat(void);
- static void OnA2BRepeat(int Param);
- static void OnIFrameDisplayed(void);
- static void OnDemuxFinished(void);
- static void OnDrmInfoMsgArrived(void);
- static void OnSubtitleArrived(void);
- static void OnSubtitleChanged(void);
- #ifdef AVI_AUDIO_CHANGE_ONSCAN //ZKR JK0413 : add for audio change on-the-fly
- static void OnAudioChanged(void);
- #endif
- #ifdef IS_MP4_CAPABLE
- static void OnChapterChanged(void);
- extern void MP4Clip_subtitleArrived(void);
- #endif
- static void OnStep(void);
- static void OnSlow(int iSpeed);
- static UINT16 getLastItemInPrevFolders(void);
- static UINT16 getFirstItemInSubFoldersOrNextFolders(void);
- static void notifyUIOnBrowserContentChange(BYTE ucUpdatePeerDirListWindow, BYTE ucUpdateFileListWindow);
- static BOOL FileSys_InRootDir(void);
- static BOOL Browser_Construct(void);
- static void Browser_Destruct(void);
- static void Browser_InitArrays(void);
- static void Browser_Build(enBuildBrowser eBuildBrowserType, BOOL bNotifyUI);
- static void Browser_OpenFolder(UINT8 ucWhichWindow, int iWhichEntry, BOOL bNotifyUI);
- static void Browser_GetFolderInfo(UINT16 uDirNum,ClipInfo *o_pInfo, enWINDOWTYPE eWin);
- static void SetBrowserStyle(enClipsBrowserStyle eBrowserStyle);
- static void OnGetClipInfoForUI(ClipInfo *o_pClipFileInfo);
- static BOOL IsGotoNextChapterAllowed(void);
- static BOOL IsGotoPreviousChapterAllowed(void);
- static void Browser_ResetPeerFoldersArray(void);
- static void Browser_ResetSubFoldersArray(void);
- static void OnDriveError(void);
- static void OnDemuxError(void);
- #ifdef I77_COMPANION_CHIP
- void JPEGClip_BeforeAbort(void);
- void DEC_JPEG_End_Resolution(void);
- #endif
- #ifdef D_DIVX_EXTERNAL_SUBTITLE_SELECTION
- void Set_SubFile_Count(WORD wCount);
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // Public Services
- // <<< SEC BK.LIM101303: Search first file if Root dose not have any file list to play.
- #ifdef EXINO2
- #ifdef MP3_SUBFOLDER_AUTOPLAY
- void Clips_set_Autoplay(BOOL bAutoplay)
- {
- g_bClipsAutoplay = bAutoplay;
- }
- #endif
- #endif
- // >>>
- enClipsListStatus Clips_getClipsListStatus(void)
- {
- return (enClipsListStatus)g_pClipsNav->m_eClipsListStatus;
- }
- /*
- Desc: This function is for Explorer style browser only. Tells Clips nav to
- play within a folder or cross folders or play a single Item.
- In: BOOL bPlayMode
- Out: None.
- */
- void Clips_SetExplorerStyleBrowserPlayMode(enClipsExplorerStyleBrowserPlayMode ePlayMode)
- {
- ie_send_ex(IE_CORE_CLIPS_EXPLORER_BROWSER_PLAY_MODE, (void*)ePlayMode);
- }
- void Clips_SetExplorerStyleBrowserDiscScanMode(BOOL bDiscScanMode)
- {
- ie_send_ex(IE_CORE_CLIPS_EXPLORER_BROWSER_DISC_SCAN_MODE, (void*)bDiscScanMode);
- }
- void Clips_findClips(UINT16 uTypesToFind)
- {
- UINT32 ulParam= (((UINT32)eFindClipRendezvous << 16) | uTypesToFind);
- #ifdef CLIPS_DISPLAY_BACKGROUND
- // Capture the current Background, to be used later
- PE_Clips_CaptureBackground();
- // Display the Background
- PE_Clips_DisplayBackground();
- #else
- PE_Clips_ClearBackground();
- #endif //CLIPS_DISPLAY_BACKGROUND
- // Reset the Available Types
- g_uAvailableClipTypes= (UINT16)eClipType_None;
- // Store the Types to Find as the default Playback-Filter
- g_uPlaybackFilter= uTypesToFind;
- // Invoke the search
- g_pClipsNav->m_eClipsListStatus= (UINT8)eCLS_Building;
- ie_send_ex(IE_CORE_CDNAV_RENDEZVOUS, (void*)ulParam);
- return;
- }
- #ifdef CLIPS_MANUAL_PLAYLIST_CONSTRUCTION_SUPPORT
- BOOL Clips_addClip(LPCWSTR i_pszFilename)
- {
- UINT16 hFindFile;
- UINT16 hClipInstance;
- FindData fdFileInfo;
- #ifdef CLIPS_DISPLAY_BACKGROUND
- // Capture the current Background, to be used later
- PE_Clips_CaptureBackground();
- // Display the Background
- PE_Clips_DisplayBackground();
- #else
- PE_Clips_ClearBackground();
- #endif //CLIPS_DISPLAY_BACKGROUND
- g_pClipsNav->m_eClipsListStatus= (UINT8)eCLS_Building;
- // Assumption: The requested file is either in the current Working-Directory,
- // or consists of a Full-Path relative to the current Working-Directory.
- hFindFile= FileSys_findFirstFile(i_pszFilename, &fdFileInfo);
- if ((NULL == hFindFile) || ! FileSys_findClose(hFindFile)) {
- tr_printf(("FATAL: Clips_addClip() Failed [1]: Cannot add %s.n", DBG_W2A(i_pszFilename)));
- return FALSE;
- }
- // Try to enqueue the Clip
- hClipInstance= ClipsRepository_addClip(&fdFileInfo);
-
- if (NULL == hClipInstance) {
- dbg_printf(("WARNING: Clips_addClip() Failed [2]: %s rejected.n", DBG_W2A(i_pszFilename)));
- return FALSE;
- }
- // Update the Available-Types
- g_uAvailableClipTypes |= (UINT16)Clip_getType(hClipInstance);
- // Update the cummulative Playback-Time
- SHARED_INFO.uClipsCnt++;
- // SHARED_INFO.uTotalPlaybackTime += pClipFileInfo->ulPlaybackTime;
- dbg_printf(("%d. %sn", ClipsRepository_getSize(), DBG_W2A(fdFileInfo.szFileID)));
- return TRUE;
- }
- BOOL Clips_addClipEx(const FindData *i_pFileInfo)
- {
- UINT16 hClipInstance;
- g_pClipsNav->m_eClipsListStatus= (UINT8)eCLS_Building;
- #ifdef CLIPS_DISPLAY_BACKGROUND
- // Capture the current Background, to be used later
- PE_Clips_CaptureBackground();
- // Display the Background
- PE_Clips_DisplayBackground();
- #else
- PE_Clips_ClearBackground();
- #endif //CLIPS_DISPLAY_BACKGROUND
- // Try to enqueue the Clip
- hClipInstance= ClipsRepository_addClip(i_pFileInfo);
- if (NULL == hClipInstance) {
- dbg_printf(("WARNING: Clips_addClipEx() Failed [1]: %s rejected.n", DBG_W2A(i_pFileInfo->szFileID)));
- return FALSE;
- }
- // Update the Available-Types
- g_uAvailableClipTypes |= (UINT16)Clip_getType(hClipInstance);
- // Update the cummulative Playback-Time
- SHARED_INFO.uClipsCnt++;
- // SHARED_INFO.uTotalPlaybackTime += pClipFileInfo->ulPlaybackTime;
- dbg_printf(("%d. %sn", ClipsRepository_getSize(), DBG_W2A(i_pFileInfo->szFileID)));
- return TRUE;
- }
- #endif //CLIPS_MANUAL_PLAYLIST_CONSTRUCTION_SUPPORT
- void Clips_removeAllClips()
- {
- ClipsRepository_empty();
- // Reset the Available Types
- g_uAvailableClipTypes= (UINT16)eClipType_None;
- // Update the cummulative Playback-Time
- SHARED_INFO.uClipsCnt= 0;
- // SHARED_INFO.uTotalPlaybackTime= 0;
- return;
- }
- void Clips_finalizeClipsList()
- {
- UINT16 uEntriesCnt, uSlot;
- SHARED_INFO.uCurrentClipNumber = 0;
- // Initialize the default Program-List to a sequencial playback of the Playlist
- PM_InitializeProgramList();
- //PM_SetPlaybackMode(PM_PLAYBACK_NORMAL);
- uEntriesCnt= ClipsRepository_getSize();
- // Initialize the settings of the Global variables
- SHARED_INFO.uClipsCnt= uEntriesCnt;
- if (0 != uEntriesCnt) {
- for (uSlot= 1; uSlot <= uEntriesCnt; uSlot++)
- PM_SetProgramListEntry(uSlot, uSlot);
- // Initialize the current Position to the first item on the Playlist
- SHARED_INFO.uCurrPlaylistItem= computePlaylistItem(0, TRUE);
- #ifdef D_NO_CLIPS_AUTORUN
- SHARED_INFO.uCurrentClipNumber = 1;
- #endif
- // Initialize the Clip-Information for the first Clip
- // Clip_getFileInfo(ClipsRepository_getInstanceAt(0),
- Clip_getCurrFileInfo(ClipsRepository_getInstanceAt(0),
- &(SHARED_INFO.cieCurrClip).ciInfo);
- (SHARED_INFO.cieCurrClip).eClipStatus= (UINT8)eCS_Idle;
- (SHARED_INFO.cieCurrClip).bIsExtendedInfoAvailable= FALSE;
- // Clear any Resume Marker
- (g_pClipsNav->m_cmResumeMarker).dwAddress= (ULONG)-1;
- }
- g_pClipsNav->m_eClipsListStatus= (UINT8)eCLS_Finalized;
- #ifdef CLIPS_JPEG_DIGEST_SUPPORT
- if ((g_pClipsNav->m_uDigestableItemsCnt > 0) &&
- (g_pClipsNav->m_uDigestableTypes & g_uPlaybackFilter))
- {
- SET_COP_MASK(COP_TITLE_MENU);
- }
- else
- CLEAR_COP_MASK(COP_TITLE_MENU);
- #endif //CLIPS_JPEG_DIGEST_SUPPORT
- #ifdef MANUAL_DIRECTORY_EXPLORER
- // Reset the Playback Mode
- if (PM_IsPlaybackProgram(PM_GetPlaybackMode()))
- PM_SetPlaybackMode(PM_PLAYBACK_NORMAL);
-
- g_pClipsNav->m_uCurrPlaybackMode = PM_PLAYBACK_NORMAL;
- OnModeChange();
- #else
- PM_SetPlaybackMode(PM_PLAYBACK_NORMAL);
- #endif
-
- return;
- }
- /*
- This function is used by UI task only.
- o_pClipFileInfo->cbFileSize is used as a synchonization flag
- between UI and core task.
- */
- BOOL Clips_getClipFileInfoAt(UINT16 uClipNumber, ClipInfo *o_pClipFileInfo)
- {
- // WORD watchdog = 500;
- if(NULL == o_pClipFileInfo)
- return FALSE;
- o_pClipFileInfo->cbFileSize = eUIToGetClipInfo;
-
- SHARED_INFO.iGetClipFileInfoAtNumber = uClipNumber;
-
- ie_send_ex(IE_CORE_GET_CLIP_FILE_INFO, (void *)(o_pClipFileInfo));
-
- while ((eUIToGetClipInfo == o_pClipFileInfo->cbFileSize) && NULL != g_pClipsNav)
- {
- usleep(10000UL);
- }
-
- if(eClipInfoReadyForUI == o_pClipFileInfo->cbFileSize)
- return TRUE;
- else
- return FALSE;
-
- }
- void Clips_setPresentationTime(enClipType eType, UINT8 uPresentationTime)
- {
- Clip_setPresentationTime(eType, uPresentationTime);
- return;
- }
- UINT16 Clips_getAvailableTypes(void)
- {
- return g_uAvailableClipTypes;
- }
- UINT16 Clips_getPlaybackFilter(void)
- {
- return g_uPlaybackFilter;
- }
- void Clips_setPlaybackFilter(UINT16 uTypesToPlay)
- {
- if (uTypesToPlay == g_uPlaybackFilter)
- return;
- g_uPlaybackFilter= uTypesToPlay;
- // If during stop, reset the playback to the first suitable item
- if (PST_STOP == gcs.pstate) {
- // Initialize the current Position to the first suitable item on the Playlist
- SHARED_INFO.uCurrPlaylistItem= computePlaylistItem(0, TRUE);
- if (0 != SHARED_INFO.uCurrPlaylistItem) {
- SHARED_INFO.uCurrentClipNumber= PM_GetProgramListEntry(SHARED_INFO.uCurrPlaylistItem);
- // Initialize the Clip-Information for the Clip
- // Clip_getFileInfo(ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1),
- Clip_getCurrFileInfo(ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1),
- &(SHARED_INFO.cieCurrClip).ciInfo);
- (SHARED_INFO.cieCurrClip).eClipStatus= (UINT8)eCS_Idle;
- (SHARED_INFO.cieCurrClip).bIsExtendedInfoAvailable= FALSE;
- // Clear any Resume Marker
- (g_pClipsNav->m_cmResumeMarker).dwAddress= (ULONG)-1;
- }
- }
- #ifdef CLIPS_JPEG_DIGEST_SUPPORT
- if ((g_pClipsNav->m_uDigestableItemsCnt > 0) &&
- (g_pClipsNav->m_uDigestableTypes & g_uPlaybackFilter))
- {
- SET_COP_MASK(COP_TITLE_MENU);
- }
- else
- CLEAR_COP_MASK(COP_TITLE_MENU);
- #endif //CLIPS_JPEG_DIGEST_SUPPORT
- return;
- }
- // <<< SEC BK.LIM101303: Search first file if Root dose not have any file list to play.
- #ifdef EXINO2
- #ifdef MP3_SUBFOLDER_AUTOPLAY
- void Clip_Initial_Find_FirstPlayableItem()
- {
- UINT16 uPlayItem, uClipNum;
- uClipNum= PM_GetProgramListEntry(SHARED_INFO.uCurrPlaylistItem);
- #ifdef DISABLE
- if( (0 == uClipNum)
- &&(0 ==SHARED_INFO.uCurrPlaylistItem)
- && (eWholeDisc == SHARED_INFO.uExplorerStyleBrowserPlayMode)
- && (eWINDOWS_EXPLORER_STYLE == SHARED_INFO.eWindowsExplorerStyleBrowser))
- #endif
- if( (0 == uClipNum)
- &&(0 ==SHARED_INFO.uCurrPlaylistItem)
- && (eWINDOWS_EXPLORER_STYLE == SHARED_INFO.eWindowsExplorerStyleBrowser))
- {
- SHARED_INFO.uCurrPlaylistItem = getFirstItemInSubFoldersOrNextFolders();
- }
- }
- #endif
- #endif
- // SEC BK.LIM101303>>>
- /////////////////////////////////////////////////////////////////////////////
- // Navigation Interface
- /////////////////////////////////////////////////////////////////////////////
- // Clips_Navigator()
- //
- // Description: The main router for Clips Navigation Events.
- //
- // Input: Op - The type of Operation being invoked
- // Event - The Event to route
- // Param - An optional Parameter to the Event being routed
- //
- // Output: None
- // In/Out: None
- // Return: Zero on success; Non-Zero otherwise.
- //
- // Remarks: None
- int Clips_Navigator(HDLR_OP Op, EVENT Event, void *Param)
- {
- switch (Op)
- {
- case HDLR_ENTER:
- constructor();
- break;
- case HDLR_EXIT:
- destructor();
- break;
- case HDLR_EVENT:
- if (NULL == g_pClipsNav)
- return -1;
- switch (Event)
- {
- case IE_CORE_PAUSE:
- OnStop(ePause);
- break;
- case IE_CORE_STOP:
- OnStop((TRUE == (BOOL)Param) ? eFullStop : eStopResume);
- break;
- case IE_CORE_RESTART:
- #ifdef DIVX_SUPPORT_MULTI_SUBTITLE_MODE0
- bNeedWaitForUI = FALSE;
- #endif
- SHARED_INFO.uCurrPlaylistItem= computePlaylistItem(0, TRUE);
- // Clear any Resume Marker
- (g_pClipsNav->m_cmResumeMarker).dwAddress= (ULONG)-1;
- // <<< SEC BK.LIM101303: Search first file if Root dose not have any file list to play
- #ifdef EXINO2
- #ifdef MP3_SUBFOLDER_AUTOPLAY
- if(g_bClipsAutoplay)
- Clip_Initial_Find_FirstPlayableItem();
- #endif
- #endif
- // SEC BK.LIM101303>>>
- // Fall-Through!
- case IE_CORE_PLAY:
- OnPlay();
- break;
- case IE_CORE_NEXT_CHAPTER:
- OnNextItem();
- break;
- case IE_CORE_PREVIOUS_CHAPTER:
- OnPreviousItem();
- break;
- case IE_CORE_GOTO_ENTRY:
- case IE_CORE_MENU_NUMERICAL_SELECTION:
- OnNumericSelection((UINT16)Param);
- break;
- #ifdef MANUAL_DIRECTORY_EXPLORER
- case IE_CORE_FIND_CLIP_ITEM_IN_OTHER_FOLDER:
- if (PST_STOP == gcs.pstate)
- {
- if(0 ==Param)
- getFirstItemInSubFoldersOrNextFolders();
- else
- if(1 == Param)
- getLastItemInPrevFolders();
- }
- break;
- case IE_CORE_SET_CLIPS_BROWSER_STYLE:
- SetBrowserStyle((enClipsBrowserStyle)Param);
- break;
- case IE_CORE_CLIPS_EXPLORER_BROWSER_PLAY_MODE:
- SHARED_INFO.uExplorerStyleBrowserPlayMode = (enClipsExplorerStyleBrowserPlayMode)Param;
- break;
- case IE_CORE_CLIPS_EXPLORER_BROWSER_DISC_SCAN_MODE:
- SHARED_INFO.bIsIntroPlayMode = (BOOL)Param;
- break;
- #endif
- case IE_CORE_GET_CLIP_FILE_INFO:
- OnGetClipInfoForUI((ClipInfo *)Param);
- break;
- case IE_CORE_CDNAV_RENDEZVOUS:
- OnRendezvous(Param);
- break;
- case IE_CORE_CDNAV_FINISHED:
- OnPlaybackFinished();
- break;
- case IE_CORE_PM_RESET:
- // Reset the PM: return to Normal Playback, no Repeats of any kind
- PM_SetPlaybackMode(PM_PLAYBACK_NORMAL);
- PM_ClearRepeat();
- break;
- case IE_CORE_CLIPS_PARAMETER_RESET:
- Clips_removeAllClips();
- ClipsSysStateReset();
- g_pClipsNav->m_eClipsListStatus= (UINT8)eCLS_Uninitialized;
- break;
- #ifdef CLIPS_JPEG_SUPPORT
- case IE_CORE_ANGLE_SELECTION:
- OnAngleSelection((enClipImageOrientation)Param);
- break;
- case IE_CORE_TRANS_SELECTION:
- OnTransitionSelection((enClipTransitionEffect)Param);
- break;
-
- #ifdef CLIPS_JPEG_DIGEST_SUPPORT
- case IE_CORE_DIGEST:
- OnDigest((UINT16)Param & 0xFFFF);
- break;
- #endif
- #endif //CLIPS_JPEG_SUPPORT
- case IE_CORE_TICK_200:
- OnTick();
- break;
- case IE_CORE_SEAMLESS_MODE_CHANGE:
- OnModeChange();
- break;
- case IE_CORE_SCAN:
- OnScan((int)Param);
- break;
- case IE_CORE_CDNAV_INTRO:
- OnIntro();
- break;
- case IE_CORE_GOTO_TIME:
- OnGotoTime((WORD)Param);
- break;
- case IE_CORE_AB_REPEAT:
- OnA2BRepeat((int)Param);
- break;
- case IE_CORE_I_FRAME:
- OnIFrameDisplayed();
- break;
- case IE_CORE_DEMUX_FINISHED:
- OnDemuxFinished();
- break;
- case IE_CORE_DEMUX_ERROR:
- OnDemuxError();
- break;
- case IE_CORE_SUBTITLE_ARRIVED:
- #ifdef IS_MP4_CAPABLE
- if (SI_IS_CURRENT_MP4_CLIP) // MP4, subtitle, text
- {
- MP4Clip_subtitleArrived();
- }
- else // AVI
- #endif
- {
- OnSubtitleArrived();
- }
- break;
- case IE_CORE_SUBTITLE_CHANGED:
- OnSubtitleChanged();
- break;
- #ifdef AVI_AUDIO_CHANGE_ONSCAN //ZKR JK0413 : add for audio change on-the-fly
- case IE_CORE_AUDIO_CHANGED:
- OnAudioChanged();
- break;
- #endif
- #ifdef IS_MP4_CAPABLE
- case IE_CORE_CHAPTER_CHANGED:
- OnChapterChanged();
- break;
- #endif
- case IE_CORE_DRM_INFO_ARRIVED:
- OnDrmInfoMsgArrived();
- break;
- case IE_CORE_STEP:
- OnStep();
- break;
- case IE_CORE_SLOW:
- OnSlow((int)Param);
- break;
- case EVENT_CLASS_CORE:
- #ifdef _DEBUG
- OnStatusReport();
- #endif //_DEBUG
- break;
- #ifdef D_USE_TIMEOUT_FOR_JPG_TRICK
- case IE_CORE_ZOOM:
- case IE_CORE_PANNING:
- if( eClipType_JPEG == SI_CLIPS_CURR_CLIP_INFO.ciInfo.eType )
- {
- if(PST_PAUSE == gcs.pstate) // Add by Torrance
- {
- timer_service_disable(g_pClipsNav->m_hPresentationTimer);
- }
- else
- {
- timer_service_enable(g_pClipsNav->m_hPresentationTimer, TRUE);
- }
- }
- break;
- #else
- case IE_CORE_ZOOM:
- timer_service_disable(g_pClipsNav->m_hPresentationTimer); //disable the timer if exist, next jpg won't be show if zoom is called.
- break;
- #endif
- case IE_CORE_DRIVE_READ_FAIL:
- OnDriveError();
- break;
- default:
- // dbg_printf(("Clips_Nav: Unexpected Event %Xn", (Event & 0xFF)));
- break;
- } // endof switch(Event)
- break;
- default:
- dbg_printf(("Clips_Nav: Unknown Operation requested %dn", Op));
- break;
- } //endof switch(Op)
- return 0;
- }
- /////////////////////////////////////////////////////////////////////////////
- // Private Services
- /////////////////////////////////////////////////////////////////////////////
- // _findAndAddClips()
- //
- // Description: Searches the File-System for certain Clips, and enqueues
- // them in the Play-List.
- //
- // Input: None
- // Output: None
- // In/Out: None
- // Return: None
- //
- // Remarks: None
- static BOOL _findAndAddClips(UINT16 uMaxClipsToFind, BOOL bRootLevel)
- {
- BOOL bSearchAborted;
- UINT16 uSubDirsCnt;
- UINT16 uPos;
- UINT16 hFindFile;
- static UINT16 uDirTreeLevel;
- static UINT16 uLastUsedArrayPos;
- static FindData *pFileInfo;
- if (bRootLevel) {
- // Allocate a FindData structure
- pFileInfo= (FindData*)malloc(sizeof(FindData));
- if (NULL == pFileInfo) {
- tr_printf(("FATAL: _findAndAddClips() Failed [2]: Low system resourcesn"));
- return FALSE;
- }
- uLastUsedArrayPos= 0;
- uDirTreeLevel= 0;
- }
- // Start scanning the Current Directory
- hFindFile= FileSys_findFirstFile(FILESYS_WILDCARD_SEARCH, pFileInfo);
- if (NULL == hFindFile) {
- // Robin_1124_2004_B, should free pFileInfo if not find File at first time
- if (bRootLevel) {
- free(pFileInfo);
- }
-
- return FALSE;
- }
- // Start scanning the Current-Directory
- bSearchAborted= FALSE;
- uSubDirsCnt= 0;
- do {
- // If an Exception was thrown, abort the search
- if (Exception_catchAndRethrow(EXCEPTION_MEDIUM_EJECTED)) {
- tr_printf(("EXCEPTION: _findAndAddClips() 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) {
- // Skip the Current and the Parent directories
- if (0x00 == pFileInfo->szFileID[0] || 0 == wcscmp(pFileInfo->szFileID, L"."))
- continue;
- if( (0x01 == pFileInfo->szFileID[0]) || 0 == wcscmp(pFileInfo->szFileID, L".."))
- continue;
- // Enqueue the Directory found, for later use
- if (! Array_setAt(SHARED_INFO.hDirsArray[0], (uLastUsedArrayPos + uSubDirsCnt),
- (const BYTE*)pFileInfo->szFileID))
- {
- dbg_printf(("WARNING: _findAndAddClips() Failed [3]n"));
- break;
- }
- Array_getAt(SHARED_INFO.hDirsArray[0],(uLastUsedArrayPos + uSubDirsCnt),(const BYTE*)pFileInfo->szFileID);
- uSubDirsCnt++;
- }
- else if (FILETYPE_NORMAL == pFileInfo->uFileType) {
- UINT16 hClipInstance= ClipsRepository_addClip(pFileInfo);
- if (NULL == hClipInstance) {
- dbg_printf(("WARNING: _findAndAddClips() 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
- // Update the cummulative Playback-Time
- //jerry cai SHARED_INFO.uClipsCnt will be updated by Clips_finalizeClipsList SHARED_INFO.uClipsCnt++;
- // SHARED_INFO.uTotalPlaybackTime += pClipFileInfo->ulPlaybackTime;
- dbg_printf(("%d. %sn", ClipsRepository_getSize(), DBG_W2A(pFileInfo->szFileID)));
- }
- } while (FileSys_findNextFile(hFindFile, pFileInfo));
- // Terminate the search
- FileSys_findClose(hFindFile);
- if (! bSearchAborted && (uDirTreeLevel < CLIPS_MAX_DIR_NESTING_LEVEL)) {
- UINT16 uFirstSubDirPos;
- // Now, handle all directories that were found on the way, recursively
- memset(pFileInfo->szFileID, 0, sizeof(pFileInfo->szFileID));
- // Record the position of the First Sub-Directory found at this level,
- // and increment the Last-Used slot of the Sub-Directories Array.
- uFirstSubDirPos= uLastUsedArrayPos;
- uLastUsedArrayPos += uSubDirsCnt;
- for (uPos= uFirstSubDirPos; uPos < (uFirstSubDirPos + uSubDirsCnt); uPos++) {
- // If an Exception was thrown, abort the search
- if (Exception_catchAndRethrow(EXCEPTION_MEDIUM_EJECTED)) {
- tr_printf(("EXCEPTION: _findAndAddClips() Aborting [5]n"));
- bSearchAborted= TRUE;
- break;
- }
- // Verify that there is vacancy in the Clips-List
- if (uMaxClipsToFind == ClipsRepository_getSize())
- break;
- // Extract the next Sub-Directory name
- if (! Array_getAt(SHARED_INFO.hDirsArray[0], uPos, (BYTE*)pFileInfo->szFileID)) {
- dbg_printf(("WARNING: _findAndAddClips() Failed [6]n"));
- continue;
- }
- // Enter the Sub-Directory
- if (! FileSys_changeDir(pFileInfo->szFileID)) {
- dbg_printf(("WARNING: _findAndAddClips() Failed [7]n"));
- continue;
- }
- // Increment the Nesting Level
- uDirTreeLevel++;
- // Continue the search recursively
- if (! _findAndAddClips(uMaxClipsToFind, FALSE)) {
- dbg_printf(("WARNING: _findAndAddClips() Failed [8]n"));
- break;
- }
- // Return to the Current-Directory
- if (! FileSys_goUp()) {
- dbg_printf(("WARNING: _findAndAddClips() Failed [9]n"));
- break;
- }
- // Restore the Nesting Level
- uDirTreeLevel--;
- }
- // Restore the Last-Used slot of the Sub-Directories Array
- uLastUsedArrayPos -= uSubDirsCnt;
- }
- if (bRootLevel) {
- free(pFileInfo);
- }
- return (! bSearchAborted);
- }
- /////////////////////////////////////////////////////////////////////////////
- // constructor()
- //
- // Description: Constructs and initializes the Clips Navigator.
- //
- // Input: None
- // Output: None
- // In/Out: None
- // Return: None
- //
- // Remarks: None
- static void constructor()
- {
- BOOL bLongFilenameSupport;
- dbg_printf(("Clips_constructor()n"));
- dbg_printf(("--> Size of Navigator is: %d Bytes (Global) + %d Bytes (Heap)n",
- (int)sizeof(S_CLIPS_GLOBALS), (int)sizeof(Clips_Nav_Info)));
- // Initialize the globals
- g_uAvailableClipTypes= (UINT16)eClipType_None;
- g_uPlaybackFilter= 0xFFFF;
- gns.clips.iClipBitRate = -1;
-
- // RB_1124_2004, when clip constuctor, set bNeedWaitForUI to FALSE
- #ifdef DIVX_SUPPORT_MULTI_SUBTITLE_MODE0
- bNeedWaitForUI = FALSE;
- #endif
- // Initialize the File-System and select the appropriate naming convention
- #ifdef CLIPS_USE_LONG_FILENAMES
- bLongFilenameSupport= TRUE;
- #else
- bLongFilenameSupport= FALSE;
- #endif //CLIPS_USE_LONG_FILENAMES
- if (! FileSys_selectType(eAny) || ! FileSys_initialize(bLongFilenameSupport)) {
- tr_printf(("WARNING: Failed to initialize the File-System.n"));
- #ifdef EXINO2 //ZKR JK0509 : can't construct fail
- ie_send(IE_CORE_MEDIA_UNIDENTIFIED);
- #endif
- return;
- }
- // Allocate the Clips Navigator
- if(NULL != g_pClipsNav)
- {
- tr_printf(("Try to reallocate resources for the Clips Navigator struct.n"));
- }
- else
- {
- g_pClipsNav= (Clips_Nav_Info *)malloc(sizeof(Clips_Nav_Info));
- if (NULL == g_pClipsNav)
- {
- tr_printf(("Failed to allocate resources for the Clips Navigator struct.n"));
- return;
- }
- }
- //initializing the rand seed
- srand((UINT16)timing_get_clock());
- //creating the presentation timer
- g_pClipsNav->m_hPresentationTimer=
- timer_service_create(OnPresentationTimeExpired, 1,
- (TIMER_DISABLED | TIMER_ONCE));
- if (NULL == g_pClipsNav->m_hPresentationTimer) {
- tr_printf(("FATAL: Clips_construct() Failed [1]: Low system resourcesn"));
- free(g_pClipsNav);
- g_pClipsNav= NULL;
- return;
- }
- g_pClipsNav->m_bPresentationMode= FALSE;
- g_pClipsNav->m_hCachedClip= NULL;
- // Clear the Resume Marker
- (g_pClipsNav->m_cmResumeMarker).dwAddress= (ULONG)-1;
- // Reset error recovery
- (g_pClipsNav->m_ErrorRecoveryInfo).uRetryCount = CLIPS_ERROR_RECOVERY_RETRY_COUNT;
- #ifdef CLIPS_JPEG_DIGEST_SUPPORT
- g_pClipsNav->m_bDigestMode= FALSE;
- g_pClipsNav->m_uDigestableTypes= (UINT16)eClipType_None;
- g_pClipsNav->m_uDigestableItemsCnt= 0;
- g_pClipsNav->m_hDigestUnits= NULL;
- #endif //CLIPS_JPEG_DIGEST_SUPPORT
- // Initialize the Clips-List and Program-List
- g_pClipsNav->m_eClipsListStatus= (UINT8)eCLS_Uninitialized;
- if (!ClipsRepository_construct(CLIPS_MAX_PROGRAM_SIZE)) {
- tr_printf(("FATAL: Clips_construct() Failed [2]: Low system resourcesn"));
- timer_service_delete(g_pClipsNav->m_hPresentationTimer);
- free(g_pClipsNav);
- g_pClipsNav= NULL;
- return;
- }
- Browser_Construct();
- // Reset the Playback Mode
- PM_SetPlaybackMode(PM_PLAYBACK_NORMAL);
- // Set the allowed Core Operations
- SET_COP_MASK(0xFFFFFFFFL);
- CLEAR_COP_MASK( COP_REVERSE_PLAY |COP_SCAN | COP_SCAN_BACKWARD |
- COP_SLOW | COP_STEP | COP_PANNING | COP_TITLE_MENU |
- COP_ROOT_MENU | COP_AUDIO_CHANGE | COP_SUBPIC_CHANGE |
- COP_ANGLE_CHANGE | COP_RETURN | COP_ABREPEAT |
- COP_SCAN | COP_SCAN_BACKWARD );
- // Initialize the current Position to the first item on the Playlist
- SHARED_INFO.uCurrPlaylistItem= 0;
- // Initialize the settings of the Global variables
- SHARED_INFO.uClipsCnt= 0;
- SHARED_INFO.uCurrentClipNumber= 0;
- SHARED_INFO.uSubDirCount= 0; //clear it, if not may get wrong track number for non-explore style menu
- SHARED_INFO.iCurrentTime= 0;
- SHARED_INFO.uTotalPlaybackTime= 0;
- SHARED_INFO.eCurrentTransition= eCTE_None;
- SHARED_INFO.iScanSpeed = 0;
- SHARED_INFO.iClipBitRate = 0;
- SHARED_INFO.bIsIntroPlayMode = FALSE;
- #ifdef MANUAL_DIRECTORY_EXPLORER
- SHARED_INFO.uSubDirArraySize = 0; //ERICM_4JUN25K
- #endif
- #ifdef MANUAL_DIRECTORY_EXPLORER
- SHARED_INFO.eWindowsExplorerStyleBrowser = eWINDOWS_EXPLORER_STYLE;
- #else
- SHARED_INFO.eWindowsExplorerStyleBrowser = eSingle_LIST_STYLE;
- #endif
-
- _uiMPEG4ProcessedFileAddr = (UINT32)-1; //Invalidate AVI index
- // for explorer style browser only.
- SHARED_INFO.uExplorerStyleBrowserPlayMode = eSingleFolder;
- SHARED_INFO.bDisplayLogoWhenPlayAudioOnlySteam = 1;
-
- memset(&SHARED_INFO.cieCurrClip, 0, sizeof(ClipInfoEx));
- // Acquire the current Playback-Mode
- g_pClipsNav->m_uCurrPlaybackMode= PM_GetPlaybackMode();
- gcs.pstate= PST_STOP; // Currently in STOP mode
- #if defined(SDRAM_2X16MBITS) && !defined(NEW_2X16M_MAPPING)
- Logo_display(); // Flush logo again, due to mp3,jpeg R1 address is different with others
- #endif
- #ifdef SUPPORT_TWO_LOGOS
- #ifdef CLIPS_DISPLAY_BACKGROUND
- PE_Clips_DisplayBackground();
- #else
- PE_Clips_DisplayLogo();
- #endif //CLIPS_DISPLAY_BACKGROUND
- #endif
- return;
- }
- /////////////////////////////////////////////////////////////////////////////
- // destructor()
- //
- // Description: Destroys the Clips Navigator.
- //
- // Input: None
- // Output: None
- // In/Out: None
- // Return: None
- //
- // Remarks: None
- static void destructor()
- {
- dbg_printf(("Clips_destructor()n"));
- if (NULL != g_pClipsNav) {
- #ifdef CLIPS_JPEG_DIGEST_SUPPORT
- if (g_pClipsNav->m_bDigestMode)
- _terminateDigestMode();
- #endif //CLIPS_JPEG_DIGEST_SUPPORT
- timer_service_disable(g_pClipsNav->m_hPresentationTimer);
- timer_service_delete(g_pClipsNav->m_hPresentationTimer);
- if (0 != SHARED_INFO.uCurrentClipNumber)
- {
- #ifdef I77_COMPANION_CHIP
- if (eClipType_JPEG == (gns.clips.cieCurrClip).ciInfo.eType)
- {
- JPEGClip_BeforeAbort();
- }
- #endif
- Clip_abortPlayback(ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1),
- FALSE);
- }
- // Release the Clips-List
- Clips_removeAllClips();
- ClipsRepository_destruct();
- Browser_Destruct();
-
- PM_InitializeProgramList();
-
- g_pClipsNav->m_eClipsListStatus= (UINT8)eCLS_Uninitialized;
- free(g_pClipsNav);
- g_pClipsNav= NULL;
- }
- // Reset the Playback Mode
- PM_SetPlaybackMode(PM_PLAYBACK_NORMAL);
- //clear repeat mode
- PM_ClearRepeat();
- // Reset the settings of the Global variables
- SHARED_INFO.uClipsCnt= 0;
- SHARED_INFO.uCurrentClipNumber= 0;
- SHARED_INFO.iCurrentTime= 0;
- SHARED_INFO.uTotalPlaybackTime= 0;
- memset(&SHARED_INFO.cieCurrClip, 0, sizeof(ClipInfoEx));
- // <<< SEC BK.LIM101303: Search first file if Root dose not have any file list to play
- #ifdef EXINO2
- #ifdef MP3_SUBFOLDER_AUTOPLAY
- if(g_bClipsAutoplay)
- g_bClipsAutoplay = FALSE;
- #endif
- #endif
- // >>>
- #ifndef SUPPORT_TWO_LOGOS
- PE_Clips_DisplayLogo();
- #endif
- return;
- }
- void ClipsSysStateReset( void )
- {
- destructor();
- constructor();
- }
- /////////////////////////////////////////////////////////////////////////////
- // invokePlayback()
- //
- // Description: Invokes playback of the current Clip on the Playlist.
- //
- // Input: None
- // Output: None
- // In/Out: None
- // Return: TRUE if playback was started successfully; FALSE otherwise.
- //
- // Remarks:
- // The method extracts the information for the current Clip from the Playlist,
- // and then computes the size of the Clip.
- static BOOL invokePlayback(BOOL bOverrideTransition)
- {
- UINT16 uClipNum;
- UINT16 hClipInstance;
- const ClipMarker *pResumeMarker;
- // WCHAR szTempFilename[SC_CLIPS_CURRENT_FILENAME_SZ*2];
- if (0 == SHARED_INFO.uCurrPlaylistItem) {
- tr_printf(("FATAL: invokePlayback() Failed [1]n"));
- return FALSE;
- }
- // Retrieve the Clip-Info corresponding to the Play-Item to play
- uClipNum= PM_GetProgramListEntry(SHARED_INFO.uCurrPlaylistItem);
- hClipInstance= ClipsRepository_getInstanceAt(uClipNum-1);
- if (NULL == hClipInstance) {
- tr_printf(("FATAL: invokePlayback() Failed [2]n"));
- return FALSE;
- }
- SHARED_INFO.iScanSpeed = 0;
- // If there is any caching in progress, then abort it (unless the Clip to
- // play is the one being cached).
- if ((NULL != g_pClipsNav->m_hCachedClip) &&
- (eCS_Finished != Clip_getStatus(g_pClipsNav->m_hCachedClip)) &&
- (hClipInstance != g_pClipsNav->m_hCachedClip))
- {
- Clip_abortPlayback(g_pClipsNav->m_hCachedClip, TRUE);
- }
- // Invalidate any Caching
- g_pClipsNav->m_hCachedClip= NULL;
- // Unconditionally override Transition-Effect if there is Clip-Type change
- if (Clip_getType(hClipInstance) != (SHARED_INFO.cieCurrClip).ciInfo.eType)
- {
- #ifdef I77_COMPANION_CHIP
- #ifdef I77_BRAIN_STORM
- if( gcst.hd_jpeg_mode_preference != SD_JPEG_MODE )
- #else
- if( gps->hd_jpeg_mode_preference != SD_JPEG_MODE )
- #endif
- {
- if(eClipType_JPEG == (SHARED_INFO.cieCurrClip).ciInfo.eType)
- DEC_JPEG_End_Resolution();
- }
- #endif
- bOverrideTransition= TRUE;
- PE_Clips_DisplayLogo();
- }
- // Cancel Presentation-Mode
- g_pClipsNav->m_bPresentationMode= FALSE;
- // Acquire the Clip-Information for the new Clip
- (SHARED_INFO.cieCurrClip).eClipStatus= (UINT8)eCS_Idle;
- // Clip_getFileInfo(hClipInstance, &(SHARED_INFO.cieCurrClip).ciInfo);
- Clip_getCurrFileInfo(hClipInstance, &(SHARED_INFO.cieCurrClip).ciInfo);
- #ifdef SUPPORT_FLASH_CARD
- if(IS_PLAYING_CARD)
- {
- STRUCT_FILE *pfile = FCU_TEMP_FILE_STRCUT_ADDR;
- FileSys_FileOpen(pfile, Clips_GetCurrClipSartAddr(), 0, Clips_GetCurrClipSize());
- }
- #endif
- #ifdef CLIPS_ACQUIRE_EXTENDED_INFO
- //if (uClipNum != SHARED_INFO.uCurrentClipNumber) {
- //fix the but that the sample rate of first trace is incorrect. ZCH SeanLui 0420
- if ((uClipNum != SHARED_INFO.uCurrentClipNumber) || ((SHARED_INFO.uCurrentClipNumber == 1) && ((SHARED_INFO.cieCurrClip).bIsExtendedInfoAvailable == FALSE)) )
- {
- //Angie_0810_2004:Move the MP3 and WMA extend info from gns to SCPAD for I86 memory reducing.
- if(gns.clips.cieCurrClip.ExtInfo_sc_handle == NULL)
- gns.clips.cieCurrClip.ExtInfo_sc_handle = SC_CLIPS_EXTINFO_ADDR;
- (SHARED_INFO.cieCurrClip).bIsExtendedInfoAvailable=
- Clip_getExtendedInfo(hClipInstance, gns.clips.cieCurrClip.ExtInfo_sc_handle);
- //LeonHe_2005_0519: Jump out directly when Failed to read the MP3 Head.
- if(isFailedToReadMP3Head)
- {
- isFailedToReadMP3Head = FALSE;//Clear the Flag
- return FALSE;
- }
- }
- #else
- (SHARED_INFO.cieCurrClip).bIsExtendedInfoAvailable= FALSE;
- #endif //CLIPS_ACQUIRE_EXTENDED_INFO
- // Move into Playback State
- if (PST_PAUSE == gcs.pstate) {
- #ifdef CLIPS_PROHIBIT_PAUSE_ACROSS_ITEM_BOUNDARIES
- // For Still-Images, force Persistent-Pause
- if (!Clip_hasAttribute(hClipInstance, eCA_StillImage))
- gcs.pstate= PST_PLAY;
- #endif //CLIPS_PROHIBIT_PAUSE_ACROSS_ITEM_BOUNDARIES
- }
- else if ((PST_STILL != gcs.pstate) ||
- !Clip_hasAttribute(hClipInstance, eCA_StillImage))
- {
- gcs.pstate= PST_PLAY;
- }
- // Initiate Error-Recovery
- (g_pClipsNav->m_ErrorRecoveryInfo).uRetryCount= CLIPS_ERROR_RECOVERY_RETRY_COUNT;
- // If the current Clip isn't a Still-Image, display the Logo or Background
- if ( !Clip_hasAttribute(hClipInstance, eCA_StillImage)
- && ( eClipType_MPEG != Clip_getType(hClipInstance) )
- && ( eClipType_AVI != Clip_getType(hClipInstance) )
- #ifdef IS_ASF_CAPABLE
- && ( eClipType_ASF != Clip_getType(hClipInstance) )
- #endif
- #ifdef IS_MP4_CAPABLE
- && ( eClipType_MP4 != Clip_getType(hClipInstance) )
- #endif
- && SHARED_INFO.bDisplayLogoWhenPlayAudioOnlySteam) {
- #ifdef CLIPS_DISPLAY_BACKGROUND
- PE_Clips_DisplayBackground();
- #else
- PE_Clips_DisplayLogo();
- #endif //CLIPS_DISPLAY_BACKGROUND
- }
- else {
- #ifdef CLIPS_DISPLAY_BACKGROUND
- if ( ( eClipType_MPEG != Clip_getType(hClipInstance) ) &&
- ( eClipType_AVI != Clip_getType(hClipInstance) )
- #ifdef IS_ASF_CAPABLE
- && ( eClipType_ASF != Clip_getType(hClipInstance) )
- #endif
- #ifdef IS_MP4_CAPABLE
- && ( eClipType_MP4 != Clip_getType(hClipInstance) )
- #endif
- )
- // Clear the Background for a Still-Image
- PE_Clips_ClearBackground();
- #endif //CLIPS_DISPLAY_BACKGROUND
- }
-
- //FW0329_2005A Upate before activate subtitle menu. Fix null instance when press NEXT
- //Robin_1112_2004, for display the clip list menu if can't auto playback the first clip
- SHARED_INFO.uCurrentClipNumber= uClipNum;
- // Check if the playback needs to be resumed, or not
- if ((ULONG)-1 != (g_pClipsNav->m_cmResumeMarker).dwAddress)
- pResumeMarker= &g_pClipsNav->m_cmResumeMarker;
- else
- pResumeMarker= NULL;
- // <<< Robin_0903_2004
- #ifdef DIVX_SUPPORT_MULTI_SUBTITLE_MODE0
- if (((eClipType_AVI == Clip_getType(hClipInstance))
- #ifdef IS_ASF_CAPABLE
- || (eClipType_ASF == Clip_getType(hClipInstance))
- #endif
- #ifdef IS_MP4_CAPABLE
- || (eClipType_MP4 == Clip_getType(hClipInstance))
- #endif
- ) && ((SHARED_INFO.cieCurrClip).ciInfo.wSubFileCnt > 1) &&
- (bNeedWaitForUI == TRUE))
- {
- ie_send_ex(IE_UI_DIVX_EXTERNAL_SUBTITLE_SELECTION, 0);
- Set_SubFile_Count(((SHARED_INFO.cieCurrClip).ciInfo.wSubFileCnt));
- gcs.pstate = PST_WAIT_UI; // RB_TBD
- return TRUE;
- }
- #endif
- // >>> Robin_0903_2004
- if ((eClipType_AVI == Clip_getType(hClipInstance))
- #ifdef IS_ASF_CAPABLE
- || (eClipType_ASF == Clip_getType(hClipInstance))
- #endif
- #ifdef IS_MP4_CAPABLE
- || (eClipType_MP4 == Clip_getType(hClipInstance))
- #endif
- )
- {
- //Prohibit continuously do the skipf and skpb for AVI, and it will be set after calling the Clip_startPlayback if allowed
- CLEAR_COP_MASK(COP_NEXT_CHAPTER);
- CLEAR_COP_MASK(COP_PREVIOUS_CHAPTER);
-
- CLEAR_COP_MASK(COP_PAUSE);
- CLEAR_COP_MASK(COP_STEP);
-
- CLEAR_COP_MASK(COP_SCAN | COP_SCAN_BACKWARD );
- #ifndef AVI_FF_NO_INDEX
- // If this is an AVI file in which the idx processing failed, don't allow resuming
- if(FALSE == _bMPEG4TrickModeOn)
- pResumeMarker = NULL;
- #endif
- }else
- {
- //Invalidate MPEG4 index
- _uiMPEG4ProcessedFileAddr= (UINT32)-1;
- }
- // Override the Transition-Effect, if required
- if (bOverrideTransition) {
- Clip_setTransitionEffect(hClipInstance, eCTE_None);
- SHARED_INFO.eCurrentTransition=eCTE_None;//angieh_0822_2003_A Override the Transition-Effect.
- }
- else {
- Clip_setTransitionEffect(hClipInstance, SHARED_INFO.eCurrentTransition);
- }
- // Start/Resume Playback
- if (!Clip_startPlayback(hClipInstance, pResumeMarker, FALSE)) {
- dbg_printf(("WARNING: invokePlayback() Failed [3]: Cannot play clip.n"));
- #ifdef DIVX_SUPPORT_MULTI_SUBTITLE_MODE0
- bNeedWaitForUI = FALSE;
- #endif
- return FALSE;
- }
- // Clear any Resume Marker
- (g_pClipsNav->m_cmResumeMarker).dwAddress= (ULONG)-1;
- // Update the shared info for the current Clip
- // SHARED_INFO.uCurrentClipNumber= uClipNum;
- SHARED_INFO.iCurrentTime= (int)Clip_getTime(hClipInstance);
- SHARED_INFO.eCurrentAngle= (UINT8)Clip_getOrientation(hClipInstance);
- #ifdef MANUAL_DIRECTORY_EXPLORER
- notifyUIOnBrowserContentChange(eCLIPS_UPDATE_NONE, eCLIPS_UPDATE_INDEX);
- #endif
- ie_send(IE_UI_CLIPS_CLEAR_UI);
- if ((eClipType_AVI == Clip_getType(hClipInstance))
- #ifdef IS_ASF_CAPABLE
- || (eClipType_ASF == Clip_getType(hClipInstance))
- #endif
- #ifdef IS_MP4_CAPABLE
- || (eClipType_MP4 == Clip_getType(hClipInstance))
- #endif
- )
- {
- SET_COP_MASK(COP_PAUSE);
- SET_COP_MASK(COP_STEP);
- }
-
- if(IsGotoNextChapterAllowed())
- SET_COP_MASK(COP_NEXT_CHAPTER);
- else
- CLEAR_COP_MASK(COP_NEXT_CHAPTER);
-
- if (IsGotoPreviousChapterAllowed())
- SET_COP_MASK(COP_PREVIOUS_CHAPTER);
- else
- CLEAR_COP_MASK(COP_PREVIOUS_CHAPTER);
-
- if (Clip_hasAttribute(hClipInstance, eCA_Zoomable))
- SET_COP_MASK(COP_ZOOM);
- else
- CLEAR_COP_MASK(COP_ZOOM);
- if (Clip_hasAttribute(hClipInstance, eCA_Scanable))
- SET_COP_MASK( COP_SCAN | COP_SCAN_BACKWARD );
- else
- CLEAR_COP_MASK(COP_SCAN | COP_SCAN_BACKWARD );
- if (Clip_hasAttribute(hClipInstance, eCA_Slowable))
- SET_COP_MASK(COP_STEP | COP_SLOW );
- else
- CLEAR_COP_MASK(COP_STEP | COP_SLOW);
- if ( Clip_hasAttribute(hClipInstance, eCA_Markable))
- SET_COP_MASK( COP_ABREPEAT | COP_TIME_PLAY );
- else
- CLEAR_COP_MASK( COP_ABREPEAT | COP_TIME_PLAY );
-
- // Renew Pause
- if (PST_PAUSE == gcs.pstate)
- OnStop(ePause);
- // dbg_printf(("Playing clip: %sn", DBG_W2A((SHARED_INFO.cieCurrClip).ciInfo.szFilename)));
- // memset(szTempFilename, 0, sizeof(szTempFilename));
- // sc_GetBytes(SC_CLIPS_CURRENT_FILENAME_ADDR, (WORD)0, (WORD)(SC_CLIPS_CURRENT_FILENAME_SZ*4), (BYTE*)szTempFilename);
- // dbg_printf(("Playing clip: %sn", DBG_W2A(szTempFilename));
-
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // computePlaylistItem()
- //
- // Description: Computes the next/previous Playlist-Item to play.
- //
- // Input: uCurrItem - The index of the current Item, as a reference;
- // bNext - Indicates whether to compute the Next Item, or Previous.
- // Output: None
- // In/Out: None
- // Return: The 1-based index in the Play-List of the requested Item; Zero if
- // there is no such Item.
- //
- // Remarks:
- // The Item is selected based on the setting of the Playback-Filter,
- // if one is in effect.
- static UINT16 computePlaylistItem(UINT16 uCurrItem, BOOL bNext)
- {
- UINT16 uPos, uRequestedItem;
- UINT16 uClipNumber, hClipInstance;
- UINT16 uProgramSize= PM_GetProgramSize();
- if (0 == uProgramSize)
- return 0;
- uRequestedItem= 0;
- // Initialize the search, according to the selected direction
- if((eWINDOWS_EXPLORER_STYLE == SHARED_INFO.eWindowsExplorerStyleBrowser)
- && eSingleItem == SHARED_INFO.uExplorerStyleBrowserPlayMode)
- uPos= uCurrItem;
- else
- if (PM_IsRepeatSingle())
- uPos= uCurrItem;
- else
- uPos= uCurrItem + (bNext ? 1 : -1);
- while (TRUE)
- {
- // Check the termination condition
- if ( (bNext && (uPos > (uProgramSize - 1))) ||
- (!bNext && (uPos == 0)) )
- {
- break;
- }
- // Acquire the Clip-Instance corresponding to the current Item
- uClipNumber= PM_GetProgramListEntry(uPos);
- hClipInstance= ClipsRepository_getInstanceAt(uClipNumber-1);
- if (NULL != hClipInstance) {
- // Examine the Clip's Type to see if it is included in the Playback Filter
- if (g_uPlaybackFilter & (UINT16)Clip_getType(hClipInstance)) {
- if ( ( ( SHARED_INFO.bIsIntroPlayMode ) && ( Clip_getType(hClipInstance) == eClipType_MP3 ) )
- || ( !SHARED_INFO.bIsIntroPlayMode )
- || (eWINDOWS_EXPLORER_STYLE == SHARED_INFO.eWindowsExplorerStyleBrowser)) // allow JPEG intro mode, ...
- {
- uRequestedItem= uPos;
- break;
- }
- }
- }
- // Move to the next/previous Item
- uPos += (bNext ? 1 : -1);
- }
- return uRequestedItem;
- }
- /////////////////////////////////////////////////////////////////////////////
- // cancelRepeatModes()
- //
- // Description: Cancels the specific Repeat-Modes, if any exist.
- //
- // Input: uModesMask - A mask specifying which Repeat-Modes to cancel
- // Output: None
- // In/Out: None
- // Return: None
- //
- // Remarks: None
- static void cancelRepeatModes(BYTE uModesMask)
- {
- BOOL bRepeatModeChanged= FALSE;
- // Cancel "Repeat Single" if it is in effect
- if ((uModesMask & PM_REPEAT_SINGLE) && PM_IsRepeatSingle()) {
- PM_SetRepeatSingle(FALSE);
- bRepeatModeChanged= TRUE;
- }
- // Cancel "Repeat All" if it is in effect
- if ((uModesMask & PM_REPEAT_ALL) && PM_IsRepeatAll()) {
- PM_SetRepeatAll(FALSE);
- bRepeatModeChanged= TRUE;
- }
- // Cancel "Repeat Folder" if it is in effect
- if ((uModesMask & PM_REPEAT_FOLDER) && PM_IsRepeatFolder()) {
- PM_SetRepeatFolder(FALSE);
- bRepeatModeChanged= TRUE;
- }
- if ((uModesMask & PM_REPEAT_AB_MASK) && (0 != PM_GetRepeatAB())) {
- PM_SetRepeatAB(0);
- OnCancelABRepeat();
- bRepeatModeChanged= TRUE;
- }
- if (bRepeatModeChanged)
- ie_send(IE_UI_STATE_CHANGE);
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // Event Handlers
- /////////////////////////////////////////////////////////////////////////////
- // OnFindClips()
- //
- // Description: A handler for the IE_CDNAV_RENDEZVOUS Event.
- //
- // Input: uTypesToFind - A bitwise-OR combination of the Clip-Types to find
- // Output: None
- // In/Out: None
- // Return: None
- //
- // Remarks:
- // This handler is responsible for automatically collecting Clips of some
- // Types.
- // It is triggered by a call to Clips_findClips().
- static void OnFindClips(UINT16 uTypesToFind)
- {
- BOOL bCWD_Established= TRUE;
-
- ClipsRepository_setTypeFilter(uTypesToFind);
- // init the Clips-List
- ClipsRepository_clear();
- // Set the appropriate Working-Directory for the search:
- // Switch the the Root directory
- if (!FileSys_goToRootDir()) {
- tr_printf(("FATAL: OnFindClips() Failed [1]: Cannot access the Root Directory.n"));
- bCWD_Established= FALSE;
- }
- // For Picture-CD, enter the "PICTURES" directory
- if (bCWD_Established &&
- (DEC_DISC_TYPE_PICTURE_CD == g_disc_type) &&
- !FileSys_changeDir(L"PICTURES"))
- {
- tr_printf(("FATAL: OnFindClips() Failed [2]: Cannot access 'PICTURES' Directory.n"));
- bCWD_Established= FALSE;
- }
- if(!bCWD_Established)
- {
- tr_printf(("FATAL: OnFindClips() Failed [3]n"));
- }
-
-
- #ifdef MANUAL_DIRECTORY_EXPLORER
- if(eWINDOWS_EXPLORER_STYLE == SHARED_INFO.eWindowsExplorerStyleBrowser)
- {
- #if defined (EXINO2) && defined(MP3_SUBFOLDER_AUTOPLAY)
- if(g_bClipsAutoplay)
- Browser_Build(eBuildAll, FALSE);
- else
- #endif
- #ifndef OPEN_CLIPS_AFTER_ONFINDCLIPS_COMPLETED
- Browser_Build(eBuildAll, TRUE);
- #else
- Browser_Build(eBuildAll, FALSE);
- ie_send(IE_UI_CLOSE_MENU);
- //MikeLv_0715 add this for auto play KODAK picture CD in directory_explorer mode.
- #ifdef D_AUTO_PLAY_KODAK_PICTURE_CD_IN_BROWSER_MODE
- if(DEC_DISC_TYPE_PICTURE_CD == g_disc_type)
- {
- if (! invokePlayback(FALSE))
- {
- tr_printf(("FATAL:OnFindClips()[4]: Failed to play-backn"));
- gcs.pstate= PST_STOP;
- return;
- }
- }
- #endif
- #endif
- }
- else
- #endif
- {
- ArrayInitBound(SHARED_INFO.hDirsArray[0], 0);
- // Start a recursive search for Clips, starting at the current directory
- _findAndAddClips(CLIPS_MAX_PROGRAM_SIZE, TRUE);
- ArrayInitBound(SHARED_INFO.hDirsArray[0], 0);
- // Finalize the Clips-List
- Clips_finalizeClipsList();
- #ifdef SUPPORT_FLASH_CARD
- if(!IS_PLAYING_CARD)
- #endif
- FileSys_close(); //MikeX_1125_2003: free scratch pad after searching clips
- #ifdef MANUAL_DIRECTORY_EXPLORER
- notifyUIOnBrowserContentChange(eCLIPS_UPDATE_ALL, eCLIPS_UPDATE_ALL);
- #endif
- }
- return;
- }
- /////////////////////////////////////////////////////////////////////////////
- // OnTick()
- //
- // Description: A handler for the IE_CORE_TICK_250 Event.
- //
- // Input: None
- // Output: None
- // In/Out: None
- // Return: None
- //
- // Remarks:
- // This handler is responsible for issuing an IE_CORE_CDNAV_FINISHED Event.
- // The handler checks whether the playback of the current Item has finished
- // by examining both the Drive's status and the fullness of the Audio-Code
- // buffer.
- static void OnTick()
- {
- UINT16 hClipInstance;
- enClipStatus eStatus;
- int currentTime;
- #ifdef V882_FLASH_CARD
- if(TRUE == FlashCard_IsCardRemoved()){
- if(PST_STOP != gcs.pstate){
- OnStop(eFullStop);
- }
- return;
- }
- #endif
- if (0 == SHARED_INFO.uCurrentClipNumber)
- return;
- #ifdef CLIPS_JPEG_DIGEST_SUPPORT
- // Nothing to do in Digest Mode except check if new line ready to copy
- if (g_pClipsNav->m_bDigestMode)
- {
- if( TRUE == DEC_JPEG_IsNewLineReady() )
- {
- DEC_JPEG_DecodeDoneCheck();
- }
- return;
- }
- #endif //CLIPS_JPEG_DIGEST_SUPPORT
- if(IsGotoNextChapterAllowed())
- SET_COP_MASK(COP_NEXT_CHAPTER);
- else
- CLEAR_COP_MASK(COP_NEXT_CHAPTER);
- if (IsGotoPreviousChapterAllowed())
- SET_COP_MASK(COP_PREVIOUS_CHAPTER);
- else
- CLEAR_COP_MASK(COP_PREVIOUS_CHAPTER);
- hClipInstance= ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1);
- // Refersh the current Clip
- Clip_refresh(hClipInstance);
- // Refresh any Cached Clip
- if (NULL != g_pClipsNav->m_hCachedClip)
- Clip_refresh(g_pClipsNav->m_hCachedClip);
- // Update the current Clip-Time
- {
- int backup;
- backup = SHARED_INFO.iCurrentTime;
-
- SHARED_INFO.iCurrentTime = (int)Clip_getTime(hClipInstance);
- if( ((SHARED_INFO.iScanSpeed > 0) && (backup > SHARED_INFO.iCurrentTime)) || PST_STOP == gcs.pstate )// Robin_0604_2004_B
- {
- SHARED_INFO.iCurrentTime = backup;
- }
- }
- #ifdef D_ENABLE_JPEG_CACHE
- //get caching/cached clip status
- if((hClipInstance != g_pClipsNav->m_hCachedClip)&&(NULL != g_pClipsNav->m_hCachedClip))
- {
- if( (eCS_Finished == Clip_getStatus(g_pClipsNav->m_hCachedClip))
- && (PST_STOP != gcs.pstate)
- #ifdef CLIPS_JPEG_DIGEST_SUPPORT
- &&(!g_pClipsNav->m_bDigestMode)
- #endif
- &&(!g_pClipsNav->m_bPresentationMode) )
- {
- _onPresentationFinished();
- }
- }
- #endif
-
- //get current clip status
- eStatus= Clip_getStatus(hClipInstance);
- if (eCS_Finished == eStatus) {
- // Detect Playback-finish
- if ((PST_STOP != gcs.pstate && PST_WAIT_UI != gcs.pstate) &&
- #ifdef CLIPS_JPEG_DIGEST_SUPPORT
- !g_pClipsNav->m_bDigestMode &&
- #endif //CLIPS_JPEG_DIGEST_SUPPORT
- !g_pClipsNav->m_bPresentationMode)
- {
- dbg_printf(("Finished playback.n"));
- ie_send(IE_CORE_CDNAV_FINISHED);
- }
- }
- else {
- // Skip to next intro item
- if ( ( SHARED_INFO.bIsIntroPlayMode ) && ( SHARED_INFO.iCurrentTime >= CLIPS_INTRO_PLAY_TIME ) )
- {
- OnPlaybackFinished();
- #ifdef MANUAL_DIRECTORY_EXPLORER
- SHARED_INFO.iCurrentTime = 0; //BillTang_0714_2004: to avoid problem in EXPLORER clips menu
- #endif
- return;
- }
- // Perform error recovery in case needed
- PerformErrorRecovery(hClipInstance, eStatus);
- }
- // Take care of A2B Mode for MP3 Clips
- if (PM_GetRepeatAB() & PM_REPEAT_AB_B){
- if(SI_IS_CURRENT_MPEG_CLIP){
- DWORD dwCurrentLocation = PE_CD_GetCurrentLocation();
-
- if ( dwCurrentLocation > (g_pClipsNav->m_PositionB.dwAddress ) ){
- UINT32 Param= ((UINT32)ePositionB << 16);
-
- ie_send_ex(IE_CORE_CDNAV_RENDEZVOUS, (void *)Param);
- }
- }else{
- currentTime = gns.clips.iCurrentTime;
- if ( currentTime> (g_pClipsNav->m_PositionB.uTime) ){
- UINT32 Param= ((UINT32)ePositionB << 16);
-
- ie_send_ex(IE_CORE_CDNAV_RENDEZVOUS, (void *)Param);
- }
- }
- }else{
- if ( PM_REPEAT_AB_A && PM_GetRepeatAB()){
- if ( g_pClipsNav->m_PositionA.uClipNumer != gns.clips.uCurrentClipNumber )
- cancelRepeatModes(PM_REPEAT_AB_MASK);
- }
- }
-
- return;
- }
- /////////////////////////////////////////////////////////////////////////////
- // OnPlay()
- //
- // Description: A handler for the IE_CORE_PLAY Event.
- //
- // Input: None
- // Output: None
- // In/Out: None
- // Return: None
- //
- // Remarks: None
- static void OnPlay()
- {
- BOOL bOverrideTransition= FALSE;
- dbg_printf(("OnPlay()n"));
- #ifdef I77_COMPANION_CHIP
- // andyc: check and makesure SPDIF is N'Sync
- {
- extern BOOL I77_resetSpdifIfNeeded(void);
- I77_resetSpdifIfNeeded() ;
- }
- // andyc: check and makesure SPDIF is N'Sync
- #endif//I77_COMPANION_CHIP
- // Verify the necessity to actually invoke playback
- if (PST_PLAY == gcs.pstate) {
- dbg_printf(("Already in Playback state. Ignored.n"));
- return;
- }
- #ifdef CLIPS_JPEG_DIGEST_SUPPORT
- // Terminate Digest-Mode, if it is in effect
- if (g_pClipsNav->m_bDigestMode) {
- bOverrideTransition= TRUE;
- _terminateDigestMode();
- }
- #endif //CLIPS_JPEG_DIGEST_SUPPORT
- #ifdef CLIPS_WMA_STOPRESUME_PATCH
- if( (PST_PAUSE == gcs.pstate) ||
- ( (eClipType_WMA== (gns.clips.cieCurrClip).ciInfo.eType)&&(gcs.pstate == PST_STOP)&&
- ((ULONG)-1 != (g_pClipsNav->m_cmResumeMarker).dwAddress) ) )
- #else
- // If the current state is Pause, then resume playback
- if( PST_PAUSE == gcs.pstate )
- #endif
- {
- UINT16 hClipInstance= ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1);
- gcs.pstate = PST_PLAY;
- if (Clip_hasAttribute(hClipInstance, eCA_StillImage) )
- {
- if( TRUE == g_pClipsNav->m_bPresentationMode)
- _onPresentationFinished();
- }
- else
- {
- Clip_pausePlayback(hClipInstance, FALSE);
- }
- return;
- }
- else if (PST_STOP == gcs.pstate) {
- bOverrideTransition= TRUE;
- }
- //Cancel Scan Mode
- if ( PST_SCAN == gcs.pstate ){
- OnScan(0);
- gcs.pstate= PST_PLAY;
- return;
- }
- if ( PST_SLOW == gcs.pstate ) {
- if ( gns.clips.iSlowSpeed > 0 ){
- PE_CD_SetSlowMotion(FALSE, (UINT8)0);
- gcs.pstate= PST_PLAY;
- }
- else
- {
- OnScan(0);
- gcs.pstate= PST_PLAY;
- }
- return;
- }
-
- //handle the case pressed 'Play' during still state
- if (PST_STILL == gcs.pstate)
- {
- UINT16 hClipInstance= ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1);
- //cancel the rotation if exist
- if ( eCIO_Original != Clip_getOrientation(hClipInstance) )
- {
- Clip_setOrientation(hClipInstance, eCIO_Original);
- }
- //Disable the timer to avoid black screen sometime because of timeout.
- //the timer will be enabled again in OnPlaybackFinished automatically after current playback finished
- if(timer_service_is_active(g_pClipsNav->m_hPresentationTimer))
- timer_service_disable(g_pClipsNav->m_hPresentationTimer);
- }
- // <<< Robin_0903_2004
- #ifdef DIVX_SUPPORT_MULTI_SUBTITLE_MODE0
- bNeedWaitForUI = !bNeedWaitForUI;
- #endif
- // >>> Robin_0903_2004
- gcs.pstate= PST_PLAY;
- if (! invokePlayback(bOverrideTransition)) {
- tr_printf(("FATAL: Failed to invoke playbackn"));
- gcs.pstate= PST_STOP;
- }
- return;
- }
- #pragma argsused
- static void OnPresentationTimeExpired(UINT8 hTimer)
- {
- UINT32 Param= ((UINT32)eTimerRendezvous << 16);
- ie_send_ex(IE_CORE_CDNAV_RENDEZVOUS, (void*)Param);
- }
- static void OnGetClipInfoForUI(ClipInfo *o_pClipFileInfo)
- {
- #ifdef MANUAL_DIRECTORY_EXPLORER
- if(SHARED_INFO.iGetClipFileInfoAtNumber <= SUB_DIR_ARRAY_SIZE)
- {
- Browser_GetFolderInfo(SHARED_INFO.iGetClipFileInfoAtNumber, o_pClipFileInfo, eRIGHT_WINDOW);
- if(ui_enter_pressed && (SHARED_INFO.iGetClipFileInfoAtNumber != 1)) //vestel's request: no setup after subdir is entered
- {
- CLEAR_COP_MASK(COP_SETUP);
- ui_enter_pressed = 0;
- }
- }
- else
- #endif
- {
- UINT16 hInstance;
- hInstance = ClipsRepository_getInstanceAt(SHARED_INFO.iGetClipFileInfoAtNumber - 1 - SUB_DIR_ARRAY_SIZE);
- // Make sure that the requested Position is legal
- if (NULL == hInstance) {
- dbg_printf(("WARNING: Clips_getClipFileInfoAt() Failed [1]: Illegal Clip-Number requested.n"));
- o_pClipFileInfo->cbFileSize = eClipInfoNotAvailable;
- return ;
- }
- // Extract the Clip-Info corresponding to the requested Clip
- Clip_getFileInfo(hInstance, o_pClipFileInfo);
- }
- o_pClipFileInfo->cbFileSize = eClipInfoReadyForUI;
- return;
- }
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : OnRendezvous
- //
- // Purpose : Handling the IE_CORE_CDNAV_RENDEZVOUS event
- //
- // Input Parameters : none
- //
- // Return Value : static void
- //
- // Description : checking the Param in order to know which handler to call.
- //////////////////////////////////////////////////////////////////////////////////
- static void OnRendezvous(void *Param)
- {
- enRendezvousType eType;
- UINT32 uParam= (UINT32)Param;
- dbg_printf(("OnRendezvousn"));
- eType= (enRendezvousType)(uParam >> 16);
- if (eFindClipRendezvous == eType)
- {
- OnFindClips((UINT16)(uParam & 0xFFFF));
- }
- else
- {
- if ( ( ePositionA == eType ) || ( ePositionB == eType ) )
- {
- dbg_printf(("Position%c Encountered.n", (ePositionA == eType) ? 'A' : 'B'));
- if (g_pClipsNav->m_PositionA.uTime != -1) //Don't jump to point A if the bookmark has already been cleared.
- {
- PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
- memcpy(&(g_pClipsNav->m_cmResumeMarker), &(g_pClipsNav->m_PositionA), sizeof(ClipMarker));
- // <<< 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;
- }
- ie_send(IE_UI_STATE_CHANGE);
- }
- }
- else
- {
- #ifdef D_ENABLE_JPEG_CACHE
- UINT16 hClipInstance= ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1);
- // If there is any caching in progress, only cancel presentation mode
- if ( ((NULL != g_pClipsNav->m_hCachedClip)
- &&(hClipInstance != g_pClipsNav->m_hCachedClip)
- &&(eCS_Finished != Clip_getStatus(g_pClipsNav->m_hCachedClip))) )
- {
- tr_printf(("npresentation expired while JPEG cachingn"));
- // Cancel Presentation-Mode
- g_pClipsNav->m_bPresentationMode= FALSE;
- }
- else
- #endif
- {
- _onPresentationFinished();
- }
- }
- }
- }
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : _onPresentationFinished
- //
- // Purpose : Performing the playback finished operations only after the
- // presentation time of the clip is finished.
- // Determine the next item to play.
- // Input Parameters : none
- //
- // Return Value : static void
- //
- // Description :
- //////////////////////////////////////////////////////////////////////////////////
- static void _onPresentationFinished(void)
- {
- UINT16 uNextItem;
-
- UINT16 hClipInstance= ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1);
- tr_printf(("_onPresentationFinished()n"));
- // Force a Full-Stop, just in case
- Clip_abortPlayback(hClipInstance, TRUE);
-
- // if(eClipType_WMA != SHARED_INFO.cieCurrClip.ciInfo.eType)//no need for WMA since sometime cause massage pool full
- // ie_send(IE_UI_CLIPS_CLEAR_UI); //ZCO LC040703: Clear UI temp messages such as Q1..Q5 etc.
- // Check if the Playback-Mode is "Single Repeat". If so, reschedule playback of the
- // current Playlist-Item again.
- if (PM_IsRepeatSingle()) {
- // <<< Robin_0903_2004
- #ifdef DIVX_SUPPORT_MULTI_SUBTITLE_MODE0
- bNeedWaitForUI = FALSE;
- #endif
- // >>> Robin_0903_2004
- // Re-invoke playback only if this Clip is not a Still Image
- if (!Clip_hasAttribute(hClipInstance, eCA_StillImage) &&
- !invokePlayback(FALSE))
- {
- tr_printf(("FATAL: F_onPresentationFinished() ailed to invoke playbackn"));
- gcs.pstate= PST_STOP;
- }
- //allow change play mode from track repeat to folder normal on the fly.
- if (Clip_hasAttribute(hClipInstance, eCA_StillImage))
- {
- UINT8 uPresentationTime;
- // Collect the Presentation-Time
- uPresentationTime= Clip_getPresentationTime(hClipInstance);
- if (0 != uPresentationTime)
- {
- // Move to Still
- gcs.pstate= PST_STILL;
- // Engage Presentation-Mode
- g_pClipsNav->m_bPresentationMode= TRUE;
- if (INFINITE_PRESENTATION_TIME != uPresentationTime) {
- dbg_printf(("INFO: Presentation-Timer set to %d seconds.n", uPresentationTime));
- timer_service_set_freq(g_pClipsNav->m_hPresentationTimer,
- (1000 * uPresentationTime));
- timer_service_enable(g_pClipsNav->m_hPresentationTimer, TRUE);
- }
- else {
- dbg_printf(("INFO: Infinite Presentation engaged.n"));
- }
- }
-
- }
- return;
- }
- if(PM_IsPlaybackRandom(PM_GetPlaybackMode()))
- {
- PM_ShuffleProgramList(FALSE, 0);
- SHARED_INFO.uCurrPlaylistItem = 0;
- }
- if((eWINDOWS_EXPLORER_STYLE == SHARED_INFO.eWindowsExplorerStyleBrowser)
- && eSingleItem == SHARED_INFO.uExplorerStyleBrowserPlayMode)
- {
- SHARED_INFO.uCurrPlaylistItem= 0;
- SHARED_INFO.uCurrentClipNumber= 0; //jerry cai May 16, 2003
- gcs.pstate= PST_STOP;
- CLEAR_COP_MASK(COP_SCAN | COP_SCAN_BACKWARD );
- #ifdef CLIPS_DISPLAY_BACKGROUND
- PE_Clips_DisplayBackground();
- #else
- PE_Clips_DisplayLogo();
- #endif //CLIPS_DISPLAY_BACKGROUND
- return;
- }
- // Compute the Next Item
- if ( ( PST_SCAN == gcs.pstate ) && ( 0 > SHARED_INFO.iScanSpeed ) ||
- ( PST_SLOW == gcs.pstate ) && ( 0 > SHARED_INFO.iSlowSpeed ) )
- // Also should consider the condition of Slow-Rev.
- // Jeanz, 2004_4_20
- {
- uNextItem= SHARED_INFO.uCurrPlaylistItem;
- gcs.pstate = PST_PLAY;
- SHARED_INFO.iScanSpeed = 0;
- }
- else
- uNextItem= computePlaylistItem(SHARED_INFO.uCurrPlaylistItem, TRUE);
- // Take care of Repeat-Folder
- if (PM_IsRepeatFolder()
- && (eSingle_LIST_STYLE == SHARED_INFO.eWindowsExplorerStyleBrowser))
- {
- UINT16 uNextClipNumber, hNextClipInstance;
- WCHAR szTempDirectoryName[SC_CLIPS_CURRENT_DIRECTORY_SZ*2];
- LPCWSTR pszCurrFolder = szTempDirectoryName;//= (SHARED_INFO.cieCurrClip).ciInfo.szDirectoryName;
- ClipInfo ciInfo;
- memset(szTempDirectoryName, 0, sizeof(szTempDirectoryName));
- sc_GetBytes(SC_CLIPS_CURRENT_DIRECTORY_ADDR, (WORD)0, (WORD)(SC_CLIPS_CURRENT_DIRECTORY_SZ*4), (BYTE*)szTempDirectoryName);
- // Acquire the Clip-Info for the next Clip, if there is such
- if (0 != uNextItem) {
- uNextClipNumber= PM_GetProgramListEntry(uNextItem);
- hNextClipInstance= ClipsRepository_getInstanceAt(uNextClipNumber-1);
- Clip_getFileInfo(hNextClipInstance, &ciInfo);
- }
- // Check if the next Clip is within the current Folder
- if ((0 == uNextItem) ||
- (0 != wcscmp(pszCurrFolder, ciInfo.szDirectoryName)))
- {
- // The next Clip isn't within the current Folder: find the first
- // Clip in this Folder.
- UINT16 uPrevItem;
- uNextItem= SHARED_INFO.uCurrentClipNumber;
- uPrevItem= computePlaylistItem(uNextItem, FALSE);
- // Scan backwards, beginning with the current Clip
- while (0 != uPrevItem) {
- uNextClipNumber= PM_GetProgramListEntry(uPrevItem);
- hNextClipInstance= ClipsRepository_getInstanceAt(uNextClipNumber-1);
- Clip_getFileInfo(hNextClipInstance, &ciInfo);
- if (0 != wcscmp(pszCurrFolder, ciInfo.szDirectoryName))
- break;
- uNextItem= uPrevItem;
- uPrevItem= computePlaylistItem(uPrevItem, FALSE);
- }
- }
- }
- #ifdef MANUAL_DIRECTORY_EXPLORER
- else
- if(0 == uNextItem
- && (eWINDOWS_EXPLORER_STYLE == SHARED_INFO.eWindowsExplorerStyleBrowser)
- && PM_IsRepeatFolder())
- {
- uNextItem = computePlaylistItem(0, TRUE);
- }
- else//go to the following folder when the current working folder is finished.
- if(0 == uNextItem
- && (eWholeDisc == SHARED_INFO.uExplorerStyleBrowserPlayMode)
- && (eWINDOWS_EXPLORER_STYLE == SHARED_INFO.eWindowsExplorerStyleBrowser))
- {
- uNextItem = getFirstItemInSubFoldersOrNextFolders();
- }
- #endif
- //the whole disc has been finished.
- if (0 == uNextItem)
- {
- if(eSingle_LIST_STYLE == SHARED_INFO.eWindowsExplorerStyleBrowser)
- SHARED_INFO.uCurrPlaylistItem= computePlaylistItem(0, TRUE);
- #ifdef AUTO_REWIND_PLAYBACK_FOR_JPEG_DISCS
- // If the current playback-mode is not "Repeat All", then don't re-invoke the playback
- if (!PM_IsRepeatAll() && ( eClipType_JPEG != g_uAvailableClipTypes ) ) {
- #else
- // If the current playback-mode is not "Repeat All", then don't re-invoke the playback
- #ifdef D_REPEAT_PROGRAM_MODE
- //jeanz_2004_0916 For wma/mp3 repeat program
- if (! PM_IsRepeatAll() && !((PM_GetPlaybackMode() == PM_PLAYBACK_PROGRAM)
- &&( (eClipType_WMA == (gns.clips.cieCurrClip).ciInfo.eType) || (eClipType_MP3 == (gns.clips.cieCurrClip).ciInfo.eType)) ))
- {
- #else
- if (! PM_IsRepeatAll()) {
- #endif
- #endif
- // Cancel any current Repeat-Modes
- if(eWINDOWS_EXPLORER_STYLE != SHARED_INFO.eWindowsExplorerStyleBrowser)
- {
- cancelRepeatModes(PM_REPEAT_SINGLE | PM_REPEAT_ALL | PM_REPEAT_FOLDER);
- // PM_SetPlaybackMode(PM_PLAYBACK_NORMAL);
- // OnModeChange();
- #ifdef I77_COMPANION_CHIP
- if ( eClipType_JPEG == (gns.clips.cieCurrClip).ciInfo.eType)
- {
- JPEGClip_BeforeAbort();
- }
- #endif
- Clip_abortPlayback(hClipInstance, FALSE);
- }
- time_display = 0;
- gcs.pstate= PST_STOP;
- CLEAR_COP_MASK(COP_SCAN | COP_SCAN_BACKWARD );
- #ifdef CLIPS_DISPLAY_BACKGROUND
- #ifdef MERGE_FOR_A_CUSTOMER
- if ( eClipType_MPEG == (gns.clips.cieCurrClip).ciInfo.eType){
- Logo_selectSource(eBlackLogo);
- Logo_display();
- }
- #endif
- PE_Clips_DisplayBackground();
- #else
- PE_Clips_DisplayLogo();
- #endif //CLIPS_DISPLAY_BACKGROUND
- ie_send( IE_UI_CLOSE_MENU );
- return;
- }
- }
- else {
- SHARED_INFO.uCurrPlaylistItem= uNextItem;
- }
- // <<< Robin_0903_2004
- #ifdef DIVX_SUPPORT_MULTI_SUBTITLE_MODE0
- bNeedWaitForUI = TRUE;
- #endif
- // >>> Robin_0903_2004
- // Invoke playback of the next item on the Playlist
- if (! invokePlayback(FALSE)) {
- tr_printf(("FATAL:_onPresentationFinished()[2] Failed to play-back the next itemn"));
- // <<< Stivenz_0223_2005: If current chapter is unsupported then goto next.
- #ifdef D_MP4_SKIP_UNSUPPORTED_CHAPTER
- if(eClipType_MP4 == (gns.clips.cieCurrClip).ciInfo.eType && bMP4DRMDisable)
- {
- dbg_printf(("WARNING: will skip this unsupport chapter.n"));
- ie_send(IE_CORE_CDNAV_FINISHED);
- }
- #else
- gcs.pstate= PST_STOP;
- #endif
- return;
- }
- return;
- }
- /////////////////////////////////////////////////////////////////////////////
- // OnPlaybackFinished()
- //
- // Description: A handler for the IE_CORE_CDNAV_FINISHED Event.
- //
- // Input: None
- // Output: None
- // In/Out: None
- // Return: None
- //
- // Remarks:
- // This Event is dispatched whenever the current Clip has finished playback.
- // The handler will select the next Item on the Playlist and invoke its playback.
- // If the entire Playlist has been exhausted, it is rewound.
- static void OnPlaybackFinished()
- {
- UINT8 uPresentationTime;
- UINT16 uExpectedItem;
- UINT16 hClipInstance= ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1);
- tr_printf(("OnPlaybackFinished()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
- // Abort the current Playback
- Clip_abortPlayback(hClipInstance, TRUE);
- // Collect the Presentation-Time
- uPresentationTime= Clip_getPresentationTime(hClipInstance);
- //In case of JPEG intro mode, presentation time is 0.
- if(eWINDOWS_EXPLORER_STYLE == SHARED_INFO.eWindowsExplorerStyleBrowser
- && SHARED_INFO.bIsIntroPlayMode)
- uPresentationTime = 0;
-
- // Try caching the next item on the Playlist
- g_pClipsNav->m_hCachedClip= NULL;
- if ( ( PST_SCAN == gcs.pstate ) && ( 0 > SHARED_INFO.iScanSpeed ) ||
- ( PST_SLOW == gcs.pstate ) && ( 0 > SHARED_INFO.iSlowSpeed ) )
- // Also should consider the condition of Slow-Rev.
- // Jeanz, 2004_4_20
- {
- #ifdef MANUAL_DIRECTORY_EXPLORER
- uExpectedItem= SHARED_INFO.uCurrPlaylistItem;
- #else
- uExpectedItem= computePlaylistItem(SHARED_INFO.uCurrPlaylistItem, FALSE);
- #endif
- }
- else
- uExpectedItem= computePlaylistItem(SHARED_INFO.uCurrPlaylistItem, TRUE);
-
- if (0 != uExpectedItem && !PM_IsPlaybackRandom(PM_GetPlaybackMode())) {
- // Calculate the next expected Clip Number
- UINT16 uExpectedClipNumber= PM_GetProgramListEntry(uExpectedItem);
- // Acquire the Instance of the next expected Clip
- hClipInstance= ClipsRepository_getInstanceAt(uExpectedClipNumber-1);
- // Try caching, if possible
- if ((NULL != hClipInstance) && Clip_hasAttribute(hClipInstance, eCA_Cacheable)
- #ifdef I77_COMPANION_CHIP// Only do caching for SD-JPEG
- #ifdef I77_BRAIN_STORM
- && ( gcst.hd_jpeg_mode_preference == SD_JPEG_MODE )
- #else//I77_BRAIN_STORM
- && ( gps->hd_jpeg_mode_preference == SD_JPEG_MODE )
- #endif//I77_BRAIN_STORM
- #endif
- && !g_pClipsNav->m_bDigestMode
- && (eCIO_Original == Clip_getOrientation(ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1)))
- )
- {
- //cache only when not digest/rotation mode
- // Select the appropriate Transition for the Clip to cache
- Clip_setTransitionEffect(hClipInstance, SHARED_INFO.eCurrentTransition);
- dbg_printf(("Caching next clipn"));
- // Attempt Caching
- if (Clip_startPlayback(hClipInstance, NULL, TRUE)){
- g_pClipsNav->m_hCachedClip= hClipInstance;
- g_pClipsNav->m_bPresentationMode= TRUE;
- }
- }
- }
- // If the current state is Pause, then do nothing
- if (PST_PAUSE == gcs.pstate && eClipType_JPEG == SI_CLIPS_CURR_CLIP_INFO.ciInfo.eType) {
- // Engage Presentation-Mode
- g_pClipsNav->m_bPresentationMode= TRUE;
- return;
- }
- // Start the Presentation-Time Timer
- if (0 != uPresentationTime) {
- // Move to Still
- gcs.pstate= PST_STILL;
- // Engage Presentation-Mode
- g_pClipsNav->m_bPresentationMode= TRUE;
-
- if (INFINITE_PRESENTATION_TIME != uPresentationTime) {
- dbg_printf(("INFO: Presentation-Timer set to %d seconds.n", uPresentationTime));
- timer_service_set_freq(g_pClipsNav->m_hPresentationTimer,
- (1000 * uPresentationTime));
- if( gcs.mZoomLevel == NO_ZOOM && eClipType_JPEG == SI_CLIPS_CURR_CLIP_INFO.ciInfo.eType )//With zoom ,keep on the fly
- {
- //no auto presentation when rotation
- #ifndef EXINO2 //ZKR JK0428 : no stop auto presentation when rotation
- #if !defined(D_USE_TIMEOUT_FOR_JPG_TRICK)&&!defined(JPEG_KEEP_SLIDESHOW_AFTER_ROTATION)
- if ( eCIO_Original == Clip_getOrientation(ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1)) )
- #endif
- #endif //EXINO2
- timer_service_enable(g_pClipsNav->m_hPresentationTimer, TRUE);
- }
- }
- else {
- dbg_printf(("INFO: Infinite Presentation engaged.n"));
- }
- }
- else {
- // No Presentation-Time was set - presentation is finished
- _onPresentationFinished();
- }
- return;
- }
- /////////////////////////////////////////////////////////////////////////////
- // OnStop()
- //
- // Description: A handler for the IE_CORE_PAUSE or IE_CORE_STOP Event.
- //
- // Input: eType - The type of Stop being requested
- // Output: None
- // In/Out: None
- // Return: None
- //
- // Remarks: None
- static void OnStop(enStopType eType)
- {
- UINT16 hClipInstance= ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1);
- #ifdef CLIPS_JPEG_DIGEST_SUPPORT
- //checking if we are on digest mode
- if (g_pClipsNav->m_bDigestMode)
- {
- _terminateDigestMode();
- #ifdef CLIPS_DISPLAY_BACKGROUND
- PE_Clips_DisplayBackground();
- #else
- PE_Clips_DisplayLogo();
- #endif //CLIPS_DISPLAY_BACKGROUND
- gcs.pstate= PST_STOP;
- return;
- }
- #endif //CLIPS_JPEG_DIGEST_SUPPORT
- // Make sure that there's any Clip to stop
- if (NULL == hClipInstance)
- return;
- //disabling the timer
- timer_service_disable(g_pClipsNav->m_hPresentationTimer);
- // Cancel Intro Play Mode if Stop/Pause
- //SHARED_INFO.bIsIntroPlayMode = FALSE;
- switch (eType)
- {
- case ePause:
- dbg_printf(("OnPause()n"));
- if (!Clip_hasAttribute(hClipInstance, eCA_StillImage))
- Clip_pausePlayback(hClipInstance, TRUE);
- gcs.pstate= PST_PAUSE;
- break;
- case eStopResume:
- case eFullStop:
- dbg_printf(("OnStop()n"));
- #ifdef DIVX_SUPPORT_MULTI_SUBTITLE_MODE0
- bNeedWaitForUI = FALSE;
- #endif
- Clip_beforeStop(hClipInstance);
- if ((eStopResume == eType) &&
- Clip_hasAttribute(hClipInstance, eCA_Markable))
- {
- dbg_printf(("Recording current-position.n"));
- // Record the Resume-Marker
- //Sean_1213_2004
- switch((gns.clips.cieCurrClip).ciInfo.eType)
- {
- #ifdef CLIPS_WMA_STOPRESUME_FROM_CURRTRACK
- case eClipType_WMA :
- break;
- #endif
- #ifdef IS_OGG_VORBIS_CAPABLE
- case eClipType_OGG :
- break;
- #endif
- default:
- Clip_recordMarker(hClipInstance, &g_pClipsNav->m_cmResumeMarker);
- }
- //<<<Sean_1213_2004
- #ifdef CLIPS_WMA_STOPRESUME_PATCH
- if (!Clip_hasAttribute(hClipInstance, eCA_StillImage)&&(eClipType_WMA== (gns.clips.cieCurrClip).ciInfo.eType))
- Clip_pausePlayback(hClipInstance, TRUE);
- #endif
- }
- else {
- SHARED_INFO.iCurrentTime = 0;// Robin_0604_2004_B, current time reset 0 when full stop
- //add by wl033004 for set the play mode to normal after full stop
- #ifdef K1_WL
- if ( PM_IsPlaybackProgram(PM_GetPlaybackMode()) || PM_IsPlaybackIntro(PM_GetPlaybackMode())
- #ifdef D_ENABLE_SHUFFLE_MODE
- || PM_IsPlaybackShuffle(PM_GetPlaybackMode())
- #endif
- )
- {
- PM_SetPlaybackMode(PM_PLAYBACK_NORMAL);
- mode_set_private_program_size(0);
- OnModeChange();
- }
- #endif
- //add by wl033004 for set the play mode to normal after full stop
- (g_pClipsNav->m_cmResumeMarker).dwAddress= (ULONG)-1;
- }
- #ifdef I77_COMPANION_CHIP
- if ( eClipType_JPEG == (gns.clips.cieCurrClip).ciInfo.eType)
- {
- JPEGClip_BeforeAbort();
- }
- #endif
- #ifdef CLIPS_WMA_STOPRESUME_PATCH
- if((eClipType_WMA != (gns.clips.cieCurrClip).ciInfo.eType)||(eStopResume != eType))
- #endif
- Clip_abortPlayback(hClipInstance, (eStopResume == eType) ? TRUE : FALSE);
- #ifdef CLIPS_DISPLAY_BACKGROUND
- #ifdef MERGE_FOR_A_CUSTOMER
- if ( eClipType_MPEG == (gns.clips.cieCurrClip).ciInfo.eType){
- Logo_selectSource(eBlackLogo);
- Logo_display();
- }
- #endif
- PE_Clips_DisplayBackground();
- #else
- PE_Clips_DisplayLogo();
- #endif //CLIPS_DISPLAY_BACKGROUND
- // Cancel any current Repeat-Modes, except Folder
-
- if(eWINDOWS_EXPLORER_STYLE != SHARED_INFO.eWindowsExplorerStyleBrowser)
- if (eStopResume != eType) //BT0407: only full stop cancel repeat mode
- cancelRepeatModes(PM_REPEAT_SINGLE | PM_REPEAT_ALL | PM_REPEAT_AB_MASK);
-
- gcs.pstate= PST_STOP;
- if (!(IS_CLIPS_TYPE_WMA || IS_CLIPS_TYPE_MP3))
- ie_send(IE_UI_CLIPS_CLEAR_UI);
- #ifdef SLOW_STOP_FOR_CLIPS
- if ( eFullStop == eType )
- delay_us(1000000UL);
- #endif//SLOW_STOP_FOR_CLIPS
- CLEAR_COP_MASK(COP_SCAN | COP_SCAN_BACKWARD );
- break;
- }
- return;
- }
- /////////////////////////////////////////////////////////////////////////////
- // OnModeChange()
- //
- // Description: A handler for the IE_CORE_SEAMLESS_MODE_CHANGE Event.
- //
- // Input: None
- // Output: None
- // In/Out: None
- // Return: None
- //
- // Remarks:
- // The Seamless Mode-Change Event is triggered whenever the user switches
- // from Normal playback to Program/Shuffle or vice-versa.
- // The following behaviours are displayed:
- // 1. For a transition from Normal Playback to Shuffle or Random:
- // a. If the Playback status is "Stopped", then the entire Playlist is
- // shuffled.
- // b. If the Playback status is "Playing", then everything except the
- // current Item is shuffled, and the current Item is placed at the
- // head of the shuffled Playlist. Playback continues normally.
- //
- // 2. For a transition from Normal Playback to Program:
- // a. If the Playback status is "Stopped", nothing usual happens.
- // b. If the Playback status is "Playing", the playback is Stopped, and
- // then restarted from the first Item on the Program.
- // 3. For a transition from Any mode to Normal Playback:
- // The entire Playlist is reconstructed, and the current Item is
- // selected to be the current Item, if the current Playback status is
- // "Playing".
- static void OnModeChange()
- {
- dbg_printf(("OnModeChangen"));
- // Find-out what kind of mode has changed: the Playback-Mode or the Repeat-Mode
- // If the change is not in Playback-Mode, then nothing to do.
- if (g_pClipsNav->m_uCurrPlaybackMode == PM_GetPlaybackMode()) {
- dbg_printf(("No Playback-Mode change detected.n"));
- return;
- }
- // In case of a Playback-Mode change, cancel all current Repeat Modes
- // Cancel Intro Play Mode if Stop
- SHARED_INFO.bIsIntroPlayMode = FALSE;
-
- cancelRepeatModes(PM_REPEAT_SINGLE | PM_REPEAT_ALL | PM_REPEAT_FOLDER | PM_REPEAT_AB_MASK);
- // for explorer style browser only.
- SHARED_INFO.uExplorerStyleBrowserPlayMode = eSingleFolder;
- // Clear any Resume Marker
- (g_pClipsNav->m_cmResumeMarker).dwAddress= (ULONG)-1;
- // Detect a transition of type: Non-Shuffle -> Shuffle Or Random
- if ((! PM_IsPlaybackShuffle(g_pClipsNav->m_uCurrPlaybackMode) &&
- PM_IsPlaybackShuffle(PM_GetPlaybackMode())) ||
- PM_IsPlaybackRandom(PM_GetPlaybackMode()))
- {
- dbg_printf(("Non_Shuffle -> Shufflen"));
- // If the current Playback-Status is other than Stopped, shuffle the Program-List while
- // keeping the current item as the first item
- if (PST_STOP != gcs.pstate)
- PM_ShuffleProgramList(TRUE, SHARED_INFO.uCurrPlaylistItem);
- else
- PM_ShuffleProgramList(FALSE, 0);
- // Now set the Current-Item to the first possible Item
- SHARED_INFO.uCurrPlaylistItem= computePlaylistItem(0, TRUE);
- }
- // Detect a transition of type: Non-Normal -> Normal
- if (! PM_IsPlaybackNormal(g_pClipsNav->m_uCurrPlaybackMode) &&
- PM_IsPlaybackNormal(PM_GetPlaybackMode()))
- {
- UINT16 uEntry, uEntriesCnt;
- WORD uCurrClipIndex= (WORD)PM_GetProgramListEntry(SHARED_INFO.uCurrPlaylistItem);
- dbg_printf(("Non_Normal -> Normaln"));
- // Rebuild the Normal Program-List (sequential playback of the Tracks)
- uEntriesCnt= ClipsRepository_getSize();
- PM_InitializeProgramList();
- for (uEntry= 1; uEntry <= uEntriesCnt; uEntry++)
- PM_SetProgramListEntry((WORD)uEntry, (WORD)uEntry);
- // Now update the Current Item to point at the Entry holding the current-Clip,
- // if playback is currently in progress
- if (PST_STOP != gcs.pstate)
- SHARED_INFO.uCurrPlaylistItem= uCurrClipIndex;
- else
- #ifdef MANUAL_DIRECTORY_EXPLORER
- SHARED_INFO.uCurrPlaylistItem= computePlaylistItem(0, TRUE);
- #else
- SHARED_INFO.uCurrPlaylistItem= 1;
- #endif
- }
- // Detect a transition of type: Non-Program -> Program
- if (! PM_IsPlaybackProgram(g_pClipsNav->m_uCurrPlaybackMode) &&
- PM_IsPlaybackProgram(PM_GetPlaybackMode()))
- {
- dbg_printf(("Non-Program ->Program n"));
- #ifdef MANUAL_DIRECTORY_EXPLORER
- SHARED_INFO.uCurrPlaylistItem= computePlaylistItem(0, TRUE);
- #else
- // Reset the Playback Filter
- g_uPlaybackFilter= g_uAvailableClipTypes;
- SHARED_INFO.uCurrPlaylistItem= 1;
- #endif
- if (PST_STOP != gcs.pstate) {
- Clip_abortPlayback(ClipsRepository_getInstanceAt(SHARED_INFO.uCurrentClipNumber-1),
- TRUE);
- 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 re-invoke playback after playback-mode changen"));
- gcs.pstate= PST_STOP;
- }
- }
- }