// // BwgBurn - CD-R/CD-RW/DVD-R/DVD-RW burning program for Windows XP // // Copyright (C) 2006 by Jack W. Griffin (butchg@comcast.net) // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License // for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the // // Free Software Foundation, Inc., // 59 Temple Place, Suite 330, // Boston, MA 02111-1307 USA // using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; namespace Bwg.Scsi { /// /// This class represents mode page 5, Write Parameters Mode Page /// public class WriteParameterModePage : ModePage { #region public types /// /// The type of write (packet/incremental, track, session) /// public enum WriteTypeType : byte { /// /// Packet or incremental /// PacketIncremental = 0, /// /// Track at once /// TrackAtOnce = 1, /// /// Session at once /// SessionAtOnce = 2, /// /// Raw data recording /// Raw = 3, /// /// Layer jump recording /// LayerJumpRecording = 4 } /// /// The multisession state of the write page /// public enum MultiSessionType : byte { /// /// No B0 pointer, therefore no next session allowed /// NoNextSession = 0, /// /// B0 pointer equal to 0xFFFFFF, therefore not next session /// allowed /// CDNoNextSessionFFFF = 1, /// /// Reserved, do not use /// Reserved = 2, /// /// B0 pointer points to next session /// NextSessionAllowed = 3 } ; /// /// /// public enum TrackModeType : byte { /// /// /// TwoChannelAudio = 0x00, /// /// /// TwoChannelAudioWithPreemphasis = 0x01, /// /// /// DataUninterrupted = 0x04, /// /// /// DataIncremental = 0x05, /// /// /// FourChannelAudio = 0x08, /// /// /// FourChannelAudioWithPreemphasis = 0x09, } ; /// /// /// public enum DataBlockTypeType : byte { /// /// Raw data, 2352 bytes /// RawData = 0, /// /// Raw data with P and Q subchannels, 2368 bytes /// RawDataWithPAndQ = 1, /// /// Raw data with P - W subchannels packed, 2448 bytes /// RawDataWithPToWPacked = 2, /// /// Raw data with P - W subchannels raw, 2448 bytes /// RawDataWithPToWRaw = 3, /// /// Data mode 1, 2048 bytes /// DataMode1 = 8, /// /// Data mode 2, 2336 bytes /// DataMode2 = 9, /// /// Data mode 2, sub-header from write params, 2048 bytes /// DataMode2Form1 = 10, /// /// Data mode 2, sub-header included, 2056 bytes /// DataMode2Form1Subheader = 11, /// /// Data mode 2, form 2, sub-header from write params, 2324 bytes /// DataMode2Form2 = 12, /// /// Data mode 2, form 2, sub-header included, 2332 bytes /// DataMode2Form2Subheader = 13, } ; /// /// /// public enum SessionFormatType : byte { /// /// CD DA, CD ROM or other data disk /// CDDA_CDROM = 0x00, /// /// CD-I disk /// CD_I = 0x10, /// /// CD-ROM XA Disk /// CDROM_XA = 0x20, } ; #endregion #region constructor /// /// Construct the mode page /// /// pointer to a buffer contains the mode page data /// the size of the buffer area /// the offset to the mode page public WriteParameterModePage(IntPtr buffer, int size, ref ushort offset) : base(buffer, size, ref offset) { } #endregion #region public properties /// /// This property is the burn proof settings on this mode page /// public bool BurnProof { get { return (m_page_data[2] & 0x40) != 0; } set { if (value) m_page_data[2] |= 0x40; else m_page_data[2] &= 0xbf; } } /// /// If true, the link size field is valid. If not true, the link size is assumed to be /// sever (per the SCSI MMC specification). /// public bool LinkSizeValid { get { return (m_page_data[2] & 0x20) != 0; } set { if (value) m_page_data[2] |= 0x20; else m_page_data[2] &= 0xdf; } } /// /// If true, any write will not effect the disk, and the write operation will only be a test. If /// false the writes will go to the disk. This is also known as simulation. /// public bool TestWrite { get { return (m_page_data[2] & 0x10) != 0; } set { if (value) m_page_data[2] |= 0x10; else m_page_data[2] &= 0xef; } } /// /// This property sets the write type /// public WriteTypeType WriteType { get { return (WriteTypeType)(m_page_data[2] & 0x0f); } set { m_page_data[2] &= 0xf0; m_page_data[2] |= (byte)value; } } /// /// This property controls the multi-session mode of the session or track to /// be burned. /// public MultiSessionType MultiSession { get { return (MultiSessionType)((m_page_data[3] >> 6) & 0x03); } set { Debug.Assert(value != MultiSessionType.Reserved); m_page_data[3] &= 0x3F; m_page_data[3] |= (byte)((byte)value << 6); } } /// /// This property controls whether the write mode is fixed packet. This only applies /// if the write type is set to Packet/Incremental. /// public bool FixedPacket { get { return (m_page_data[3] & 0x20) != 0; } set { if (value) m_page_data[3] |= 0x20; else m_page_data[3] &= 0xdf; } } /// /// If true and the media is CD, SCMS copy protection is enabled. /// public bool Copy { get { return (m_page_data[3] & 0x10) != 0; } set { if (value) m_page_data[3] |= 0x10; else m_page_data[3] &= 0xef; } } /// /// The track mode. This should be 5 for DVD media, and is the /// public TrackModeType TrackMode { get { return (TrackModeType)(m_page_data[3] & 0x0d); } set { m_page_data[3] &= 0xf2; m_page_data[3] |= (byte)value; } } /// /// If true, digital copy if premitted of the content, otherwise it is not. /// public bool DigitalCopyPermitted { get { return (m_page_data[3] & 0x02) != 0; } set { if (value) m_page_data[3] |= 0x02; else m_page_data[3] &= 0xfd; } } /// /// /// public DataBlockTypeType DataBlockType { get { return (DataBlockTypeType)(m_page_data[4] & 0x0f); } set { m_page_data[4] &= 0xf0; m_page_data[4] |= (byte)value; } } /// /// /// public byte LinkSize { get { return m_page_data[5]; } set { m_page_data[5] = value; } } /// /// /// public byte HostApplicationCode { get { return (byte)(m_page_data[7] & 0x3f); } set { m_page_data[7] &= 0xc0; m_page_data[7] |= (byte)(value & 0x3f); } } /// /// /// public SessionFormatType SessionFormat { get { return (SessionFormatType)m_page_data[8]; } set { m_page_data[8] = (byte)value; } } /// /// /// public int PacketSize { get { return ModeGet32(10); } set { ModeSet32(10, value); } } /// /// /// public ushort AudioPauseLength { get { return ModeGet16(14); } set { ModeSet16(14, value); } } /// /// /// public byte[] MediaCatalogNumber { get { byte[] num = new byte[16]; for (int i = 0; i < 16; i++) num[i] = m_page_data[16 + i]; return num; } set { Debug.Assert(value.GetLength(0) == 16); for (int i = 0; i < 16; i++) m_page_data[16 + i] = value[i]; } } /// /// /// public byte[] InternationalStandardRecordingCode { get { byte[] num = new byte[16]; for (int i = 0; i < 16; i++) num[i] = m_page_data[32 + i]; return num; } set { Debug.Assert(value.GetLength(0) == 16); for (int i = 0; i < 16; i++) m_page_data[32 + i] = value[i]; } } /// /// /// public byte SubHeaderByte0 { get { return m_page_data[48]; } set { m_page_data[48] = value; } } /// /// /// public byte SubHeaderByte1 { get { return m_page_data[49]; } set { m_page_data[49] = value; } } /// /// /// public byte SubHeaderByte2 { get { return m_page_data[50]; } set { m_page_data[50] = value; } } /// /// /// public byte SubHeaderByte3 { get { return m_page_data[51]; } set { m_page_data[51] = value; } } #endregion } }