如何使用 IMAPI2 检索和设置刻录速度?

发布于 2024-10-31 09:22:01 字数 86 浏览 6 评论 0原文

有谁知道如何使用 IMAPI2 设置 CD/DVD 刻录速度(例如 4x、10x)?

另外,我首先需要获得媒体支持的速度。我怎样才能找回它们?

Does anyone know how to set CD/DVD burn speed (e.g. 4x, 10x) using IMAPI2?

Also, I first need to get the speeds supported by the media. How can I retrieve them?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

佞臣 2024-11-07 09:22:01
  1. 要设置刻录速度,您可以使用方法IDiscFormat2Data::SetWriteSpeed 来自 IDiscFormat2Data 接口。它允许您请求光学介质支持的最大速度或指定所需的刻录速度。

  2. 要检索刻录设备和当前介质支持的写入速度,您可以使用方法IDiscFormat2Data::get_SupportedWriteSpeeds

  3. < p>要检查当前的写入速度,您可以使用 IDiscFormat2Data::get_CurrentWriteSpeed 方法。

这些方法使用每秒扇区数,而不是 4x、10x 等。您可以使用以下常量将一种方法转换为另一种方法:

  • IMAPI_SECTOR_SIZE
    扇区中的字节数。
  • IMAPI_SECTORS_PER_SECOND_AT_1X_CD
    CD 旋转的基本速率,以每秒扇区为单位测量。
  • IMAPI_SECTORS_PER_SECOND_AT_1X_DVD
    DVD 旋转的基本速率,以每秒扇区为单位测量。
  • IMAPI_SECTORS_PER_SECOND_AT_1X_BD
    蓝光光盘旋转的基本速率,以每秒扇区为单位测量。

来自imapi2.h头文件:

<前><代码>#define IMAPI_SECTORS_PER_SECOND_AT_1X_CD 75
#define IMAPI_SECTORS_PER_SECOND_AT_1X_DVD 680
#定义 IMAPI_SECTORS_PER_SECOND_AT_1X_BD 2195
#定义 IMAPI_SECTORS_PER_SECOND_AT_1X_HD_DVD 4568

  1. To set the burn speed you can use the method IDiscFormat2Data::SetWriteSpeed from IDiscFormat2Data interface. It lets you request the maximum speed supported by optical media or specify the wanted burning speed.

  2. In order to retrieve the supported write speeds by the burning device and current media you can use the method IDiscFormat2Data::get_SupportedWriteSpeeds

  3. To check the current write speed you have the IDiscFormat2Data::get_CurrentWriteSpeed method.

Those methods use sectors per second instead of 4x, 10x, etc. You can convert from one to another using the following constants:

  • IMAPI_SECTOR_SIZE
    Number of bytes in a sector.
  • IMAPI_SECTORS_PER_SECOND_AT_1X_CD
    Base rate of speed that a CD spins, measured in sectors per second.
  • IMAPI_SECTORS_PER_SECOND_AT_1X_DVD
    Base rate of speed that a DVD spins, measured in sectors per second.
  • IMAPI_SECTORS_PER_SECOND_AT_1X_BD
    Base rate of speed that a Blu-ray disc spins, measured in sectors per second.

from imapi2.h header:

#define IMAPI_SECTORS_PER_SECOND_AT_1X_CD      75
#define IMAPI_SECTORS_PER_SECOND_AT_1X_DVD     680
#define IMAPI_SECTORS_PER_SECOND_AT_1X_BD      2195
#define IMAPI_SECTORS_PER_SECOND_AT_1X_HD_DVD  4568
逆夏时光 2024-11-07 09:22:01

Microsoft 最初发布了 C# 的 IMAPI 接口。它有很多问题。您可以阅读有关它的更多信息 这里。所以我正在使用这个源代码(由
Eric Haddan 在 Code Project 上)而不是 Microsoft 发布的副本。因此,您可能会发现文档方面存在一些差异。

在与写入速度交互(获取/设置)之前,您需要执行一些初始操作,例如设置记录器。我假设您知道所有这些,并在这个答案中跳过它以缩短长度。

要设置刻录速度,您可以选择首先获取支持的写入速度:

private string[] GetSupportedWriteSpeeds()
{
    string[] list = new string[msftDiscFormat2Data.SupportedWriteSpeedDescriptors.Length];
    for(int i = 0; i < msftDiscFormat2Data.SupportedWriteSpeedDescriptors.Length; i++)
    {
        IWriteSpeedDescriptor objIWriteSpeedDescriptor = (IWriteSpeedDescriptor)msftDiscFormat2Data.SupportedWriteSpeedDescriptors[i];
        list[i] = objIWriteSpeedDescriptor.WriteSpeed.ToString();
    }
    return list;
}

然后,根据上面收到的支持的值,您可以设置写入速度:

private void SetWriteSpeed(int requestedSectorsPerSecond, bool rotationTypeIsPureCAV)
{
    /*selectedWritingSpeed
        Unit = Disc sectors per second.
        Values: -
        -1 = "Default OR Fastest" as documented in IMAPI documentation.
        [ANY VALUE] = Actual writing speed to set.
    */
    msftDiscFormat2Data.SetWriteSpeed(requestedSectorsPerSecond, rotationTypeIsPureCAV);
}

在上面的方法中,参数 requestedSectorsPerSecond 是字符串的索引您从之前的方法收到的数组(写入速度)。您可以将旋转类型(纯 CAV)设置为 false

以下内容来自 Microsoft :

RequestedSectorsPerSecond

请求的写入速度以每秒磁盘扇区为单位测量。

值 0xFFFFFFFF (-1) 请求使用介质支持的最快速度进行写入。这是默认设置。

RotationTypeIsPureCAV

请求的转速控制类型。设置为 VARIANT_TRUE 以请求恒定角速度 (CAV) 转速控制类型。设置为 VARIANT_FALSE 以使用记录仪支持的另一种转速控制类型。默认值为 VARIANT_FALSE。

上面代码中使用的对象名称是根据 IMAPI 本身。这就是为什么我没有添加更多关于 IMAPI 接口的描述。 @rmp 的其他答案已经给出了更多详细信息。

Microsoft initially released IMAPI interface for C#. It had many problems. You can read more about it here. So I am using this source code (written by
Eric Haddan on Code Project) instead of the copy that was released by Microsoft. So, you may see some differences with respect to documentation.

Before you interact with write speed (get/set), you need to do some initial actions like setting the recorder. I am assuming you know all this and skipping it in this answer to shorten the length.

To set the burn speed, you optionally need to get the supported write speeds first:

private string[] GetSupportedWriteSpeeds()
{
    string[] list = new string[msftDiscFormat2Data.SupportedWriteSpeedDescriptors.Length];
    for(int i = 0; i < msftDiscFormat2Data.SupportedWriteSpeedDescriptors.Length; i++)
    {
        IWriteSpeedDescriptor objIWriteSpeedDescriptor = (IWriteSpeedDescriptor)msftDiscFormat2Data.SupportedWriteSpeedDescriptors[i];
        list[i] = objIWriteSpeedDescriptor.WriteSpeed.ToString();
    }
    return list;
}

Then, based on received supported values above, you can set the write speed:

private void SetWriteSpeed(int requestedSectorsPerSecond, bool rotationTypeIsPureCAV)
{
    /*selectedWritingSpeed
        Unit = Disc sectors per second.
        Values: -
        -1 = "Default OR Fastest" as documented in IMAPI documentation.
        [ANY VALUE] = Actual writing speed to set.
    */
    msftDiscFormat2Data.SetWriteSpeed(requestedSectorsPerSecond, rotationTypeIsPureCAV);
}

In above method, parameter requestedSectorsPerSecond is index of string array (write speed) you received from earlier method. You may set rotation type (pure CAV) to false.

Following is from Microsoft:

RequestedSectorsPerSecond

Requested write speed measured in disc sectors per second.

A value of 0xFFFFFFFF (-1) requests that the write occurs using the fastest supported speed for the media. This is the default.

RotationTypeIsPureCAV

Requested rotational-speed control type. Set to VARIANT_TRUE to request constant angular velocity (CAV) rotational-speed control type. Set to VARIANT_FALSE to use another rotational-speed control type that the recorder supports. The default is VARIANT_FALSE.

Names of the objects used in code above are according to IMAPI itself. That is why, I am not adding more description about the IMAPI interface. More details are already given by other answer from @rmp.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文