Mirage.Sector

g GObject.GInterface GObject.GInterface Mirage.Contextual Mirage.Contextual GObject.GInterface->Mirage.Contextual GObject.Object GObject.Object Mirage.Object Mirage.Object GObject.Object->Mirage.Object Mirage.Contextual->Mirage.Object Mirage.Sector Mirage.Sector Mirage.Object->Mirage.Sector

Subclasses:

None

Methods

Inherited:

Mirage.Object (2), GObject.Object (37), Mirage.Contextual (8)

Structs:

GObject.ObjectClass (5)

extract_data (main_data_length, subchannel_data, subchannel_data_length)

feed_data (address, type, main_data, main_data_length, subchannel_format, subchannel_data, subchannel_data_length, ignore_data_mask)

get_address ()

get_data ()

get_edc_ecc ()

get_header ()

get_sector_type ()

get_subchannel (format)

get_subheader ()

get_sync ()

scramble ()

set_data (buf)

set_edc_ecc (buf)

set_header (buf)

set_subchannel (format, buf)

set_subheader (buf)

set_sync (buf)

verify_lec ()

verify_subchannel_crc ()

Virtual Methods

Inherited:

GObject.Object (7), Mirage.Contextual (2)

Properties

None

Signals

Inherited:

Mirage.Object (1), GObject.Object (1)

Fields

Inherited:

Mirage.Object (1), GObject.Object (1)

Name

Type

Access

Description

parent_instance

Mirage.Object

r

Class Details

class Mirage.Sector(**kwargs)
Bases:

Mirage.Object

Abstract:

No

Structure:

Mirage.SectorClass

All the fields in the Mirage.Sector structure are private to the Mirage.Sector implementation and should never be accessed directly.

extract_data(main_data_length, subchannel_data, subchannel_data_length)
Parameters:
  • main_data_length (int) – requested length of data in main data buffer

  • subchannel_data (int or None) – location to store pointer to subchannel data buffer, or None

  • subchannel_data_length (int) – requested length of data in subchannel data buffer

Raises:

GLib.Error

Returns:

True on success, False on failure

main_data:

location to store pointer to main data buffer

subchannel_format:

requested subchannel data format

Return type:

(bool, main_data: int, subchannel_format: Mirage.SectorSubchannelFormat)

Extracts data from sector. Which parts of main channel data are extracted depends on provided main_data_length.

Intended for internal use.

feed_data(address, type, main_data, main_data_length, subchannel_format, subchannel_data, subchannel_data_length, ignore_data_mask)
Parameters:
  • address (int) – absolute disc address the sector represents. Given in sectors.

  • type (Mirage.SectorType) – track type (one of Mirage.SectorType)

  • main_data (int) – main data buffer

  • main_data_length (int) – length of data in main data buffer

  • subchannel_format (Mirage.SectorSubchannelFormat) – subchannel data format

  • subchannel_data (int or None) – subchannel data buffer

  • subchannel_data_length (int) – length of data in subchannel data buffer

  • ignore_data_mask (int) – a mask of Mirage.SectorValidData values, indicating which parts of main channel sector data, if any, should be ignored and regerated even though they are provided by the data feed

Raises:

GLib.Error

Returns:

True on success, False on failure

Return type:

bool

Feeds data to sector. If type is Mirage.SectorType.RAW or Mirage.SectorType.RAW_SCRAMBLED, the real sector type is determined during feeding.

Intended for internal use.

get_address()
Returns:

sector address

Return type:

int

Retrieves absolute disc address of the sector.

get_data()
Raises:

GLib.Error

Returns:

True on success, False on failure

ret_buf:

location to store pointer to buffer containing user data, or None

Return type:

(bool, ret_buf: bytes)

Retrieves sector’s user data. The pointer to appropriate location in sector’s data buffer is stored into ret_buf; therefore, the buffer should not be modified.

get_edc_ecc()
Raises:

GLib.Error

Returns:

True on success, False on failure

ret_buf:

location to store pointer to buffer containing EDC/ECC data, or None

Return type:

(bool, ret_buf: bytes)

Retrieves sector’s EDC/ECC data. The pointer to appropriate location in sector’s data buffer is stored into ret_buf; therefore, the buffer should not be modified.

If EDC/ECC data is not provided by image file(s), it is generated.

get_header()
Raises:

GLib.Error

Returns:

True on success, False on failure

ret_buf:

location to store pointer to buffer containing header, or None

Return type:

(bool, ret_buf: bytes)

Retrieves sector’s header. The pointer to appropriate location in sector’s data buffer is stored into ret_buf; therefore, the buffer should not be modified.

If header is not provided by image file(s), it is generated.

get_sector_type()
Returns:

sector type (track mode)

Return type:

Mirage.SectorType

Retrieves sector type (track mode); one of Mirage.SectorType.

get_subchannel(format)
Parameters:

format (Mirage.SectorSubchannelFormat) – subchannel format

Raises:

GLib.Error

Returns:

True on success, False on failure

ret_buf:

location to store pointer to buffer containing subchannel, or None

Return type:

(bool, ret_buf: bytes)

Retrieves sector’s subchannel. format must be one of Mirage.SectorSubchannelFormat. The pointer to appropriate location in sector’s data buffer is stored into ret_buf; therefore, the buffer should not be modified.

If subchannel is not provided by image file(s), it is generated.

get_subheader()
Raises:

GLib.Error

Returns:

True on success, False on failure

ret_buf:

location to store pointer to buffer containing subheader, or None

Return type:

(bool, ret_buf: bytes)

Retrieves sector’s subheader. The pointer to appropriate location in sector’s data buffer is stored into ret_buf; therefore, the buffer should not be modified.

If subheader is not provided by image file(s), it is generated.

get_sync()
Raises:

GLib.Error

Returns:

True on success, False on failure

ret_buf:

location to store pointer to buffer containing sync pattern, or None

Return type:

(bool, ret_buf: bytes)

Retrieves sector’s sync pattern. The pointer to appropriate location in sector’s data buffer is stored into ret_buf; therefore, the buffer should not be modified.

If sync pattern is not provided by image file(s), it is generated.

scramble()

Scrambles 2340 bytes of sector data after sync pattern, using scrambler from ECMA-130 Annex B. Running this function on already-scrambled sector results in unscrambling.

set_data(buf)
Parameters:

buf (bytes) – buffer containing user data

Raises:

GLib.Error

Returns:

True on success, False on failure

Return type:

bool

Sets sector’s user data to that stored in buf.

set_edc_ecc(buf)
Parameters:

buf (bytes) – buffer containing EDC/ECC data

Raises:

GLib.Error

Returns:

True on success, False on failure

Return type:

bool

Sets sector’s EDC/ECC data to that stored in buf.

set_header(buf)
Parameters:

buf (bytes) – buffer containing header

Raises:

GLib.Error

Returns:

True on success, False on failure

Return type:

bool

Sets sector’s header to that stored in buf.

set_subchannel(format, buf)
Parameters:
Raises:

GLib.Error

Returns:

True on success, False on failure

Return type:

bool

Sets sector’s subchannel data to that stored in buf. format must be one of Mirage.SectorSubchannelFormat.

set_subheader(buf)
Parameters:

buf (bytes) – buffer containing subheader

Raises:

GLib.Error

Returns:

True on success, False on failure

Return type:

bool

Sets sector’s subheader to that stored in buf.

set_sync(buf)
Parameters:

buf (bytes) – buffer containing sync pattern

Raises:

GLib.Error

Returns:

True on success, False on failure

Return type:

bool

Sets sector’s sync pattern to that stored in buf.

verify_lec()
Returns:

True if sector passes verification (i.e. no L-EC errors are detected) otherwise False

Return type:

bool

Verifies the sector data in terms of L-EC error detection/correction. Data sectors (Mode 1, Mode 2 Form 1 and Mode 2 Form 2) contain error detection/error correction codes which is part of so called layered error correction. This function calculates the EDC for sector data and compares it with EDC provided by the image file.

As a result of comparison, the sectors with intentionally faulty EDC (and possibly ECC, though ECC is not verified) can be discovered.

This function requires EDC/ECC data to be provided by the image. If it is not provided, it would be generated by Mirage.Sector on first access via Mirage.Sector.get_edc_ecc() using the same algorithm as the one used by this function. Therefore, in case of EDC/ECC data missing, the verification automatically succeeds.

verify_subchannel_crc()
Returns:

True if sector’s Q subchannel CRC passes verification otherwise False

Return type:

bool

Verifies the Q subchannel’s CRC for the sector.

As a result of comparison, the sectors with intentionally faulty Q subchannel can be discovered.

This function requires subchannel data to be provided by the image. If it is not provided, it would be generated by Mirage.Sector on first access via Mirage.Sector.get_subchannel() using the same algorithm as the one used by this function. Therefore, in case of subchannel data missing, the verification automatically succeeds.