BOOL ModeUpdateUIBackgroud_CheckEng(void) { BOOL ret = FALSE; FST_FILE filehdl = NULL; filehdl = FileSys_OpenFile(UPDATE_FILE,FST_OPEN_READ); if (filehdl!=NULL) { FileSys_CloseFile(filehdl); ret = TRUE; } return ret; }
BOOL ModeCalibration_CheckEng(void) { BOOL ret = FALSE; FST_FILE filehdl = NULL; filehdl = FileSys_OpenFile(ENG_MODE_FILE,FST_OPEN_READ); if (filehdl!=NULL) { FileSys_CloseFile(filehdl); ret = TRUE; } return ret; }
INT32 SetupExe_OnFileSysInit(VControl *pCtrl, UINT32 paramNum, UINT32 *paramArray) { #if _DEMO_TODO //#NT#2010/11/27Steven feng-begin UINT32 uiPoolAddr; UINT32 uiBufSize = 0 ,status; //#NT#2011/02/16#Steven feng -begin #if SLIDESHOW_MUSIC_OPTION UINT32 i; #endif //#NT#2011/02/16#Steven feng -end //#NT#2010/11/27Steven feng-end //debug_msg("[SetupObj] FileSysInit\r\n"); //#NT#2010/09/28#Lincy Lin -begin //#NT#Add check if write Photo frame Pstore when update FW if(FlowMode_IsPowerOnUpdateFW()) { FST_FILE filehdl = NULL; INT32 ret = FST_STA_ERROR; //#NT#2011/01/07#Janice Huang -begin //#NT#add warn wind,for Production line ,unplug bettery Ux_OpenWindow(&DialogWarnCtrl, 2, WRN_FW_UPDATING, WARN_ALWAYS); //#NT#2010/11/04#Lincy Lin -begin // delay for AE stable SwTimer_DelayMs(100); //#NT#2010/11/04#Lincy Lin -end UIRes_ChkWritePHFE(); //#NT#2011/02/14Steven feng-begin #if SLIDESHOW_MUSIC_OPTION UIRes_ChkWriteSSWAV(); #endif //#NT#2011/02/14Steven feng-end //#NT#2010/11/27Steven feng-begin uiPoolAddr = OS_GetMempoolAddr(POOL_ID_APP); filehdl = FileSys_OpenFile(CAL_CLEAR_FOLDER,FST_OPEN_READ); ret = FileSys_ReadFile(filehdl,(UINT8*)uiPoolAddr,&uiBufSize, 0, 0); FileSys_CloseFile(filehdl); if(ret == FST_STA_OK) { debug_err(("^G Clear Cal Data & status\r\n")); Cal_ItemClearStatus(); } else debug_err(("^G Reserve Cal Data & status\r\n")); //#NT#2010/11/27Steven feng-end //#NT#2011/01/28#Brad Chen -begin //#NT# add burn ISO if(_MSDC_MODE_==_MSDC_ALL_NAND2_|| _MSDC_MODE_ == _MSDC_SINGLE_NAND2_) { ER result = E_OK; char *fileName = "A:\\GEISO.ISO"; FST_FILE *pFile; UINT32 value = 0X30444301; result = copy_iso(); pFile = FileSys_OpenFile((char *)fileName,FST_OPEN_READ); if (pFile != NULL) { FormatNand(); } else { debug_err(("open file error\r\n")); } result = check_iso(0x8000,value,4); if (result == E_OK) { debug_msg(" set AutoRunISOWriteSts OK\r\n"); UI_SetData(FL_AutoRunISOWriteSts,TRUE); } else debug_msg(" set AutoRunISOWriteSts Fail\r\n"); } //#NT#2011/01/28#Brad Chen -end Ux_CloseWindow(&DialogWarnCtrl,0); UIRes_InitReadPHFE(); //#NT#2011/02/16#Steven feng -begin #if SLIDESHOW_MUSIC_OPTION for(i = 0 ; i<4 ; i++) UIRes_InitReadSSWAV(i); #endif //#NT#2011/02/16#Steven feng -end Ux_OpenWindow(&DialogWarnCtrl, 2, WRN_FW_CHECK, WARN_ALWAYS); //post event again,because open wind ,miss the event Ux_PostEvent(NVTEVT_STORAGE_INIT, 0, 0); //#NT#2011/01/07#Janice Huang -end //#NT#2011/03/01#Lincy Lin -begin //#NT#Fix remove battery the info not save bug Save_MenuInfo(); //#NT#2011/03/01#Lincy Lin -end } else { //#NT#2010/09/28#Lincy Lin -end //#NT#2010/11/01#Lincy Lin -begin UIRes_InitReadPHFE(); //#NT#2010/11/01#Lincy Lin -end } #if _PWRON_WAIT_FILESYSTEM_ if (UIStorageCheck(STORAGE_CHECK_DCIM_READONLY, NULL) == TRUE) { UI_SetData(FL_IsDCIMReadOnly,TRUE); } #endif //#NT#2011/03/24#Lincy Lin -begin //#NT# BackupPhotoParamsInfo(); //#NT#2011/03/24#Lincy Lin -end #endif return NVTEVT_CONSUME; }
static BOOL UI_WriteLogoFileName(UINT32 logoId) { FST_FILE pFile; UINT32 uiFileSize; UINT8 *BgBuf; char *fileName; URECT Rect = {0, 0, 320, 240}; ER erReturn = E_OK; PSTORE_SECTION_HANDLE* pSecHdl; // to save the handle of PStore section char *psecnameId; if (logoId == UI_LOGO_POWERON) { fileName = "A:\\logo.jpg"; psecnameId = PS_POWERON_LOGO; } else //if (logoId == UI_LOGO_POWEROFF) { fileName = "A:\\logo2.jpg"; psecnameId = PS_POWEROFF_LOGO; } FileSys_WaitFinish(); pFile = FileSys_OpenFile(fileName, FST_OPEN_READ); if (pFile == NULL) { debug_err(("open file error\r\n")); return FALSE; } uiFileSize = FileSys_GetFileLen(fileName); // for small page nand USE_MSG(("file size = %d\r\n",uiFileSize)); if ((uiFileSize < 1024) || (uiFileSize > LOGO_MAX_FILESIZE)) { Cal_FillRect(&Rect, _OSD_INDEX_BLACK); Cal_ShowStringByColor("jpg size is too big or too small\n", &Rect, _OSD_INDEX_YELLOW, _OSD_INDEX_BLACK); Delay_DelayMs(2000); Cal_FillRect(&Rect, _OSD_INDEX_BLACK); debug_err(("Write logo error\n\r")); return FALSE; } BgBuf = (UINT8 *)OS_GetMempoolAddr(POOL_ID_APP); if (FileSys_ReadFile(pFile,(UINT8 *)(BgBuf+4),&uiFileSize,FST_FLAG_NONE,NULL)!=FST_STA_OK) { USE_MSG(("file read failed\r\n")); return FALSE; } FileSys_CloseFile(pFile); *BgBuf = LO_BYTE(LO_WORD(uiFileSize)); *(BgBuf+1) = HI_BYTE(LO_WORD(uiFileSize)); *(BgBuf+2) = LO_BYTE(HI_WORD(uiFileSize)); *(BgBuf+3) = HI_BYTE(HI_WORD(uiFileSize)); pSecHdl = PStore_OpenSection(psecnameId, PS_RDWR | PS_CREATE); if (pSecHdl == E_PS_SECHDLER) { debug_err(("Section open fail\r\n")); goto err_ret; } erReturn = PStore_WriteSection(BgBuf, 0, SYSPARAM_LOGO_LEN, pSecHdl); if (erReturn != E_PS_OK) { debug_err(("PStore program error\r\n")); goto err_ret; } //#PIC#2010/07/23#Creator -begin PStore_CloseSection(pSecHdl); //#PIC#2010/07/23#Creator -end return TRUE; err_ret: PStore_CloseSection(pSecHdl); //PStore_DisablePS(); return FALSE; }
void UI_UpdateCfgFile(void) { #if 0 UINT32 uiKeyAct, uiKeyCode; FLGPTN uiFlag; #endif char* str; FST_FILE pFile; UINT32 uiFileSize; UINT8 *BgBuf; char *fileName; URECT Rect = {0, 0, 320, 240}; BOOL Ret =TRUE ; ER erReturn; PSTORE_SECTION_HANDLE* pSecHdl; // to save the handle of PStore section fileName = "A:\\NTCONFIG.bin"; FileSys_WaitFinish(); pFile = FileSys_OpenFile(fileName, FST_OPEN_READ); if (pFile == NULL) { debug_err(("open file error\r\n")); Ret =FALSE; } uiFileSize = FileSys_GetFileLen(fileName); // for small page nand USE_MSG(("file size = %d\r\n",uiFileSize)); //if file is null if (uiFileSize == 0) { USE_MSG(("file size is 0\r\n")); Ret =FALSE; } if (uiFileSize > CFG_MAX_FILESIZE) { USE_MSG(("file size is bigger = %d\r\n",uiFileSize)); Ret =FALSE; } //get_blk((void *)&BgBuf, POOL_ID_SICD); //rel_blk(POOL_ID_SICD, BgBuf); //SysGetSICDAddr((UINT32*)&BgBuf); BgBuf = (UINT8 *)OS_GetMempoolAddr(POOL_ID_APP); if (FileSys_ReadFile(pFile,BgBuf,&uiFileSize,FST_FLAG_NONE,NULL)!=FST_STA_OK) { USE_MSG(("file read failed\r\n")); Ret =FALSE; } FileSys_CloseFile(pFile); *BgBuf = LO_BYTE(LO_WORD(uiFileSize)); *(BgBuf+1) = HI_BYTE(LO_WORD(uiFileSize)); *(BgBuf+2) = LO_BYTE(HI_WORD(uiFileSize)); *(BgBuf+3) = HI_BYTE(HI_WORD(uiFileSize)); //PStore_EnablePS(); pSecHdl = PStore_OpenSection(PS_BG_CFG, PS_RDWR | PS_CREATE); if (pSecHdl == E_PS_SECHDLER) { debug_err(("Section open fail\r\n")); PStore_CloseSection(pSecHdl); //PStore_DisablePS(); Ret =FALSE; } erReturn = PStore_WriteSection(BgBuf, 0, SYSPARAM_SYSFLAG_LEN, pSecHdl); PStore_CloseSection(pSecHdl); if (erReturn != E_PS_OK) { debug_err(("PStore program error\r\n")); Ret =FALSE; } Cal_FillRect(&Rect, _OSD_INDEX_BLACK); Rect.x = 56; Rect.y = 108; Rect.w = 212; Rect.h = 24; if (Ret == FALSE) { str = "Update Cfg file error"; Cal_ShowStringByColor(str, &Rect, _OSD_INDEX_YELLOW, _OSD_INDEX_BLACK); }else { str = "Update Cfg file ok"; Cal_ShowStringByColor(str, &Rect, _OSD_INDEX_YELLOW, _OSD_INDEX_BLACK); } Delay_DelayMs(1000); if (Ret) { System_PowerOff(SYS_POWEROFF_NORMAL); } #if 0 clr_flg(FLG_ID_CALIBRATION, 0xffffffff); while (1) { wai_flg(&uiFlag, FLG_ID_CALIBRATION, 0xffffffff, TWF_ORW | TWF_CLR); debug_msg("^GuiFlag:%x\r\n",uiFlag); if (uiFlag) break; } #else Delay_DelayMs(1500); #endif }
void FlowMode_OnUsbUnplug(void) { UINT32 filesize ; char * uiBuffer ; //ER status ; UIDebug_usb(("^BFlowMode_OnUsbUnplug begin\r\n")); //#NT#2010/03/16#Lincy Lin -begin //#NT# For Calibration #if 1 if(IS_USB_VENDOR()) { FST_FILE filehdl = NULL; INT32 ret = FST_STA_ERROR; #if _DEMO_TODO GxFile_GetStorageObj(PRIMARY_STGTYPE_CARD)->Close(); //GxFile_ChangeStorage(PRIMARY_STGTYPE_CARD); GxFile_ChangeStorage(PRIMARY_STGTYPE_CARD); #endif uiBuffer = (char *)OS_GetMempoolAddr(POOL_ID_GFX_IMAGE); debug_err(("\n[IMG] Pool size read %d \r\n", OS_GetMempoolSize(POOL_ID_GFX_IMAGE))); // Update English Language begin filesize = 0x4; // Disable IDE video1/video2 output //UI_Show(UI_SHOW_INFO, TRUE); //OSD2 //UI_Show(UI_SHOW_WINDOW, TRUE); //OSD1 //UI_Show(UI_SHOW_BACKGND, TRUE); //VDO2 //UI_Show(UI_SHOW_PREVIEW, TRUE); //VDO1 GxVideo_SetDeviceCtrl(DOUT1, DISPLAY_DEVCTRL_BRIGHTLVL, 5); filehdl = FileSys_OpenFile("A:\\FO.txt",FST_OPEN_READ); ret = FileSys_ReadFile(filehdl,(UINT8*)uiBuffer,&filesize, 0, 0); FileSys_CloseFile(filehdl); if(ret==FST_STA_OK) { Ux_SendEvent(0, NVTEVT_SYSTEM_MODE, 1, PRIMARY_MODE_PHOTO); #if (_CALIBRATION_MODE_ == ENABLE) //g_IsautoMTF = TRUE; g_bCalbirationOpened = FALSE; #endif SwTimer_DelayMs(1500); Ux_PostEvent(NVTEVT_STORAGE_INIT, 0, 0); //FocusOffsetAdjust(); //debug_err(("^R status = 0x%x 0x%x \r\n" , status , *(UINT32 *)uiBuffer)); } else { UIDebug_usb(("^B USB PlugOff,PwrOff 1\r\n")); System_PowerOff(SYS_POWEROFF_NORMAL); } } else { UIDebug_usb(("^B USB PlugOff,PwrOff 2\r\n")); System_PowerOff(SYS_POWEROFF_NORMAL); } #else #if (MODEKEY_FUNCTION == ENABLE) Ux_SendEvent(0, NVTEVT_SYSTEM_MODE, 1, System_GetState(SYS_STATE_PREVMODE)); //#NT#2009/12/24#Lily Kao - begin debug_msg("USB_CB:PlugOff,PrevMode=%d\r\n",System_GetState(SYS_STATE_PREVMODE)); //System_PowerOff(); //#NT#2010/01/14#Lincy Lin -begin //#NT#2010/02/03#Brad Chen -begin //#NT# add USB unplug then change to photo mode { UINT32 uiDscMode; //#NT#2010/01/20#JeahYen -begin uiDscMode = Input_Key2Mode(GxKey_GetData(GXKEY_STS_KEY1)); //#NT#2010/01/20#JeahYen -end UI_SetData(FL_ModeIndex,uiDscMode); UI_Switch_DscMode(uiDscMode,DSCMODE_SWITCH_FORCE,DSCMODE_SWITCHDIR_DONT_CARE); } //#NT#2010/02/03#Brad Chen -end #else { UINT32 uiDscMode; //#NT#2010/01/20#JeahYen -begin uiDscMode = Input_Key2Mode(GxKey_GetData(GXKEY_STS_KEY1)); //#NT#2010/01/20#JeahYen -end UI_SetData(FL_ModeIndex,uiDscMode); UI_Switch_DscMode(uiDscMode,DSCMODE_SWITCH_FORCE,DSCMODE_SWITCHDIR_DONT_CARE); } #endif #endif //#NT#2010/03/16#Lincy Lin -end UIDebug_usb(("^BFlowMode_OnUsbUnplug end\r\n")); }
UINT32 System_OnStrg_UploadFW(UINT32 DevID) { UINT32 m_MemSrc=0; UINT32 uiMemSize=0; UINT32 m_SectSize = 0; //DX_HANDLE pStrgDev = (DX_HANDLE)GxStrg_GetDevice(DevID); DX_HANDLE pGxStrgDXH = (DX_HANDLE)GxStrg_GetDevice(DevID); //HNVT_STRG pStrg,pWhichObj; DX_HANDLE pFSStrgDXH; FST_FILE hFile=NULL; UINT32 uiSize=0; //FileSize INT32 fst_er; #if (FW_CHECK_METHOD != FW_CHECK_NOCHECK) UINT32 uiSizeExt; MEMCHECK_PSEUDOSTR Pesudo = {0}; #endif FWSRV_ER fws_er; //alloc mem uiMemSize = 0x1000000; // 16MB m_MemSrc = SxCmd_GetTempMem(uiMemSize); //if (pStrgDev == 0) if (pGxStrgDXH == 0) { debug_msg("Incorrect storage\r\n"); return UPDNAND_STS_FW_INVALID_STG; } //pStrg = (HNVT_STRG)Dx_Getcaps(pStrgDev, STORAGE_CAPS_HANDLE, 0); //if (pStrg == 0) //{ // debug_msg("Incorrect storage\r\n"); // return UPDNAND_STS_FW_INVALID_STG; //} //FileSys_GetStrgObj(&pWhichObj); FileSys_GetStrgObj(&pFSStrgDXH); //if(pWhichObj != pStrg) if(pFSStrgDXH != pGxStrgDXH) { debug_msg("Incorrect storage\r\n"); return UPDNAND_STS_FW_INVALID_STG; } memset(&Cmd,0,sizeof(Cmd)); Cmd.Idx = FWSRV_CMD_IDX_GET_BLK_SIZE; Cmd.Out.pData = &m_SectSize; Cmd.Out.uiNumByte = sizeof(m_SectSize); Cmd.Prop.bExitCmdFinish = TRUE; fws_er = FwSrv_Cmd(&Cmd); if(fws_er != FWSRV_ER_OK) { debug_msg("FW bin write failed\r\n"); return UPDNAND_STS_FW_WRITE_CHK_ERR; } uiSize = (UINT32)FileSys_GetFileLen(uiUpdateFWName); if((uiSize==0) || (uiSize>uiMemSize)) { debug_msg("FW bin read fail.\r\n"); return UPDNAND_STS_FW_READ_ERR; } hFile = FileSys_OpenFile(uiUpdateFWName, FST_OPEN_READ); if(hFile != 0) { fst_er = FileSys_ReadFile(hFile, (UINT8*)m_MemSrc, &uiSize, 0, NULL); FileSys_CloseFile(hFile); if(fst_er != FST_STA_OK) { debug_msg("FW bin read fail. 1\r\n"); return UPDNAND_STS_FW_READ2_ERR; } } else { debug_msg("FW bin read fail. 2\r\n"); return UPDNAND_STS_FW_READ2_ERR; } #if (FW_CHECK_METHOD != FW_CHECK_NOCHECK) //Pesudo string is appended to Crc & Checksum flow. //It is an additional protection key for project. //Both two pseudo strings setting must be match exactly // in "FW bin encryption prcoess" & "update FW process" of project. //In FW bin encryption process: (see config in MakeOption.txt) // this string is not written to file. //In update FW process: (FW update FW, or Loader update FW) // this string is not written to nand. Pesudo.uiAddr = m_MemSrc; Pesudo.uiLen = uiSize; Pesudo.uiMemSize = uiMemSize; Pesudo.pPseudoStr = FW_CHECK_PSEUDO_STR; uiSizeExt=MemCheck_AddPseudoStr(&Pesudo); #if (FW_CHECK_METHOD == FW_CHECK_CRC) if(MemCheck_CalcCrcCode(m_MemSrc,uiSizeExt)!=0) #else if(MemCheck_CalcCheckSum16Bit(m_MemSrc,uiSizeExt)!=0) #endif { debug_msg("FW bin check error\r\n"); return UPDNAND_STS_FW_READ_CHK_ERR; } #endif memset(&Cmd,0,sizeof(Cmd)); Buf.uiAddr = m_MemSrc; Buf.uiSize = (uiSize+(m_SectSize-1))&(~(m_SectSize-1)); Cmd.Idx = FWSRV_CMD_IDX_FW_WRITE; Cmd.In.pData = &Buf; Cmd.In.uiNumByte = sizeof(Buf); Cmd.Prop.bExitCmdFinish = TRUE; fws_er = FwSrv_Cmd(&Cmd); if(fws_er != FWSRV_ER_OK) { debug_msg("FW bin write failed\r\n"); return UPDNAND_STS_FW_WRITE_CHK_ERR; } return UPDNAND_STS_FW_OK; }
INT32 JPG2MOV_MakeMovie(JPG2MOV_OBJ *pObj) { #define BS_SIZE_MAX (10*1024*1024) // 10MB #define YUV_SIZE_MAX (12*1024*1024) // 12MB #define MEDIAREC_BUF_SIZE (60*1024*1024) // 60MB UINT32 uiPoolAddr, uiPoolSize, uiBSAddr, uiFileSize; UINT32 i, j, uiTimeCount, uiMediaRecAddr; JPG2YUV_INFO Jpg2Yuv; FST_FILE pFile; ER err = E_OK; MEDIAREC_OBJ MediaRecObj = {0}; UINT32 FileNumber; FILEDB_HANDLE fileDbHandle, fileDbbufSize=0x200000, fileDbbufAddr; PFILEDB_FILE_ATTR pFileAttr; uiPoolAddr = OS_GetMempoolAddr(POOL_ID_APP); uiPoolSize = OS_GetMempoolSize(POOL_ID_APP); uiBSAddr = uiPoolAddr + uiPoolSize - BS_SIZE_MAX; uiMediaRecAddr = uiPoolAddr + YUV_SIZE_MAX; fileDbbufAddr = uiBSAddr - fileDbbufSize; // ----------------------------------- <--- APP buffer starting address // | JPEG decode YUV buffer | (original image format) // ----------------------------------- // | YUV buffer 1 for media recorder | (image format transform: to YUV420 UV-pack, ...) // ----------------------------------- // | YUV buffer 2 for media recorder | // ----------------------------------- // | YUV buffer 3 for media recorder | // ----------------------------------- // | ... | // ----------------------------------- // | JPEG bitstream buffer | // ----------------------------------- <--- IQ buffer end address // // Note: Be sure the buffer is enough for storing the necessary YUV patterns! Perf_Open(); uiTimeCount = Perf_GetCurrent(); MediaRecObj.CallBackFunc = JPG2MOV_RecCB; if (MediaRec_Open(&MediaRecObj) != E_OK) { DBG_ERR("MediaRec_Open() failed!\r\n"); return E_SYS; } // reset video encode ready flag to TRUE g_bVidEncReady = TRUE; //MediaRec_OpenCutMsg(1); MediaRec_SetGiveYUVBuf(uiMediaRecAddr, MEDIAREC_BUF_SIZE); JPG2MOV_SetRecParam(); //MediaRec_ChangeParameter(MEDIAREC_RECPARAM_PRE_ENCODE, FALSE, 0, 0); //MediaRec_ChangeParameter(MEDIAREC_RECPARAM_MERGEYUV, 1, 0, 0); MediaRec_Record(); // create fileDB for copy { FILEDB_INIT_OBJ FilDBInitObj={0}; CHAR rootPath[20]=FILEDB_TMLPS_ROOT;//"A:\\TMLPS\\"; FilDBInitObj.rootPath = rootPath; FilDBInitObj.bIsRecursive = TRUE; FilDBInitObj.bIsCyclic = TRUE; FilDBInitObj.bIsMoveToLastFile = TRUE; FilDBInitObj.bIsSupportLongName = TRUE; FilDBInitObj.bIsDCFFileOnly = FALSE; FilDBInitObj.bIsChkHasFile = FALSE; FilDBInitObj.u32MaxFilePathLen = 60; FilDBInitObj.u32MaxFileNum = 20000; FilDBInitObj.fileFilter = FILEDB_FMT_JPG; FilDBInitObj.u32MemAddr = dma_getCacheAddr(fileDbbufAddr); FilDBInitObj.u32MemSize = fileDbbufSize; fileDbHandle = FileDB_Create(&FilDBInitObj); } // merge JPEG file one by one FileNumber = FileDB_GetTotalFileNum(fileDbHandle); for (i = 0; i < FileNumber; i++) { DBG_MSG("Handle photo no. %d\r\n", i); // 1. Read JPG data from file pFileAttr = FileDB_SearhFile(fileDbHandle, i); //sprintf(sFileName, "A:\\TMLPS\\PHOTO\\2000_0509_043848_001.JPG", (i+1)); uiFileSize = BS_SIZE_MAX; pFile = FileSys_OpenFile(pFileAttr->filePath, FST_OPEN_READ); if (pFile) { FileSys_ReadFile(pFile, (UINT8 *)uiBSAddr, &uiFileSize, 0, NULL); FileSys_CloseFile(pFile); DBG_MSG("File %s, size %d\r\n", sFileName, uiFileSize); if (uiFileSize == BS_SIZE_MAX) { DBG_ERR("Read buffer is not enough!\r\n"); MediaRec_Stop(MEDIAREC_WAIT_END); MediaRec_Close(); return E_SYS; } } else { DBG_ERR("Open %s for reading failed!\r\n", sFileName); MediaRec_Stop(MEDIAREC_WAIT_END); MediaRec_Close(); return E_SYS; } // 2. Decode JPEG, do format transform and image scaling Jpg2Yuv.uiJpgAddr = uiBSAddr; Jpg2Yuv.uiJpgSize = uiFileSize; Jpg2Yuv.uiYAddr = uiPoolAddr; err = JPG2YUV_DecodeAndScale(&Jpg2Yuv); // 3. Wait for video encode ready last time j = 0; while (j < 40) { if (g_bVidEncReady) // check video encode ready { break; } Delay_DelayMs(1); // delay 1 ms j++; } // 4. Trigger writing file every second if (i && ((i % 30) == 0)) { MediaRec_TriggerWriteFile(); } // 5. Do H.264 encode if (err == E_OK) { MEDIAREC_READYBUF_INFO readyInfo; readyInfo.y = Jpg2Yuv.uiYAddr; readyInfo.cb = Jpg2Yuv.uiUAddr; readyInfo.cr = Jpg2Yuv.uiVAddr; readyInfo.y_lot = Jpg2Yuv.uiYLineOffset; readyInfo.uv_lot = Jpg2Yuv.uiUVLineOffset; g_bVidEncReady = FALSE; MediaRec_GiveYUV(&readyInfo); } // 6. Update progress test if (pObj->fpProgressCB) pObj->fpProgressCB(((i+1)*100)/FileNumber); } FileDB_Release(fileDbHandle); MediaRec_Stop(MEDIAREC_WAIT_END); MediaRec_Close(); uiTimeCount = Perf_GetCurrent() - uiTimeCount; DBG_DUMP("^YTotal merge time %d ms\r\n", uiTimeCount/1000); return E_OK; }
int WifiCmd_GetData(char* path, char* argument, cyg_uint32 bufAddr, cyg_uint32* bufSize, char* mimeType, cyg_uint32 segmentCount) { UINT32 cmd=0,par=0; char* pch=0; UINT32 ret =0; UINT32 UserCB = 0; //char *parStr;//post event,data in stack would release DBG_IND("Data2 path = %s, argument -> %s, mimeType= %s, bufsize= %d, segmentCount= %d\r\n",path,argument, mimeType, *bufSize, segmentCount); if(strncmp(argument,CMD_STR,strlen(CMD_STR))==0) { if(segmentCount==0) WifiCmd_Lock(); sscanf(argument+strlen(CMD_STR),"%d",&cmd); pch=strchr(argument+strlen(CMD_STR),'&'); if(pch) { if(strncmp(pch,PAR_STR,strlen(PAR_STR))==0) { sscanf(pch+strlen(PAR_STR),"%d",&par); ret = WifiCmd_DispatchCmd(cmd,WIFICMD_PAR_NUM,par,&UserCB); } else if(strncmp(pch,PARS_STR,strlen(PARS_STR))==0) { //DBG_ERR("%s\r\n",pch+strlen(PARS_STR)); ret = WifiCmd_DispatchCmd(cmd,WIFICMD_PAR_STR,(UINT32)pch+strlen(PARS_STR),&UserCB); } } else { ret = WifiCmd_DispatchCmd(cmd,WIFICMD_PAR_NULL,0,&UserCB); } if(UserCB) { UINT32 hfs_result; hfs_result = ((cyg_hfs_getCustomData *)UserCB)(path,argument,bufAddr,bufSize,mimeType,segmentCount); if(hfs_result != CYG_HFS_CB_GETDATA_RETURN_CONTINUE) WifiCmd_Unlock(); return hfs_result; } else //default return value xml { if(gDefReturnFormat) { gDefReturnFormat(cmd,ret,bufAddr,bufSize,mimeType); WifiCmd_Unlock(); return CYG_HFS_CB_GETDATA_RETURN_OK; } else { DBG_ERR("no default CB\r\n"); WifiCmd_Unlock(); return CYG_HFS_CB_GETDATA_RETURN_ERROR; } } } else //for test,list url command { UINT32 len=0; char* buf = (char*)bufAddr; FST_FILE filehdl=0; char pFilePath[32]; UINT32 fileLen =*bufSize; sprintf(pFilePath,"%s",HTML_PATH); //html of all command list filehdl = FileSys_OpenFile(pFilePath,FST_OPEN_READ); if(filehdl) { // set the data mimetype strcpy(mimeType,"text/html"); FileSys_ReadFile(filehdl, (UINT8 *)buf, &fileLen, 0,0); FileSys_CloseFile(filehdl); *bufSize = fileLen; *(buf+fileLen) ='\0'; } else { strcpy(mimeType,"text/html"); len = sprintf(buf,"no %s file",HTML_PATH); buf+=len; *bufSize = (cyg_uint32)(buf)-bufAddr; } } return CYG_HFS_CB_GETDATA_RETURN_OK; }
INT32 UIFlowWndPlay_OnKeyEnter(VControl *pCtrl, UINT32 paramNum, UINT32 *paramArray) { //#NT#2012/08/31#Calvin Chang#Porting Media Flow -begin //UINT32 uiCurindex; UINT32 uiPoolAddr; char pFilePath[FULL_FILE_PATH_LEN]; UINT32 fileType = DCF_FILE_TYPE_JPG; UINT32 uiPBFileFmt; switch(g_PlbData.State) { case PLB_ST_PLAY_MOV: case PLB_ST_FWD_MOV: case PLB_ST_BWD_MOV: Ux_SendEvent(&UIMoviePlayObjCtrl, NVTEVT_PAUSE_PLAY_MOVIE, 0); FlowPB_IconDrawMovPlay(TRUE); g_PlbData.State = PLB_ST_PAUSE_MOV; //#NT#2012/10/23#Philex Lin - begin // enable auto power off/USB detect timer // enable sound key tone flag KeyScan_EnableMisc(TRUE); //#NT#2012/10/23#Philex Lin - end break; case PLB_ST_PAUSE_MOV: //#NT#2012/10/23#Philex Lin - begin // disable auto power off/USB detect timer // disable key tone flag KeyScan_EnableMisc(FALSE); //#NT#2012/10/23#Philex Lin - end // Start to Play Ux_SendEvent(&UIMoviePlayObjCtrl, NVTEVT_PLAY_PLAY_MOVIE, 2, g_uiUIFlowWndPlayCurrenSpeed, g_uiUIFlowWndPlayCurrenDirection); FlowPB_IconDrawMovPlay(TRUE); g_PlbData.State = PLB_ST_PLAY_MOV; break; default: case PLB_ST_FULL: uiPBFileFmt = AppPlay_GetData(PLAY_FILEFMT); if (uiPBFileFmt & PBFMT_AVI || uiPBFileFmt & PBFMT_MOVMJPG || uiPBFileFmt & PBFMT_MP4) { // Open Video File if (gphUIFlowMovPlay_Filehdl) { FileSys_CloseFile(gphUIFlowMovPlay_Filehdl); gphUIFlowMovPlay_Filehdl = NULL; } if (uiPBFileFmt & PBFMT_AVI) fileType = DCF_FILE_TYPE_AVI; else if (uiPBFileFmt & PBFMT_MOVMJPG) fileType = DCF_FILE_TYPE_MOV; else if (uiPBFileFmt & PBFMT_MP4) fileType = DCF_FILE_TYPE_MOV; else { debug_msg("Wrong video file format!! \r\n"); break; } // Get Current index PB_GetParam(PBPRMID_CURR_FILEPATH, (UINT32 *)pFilePath); #if 0 uiCurindex = DCF_GetCurIndex(); DCF_GetObjPath(uiCurindex,fileType,pFilePath); #endif // Open Test Media File gphUIFlowMovPlay_Filehdl = FileSys_OpenFile(pFilePath, FST_OPEN_READ); if (!gphUIFlowMovPlay_Filehdl) { debug_msg("UIFlowWndPlay_OnKeyEnter: Can't open Video file!\r\n"); break; } //#NT#2012/10/23#Philex Lin - begin // disable auto power off/USB detect timer // disable key tone flag KeyScan_EnableMisc(FALSE); //#NT#2012/10/23#Philex Lin - end // Buffer Allocation get_blf((VP*)&(uiPoolAddr), POOL_ID_APP); rel_blf(POOL_ID_APP, (VP)uiPoolAddr); g_UIPlayMediaObj.hActMediafilehdl = gphUIFlowMovPlay_Filehdl; g_UIPlayMediaObj.CallBackFunc = Play_MovieCB; // g_UIPlayMediaObj.uiMemAddr = uiPoolAddr; g_UIPlayMediaObj.uiMemAddr = (UINT32)OS_GetMempoolAddr(POOL_ID_APP); g_UIPlayMediaObj.uiMemSize = POOL_SIZE_APP; //g_UIPlayMediaObj.iAudioType = AUDIO_OUTPUT_HP; g_UIPlayMediaObj.bDisableAudio = FALSE; UIFlowMoviePlay_SetSpeed(g_PlbData.VideoPBSpeed); g_uiUIFlowWndPlayCurrenDirection = MEDIAPLAY_DIR_FORWARD; //flush event first Ux_FlushEventByRange(NVTEVT_KEY_EVT_START,NVTEVT_KEY_EVT_END); //stop scan //SxTimer_SetFuncActive(SX_TIMER_DET_STRG_ID, FALSE); SxTimer_SetFuncActive(SX_TIMER_DET_SYSTEM_BUSY_ID, FALSE); Ux_SendEvent(&UIMoviePlayObjCtrl, NVTEVT_INIT_PLAY_MOVIE, 1, &g_UIPlayMediaObj); // Start to Play Ux_SendEvent(&UIMoviePlayObjCtrl, NVTEVT_PLAY_PLAY_MOVIE, 2, g_uiUIFlowWndPlayCurrenSpeed, g_uiUIFlowWndPlayCurrenDirection); if (KeyScan_GetPlugDev()!=PLUG_HDMI) { //FlowPB_IconDrawMovPlayVolumn(g_uiUIFlowWndPlayCurrentVolume); } FlowPB_IconDrawMovPlay(TRUE); g_PlbData.State = PLB_ST_PLAY_MOV; } break; } //#NT#2012/08/31#Calvin Chang -end return NVTEVT_CONSUME; }