c# - IMAPI界面可以选择刻录模式吗?

标签 c# imapi

我正在使用 IMAPIv2 在我的 C# 项目中刻录 CD/DVD。我意识到接口(interface)以 XA 格式(模式 2)刻录。我相信 XA 格式主要用于 ISO。网上很多关于IMAPIv2的例子都是用下面的方法来演示磁盘总空间和可用空间:

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;

不幸的是,如果我如上所述将 2048 * 与 TotalSectorsOnMedia 相乘,我将无法获得正确的总磁盘容量。当我使用 IMAPIv2 刻录 800 MB 容量的光盘时,上面的代码将显示我的光盘容量大约为 650 MB。当我用其他软件刻录机检查光盘时,我看到模式设置为 XA。是否可以在刻录前设置此模式?另外,如果有以模式1写入的 session ,我将如何解决确定磁盘可用空间的问题?是否可以了解光盘是在哪种模式下写入的?

谢谢。

最佳答案

为了获得总磁盘容量,您需要将扇区数乘以每个扇区上用户数据字段的长度(在 CD-ROM/XA(扩展架构)模式 2 上为 2336 字节,而不是2048)


CD-ROM 上的一个扇区包含 2048 字节的用户数据,剩下 304 字节用于其他用途。每个数据扇区都以 16 字节的 header 开头:

  • 12 字节同步字段(00 ff ff ff ff ff ff ff ff ff ff 00)
  • 3 字节地址(分、秒、秒的小数(1/75))
  • 1字节模式

模式字节决定扇区中剩余的 2336 字节是什么样的:

  • 模式0:空数据;对 CD 录制没有实际意义
  • 模式 1:典型的 CD-ROM 布局 2048 字节的用户数据 4 个字节的 EDC(错误检测码,一个 32 位 CRC) 8 个字节的保留空间,设置为零 172 字节的“P”奇偶校验 104字节的“Q”奇偶校验
  • 方式二:2336字节用户数据,一般用于CD-ROM/XA

为了检索为一个轨道中的扇区提供的数据类型,您可以使用方法 get_SectorType来自 IRawCDImageTrackInfo界面。

可能的扇区类型由 IMAPI_CD_SECTOR_TYPE 定义枚举:

typedef enum  { 
 IMAPI_CD_SECTOR_AUDIO          = 0x00,
 IMAPI_CD_SECTOR_MODE_ZERO      = 0x01,
 IMAPI_CD_SECTOR_MODE1          = 0x02,
 IMAPI_CD_SECTOR_MODE2FORM0     = 0x03,
 IMAPI_CD_SECTOR_MODE2FORM1     = 0x04,
 IMAPI_CD_SECTOR_MODE2FORM2     = 0x05,
 IMAPI_CD_SECTOR_MODE1RAW       = 0x06,
 IMAPI_CD_SECTOR_MODE2FORM0RAW  = 0x07,
 IMAPI_CD_SECTOR_MODE2FORM1RAW  = 0x08,
 IMAPI_CD_SECTOR_MODE2FORM2RAW  = 0x09
} IMAPI_CD_SECTOR_TYPE;
  • IMAPI_CD_SECTOR_AUDIO With this sector type, Audio data has 2352 bytes per sector/frame. This can be broken down into 588 contiguous samples, each sample being four bytes. The layout of a single sample matches the 16-bit stereo 44.1KHz WAV file data. This type of sector has no additional error correcting codes.
  • IMAPI_CD_SECTOR_MODE_ZERO With this sector type, user data has 2336 bytes per sector/frame. This seldom-used sector type contains all zero data, and is almost never seen in media today.
  • IMAPI_CD_SECTOR_MODE1 With this sector type, user data has 2048 bytes per sector/frame. Mode1 data is the most common data form for pressed CD-ROM media. This data type also provides the greatest level of ECC/EDC among the standard sector types.
  • IMAPI_CD_SECTOR_MODE2FORM0 With this sector type, user data has 2336 bytes per sector/frame. All Mode 2 sector types are also known as "CD-ROM XA" modes, which allows mixing of audio and data tracks on a single disc. This sector type is also known as Mode 2 "Formless", is considered deprecated, and is very seldom used.
  • IMAPI_CD_SECTOR_MODE2FORM1 With this sector type, user data has 2048 bytes per sector/frame. All Mode 2 sector types are also known as "CD-ROM XA" modes, which allows mixing of audio and data tracks on a single disc.
  • IMAPI_CD_SECTOR_MODE2FORM2 With this sector type, user data has 2336 bytes per sector/frame, of which the final four bytes are an optional CRC code (zero if not used). All Mode 2 sector types are also known as "CD-ROM XA" modes, which allows mixing of audio and data tracks on a single disc. This sector type is most often used when writing VideoCD discs.
  • IMAPI_CD_SECTOR_MODE1RAW With this sector type, user data has 2352 bytes per sector/frame. This is pre-processed Mode1Cooked data sectors, with sector header, ECC/EDC, and scrambling already added to the data stream.
  • IMAPI_CD_SECTOR_MODE2FORM0RAW With this sector type, user data has 2352 bytes per sector/frame. This is pre-processed Mode2Form0 data sectors, with sector header, ECC/EDC, and scrambling already added to the data stream.
  • IMAPI_CD_SECTOR_MODE2FORM1RAW With this sector type, user data has 2352 bytes per sector/frame. This is pre-processed Mode2Form1 data sectors, with sector header, ECC/EDC, and scrambling already added to the data stream.
  • IMAPI_CD_SECTOR_MODE2FORM2RAW With this sector type, user data has 2352 bytes per sector/frame. This is pre-processed Mode2Form2 data sectors, with sector header, ECC/EDC, and scrambling already added to the data stream.

Remarks: Some sector types are not compatible with other sector types within a single image. The following are typical examples of this condition: If the first track is audio, then all tracks must be audio. If the first track is Mode1, then all tracks must be Mode1. Only the three Mode2 (XA) sectors (Mode 2 Form 0, Mode 2 Form 1, and Mode 2 Form 2) may be mixed within a single disc image, and even then, only with other Mode 2 (XA) sector types.

关于c# - IMAPI界面可以选择刻录模式吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4874374/

相关文章:

c# - ASP .NET Core 写入 XML 文件

c++ - 查找 imapi2 com 对象的 uuid/ header 或获取 __uuidof 以在 mingw 上工作

c# - 无法在 Windows 应用商店应用程序中删除 Sqlite 数据库中的记录

c# - MSAL 是否仅适用于 Azure 和 Microsoft 身份平台?

c# - MsftDiscFormat2Data 事件处理程序

java - 使用IMAPI 2.0监视刻录进度并将更新传递给Java

IMAPI:get_MediaPhysicallyBlank 和 get_MediaHeuristicallyBlank 之间有什么区别?

c++ - 如何实例化MsftRawCDImageCreator?

c# - Excel 自动化 Windows 服务

c# - 在 mouse_click 事件中选择 DataGridView 中的行