I am using IMAPIv2 to burn CD/DVDs in my C# project. I realized that the interface burns in XA-format (Mode 2). I believe XA-format is mainly used for ISOs. A lot of examples about IMAPIv2 on the web uses the following method to demonstrate total disc space and free space:
discFormatData.Recorder = discRecorder;
IMAPI_MEDIA_PHYSICAL_TYPE mediaType = discFormatData.CurrentPhysicalMediaType;
this.MediaType = GetMediaTypeString(mediaType);
fileSystemImage = new MsftFileSystemImage();
fileSystemImage.ChooseImageDefaultsForMediaType(mediaType);
MediaStateString = GetMediaStatus(discFormatData.CurrentMediaStatus);
if (discFormatData.MediaHeuristicallyBlank) MediaStateString = "Blank";
Int64 freeMediaBlocks = discFormatData.FreeSectorsOnMedia;
this.TotalDiscCapacity = 2048 * freeMediaBlocks;
Int64 userMediaBlocks = discFormatData.TotalSectorsOnMedia - discFormatData.FreeSectorsOnMedia;
this.TotalUsedDiscSpace = 2048 * userMediaBlocks;
Unfortunately, if I multiply 2048 * with TotalSectorsOnMedia as described above I will not get a correct Total Disc Capacity. When I burn a 800 MB capacity disc with IMAPIv2 then the above code will show that my disc capacity is somewhat around 650 MB. When I check the disc with other software burners, i see that the mode is set XA. Is it possible to set this mode before burning? Also, how would I solve the issue of determining disc free space if there are sessions written in mode 1? Is it possible to learn in which mode the disc is written?
Thanks.
In order to get the total disk capacity you need to multiply the number of sectors by the length of the user data field on each sector(which on CD-ROM/XA (eXtended Architecture) Mode 2 would be 2336 bytes instead of 2048)
A sector on a CD-ROM holds 2048 bytes of user data, leaving 304 bytes for other purposes. Every data sector begins with a 16-byte header:
The mode byte determines what the remaining 2336 bytes in the sector looks like:
In order to retrieve the type of data provided for the sectors in one track you can use the method get_SectorType from IRawCDImageTrackInfo interface.
The possible sector types are defined by the IMAPI_CD_SECTOR_TYPE enumeration: