How to retrieve and set burn speed using IMAPI2?

1.7k views Asked by At

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?

2

There are 2 answers

0
Amit Joshi On

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.

0
rmp On
  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