2017-05-19 20:28:49 +01:00
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:23 +00:00
|
|
|
// Aaru Data Preservation Suite
|
2015-12-01 03:23:31 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : DI.cs
|
2016-07-28 18:13:49 +01:00
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
2015-12-01 03:23:31 +00:00
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// Component : Device structures decoders.
|
2015-12-01 03:23:31 +00:00
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// Decodes Blu-ray Disc Information.
|
2015-12-01 03:23:31 +00:00
|
|
|
//
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// This library is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU Lesser General Public License as
|
|
|
|
|
// published by the Free Software Foundation; either version 2.1 of the
|
2015-12-01 03:23:31 +00:00
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// This library 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
|
|
|
|
|
// Lesser General Public License for more details.
|
2015-12-01 03:23:31 +00:00
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2015-12-01 03:23:31 +00:00
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2022-02-18 10:02:39 +00:00
|
|
|
// Copyright © 2011-2022 Natalia Portillo
|
2015-12-01 03:23:31 +00:00
|
|
|
// ****************************************************************************/
|
2016-07-28 18:13:49 +01:00
|
|
|
|
2015-12-01 03:23:31 +00:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2017-12-22 02:04:18 +00:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2015-12-01 03:23:31 +00:00
|
|
|
using System.Text;
|
2020-02-27 00:33:24 +00:00
|
|
|
using Aaru.Console;
|
2020-07-20 15:43:51 +01:00
|
|
|
using Aaru.Helpers;
|
2015-12-01 03:23:31 +00:00
|
|
|
|
2022-11-15 15:58:41 +00:00
|
|
|
namespace Aaru.Decoders.Bluray;
|
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
// Information from the following standards:
|
|
|
|
|
// ANSI X3.304-1997
|
|
|
|
|
// T10/1048-D revision 9.0
|
|
|
|
|
// T10/1048-D revision 10a
|
|
|
|
|
// T10/1228-D revision 7.0c
|
|
|
|
|
// T10/1228-D revision 11a
|
|
|
|
|
// T10/1363-D revision 10g
|
|
|
|
|
// T10/1545-D revision 1d
|
|
|
|
|
// T10/1545-D revision 5
|
|
|
|
|
// T10/1545-D revision 5a
|
|
|
|
|
// T10/1675-D revision 2c
|
|
|
|
|
// T10/1675-D revision 4
|
|
|
|
|
// T10/1836-D revision 2g
|
|
|
|
|
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
|
|
|
|
|
SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")]
|
|
|
|
|
public static class DI
|
2015-12-01 03:23:31 +00:00
|
|
|
{
|
2022-03-06 13:29:37 +00:00
|
|
|
public enum BluSize : byte
|
2015-12-01 03:23:31 +00:00
|
|
|
{
|
2022-03-06 13:29:37 +00:00
|
|
|
/// <summary>120mm</summary>
|
|
|
|
|
OneTwenty = 0,
|
|
|
|
|
/// <summary>80mm</summary>
|
|
|
|
|
Eighty = 1
|
|
|
|
|
}
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
public enum ChannelLength : byte
|
|
|
|
|
{
|
|
|
|
|
/// <summary>74.5nm channel or 25Gb/layer</summary>
|
|
|
|
|
Seventy = 1,
|
|
|
|
|
/// <summary>69.0nm channel or 27Gb/layer</summary>
|
|
|
|
|
Sixty = 2
|
|
|
|
|
}
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
public enum HybridLayer : byte
|
|
|
|
|
{
|
|
|
|
|
/// <summary>No hybrid layer</summary>
|
|
|
|
|
None = 0,
|
|
|
|
|
/// <summary>-ROM layer</summary>
|
|
|
|
|
ReadOnly = 1,
|
|
|
|
|
/// <summary>-R layer</summary>
|
|
|
|
|
Recordable = 2,
|
|
|
|
|
/// <summary>-RW layer</summary>
|
|
|
|
|
Rewritable = 3
|
|
|
|
|
}
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
#region Private constants
|
|
|
|
|
const string DiscTypeBDROM = "BDO";
|
|
|
|
|
const string DiscTypeBDRE = "BDW";
|
|
|
|
|
const string DiscTypeBDR = "BDR";
|
2015-12-01 03:23:31 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
/// <summary>Disc Information Unit Identifier "DI"</summary>
|
|
|
|
|
const ushort DIUIdentifier = 0x4449;
|
|
|
|
|
#endregion Private constants
|
2015-12-01 03:23:31 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
#region Public methods
|
|
|
|
|
public static DiscInformation? Decode(byte[] DIResponse)
|
|
|
|
|
{
|
|
|
|
|
if(DIResponse == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
if(DIResponse.Length != 4100)
|
2015-12-01 03:23:31 +00:00
|
|
|
{
|
2022-03-06 13:29:37 +00:00
|
|
|
AaruConsole.DebugWriteLine("BD Disc Information decoder",
|
2022-03-07 07:36:42 +00:00
|
|
|
"Found incorrect Blu-ray Disc Information size ({0} bytes)", DIResponse.Length);
|
2015-12-01 03:23:31 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
return null;
|
|
|
|
|
}
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
var decoded = new DiscInformation
|
|
|
|
|
{
|
|
|
|
|
DataLength = BigEndianBitConverter.ToUInt16(DIResponse, 0),
|
|
|
|
|
Reserved1 = DIResponse[2],
|
|
|
|
|
Reserved2 = DIResponse[3]
|
|
|
|
|
};
|
2015-12-01 03:23:31 +00:00
|
|
|
|
2022-11-15 15:58:41 +00:00
|
|
|
int offset = 4;
|
|
|
|
|
List<DiscInformationUnits> units = new();
|
2015-12-01 03:23:31 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
while(true)
|
|
|
|
|
{
|
|
|
|
|
if(offset >= 4100)
|
|
|
|
|
break;
|
2015-12-01 03:23:31 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
var unit = new DiscInformationUnits
|
2015-12-01 03:23:31 +00:00
|
|
|
{
|
2022-03-06 13:29:37 +00:00
|
|
|
Signature = BigEndianBitConverter.ToUInt16(DIResponse, 0 + offset)
|
|
|
|
|
};
|
2015-12-01 03:23:31 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
if(unit.Signature != DIUIdentifier)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
unit.Format = DIResponse[2 + offset];
|
|
|
|
|
unit.UnitsPerBlock = (byte)((DIResponse[3 + offset] & 0xF8) >> 3);
|
|
|
|
|
unit.Layer = (byte)(DIResponse[3 + offset] & 0x07);
|
|
|
|
|
unit.Legacy = DIResponse[4 + offset];
|
|
|
|
|
unit.Sequence = DIResponse[5 + offset];
|
|
|
|
|
unit.Continuation = (DIResponse[6 + offset] & 0x80) == 0x80;
|
|
|
|
|
unit.Length = (byte)(DIResponse[6 + offset] & 0x7F);
|
|
|
|
|
unit.Reserved = DIResponse[7 + offset];
|
|
|
|
|
unit.DiscTypeIdentifier = new byte[3];
|
|
|
|
|
Array.Copy(DIResponse, 8 + offset, unit.DiscTypeIdentifier, 0, 3);
|
|
|
|
|
unit.DiscSize = (BluSize)((DIResponse[11 + offset] & 0xC0) >> 6);
|
|
|
|
|
unit.DiscClass = (byte)((DIResponse[11 + offset] & 0x30) >> 4);
|
|
|
|
|
unit.DiscVersion = (byte)(DIResponse[11 + offset] & 0x0F);
|
|
|
|
|
unit.Layers = (byte)((DIResponse[12 + offset] & 0xF0) >> 4);
|
|
|
|
|
unit.DvdLayer = (HybridLayer)((DIResponse[13 + offset] & 0xC0) >> 6);
|
|
|
|
|
unit.CdLayer = (HybridLayer)((DIResponse[13 + offset] & 0x30) >> 4);
|
|
|
|
|
unit.ChannelLength = (ChannelLength)(DIResponse[13 + offset] & 0x0F);
|
|
|
|
|
unit.Polarity = DIResponse[14 + offset];
|
|
|
|
|
unit.RecordedPolarity = DIResponse[14 + offset];
|
|
|
|
|
unit.Bca = (byte)(DIResponse[16 + offset] & 0x0F);
|
|
|
|
|
unit.MaxTransfer = DIResponse[17 + offset];
|
|
|
|
|
|
|
|
|
|
unit.LastPsn = (uint)((DIResponse[20 + offset] << 24) + (DIResponse[21 + offset] << 16) +
|
|
|
|
|
(DIResponse[22 + offset] << 8) + DIResponse[23 + offset]);
|
|
|
|
|
|
|
|
|
|
// TODO: In -R/-RE how does this relate to layer size???
|
|
|
|
|
unit.FirstAun = (uint)((DIResponse[24 + offset] << 24) + (DIResponse[25 + offset] << 16) +
|
|
|
|
|
(DIResponse[26 + offset] << 8) + DIResponse[27 + offset]);
|
|
|
|
|
|
|
|
|
|
unit.LastAun = (uint)((DIResponse[28 + offset] << 24) + (DIResponse[29 + offset] << 16) +
|
|
|
|
|
(DIResponse[30 + offset] << 8) + DIResponse[31 + offset]);
|
|
|
|
|
|
|
|
|
|
switch(Encoding.ASCII.GetString(unit.DiscTypeIdentifier))
|
|
|
|
|
{
|
|
|
|
|
case DiscTypeBDROM:
|
2017-12-22 02:04:18 +00:00
|
|
|
{
|
2022-03-06 13:29:37 +00:00
|
|
|
unit.FormatDependentContents = new byte[32];
|
|
|
|
|
Array.Copy(DIResponse, 32 + offset, unit.FormatDependentContents, 0, 32);
|
2015-12-01 03:23:31 +00:00
|
|
|
|
2019-11-25 00:54:38 +00:00
|
|
|
break;
|
2022-03-06 13:29:37 +00:00
|
|
|
}
|
2015-12-01 03:23:31 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
case DiscTypeBDRE:
|
|
|
|
|
case DiscTypeBDR:
|
2015-12-01 03:23:31 +00:00
|
|
|
{
|
2022-03-06 13:29:37 +00:00
|
|
|
unit.FormatDependentContents = new byte[66];
|
|
|
|
|
Array.Copy(DIResponse, 32 + offset, unit.FormatDependentContents, 0, 66);
|
|
|
|
|
unit.ManufacturerID = new byte[6];
|
|
|
|
|
Array.Copy(DIResponse, 100 + offset, unit.ManufacturerID, 0, 6);
|
|
|
|
|
unit.MediaTypeID = new byte[3];
|
|
|
|
|
Array.Copy(DIResponse, 106 + offset, unit.MediaTypeID, 0, 3);
|
|
|
|
|
unit.TimeStamp = BigEndianBitConverter.ToUInt16(DIResponse, 109 + offset);
|
|
|
|
|
unit.ProductRevisionNumber = DIResponse[111 + offset];
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
offset += 14;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
break;
|
2015-12-01 03:23:31 +00:00
|
|
|
}
|
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
AaruConsole.DebugWriteLine("BD Disc Information decoder",
|
|
|
|
|
"Found unknown disc type identifier \"{0}\"",
|
|
|
|
|
Encoding.ASCII.GetString(unit.DiscTypeIdentifier));
|
2015-12-01 03:23:31 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2015-12-01 03:23:31 +00:00
|
|
|
}
|
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
units.Add(unit);
|
2015-12-01 03:23:31 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
offset += unit.Length;
|
2015-12-01 03:23:31 +00:00
|
|
|
}
|
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
if(units.Count <= 0)
|
|
|
|
|
return decoded;
|
2015-12-01 03:23:31 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
decoded.Units = new DiscInformationUnits[units.Count];
|
2015-12-01 03:23:31 +00:00
|
|
|
|
2022-11-15 15:58:41 +00:00
|
|
|
for(int i = 0; i < units.Count; i++)
|
2022-03-06 13:29:37 +00:00
|
|
|
decoded.Units[i] = units[i];
|
2015-12-01 03:23:31 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
return decoded;
|
|
|
|
|
}
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
public static string Prettify(DiscInformation? DIResponse)
|
|
|
|
|
{
|
|
|
|
|
if(DIResponse == null)
|
|
|
|
|
return null;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
DiscInformation response = DIResponse.Value;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
var sb = new StringBuilder();
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
foreach(DiscInformationUnits unit in response.Units)
|
|
|
|
|
{
|
|
|
|
|
sb.AppendFormat("DI Unit Sequence: {0}", unit.Sequence).AppendLine();
|
|
|
|
|
sb.AppendFormat("DI Unit Format: 0x{0:X2}", unit.Format).AppendLine();
|
|
|
|
|
sb.AppendFormat("There are {0} per block", unit.UnitsPerBlock).AppendLine();
|
|
|
|
|
sb.AppendFormat("This DI refers to layer {0}", unit.Layer).AppendLine();
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
if(Encoding.ASCII.GetString(unit.DiscTypeIdentifier) == DiscTypeBDRE)
|
|
|
|
|
sb.AppendFormat("Legacy value: 0x{0:X2}", unit.Legacy).AppendLine();
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
sb.AppendLine(unit.Continuation ? "This DI continues previous unit" : "This DI starts a new unit");
|
|
|
|
|
sb.AppendFormat("DI Unit is {0} bytes", unit.Length).AppendLine();
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
sb.AppendFormat("Disc type identifier: \"{0}\"", Encoding.ASCII.GetString(unit.DiscTypeIdentifier)).
|
|
|
|
|
AppendLine();
|
2018-03-30 23:12:56 +01:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
switch(unit.DiscSize)
|
|
|
|
|
{
|
|
|
|
|
case BluSize.OneTwenty:
|
|
|
|
|
sb.AppendLine("Disc size: 120mm");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
break;
|
|
|
|
|
case BluSize.Eighty:
|
|
|
|
|
sb.AppendLine("Disc size: 80mm");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
sb.AppendFormat("Disc size: Unknown code {0}", (byte)unit.DiscSize).AppendLine();
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
sb.AppendFormat("Disc class: {0}", unit.DiscClass).AppendLine();
|
|
|
|
|
sb.AppendFormat("Disc version: {0}", unit.DiscVersion).AppendLine();
|
|
|
|
|
sb.AppendFormat("This disc has {0} layers", unit.Layers).AppendLine();
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
switch(unit.DvdLayer)
|
|
|
|
|
{
|
|
|
|
|
case HybridLayer.None:
|
|
|
|
|
sb.AppendLine("This disc does not contain a DVD layer.");
|
2018-03-30 23:12:56 +01:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
break;
|
|
|
|
|
case HybridLayer.ReadOnly:
|
|
|
|
|
sb.AppendLine("This disc contains a DVD-ROM layer.");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
break;
|
|
|
|
|
case HybridLayer.Recordable:
|
|
|
|
|
sb.AppendLine("This disc contains a DVD-R layer.");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
break;
|
|
|
|
|
case HybridLayer.Rewritable:
|
|
|
|
|
sb.AppendLine("This disc contains a DVD-RW layer.");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
switch(unit.CdLayer)
|
|
|
|
|
{
|
|
|
|
|
case HybridLayer.None:
|
|
|
|
|
sb.AppendLine("This disc does not contain a CD layer.");
|
2018-03-30 23:12:56 +01:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
break;
|
|
|
|
|
case HybridLayer.ReadOnly:
|
|
|
|
|
sb.AppendLine("This disc contains a CD-ROM layer.");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
break;
|
|
|
|
|
case HybridLayer.Recordable:
|
|
|
|
|
sb.AppendLine("This disc contains a CD-R layer.");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
break;
|
|
|
|
|
case HybridLayer.Rewritable:
|
|
|
|
|
sb.AppendLine("This disc contains a CD-RW layer.");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2018-03-30 23:12:56 +01:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
switch(unit.ChannelLength)
|
|
|
|
|
{
|
|
|
|
|
case ChannelLength.Seventy:
|
|
|
|
|
sb.AppendLine("Disc uses a 74.5nm channel giving 25 Gb per layer.");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
break;
|
|
|
|
|
case ChannelLength.Sixty:
|
|
|
|
|
sb.AppendLine("Disc uses a 69.0nm channel giving 27 Gb per layer.");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
sb.AppendFormat("Disc uses unknown channel length with code {0}", (byte)unit.ChannelLength).
|
|
|
|
|
AppendLine();
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2018-03-30 23:12:56 +01:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
switch(unit.Polarity)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
sb.AppendLine("Disc uses positive polarity.");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
sb.AppendLine("Disc uses negative polarity.");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
sb.AppendFormat("Disc uses unknown polarity with code {0}", unit.Polarity).AppendLine();
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2018-03-30 23:12:56 +01:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
if(Encoding.ASCII.GetString(unit.DiscTypeIdentifier) == DiscTypeBDR)
|
|
|
|
|
switch(unit.RecordedPolarity)
|
2018-03-30 23:12:56 +01:00
|
|
|
{
|
|
|
|
|
case 0:
|
2022-03-06 13:29:37 +00:00
|
|
|
sb.AppendLine("Recorded marks have a lower reflectivity than unrecorded ones (HTL disc).");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2018-03-30 23:12:56 +01:00
|
|
|
break;
|
|
|
|
|
case 1:
|
2022-03-06 13:29:37 +00:00
|
|
|
sb.AppendLine("Recorded marks have a higher reflectivity than unrecorded ones (LTH disc).");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2018-03-30 23:12:56 +01:00
|
|
|
break;
|
|
|
|
|
default:
|
2022-03-06 13:29:37 +00:00
|
|
|
sb.AppendFormat("Disc uses unknown recorded reflectivity polarity with code {0}",
|
|
|
|
|
unit.RecordedPolarity).AppendLine();
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2018-03-30 23:12:56 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
switch(unit.Bca)
|
2021-06-23 20:47:00 +01:00
|
|
|
{
|
2022-03-06 13:29:37 +00:00
|
|
|
case 0:
|
|
|
|
|
sb.AppendLine("Disc doesn't have a BCA.");
|
2021-06-23 20:47:00 +01:00
|
|
|
|
|
|
|
|
break;
|
2022-03-06 13:29:37 +00:00
|
|
|
case 1:
|
|
|
|
|
sb.AppendLine("Disc has a BCA.");
|
2021-06-23 20:47:00 +01:00
|
|
|
|
|
|
|
|
break;
|
2022-03-06 13:29:37 +00:00
|
|
|
default:
|
|
|
|
|
sb.AppendFormat("Disc uses unknown BCA code {0}", unit.Bca).AppendLine();
|
2021-06-23 20:47:00 +01:00
|
|
|
|
|
|
|
|
break;
|
2022-03-06 13:29:37 +00:00
|
|
|
}
|
2021-06-23 20:47:00 +01:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
if(unit.MaxTransfer > 0)
|
|
|
|
|
sb.AppendFormat("Disc has a maximum transfer rate of {0} Mbit/sec.", unit.MaxTransfer).AppendLine();
|
|
|
|
|
else
|
|
|
|
|
sb.AppendLine("Disc does not specify a maximum transfer rate.");
|
2021-06-23 20:47:00 +01:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
sb.AppendFormat("Last user data PSN for disc: {0}", unit.LastPsn).AppendLine();
|
2021-06-23 20:47:00 +01:00
|
|
|
|
2022-03-07 07:36:42 +00:00
|
|
|
sb.AppendFormat("First address unit number of data zone in this layer: {0}", unit.FirstAun).AppendLine();
|
2021-06-23 20:47:00 +01:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
sb.AppendFormat("Last address unit number of data zone in this layer: {0}", unit.LastAun).AppendLine();
|
2021-06-23 20:47:00 +01:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
if(Encoding.ASCII.GetString(unit.DiscTypeIdentifier) == DiscTypeBDR ||
|
|
|
|
|
Encoding.ASCII.GetString(unit.DiscTypeIdentifier) == DiscTypeBDRE)
|
|
|
|
|
{
|
|
|
|
|
sb.AppendFormat("Disc manufacturer ID: \"{0}\"", Encoding.ASCII.GetString(unit.ManufacturerID)).
|
|
|
|
|
AppendLine();
|
2021-06-23 20:47:00 +01:00
|
|
|
|
2022-03-07 07:36:42 +00:00
|
|
|
sb.AppendFormat("Disc media type ID: \"{0}\"", Encoding.ASCII.GetString(unit.MediaTypeID)).AppendLine();
|
2021-06-23 20:47:00 +01:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
sb.AppendFormat("Disc timestamp: 0x{0:X2}", unit.TimeStamp).AppendLine();
|
2022-11-13 19:09:08 +00:00
|
|
|
sb.AppendFormat("Disc product revision number: {0}", unit.ProductRevisionNumber).AppendLine();
|
2022-03-06 13:29:37 +00:00
|
|
|
}
|
2021-06-23 20:47:00 +01:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
sb.AppendFormat("Blu-ray DI Unit format dependent contents as hex follows:");
|
|
|
|
|
sb.AppendLine(PrintHex.ByteArrayToHexArrayString(unit.FormatDependentContents, 80));
|
|
|
|
|
}
|
2021-06-23 20:47:00 +01:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
2021-06-23 20:47:00 +01:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
public static string Prettify(byte[] DIResponse) => Prettify(Decode(DIResponse));
|
2021-06-23 20:47:00 +01:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
public static string ManufacturerFromDI(string manufacturerId)
|
|
|
|
|
{
|
2022-11-15 15:58:41 +00:00
|
|
|
string manufacturer = "";
|
2015-12-01 03:23:31 +00:00
|
|
|
|
2022-11-13 19:09:08 +00:00
|
|
|
// ReSharper disable StringLiteralTypo
|
2022-03-06 13:29:37 +00:00
|
|
|
switch(manufacturerId)
|
2015-12-01 03:23:31 +00:00
|
|
|
{
|
2022-03-06 13:29:37 +00:00
|
|
|
case "AMESOB":
|
|
|
|
|
case "OTCBDR":
|
|
|
|
|
manufacturer = "Amethystum Storage Technology Co., Ltd.";
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "UMEBDR":
|
|
|
|
|
case "ANWELL":
|
|
|
|
|
manufacturer = "Avic Umedisc HK Ltd.";
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "MAXELL":
|
|
|
|
|
manufacturer = "Hitachi Maxell, Ltd.";
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "CMCMAG":
|
|
|
|
|
manufacturer = "CMC Magnetics Corporation";
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "ISMMBD":
|
|
|
|
|
manufacturer = "Info Source Digital Media (Zhong Shan) Co., Ltd.";
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "LGEBRA":
|
|
|
|
|
manufacturer = "LG Electronics Inc.";
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "MILLEN":
|
|
|
|
|
manufacturer = "Millenniata, Inc.";
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "VERBAT":
|
|
|
|
|
case "VAMKM":
|
|
|
|
|
manufacturer = "Mitsubishi Chemical Media Co., Ltd.";
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "PHILIP":
|
|
|
|
|
case "MBI":
|
|
|
|
|
manufacturer = "Moser Baer India Ltd.";
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "MEI":
|
|
|
|
|
case "PAN":
|
|
|
|
|
manufacturer = "Matsushita Electric Industrial Co., Ltd.";
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "PRODIS":
|
|
|
|
|
manufacturer = "Prodisc Technology Inc.";
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "RITEK":
|
|
|
|
|
manufacturer = "Ritek Co.";
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "SONY":
|
|
|
|
|
manufacturer = "Sony Corporation";
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "TYG-BD":
|
|
|
|
|
manufacturer = "Taiyo Yuden Company Ltd.";
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "TDKBLD":
|
|
|
|
|
manufacturer = "TDK Corporation";
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "JVC-AM":
|
|
|
|
|
case "JVCVAM":
|
|
|
|
|
manufacturer = "Victor Advanced media Co., Ltd.";
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "JVCRE1":
|
|
|
|
|
manufacturer = "JVC KENWOOD Corporation";
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "INFOME":
|
|
|
|
|
manufacturer = "InfoMedia Inc.";
|
|
|
|
|
|
|
|
|
|
break;
|
2015-12-01 03:23:31 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-13 19:09:08 +00:00
|
|
|
// ReSharper restore StringLiteralTypo
|
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
return manufacturer != "" ? $"{manufacturer} (\"{manufacturerId}\")" : $"\"{manufacturerId}\"";
|
|
|
|
|
}
|
|
|
|
|
#endregion Public methods
|
|
|
|
|
|
|
|
|
|
#region Public structures
|
|
|
|
|
public struct DiscInformation
|
|
|
|
|
{
|
|
|
|
|
/// <summary>Bytes 0 to 1 Always 4098</summary>
|
|
|
|
|
public ushort DataLength;
|
|
|
|
|
/// <summary>Byte 2 Reserved</summary>
|
|
|
|
|
public byte Reserved1;
|
|
|
|
|
/// <summary>Byte 3 Reserved</summary>
|
|
|
|
|
public byte Reserved2;
|
|
|
|
|
/// <summary>Byte 4 to 4099 Disc information units</summary>
|
|
|
|
|
public DiscInformationUnits[] Units;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public struct DiscInformationUnits
|
|
|
|
|
{
|
|
|
|
|
/// <summary>Byte 0 "DI"</summary>
|
|
|
|
|
public ushort Signature;
|
|
|
|
|
/// <summary>Byte 2 Disc information format</summary>
|
|
|
|
|
public byte Format;
|
|
|
|
|
/// <summary>Byte 3, bits 7 to 3 Number of DI units per block</summary>
|
|
|
|
|
public byte UnitsPerBlock;
|
|
|
|
|
/// <summary>Byte 3, bits 2 to 0 Layer this DI refers to</summary>
|
|
|
|
|
public byte Layer;
|
|
|
|
|
/// <summary>Byte 4 Reserved for BD-ROM, legacy information for BD-R/-RE</summary>
|
|
|
|
|
public byte Legacy;
|
|
|
|
|
/// <summary>Byte 5 Sequence number for this DI unit</summary>
|
|
|
|
|
public byte Sequence;
|
|
|
|
|
/// <summary>Byte 6, bit 7 If set this DI is a continuation of the previous one</summary>
|
|
|
|
|
public bool Continuation;
|
|
|
|
|
/// <summary>Byte 6, bits 6 to 0 Number of bytes used by this DI unit, should be 64 for BD-ROM and 112 for BD-R/-RE</summary>
|
|
|
|
|
public byte Length;
|
|
|
|
|
/// <summary>Byte 7 Reserved</summary>
|
|
|
|
|
public byte Reserved;
|
|
|
|
|
/// <summary>Bytes 8 to 10 Disc type identifier</summary>
|
|
|
|
|
public byte[] DiscTypeIdentifier;
|
|
|
|
|
/// <summary>Byte 11, bits 7 to 6 Disc size</summary>
|
|
|
|
|
public BluSize DiscSize;
|
|
|
|
|
/// <summary>Byte 11, bits 5 to 4 Disc class</summary>
|
|
|
|
|
public byte DiscClass;
|
|
|
|
|
/// <summary>Byte 11, bits 3 to 0 Disc version</summary>
|
|
|
|
|
public byte DiscVersion;
|
|
|
|
|
/// <summary>Byte 12, bits 7 to 4 Layers in this disc</summary>
|
|
|
|
|
public byte Layers;
|
|
|
|
|
/// <summary>Byte 12, bits 3 to 0 Reserved</summary>
|
|
|
|
|
public byte Reserved2;
|
|
|
|
|
/// <summary>Byte 13, bits 7 to 6 DVD layer</summary>
|
|
|
|
|
public HybridLayer DvdLayer;
|
|
|
|
|
/// <summary>Byte 13, bits 5 to 4 CD layer</summary>
|
|
|
|
|
public HybridLayer CdLayer;
|
|
|
|
|
/// <summary>Byte 13, bits 3 to 0 Channel length</summary>
|
|
|
|
|
public ChannelLength ChannelLength;
|
|
|
|
|
/// <summary>Byte 14 Polarity</summary>
|
|
|
|
|
public byte Polarity;
|
|
|
|
|
/// <summary>Byte 15 Recorded polarity</summary>
|
|
|
|
|
public byte RecordedPolarity;
|
|
|
|
|
/// <summary>Byte 16, bits 7 to 4 Reserved</summary>
|
|
|
|
|
public byte Reserved3;
|
|
|
|
|
/// <summary>Byte 16, bits 3 to 0 If 0 no BCA, if 1 BCA, rest not defined</summary>
|
|
|
|
|
public byte Bca;
|
|
|
|
|
/// <summary>Byte 17 Maximum transfer speed in megabits/second, 0 if no maximum</summary>
|
|
|
|
|
public byte MaxTransfer;
|
|
|
|
|
/// <summary>Bytes 18 to 19 Reserved</summary>
|
|
|
|
|
public ushort Reserved4;
|
|
|
|
|
/// <summary>Bytes 20 to 23 Last user data PSN for disc</summary>
|
|
|
|
|
public uint LastPsn;
|
|
|
|
|
/// <summary>Bytes 24 to 27 First address unit number of data zone in this layer</summary>
|
|
|
|
|
public uint FirstAun;
|
|
|
|
|
/// <summary>Bytes 28 to 31 Last address unit number of data zone in this layer</summary>
|
|
|
|
|
public uint LastAun;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Bytes 32 to 63 for BD-ROM, bytes 32 to 99 for BD-R/-RE Format dependent contents, disclosed in private blu-ray
|
|
|
|
|
/// specifications
|
|
|
|
|
/// </summary>
|
|
|
|
|
public byte[] FormatDependentContents;
|
|
|
|
|
/// <summary>Bytes 100 to 105, BD-R/-RE only Manufacturer ID</summary>
|
|
|
|
|
public byte[] ManufacturerID;
|
|
|
|
|
/// <summary>Bytes 106 to 108, BD-R/-RE only Media type ID</summary>
|
|
|
|
|
public byte[] MediaTypeID;
|
|
|
|
|
/// <summary>Bytes 109 to 110, BD-R/-RE only Timestamp</summary>
|
|
|
|
|
public ushort TimeStamp;
|
|
|
|
|
/// <summary>Byte 111 Product revision number</summary>
|
|
|
|
|
public byte ProductRevisionNumber;
|
2015-12-01 03:23:31 +00:00
|
|
|
}
|
2022-03-06 13:29:37 +00:00
|
|
|
#endregion Public structures
|
2017-12-19 20:33:03 +00:00
|
|
|
}
|