⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 burn.cpp

📁 It is for standalone platform executing DVD Burning function,it supports DVD+R/+RW Disc .
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/***************************************** Copyright  2001-2003   Sigma Designs, Inc. All Rights Reserved Proprietary and Confidential *****************************************/#ifndef ALLOW_OS_CODE#define ALLOW_OS_CODE 1#endif //ALLOW_OS_CODE#include "../gui/guinavigation.h"#include "udf.h"#if 1#define GUIDBG ENABLE#else#define GUIDBG DISABLE#endif#ifdef GUI_REFID_2static RMbool debug = TRUE;#endif#define RMstatus int#define ITRI_ID       "KODAK_DISC"RMascii ITRI_Defined_MOUNT_POINT[128] = "";//burn_step=(Writed_Size*100)/ITRI_Size;RMuint16  burn_step;RMuint16 global_step;//-------------------------------------------------------------------------------typedef RMascii typeUdfPath[48];typedef struct{	typeUdfPath  F_name;	RMuint32     FileAddr;	RMuint32     F_Lengh; 	RMuint8      Attribute;	//1:jpeg  2:mp3  3:wmv}typeUdfFile; //ccc_hsin//-------------------------------------------------------------------------------extern RMDVDdiscType DVDdiscType;extern RMuint8 *udf_ptr;           //Allocate 300 sectors for UDF ContentRMuint8 *data_buf=NULL,*CurPtr=NULL; RMuint8 *pattern=NULL,*buf_ptr=NULL; //Allocate 300 secotrs for File Content//RMuint8 *ICB_FID_Ptr=NULL;         //Allocate for Recording ICB-FID Relation BufferRMuint32 PrevITRINWA,CurrentITRINWA,itri_NWA=0,UDF102_Reserved=700;RMuint8 *ICBFidPtr=NULL;RMuint16 loop_no=0;FILE *fp=NULL;RMuint32 global_blks;RMuint8  ITRI_DISC_Flag=0;typeCuracaoContext *ITRI_context;RMcuracaoGui *ITRI_gui=NULL; RMcuracaoGuiNavigation *ITRI_pnav=NULL;RMuint16 FileNum=0;RMuint32 NextWriteAddr=300;RMuint8 numofSessions;typeUdfFile* FileListPtr = NULL;char Format_Flag = 0;RMuint32 ITRI_Size,Writed_Size;void WriteSingleFile(typeIsoPath path,RMuint32 NWA,RMuint32 length);void WriteSingleMPVFile(typeIsoPath path,RMuint32 NWA,RMuint32 length);RMstatus HandleMultiCopyFunc();void WriteSequence(typeIsoPath path,RMuint8 is_small_flag,RMuint16 loop_num,RMuint32 lba1,RMuint32 F_Length,RMuint32 totalblocks);void WriteMPVSequence(typeIsoPath path,RMuint8 is_small_flag,RMuint16 loop_num,RMuint32 lba1,RMuint32 F_Length,RMuint32 totalblocks);RMstatus Type2WriteDisc(RMuint16 numofItems,RMuint8 type);RMstatus Type4WriteDisc(RMuint16 numofItems,RMuint8 type);RMstatus  WriteKODAKPVMFile(RMbool itri_pattern,RMuint8 *tmp_ptr,RMuint16 numofItems);RMstatus ITRI_NO_PatternedWriteSequence(RMuint16 numofItems,RMuint8 type);RMstatus ITRI_PatternedWriteSequence(RMuint16 numofItems,RMuint8 type);RMstatus ITRI_WriteCommand(RMuint8 *itri_buf,RMuint32 NWA,RMuint16 transferLen);RMstatus CloseDVDWriter(void);RMstatus OpenDVDWriter(void);RMstatus SetupDVDWriter(void);void ReleaseBuffer(void);RMstatus PseudoWriteSequence(void);//RMstatus  ComputeFileListInfo(void);RMstatus  ITRI_BurnedFiles(void);RMstatus  ComputeMultiFileListInfo(RMuint16 numofItems,RMuint8 type);RMstatus GetFileNameFromPath(RMuint32 isoitem, RMascii *name);RMstatus GetFileNameExtFromPath(RMascii *ext);RMstatus Format_Disc(void);RMstatus EraseDisc(void);void  CloseDisc(void);void AllocateBuffer(void);long  Write_PASS_PVM(void);//long Write_ALBUM_PVM(void);long Write_ALBUM_PVM(RMuint8 *pass_ptr,RMuint16 num);long Write_AssetList_PVM(void);long Write_Audio_PVM(RMuint8 *pass_ptr,RMuint16 num);long Write_Movies_PVM(RMuint8 *pass_ptr,RMuint16 num);long Write_Pictures_PVM(RMuint8 *pass_ptr,RMuint16 num);RMstatus  Compute_ITRI_ListInfo(RMuint16 numofItems,RMuint8 type);RMstatus  Compute_ITRI_ListInfo1(RMuint16 numofItems,RMuint8 type);RMstatus GetFileNameFromMyFavor(RMascii *Myfavor,RMascii *name);RMstatus GetFileNameExtFromMyFavor(RMascii *Myfavor,RMascii *name);RMstatus  WriteKODAKPVMFile2(RMuint8 *tmp_ptr,RMuint16 numofItems);extern RMstatus  UDF102_FS_Create(RMuint8 isMultiSession,RMuint8 *pattern_info,RMuint32 offset_lba);extern RMstatus  UDF102_File_ICB_Create(RMuint8 *pattern);RMstatus HandleMultiCopyFunc(){   RMstatus status;   RMCopyAscii(ITRI_Defined_MOUNT_POINT,MOUNT_POINT);   //printf("MOUNT_POINT:%s ,%s(johnny defined!) \n",MOUNT_POINT,ITRI_Defined_MOUNT_POINT);   status=SetupDVDWriter();   if (status !=RM_OK)   {	   		if (ITRI_DISC_Flag==0xff)	   ITRI_pnav->DisplayPopup("NoDiskPopupOut", TRUE); 	else if (ITRI_DISC_Flag==0x05)	{	ITRI_pnav->DisplayPopup("WrongDiscPopupOut", TRUE); 	printf("@@@@@ ITRI_DISC_Flag==0x05 \n");	return RM_ERROR;	} 	else if ((ITRI_DISC_Flag!=0x01)&&(ITRI_DISC_Flag!=0x02)&&(ITRI_DISC_Flag!=0x03)&&(ITRI_DISC_Flag!=0x04))	{   ITRI_pnav->DisplayPopup("WrongDiscPopupOut", TRUE); 	printf("@@@@@ Other case  \n");	return RM_ERROR;        }      }if(Format_Flag)   		Format_Disc();   PseudoWriteSequence();   Format_Flag = 0;   ITRI_BurnedFiles();      CloseDVDWriter();   return RM_OK;}RMstatus  ITRI_BurnedFiles(void){  typeIsoPath ext;  RMascii fullpath[80];  RMuint16 numofItems;  RMuint8 type;  numofItems=ITRI_pnav->MyFavorfilecount;  RMMemset(fullpath,0x00,80);  RMCopyAscii(fullpath,ITRI_pnav->MyFavorfilefirst->path);  RMAppendAscii(fullpath,ITRI_pnav->MyFavorfilefirst->name);   if (RMFAILED(GetFileNameExtFromMyFavor(fullpath,ext)))         return RM_ERROR;   if ((strcmp(ext,"mp3")==0)||(strcmp(ext,"MP3")==0))//((ext=="mp3")||(ext=="MP3"))    {printf("MP3:Total num:%d\n",numofItems);type=2;}   else if ((strcmp(ext,"jpg")==0)||(strcmp(ext,"JPG")==0))//((ext=="jpg")||(ext=="JPG"))    { printf("JPG:Total num:%d\n",numofItems);type=1;}   else if ((strcmp(ext,"wmv")==0)||(strcmp(ext,"WMV")==0))//if ((ext=="wmv")||(ext=="WMV") )    { printf("WMV:Total num:%d\n",numofItems);type=3;}   else    { type=3;}   //Pass 1. Total copy file no    //    2.  File Type     //      3. disc flag   //ComputeMultiFileListInfo(numofItems,type);      switch (ITRI_DISC_Flag)   {             case 1:     case 3:     	Compute_ITRI_ListInfo(numofItems,type);      break;     case 2:     case 4:     	Compute_ITRI_ListInfo1(numofItems,type);	break;             }return RM_OK;}void AllocateBuffer(void){  //Allocate 400 sectors for File written &UDF/ISO FS udf_ptr=(RMuint8 *)RMMalloc(15+430*2048);//400*2048  if (udf_ptr!=NULL)  {    //printf("********* Alloc UDF Buffer Successfully\n");    RMMemset(udf_ptr,0x00,430*2048);   } else {printf("Allocate No buffer:udf_ptr \n");}  pattern=(udf_ptr+400*2048); RMMemset(pattern,0x00,2048*6); CurPtr=(udf_ptr+406*2048); RMMemset(CurPtr,0x00,2048*12);  buf_ptr=(udf_ptr+418*2048); RMMemset(buf_ptr,0x00,2048*6); //buf_ptr=(RMuint8 *)RMMalloc(15+2048*6);//2048*6 ICBFidPtr=(udf_ptr+424*2048); RMMemset(ICBFidPtr,0x00,2048*6); /*ICBFidPtr=(RMuint8 *)RMMalloc(15+2048*6); if (ICBFidPtr!=NULL) {	RMMemset(ICBFidPtr,0x00,2048*6);} if (buf_ptr!=NULL)  {    //printf("********* Alloc UDF Buffer Successfully\n");    RMMemset(buf_ptr,0x00,2048*6);//2048*6   } else {printf("Allocate No buffer:buf_ptr \n");}//ICBFidPtr*/}void ReleaseBuffer(void){  //1. udf_ptr:400   RMFree(udf_ptr);  if (udf_ptr==NULL);  {       udf_ptr=NULL;  }  //2. pattern:6   pattern=NULL;  CurPtr=NULL;  buf_ptr=NULL;  ICBFidPtr=NULL;  }RMstatus  Compute_ITRI_ListInfo1(RMuint16 numofItems,RMuint8 type){      AllocateBuffer();        switch (ITRI_DISC_Flag)   {             case 2:     	printf("Blank DVD+R DIsc \n");	printf("2 NWA=%ld \n",NextWriteAddr);	Type2WriteDisc(numofItems,type);	break;     case 4:     	printf("Writed DVD+R DIsc \n");	printf("4 NWA=%ld \n",NextWriteAddr);	Type4WriteDisc(numofItems,type);	break;      }      ReleaseBuffer();   return RM_OK;}void  CloseDisc(void){	 			RMstatus status;		RMbool isDiscReady;		status = RMFDiscIsReady (ITRI_context->disc, &isDiscReady);          			while ((status!=RM_OK)||(!isDiscReady))               				status = RMFDiscIsReady (ITRI_context->disc, &isDiscReady);							FVD_SyncCache(ITRI_context->disc,0,0);                 isDiscReady=false;                status = RMFDiscIsReady (ITRI_context->disc, &isDiscReady);                while ( (status!=RM_OK)||(isDiscReady==false))                   status = RMFDiscIsReady (ITRI_context->disc, &isDiscReady);                     isDiscReady=false;                status=FVD_CloseTrack(ITRI_context->disc,0x01,numofSessions);//numofSessions                while ((!isDiscReady)||(status!=RM_OK))                   {status = RMFDiscIsReady (ITRI_context->disc, &isDiscReady);  }                          isDiscReady=false;                status=FVD_CloseTrack(ITRI_context->disc,0x02,0x00);                while ((!isDiscReady)||(status!=RM_OK))                    status = RMFDiscIsReady (ITRI_context->disc, &isDiscReady);         		    }RMstatus  WriteKODAKPVMFile2(RMuint8 *tmp_ptr,RMuint16 numofItems){	//RMuint16 i;	typeUdfFile udf_file;	RMascii fullpath[80];	long length;	 //Write PASSIDX.PVM	 		 RMMemset(fullpath,0x00,80);		 RMMemset(&udf_file,0x00,60);                 RMCopyAscii(fullpath,"/tmp/itri_tmp.txt");                 RMMemcpy(&udf_file,tmp_ptr+20+numofItems*60,60);	   	 length=Write_PASS_PVM();                 WriteSingleMPVFile(fullpath,udf_file.FileAddr,(RMuint32)length);                	 //Write  ALBUM.PVM	 	 RMMemset(fullpath,0x00,80);		 RMMemset(&udf_file,0x00,60);                 RMCopyAscii(fullpath,"/tmp/itri_tmp.txt");                 RMMemcpy(&udf_file,tmp_ptr+20+(numofItems+1)*60,60);		 		 length=Write_ALBUM_PVM(tmp_ptr+20,numofItems+6);                 WriteSingleMPVFile(fullpath,udf_file.FileAddr,(RMuint32)length);	     	 	//Write AssetList	    	 RMMemset(fullpath,0x00,80);		 RMMemset(&udf_file,0x00,60);                 RMCopyAscii(fullpath,"/tmp/itri_tmp.txt");                 RMMemcpy(&udf_file,tmp_ptr+20+(numofItems+2)*60,60);		 		 length=Write_AssetList_PVM();                 WriteSingleMPVFile(fullpath,udf_file.FileAddr,(RMuint32)length);	     		 		 	 //Write_PASS_PICTURES.PVM ICB=37	 	 RMMemset(fullpath,0x00,80);		 RMMemset(&udf_file,0x00,60);                 RMCopyAscii(fullpath,"/tmp/itri_tmp.txt");                 RMMemcpy(&udf_file,tmp_ptr+20+(numofItems+3)*60,60);		 length=Write_Pictures_PVM(tmp_ptr+20,numofItems+6);                 WriteSingleMPVFile(fullpath,udf_file.FileAddr,(RMuint32)length);	     	 	 	 	 //Write_PASS_AUDIO.PVM    ICB=38	 	RMMemset(fullpath,0x00,80);		 RMMemset(&udf_file,0x00,60);                 RMCopyAscii(fullpath,"/tmp/itri_tmp.txt");                 RMMemcpy(&udf_file,tmp_ptr+20+(numofItems+4)*60,60);		 length=Write_Audio_PVM(tmp_ptr+20,numofItems+6);                 WriteSingleMPVFile(fullpath,udf_file.FileAddr,(RMuint32)length);	     	 	 	 	 	 				 	//Write_PASS_MOVIES.PVM   ICB=39		RMMemset(fullpath,0x00,80);		 RMMemset(&udf_file,0x00,60);                 RMCopyAscii(fullpath,"/tmp/itri_tmp.txt");                 RMMemcpy(&udf_file,tmp_ptr+20+(numofItems+5)*60,60);		 length=Write_Movies_PVM(tmp_ptr+20,numofItems+6);                 WriteSingleMPVFile(fullpath,udf_file.FileAddr,(RMuint32)length);	     		 			 		 RMMemset(&udf_file,0x00,60);		printf("2 @@@@@@@@ Test PASS PVM NWA @@@@@@@@@@@@\n");		for (RMuint16 i=numofItems;i<numofItems+6;i++)		{			RMMemcpy(&udf_file,tmp_ptr+20+i*60,60);					printf("F_name=%s ,NWA=%ld,length=%ld \n",udf_file.F_name,udf_file.FileAddr,udf_file.F_Lengh);			}	 		 return RM_OK;}RMstatus  WriteKODAKPVMFile(RMbool itri_pattern,RMuint8 *tmp_ptr,RMuint16 numofItems){	RMascii fullpath[80];	typeUdfFile udf_file;	long length;	//Write PASSIDX.PVM   itri_NWA	 RMMemset(&udf_file,0x00,60);         RMCopyAscii(fullpath,"/tmp/itri_tmp.txt");         RMCopyAscii(udf_file.F_name,"PASSIDX.PVM");         udf_file.FileAddr=itri_NWA;         length=Write_PASS_PVM();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -