About Multisession

vbimport

#1

Hello All,

I am using NeroAPI sample code(VC++).

////////////////////////////////////////////////////////////////////////////////
int NumberTracks = nci->ncdiNumTracks; //from NERO_CD_INFO

NERO_ISO_ITEM *niiTemp;
void *pCDStamp=NULL;

niiTemp = NeroImportIsoTrackEx(ndhDeviceHandle, NumberTracks,
&pCDStamp, NIITEF_IMPORT_ISO_ONLY);

//mniiFile array is burnt now
//niiTemp is previous session.
niiTemp->nextItem = &mniiFile[0];
mniiFile[m_cnt-1].nextItem = NULL;

writeCD.nwcdIsoTrack = NeroCreateIsoTrackEx(niiTemp, “multi”, NCITEF_CREATE_ISO_FS|NCITEF_USE_JOLIET);

int iRes = NeroBurn(ndhDeviceHandle, NERO_ISO_AUDIO_CD, &writeCD, NBF_WRITE | NBF_CLOSE_SESSION, 0, &npProgress);

////////////////////////////////////////////////////////////////////////
I am trying to burn multisession. But I have a problem.
I have a disc that have been burnt 5 times using Nero program(multisession).
If burning multisession with this disc continually, it always include new files and only first session. I don’t know why happend in above code.
Please let me know why.
Thanks a lot in advance.

regds


#2

Where have you got NumberTracks value from? I.e. have you done a cdinfo first to find the number of sessions? If not then NumberTracks will always be 0 and you will always import the first session.

Mike


#3

The first obvious problem is the

int NumberTracks = nci->ncdiNumTracks; //from NERO_CD_INFO
You use NumberTracks variable to supply NeroImportIsoTrackEx() with the track to import. This will be always incorrect as for a total of 5 tracks, their sequence numbers are 0, 1, 2, 3 and 4… while you are passing 5.

If your intention is to import the last track, you should pass NumberTracks-1. In addition to this, the function you use is deprecated. You should use [color=black]NeroImportDataTrack().

[/color]The code does not show whether you connect the entries from the mniiFile array properly. You only connect the first entry to the imported tree.


#4

Hi, alexp

/////////////////////////////////////////////////////////////////////////////////
NERO_CD_INFO *nci = NeroGetCDInfo(ndhDeviceHandle, NGCDI_READ_CD_TEXT);
CString str;
str.Format("%d",nci->ncdiNumTracks);
MessageBox(str);

NERO_ISO_ITEM *niiTemp;
void *pCDStamp=NULL;
NERO_IMPORT_DATA_TRACK_RESULT nidtrResult;
NERO_IMPORT_DATA_TRACK_INFO pInfo;

niiTemp = NeroImportDataTrack(ndhDeviceHandle, nci->ncdiNumTracks-1,
&pCDStamp,&pInfo, NIITEF_IMPORT_ISO_ONLY, &nidtrResult, NULL);

niiTemp->nextItem = &mniiFile[0];
mniiFile[m_cnt-1].nextItem = NULL;

///////////////////////////////////////////////////////////////

So, I changed the function NeroImportIsoTrackEx() to NeroImportDataTrack().
and I got the NumberTracks from NeroGetCDInfo(). But the working is same.
I burned first session and current files. I still don’t know the reason. If you know how to connect all things as first, second and third session, let me know that.

Joon


#5

I am not sure what exactly seems to be the problem, but if you burn a first session, then import it and burn the second one, then import the second and write the third, you will effectively get ALL files referenced in a third session, both the new ones and the ones from the first and second session. Perhaps this is the effect that you are seeing?

If you continually import the last session, you will always have ALL files in your new session.

As for the code, the following does not look promising, even though you are not complaining about any consequences this may have.

niiTemp->nextItem = &mniiFile[0];
mniiFile[m_cnt-1].nextItem = NULL;

Unless your niiTemp imported tree has only a single folder in root, you are effectively cutting off other root items by doing a niiTemp->nextItem = &mniiFile[0]. On the other hand, one would expect a loop to interconnect mniiFiles with indices from 0 to m_cnt-1. This does not happen. So, it is quite questionable what happens to your file/folder tree just before burning.


#6

Hi alexp,

I think you may be right. So, I changed the code as :

//before
niiTemp->nextItem = &mniiFile[0];
mniiFile[m_cnt-1].nextItem = NULL;

//after
mniiFile[m_cnt-1].nextItem = niiTemp;

In this code, I can burn last session all items. but I couldn’t burn new files that saved already in the array of mniiFile. So, I think I have to find the last point in niiTemp.
Right? If you have any ideas, let me know that.

Joon


#7

Huh… every time you are showing only portions of the code that does not work. I have twice already emphasized the importance of mniiFile interconnection but you never show how you do this. Your code clearly shows that you are either doing this incorrectly or not showing us everything. Your problem is definitely in the fact


#8

Hi alexp,

Sorry about that.
This is my code but still is not working like multisession.

//neroFiddlesDlg.h
NERO_ISO_ITEM mniiFile[FILEMAXNUMBER];

//neroFiddlesDlg.cpp
void CNeroFiddlesDlg::OnBrowse()
{
static char BASED_CODE szFilter[] = “All Files (.)|.||”;
CFileDialog dlgOpen(TRUE, NULL, NULL, OFN_FILEMUSTEXIST, szFilter, this);
if (dlgOpen.DoModal() == IDOK)
AppendRealFile(dlgOpen.GetPathName(), dlgOpen.GetFileName());
}

void CNeroFiddlesDlg::AppendRealFile(CString pathname, CString filename)
{
strcpy(mniiFile[m_cnt].fileName, filename);
strcpy(mniiFile[m_cnt].sourceFilePath, pathname);
mniiFile[m_cnt].isDirectory=FALSE;
mniiFile[m_cnt].isReference=FALSE;
m_FileList.AddString(filename);
AppendFileString(pathname);

if (pndiDeviceInfos->nsdisNumDevInfos > 0)
mbtnBurn.EnableWindow(true);

mniiFile[m_cnt].nextItem = &mniiFile[m_cnt+1];
m_cnt++;
}

void CNeroFiddlesDlg::OnBurn()
{
if (m_cnt == 0)
{
AppendString(“You have to choose a file before you can start burning!”);
}
else
{
writeCD.nwcdpCDStamp=NULL;
writeCD.nwcdArtist=NULL;
writeCD.nwcdTitle=NULL;

writeCD.nwcdCDExtra=FALSE;
writeCD.nwcdNumTracks=0;
writeCD.nwcdMediaType = MEDIA_CD;

int i = mcbxDevices.GetCurSel();

NERO_SCSI_DEVICE_INFO* nsdiDevice = (NERO_SCSI_DEVICE_INFO*)mcbxDevices.GetItemDataPtr(i);
ndhDeviceHandle = NeroOpenDevice(nsdiDevice);

NERO_CD_INFO *nci = NeroGetCDInfo(ndhDeviceHandle, NGCDI_READ_CD_TEXT);
NERO_ISO_ITEM *niiTemp;
void *pCDStamp=NULL;
NERO_IMPORT_DATA_TRACK_RESULT nidtrResult;
NERO_IMPORT_DATA_TRACK_INFO pInfo;

niiTemp = NeroImportDataTrack(ndhDeviceHandle, nci->ncdiNumTracks-1, &pCDStamp,&pInfo, NIITEF_IMPORT_ISO_ONLY, &nidtrResult, NULL);

         //before I did
         niiTemp->nextItem = &mniiFile[0];
         mniiFile[m_cnt-1].nextItem = NULL;

         //after I did, but not working.
         //mniiFile[m_cnt-1].nextItem = niiTemp;


if (!ndhDeviceHandle)
{
  AppendString("Device could not be opened: "+(CString)nsdiDevice->nsdiDeviceName);
}
else
{
  mbtnAbort.EnableWindow(true);
  mCancel.EnableWindow(false);
  mOK.EnableWindow(false);
  mcbxDevices.EnableWindow(false);
  mbtnBrowse.EnableWindow(false);
  mbtnBurn.EnableWindow(false);

  mpgsProgress.SetRange(0,100);

  writeCD.nwcdIsoTrack = NeroCreateIsoTrackEx(niiTemp, LABEL, NCITEF_CREATE_ISO_FS|NCITEF_USE_JOLIET);
  int iRes = NeroBurn(ndhDeviceHandle, NERO_ISO_AUDIO_CD, &writeCD, NBF_WRITE | NBF_CLOSE_SESSION, 0, &npProgress);

  NeroFreeIsoTrack(writeCD.nwcdIsoTrack);

  NeroCloseDevice(ndhDeviceHandle);

  mbtnAbort.EnableWindow(false);
  mCancel.EnableWindow(true);
  mOK.EnableWindow(true);
  mcbxDevices.EnableWindow(true);
  mbtnBrowse.EnableWindow(true);
  mbtnBurn.EnableWindow(true);

  mpgsProgress.SetPos(0);
  mbAborted = false;
  char* Log = NeroGetErrorLog();
  AppendString(Log);	  
  NeroFreeMem(Log);
       
  switch(iRes)
  {
    case NEROAPI_BURN_OK:
      AppendString ("BurnCD() : burn successful");
      break;
    case NEROAPI_BURN_UNKNOWN_CD_FORMAT:
      AppendString ("BurnCD() : unknown CD format");
      break;
    case NEROAPI_BURN_INVALID_DRIVE:
      AppendString ("BurnCD() : invalid drive");
      break;
    case NEROAPI_BURN_FAILED:
      AppendString ("BurnCD() : burn failed");
      break;
    case NEROAPI_BURN_FUNCTION_NOT_ALLOWED:
      AppendString ("BurnCD() : function not allowed");
      break;
    case NEROAPI_BURN_DRIVE_NOT_ALLOWED:
      AppendString ("BurnCD() : drive not allowed");
      break;
	case NEROAPI_BURN_USER_ABORT:
      AppendString ("BurnCD() : user aborted");
      break;
	case NEROAPI_BURN_BAD_MESSAGE_FILE:
      AppendString ("BurnCD() : bad message file");
      break;
    default:
      AppendString ("BurnCD() : unknown error");
	  break;
  }
}

}
}

Please show me the way. bye for now.
Joon


#9

Are you setting the size of the NERO_ISO_ITEM structure anywhere (the itemSize field)? For future compatibility reasons you should best allocate NERO_ISO_ITEMs dynamically using NeroCreteIsoItem() which will always set the size for you.


#10

Hi alexp,

I don’t understand it. In NeroAPI, I couldn’t find setting the size of the NERO_ISO_ITEM. Does the itemSize mean the size of file or whole structure of NERO_ISO_ITEM? I don’t know how to set. can you show the sample code for me?

Joon


#11

It should be set to sizeof (NERO_ISO_ITEM) but if you can’t see it you are probably using an older NeroSDK. What is your SDK version? Perhaps you could use the newest SDK and see if that changes anything with respect to your problem.


#12

Hi alexp,

I am using NeroSDK-1.05. In here, I just used the sample of NeroFiddles of NeroAPI. What is the newest version? Where can I get it?

Joon


#13

Hi all,

If you know the solution about my problem, just mail me.
this is my address : jt1013@nate.com or jt1013@paran.com

Joon


#14

If you are using NeroSDK 1.05 you must be aware of the itemSize because it is there. Please consult NeroAPI.h header file.


#15

Hi alexp,

I think the NeroAPI.h is to declare. So there is just the declaration of the function. I just would like to know example for itemSize. Please teach me the example for multisession. I am sorry that I am confused about your answer.

joon


#16

You shouldn’t set itemSize manually. Please see my previous post http://club.cdfreaks.com/showpost.php?p=836499&postcount=9

You are generally on the right track but there seems to be some strange bug in your code. Unfortunately, we never saw your full code so it is hard to tell exactly where the bug is. For a working C++ example you can always refer to NeroCMD source available in the NeroSDK.


#17

Hi alexp,

Thanks your answer. So I attached my code all things. Please, See them and answer me exactly what the bug is. I am waiting for your reply.

Joon


#18

Hi alexp,

Thanks your answer. So I attached my code all things. Please, look at them and answer me exactly what the bug is. I am waiting for your reply.

Joon

NeroFiddles.zip (40 KB)


#19

There are at least two major problems in your code. Apart from not using NeroCreateIsoItem() as previously advised, you are not even doing a basic memset (mniifile, 0, sizeof (mniifile)) in your constructor (which is a must-do if NERO_ISO_ITEMs are allocated statically). If you step through with the debugger you will soon realize the nasty 0xcccccccc values all over the place in your NERO_ISO_ITEM. Now, thanks to the other problem, the former one does not show (the app would crash). No matter what is your actual root NERO_ISO_ITEM you seem to keep passing the root item of the imported tree - niiTemp. As you add niiTemp to the end of the new content tree, passing just niiTemp to NeroCreateIsoTrackEx() gives you an ISO track with just files from the previous session. If you want to see any new files, you need to pass the actual root item of your tree which would probably be &mniifile[0].

Though, I would strongly advise you to rework your code a bit. It would be much simpler to do nothing when new files are added to the list. Only when in OnBurn() should you traverse the list and create a NERO_ISO_ITEM tree on the fly (using NeroCreateIsoItem()) and free it later when no longer needed.