Пример #1
0
        public static CDATIP?Decode(byte[] CDATIPResponse)
        {
            if (CDATIPResponse == null)
            {
                return(null);
            }

            CDATIP decoded = new CDATIP();

            if (CDATIPResponse.Length != 32 && CDATIPResponse.Length != 28)
            {
                DicConsole.DebugWriteLine("CD ATIP decoder",
                                          "Expected CD ATIP size (32 bytes) is not received size ({0} bytes), not decoding",
                                          CDATIPResponse.Length);
                return(null);
            }

            decoded.DataLength     = BigEndianBitConverter.ToUInt16(CDATIPResponse, 0);
            decoded.Reserved1      = CDATIPResponse[2];
            decoded.Reserved2      = CDATIPResponse[3];
            decoded.ITWP           = (byte)((CDATIPResponse[4] & 0xF0) >> 4);
            decoded.DDCD           = Convert.ToBoolean(CDATIPResponse[4] & 0x08);
            decoded.ReferenceSpeed = (byte)(CDATIPResponse[4] & 0x07);
            decoded.AlwaysZero     = Convert.ToBoolean(CDATIPResponse[5] & 0x80);
            decoded.URU            = Convert.ToBoolean(CDATIPResponse[5] & 0x40);
            decoded.Reserved3      = (byte)(CDATIPResponse[5] & 0x3F);

            decoded.AlwaysOne   = Convert.ToBoolean(CDATIPResponse[6] & 0x80);
            decoded.DiscType    = Convert.ToBoolean(CDATIPResponse[6] & 0x40);
            decoded.DiscSubType = (byte)((CDATIPResponse[6] & 0x38) >> 3);
            decoded.A1Valid     = Convert.ToBoolean(CDATIPResponse[6] & 0x04);
            decoded.A2Valid     = Convert.ToBoolean(CDATIPResponse[6] & 0x02);
            decoded.A3Valid     = Convert.ToBoolean(CDATIPResponse[6] & 0x01);

            decoded.Reserved4         = CDATIPResponse[7];
            decoded.LeadInStartMin    = CDATIPResponse[8];
            decoded.LeadInStartSec    = CDATIPResponse[9];
            decoded.LeadInStartFrame  = CDATIPResponse[10];
            decoded.Reserved5         = CDATIPResponse[11];
            decoded.LeadOutStartMin   = CDATIPResponse[12];
            decoded.LeadOutStartSec   = CDATIPResponse[13];
            decoded.LeadOutStartFrame = CDATIPResponse[14];
            decoded.Reserved6         = CDATIPResponse[15];

            decoded.A1Values = new byte[3];
            decoded.A2Values = new byte[3];
            decoded.A3Values = new byte[3];

            Array.Copy(CDATIPResponse, 16, decoded.A1Values, 0, 3);
            Array.Copy(CDATIPResponse, 20, decoded.A2Values, 0, 3);
            Array.Copy(CDATIPResponse, 24, decoded.A3Values, 0, 3);

            decoded.Reserved7 = CDATIPResponse[19];
            decoded.Reserved8 = CDATIPResponse[23];
            decoded.Reserved9 = CDATIPResponse[27];

            if (CDATIPResponse.Length < 32)
            {
                return(decoded);
            }

            decoded.S4Values = new byte[3];
            Array.Copy(CDATIPResponse, 28, decoded.S4Values, 0, 3);
            decoded.Reserved10 = CDATIPResponse[31];

            return(decoded);
        }
Пример #2
0
        public static string Prettify(CDATIP?CDATIPResponse)
        {
            if (CDATIPResponse == null)
            {
                return(null);
            }

            CDATIP response = CDATIPResponse.Value;

            StringBuilder sb = new StringBuilder();

            if (response.DDCD)
            {
                sb.AppendFormat("Indicative Target Writing Power: 0x{0:X2}", response.ITWP).AppendLine();
                sb.AppendLine(response.DiscType ? "Disc is DDCD-RW" : "Disc is DDCD-R");
                switch (response.ReferenceSpeed)
                {
                case 2:
                    sb.AppendLine("Reference speed is 4x");
                    break;

                case 3:
                    sb.AppendLine("Reference speed is 8x");
                    break;

                default:
                    sb.AppendFormat("Reference speed set is unknown: {0}", response.ReferenceSpeed).AppendLine();
                    break;
                }

                sb.AppendFormat("ATIP Start time of Lead-in: 0x{0:X6}",
                                (response.LeadInStartMin << 16) + (response.LeadInStartSec << 8) +
                                response.LeadInStartFrame).AppendLine();
                sb.AppendFormat("ATIP Last possible start time of Lead-out: 0x{0:X6}",
                                (response.LeadOutStartMin << 16) + (response.LeadOutStartSec << 8) +
                                response.LeadOutStartFrame).AppendLine();
                sb.AppendFormat("S4 value: 0x{0:X6}",
                                (response.S4Values[0] << 16) + (response.S4Values[1] << 8) + response.S4Values[2])
                .AppendLine();
            }
            else
            {
                sb.AppendFormat("Indicative Target Writing Power: 0x{0:X2}", response.ITWP & 0x07).AppendLine();
                if (response.DiscType)
                {
                    switch (response.DiscSubType)
                    {
                    case 0:
                        sb.AppendLine("Disc is CD-RW");
                        break;

                    case 1:
                        sb.AppendLine("Disc is High-Speed CD-RW");
                        break;

                    case 2:
                        sb.AppendLine("Disc is Ultra-Speed CD-RW");
                        break;

                    case 3:
                        sb.AppendLine("Disc is Ultra-Speed+ CD-RW");
                        break;

                    case 4:
                        sb.AppendLine("Disc is medium type B, low beta category (B-) CD-RW");
                        break;

                    case 5:
                        sb.AppendLine("Disc is medium type B, high beta category (B+) CD-RW");
                        break;

                    case 6:
                        sb.AppendLine("Disc is medium type C, low beta category (C-) CD-RW");
                        break;

                    case 7:
                        sb.AppendLine("Disc is medium type C, high beta category (C+) CD-RW");
                        break;

                    default:
                        sb.AppendFormat("Unknown CD-RW disc subtype: {0}", response.DiscSubType).AppendLine();
                        break;
                    }

                    switch (response.ReferenceSpeed)
                    {
                    case 1:
                        sb.AppendLine("Reference speed is 2x");
                        break;

                    default:
                        sb.AppendFormat("Reference speed set is unknown: {0}", response.ReferenceSpeed)
                        .AppendLine();
                        break;
                    }
                }
                else
                {
                    sb.AppendLine("Disc is CD-R");
                    switch (response.DiscSubType)
                    {
                    case 0:
                        sb.AppendLine("Disc is normal speed (CLV) CD-R");
                        break;

                    case 1:
                        sb.AppendLine("Disc is high speed (CAV) CD-R");
                        break;

                    case 2:
                        sb.AppendLine("Disc is medium type A, low beta category (A-) CD-R");
                        break;

                    case 3:
                        sb.AppendLine("Disc is medium type A, high beta category (A+) CD-R");
                        break;

                    case 4:
                        sb.AppendLine("Disc is medium type B, low beta category (B-) CD-R");
                        break;

                    case 5:
                        sb.AppendLine("Disc is medium type B, high beta category (B+) CD-R");
                        break;

                    case 6:
                        sb.AppendLine("Disc is medium type C, low beta category (C-) CD-R");
                        break;

                    case 7:
                        sb.AppendLine("Disc is medium type C, high beta category (C+) CD-R");
                        break;

                    default:
                        sb.AppendFormat("Unknown CD-R disc subtype: {0}", response.DiscSubType).AppendLine();
                        break;
                    }
                }

                sb.AppendLine(response.URU ? "Disc use is unrestricted" : "Disc use is restricted");

                sb.AppendFormat("ATIP Start time of Lead-in: {0}:{1:D2}:{2:D2}", response.LeadInStartMin,
                                response.LeadInStartSec, response.LeadInStartFrame).AppendLine();
                sb.AppendFormat("ATIP Last possible start time of Lead-out: {0}:{1:D2}:{2:D2}",
                                response.LeadOutStartMin, response.LeadOutStartSec, response.LeadOutStartFrame)
                .AppendLine();
                if (response.A1Valid)
                {
                    sb.AppendFormat("A1 value: 0x{0:X6}",
                                    (response.A1Values[0] << 16) + (response.A1Values[1] << 8) + response.A1Values[2])
                    .AppendLine();
                }
                if (response.A2Valid)
                {
                    sb.AppendFormat("A2 value: 0x{0:X6}",
                                    (response.A2Values[0] << 16) + (response.A2Values[1] << 8) + response.A2Values[2])
                    .AppendLine();
                }
                if (response.A3Valid)
                {
                    sb.AppendFormat("A3 value: 0x{0:X6}",
                                    (response.A3Values[0] << 16) + (response.A3Values[1] << 8) + response.A3Values[2])
                    .AppendLine();
                }
                if (response.S4Values != null)
                {
                    sb.AppendFormat("S4 value: 0x{0:X6}",
                                    (response.S4Values[0] << 16) + (response.S4Values[1] << 8) + response.S4Values[2])
                    .AppendLine();
                }
            }

            if (response.LeadInStartMin != 97)
            {
                return(sb.ToString());
            }

            int type = response.LeadInStartFrame % 10;
            int frm  = response.LeadInStartFrame - type;

            if (response.DiscType)
            {
                sb.AppendLine("Disc uses phase change");
            }
            else
            {
                sb.AppendLine(type < 5
                                  ? "Disc uses long strategy type dye (Cyanine, AZO, etc...)"
                                  : "Disc uses short strategy type dye (Phthalocyanine, etc...)");
            }

            string manufacturer = ManufacturerFromATIP(response.LeadInStartSec, frm);

            if (manufacturer != "")
            {
                sb.AppendFormat("Disc manufactured by: {0}", manufacturer).AppendLine();
            }

            return(sb.ToString());
        }
Пример #3
0
        public static string Prettify(byte[] CDATIPResponse)
        {
            CDATIP decoded = Decode(CDATIPResponse);

            return(Prettify(decoded));
        }