mirror of
https://github.com/aaru-dps/Aaru.Decoders.git
synced 2025-12-16 19:24:32 +00:00
Code reformat.
This commit is contained in:
179
DVD/CSS&CPRM.cs
179
DVD/CSS&CPRM.cs
@@ -36,147 +36,94 @@ using System.Text;
|
||||
namespace DiscImageChef.Decoders.DVD
|
||||
{
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// ECMA 365
|
||||
/// 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 ECMA 365
|
||||
/// </summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
[SuppressMessage("ReSharper", "NotAccessedField.Global")]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
|
||||
SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")]
|
||||
public static class CSS_CPRM
|
||||
{
|
||||
public struct LeadInCopyright
|
||||
{
|
||||
/// <summary>
|
||||
/// Bytes 0 to 1
|
||||
/// Data length
|
||||
/// </summary>
|
||||
public ushort DataLength;
|
||||
/// <summary>
|
||||
/// Byte 2
|
||||
/// Reserved
|
||||
/// </summary>
|
||||
public byte Reserved1;
|
||||
/// <summary>
|
||||
/// Byte 3
|
||||
/// Reserved
|
||||
/// </summary>
|
||||
public byte Reserved2;
|
||||
/// <summary>
|
||||
/// Byte 4
|
||||
/// Copy protection system type
|
||||
/// </summary>
|
||||
public CopyrightType CopyrightType;
|
||||
/// <summary>
|
||||
/// Byte 5
|
||||
/// Bitmask of regions where this disc is playable
|
||||
/// </summary>
|
||||
public byte RegionInformation;
|
||||
/// <summary>
|
||||
/// Byte 6
|
||||
/// Reserved
|
||||
/// </summary>
|
||||
public byte Reserved3;
|
||||
/// <summary>
|
||||
/// Byte 7
|
||||
/// Reserved
|
||||
/// </summary>
|
||||
public byte Reserved4;
|
||||
}
|
||||
|
||||
public struct DiscKey
|
||||
{
|
||||
/// <summary>
|
||||
/// Bytes 0 to 1
|
||||
/// Data length
|
||||
/// </summary>
|
||||
public ushort DataLength;
|
||||
/// <summary>
|
||||
/// Byte 2
|
||||
/// Reserved
|
||||
/// </summary>
|
||||
public byte Reserved1;
|
||||
/// <summary>
|
||||
/// Byte 3
|
||||
/// Reserved
|
||||
/// </summary>
|
||||
public byte Reserved2;
|
||||
/// <summary>
|
||||
/// Bytes 4 to 2052
|
||||
/// Disc key for CSS, Album Identifier for CPPM
|
||||
/// </summary>
|
||||
public byte[] Key;
|
||||
}
|
||||
|
||||
public static LeadInCopyright? DecodeLeadInCopyright(byte[] response)
|
||||
{
|
||||
if(response?.Length != 8) return null;
|
||||
if(response?.Length != 8)
|
||||
return null;
|
||||
|
||||
return new LeadInCopyright
|
||||
{
|
||||
DataLength = (ushort)((response[0] << 8) + response[1]),
|
||||
Reserved1 = response[2],
|
||||
Reserved2 = response[3],
|
||||
CopyrightType = (CopyrightType)response[4],
|
||||
DataLength = (ushort)((response[0] << 8) + response[1]), Reserved1 = response[2],
|
||||
Reserved2 = response[3], CopyrightType = (CopyrightType)response[4],
|
||||
RegionInformation = response[5],
|
||||
Reserved3 = response[6],
|
||||
Reserved4 = response[7]
|
||||
Reserved3 = response[6], Reserved4 = response[7]
|
||||
};
|
||||
}
|
||||
|
||||
public static string PrettifyLeadInCopyright(LeadInCopyright? cmi)
|
||||
{
|
||||
if(cmi == null) return null;
|
||||
if(cmi == null)
|
||||
return null;
|
||||
|
||||
LeadInCopyright decoded = cmi.Value;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
var sb = new StringBuilder();
|
||||
|
||||
switch(decoded.CopyrightType)
|
||||
{
|
||||
case CopyrightType.NoProtection:
|
||||
sb.AppendLine("Disc has no encryption.");
|
||||
|
||||
break;
|
||||
case CopyrightType.CSS:
|
||||
sb.AppendLine("Disc is encrypted using CSS or CPPM.");
|
||||
|
||||
break;
|
||||
case CopyrightType.CPRM:
|
||||
sb.AppendLine("Disc is encrypted using CPRM.");
|
||||
|
||||
break;
|
||||
case CopyrightType.AACS:
|
||||
sb.AppendLine("Disc is encrypted using AACS.");
|
||||
|
||||
break;
|
||||
default:
|
||||
sb.AppendFormat("Disc is encrypted using unknown algorithm with ID {0}.", decoded.CopyrightType);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if(decoded.CopyrightType == 0) return sb.ToString();
|
||||
if(decoded.CopyrightType == 0)
|
||||
return sb.ToString();
|
||||
|
||||
if(decoded.RegionInformation == 0xFF) sb.AppendLine("Disc cannot be played in any region at all.");
|
||||
else if(decoded.RegionInformation == 0x00) sb.AppendLine("Disc can be played in any region.");
|
||||
if(decoded.RegionInformation == 0xFF)
|
||||
sb.AppendLine("Disc cannot be played in any region at all.");
|
||||
else if(decoded.RegionInformation == 0x00)
|
||||
sb.AppendLine("Disc can be played in any region.");
|
||||
else
|
||||
{
|
||||
sb.Append("Disc can be played in the following regions:");
|
||||
if((decoded.RegionInformation & 0x01) != 0x01) sb.Append(" 0");
|
||||
if((decoded.RegionInformation & 0x02) != 0x02) sb.Append(" 1");
|
||||
if((decoded.RegionInformation & 0x04) != 0x04) sb.Append(" 2");
|
||||
if((decoded.RegionInformation & 0x08) != 0x08) sb.Append(" 3");
|
||||
if((decoded.RegionInformation & 0x10) != 0x10) sb.Append(" 4");
|
||||
if((decoded.RegionInformation & 0x20) != 0x20) sb.Append(" 5");
|
||||
if((decoded.RegionInformation & 0x40) != 0x40) sb.Append(" 6");
|
||||
if((decoded.RegionInformation & 0x80) != 0x80) sb.Append(" 7");
|
||||
|
||||
if((decoded.RegionInformation & 0x01) != 0x01)
|
||||
sb.Append(" 0");
|
||||
|
||||
if((decoded.RegionInformation & 0x02) != 0x02)
|
||||
sb.Append(" 1");
|
||||
|
||||
if((decoded.RegionInformation & 0x04) != 0x04)
|
||||
sb.Append(" 2");
|
||||
|
||||
if((decoded.RegionInformation & 0x08) != 0x08)
|
||||
sb.Append(" 3");
|
||||
|
||||
if((decoded.RegionInformation & 0x10) != 0x10)
|
||||
sb.Append(" 4");
|
||||
|
||||
if((decoded.RegionInformation & 0x20) != 0x20)
|
||||
sb.Append(" 5");
|
||||
|
||||
if((decoded.RegionInformation & 0x40) != 0x40)
|
||||
sb.Append(" 6");
|
||||
|
||||
if((decoded.RegionInformation & 0x80) != 0x80)
|
||||
sb.Append(" 7");
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
@@ -184,5 +131,35 @@ namespace DiscImageChef.Decoders.DVD
|
||||
|
||||
public static string PrettifyLeadInCopyright(byte[] response) =>
|
||||
PrettifyLeadInCopyright(DecodeLeadInCopyright(response));
|
||||
|
||||
public struct LeadInCopyright
|
||||
{
|
||||
/// <summary>Bytes 0 to 1 Data length</summary>
|
||||
public ushort DataLength;
|
||||
/// <summary>Byte 2 Reserved</summary>
|
||||
public byte Reserved1;
|
||||
/// <summary>Byte 3 Reserved</summary>
|
||||
public byte Reserved2;
|
||||
/// <summary>Byte 4 Copy protection system type</summary>
|
||||
public CopyrightType CopyrightType;
|
||||
/// <summary>Byte 5 Bitmask of regions where this disc is playable</summary>
|
||||
public byte RegionInformation;
|
||||
/// <summary>Byte 6 Reserved</summary>
|
||||
public byte Reserved3;
|
||||
/// <summary>Byte 7 Reserved</summary>
|
||||
public byte Reserved4;
|
||||
}
|
||||
|
||||
public struct DiscKey
|
||||
{
|
||||
/// <summary>Bytes 0 to 1 Data length</summary>
|
||||
public ushort DataLength;
|
||||
/// <summary>Byte 2 Reserved</summary>
|
||||
public byte Reserved1;
|
||||
/// <summary>Byte 3 Reserved</summary>
|
||||
public byte Reserved2;
|
||||
/// <summary>Bytes 4 to 2052 Disc key for CSS, Album Identifier for CPPM</summary>
|
||||
public byte[] Key;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user