2011-11-15 10:56:49 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
using System.Net;
|
2011-10-24 14:32:51 +00:00
|
|
|
|
using CUETools.AccurateRip;
|
|
|
|
|
|
using CUETools.CDImage;
|
2011-11-15 10:56:49 +00:00
|
|
|
|
using CUETools.Parity;
|
2011-10-24 14:32:51 +00:00
|
|
|
|
|
|
|
|
|
|
namespace CUETools.CTDB
|
|
|
|
|
|
{
|
|
|
|
|
|
public class DBEntry
|
|
|
|
|
|
{
|
2011-10-27 20:50:11 +00:00
|
|
|
|
public ushort[,] syndrome;
|
2011-11-15 10:56:49 +00:00
|
|
|
|
public uint[] trackcrcs;
|
2011-10-24 14:32:51 +00:00
|
|
|
|
public int conf;
|
|
|
|
|
|
public int stride;
|
|
|
|
|
|
public int offset;
|
|
|
|
|
|
public uint crc;
|
|
|
|
|
|
public bool hasErrors;
|
|
|
|
|
|
public bool canRecover;
|
|
|
|
|
|
public CDRepairFix repair;
|
|
|
|
|
|
public HttpStatusCode httpStatus;
|
2011-10-30 23:39:20 +00:00
|
|
|
|
public long id;
|
2011-10-24 14:32:51 +00:00
|
|
|
|
public CDImageLayout toc;
|
|
|
|
|
|
public string hasParity;
|
|
|
|
|
|
|
2011-11-15 10:56:49 +00:00
|
|
|
|
public DBEntry(CTDBResponseEntry ctdbRespEntry)
|
2011-10-24 14:32:51 +00:00
|
|
|
|
{
|
2011-11-15 10:56:49 +00:00
|
|
|
|
this.syndrome = ctdbRespEntry.syndrome == null
|
|
|
|
|
|
? ParityToSyndrome.Parity2Syndrome(1, 1, 8, 8, Convert.FromBase64String(ctdbRespEntry.parity))
|
|
|
|
|
|
: ParityToSyndrome.Bytes2Syndrome(1, Math.Min(AccurateRipVerify.maxNpar, ctdbRespEntry.npar), Convert.FromBase64String(ctdbRespEntry.syndrome));
|
|
|
|
|
|
this.conf = ctdbRespEntry.confidence;
|
|
|
|
|
|
this.stride = ctdbRespEntry.stride * 2;
|
|
|
|
|
|
this.crc = uint.Parse(ctdbRespEntry.crc32, NumberStyles.HexNumber);
|
|
|
|
|
|
this.id = ctdbRespEntry.id;
|
|
|
|
|
|
this.toc = CDImageLayout.FromString(ctdbRespEntry.toc);
|
|
|
|
|
|
this.hasParity = ctdbRespEntry.hasparity;
|
|
|
|
|
|
if (ctdbRespEntry.trackcrcs != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var crcs = ctdbRespEntry.trackcrcs.Split(' ');
|
|
|
|
|
|
if (crcs.Length == this.toc.AudioTracks)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.trackcrcs = new uint[crcs.Length];
|
|
|
|
|
|
for (int i = 0; i < this.trackcrcs.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.trackcrcs[i] = uint.Parse(crcs[i], NumberStyles.HexNumber);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2011-10-24 14:32:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2011-10-27 20:50:11 +00:00
|
|
|
|
public int Npar
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return syndrome.GetLength(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2011-10-24 14:32:51 +00:00
|
|
|
|
public string Status
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!hasErrors)
|
|
|
|
|
|
{
|
|
|
|
|
|
return string.Format("verified OK, confidence {0}", conf);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (canRecover)
|
|
|
|
|
|
{
|
|
|
|
|
|
return string.Format("differs in {1} samples, confidence {0}", conf, repair.CorrectableErrors);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (httpStatus == HttpStatusCode.OK)
|
|
|
|
|
|
{
|
|
|
|
|
|
return "could not be verified";
|
|
|
|
|
|
}
|
|
|
|
|
|
return "could not be verified: " + httpStatus.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|