Merge pull request #506 from hawken93/linting

Removing tabs and trailing whitespace
pull/702/head
Joshua M. Boniface 6 years ago committed by GitHub
commit 15c89d281e

@ -3,7 +3,7 @@ using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("BDInfo")] [assembly: AssemblyTitle("BDInfo")]
@ -19,11 +19,11 @@ using System.Runtime.InteropServices;
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.1")] [assembly: AssemblyVersion("1.0.1")]

@ -148,7 +148,7 @@ namespace BDInfo
stream.IsVBR = true; stream.IsVBR = true;
stream.IsInitialized = true; stream.IsInitialized = true;
break; break;
default: default:
stream.IsVBR = false; stream.IsVBR = false;
stream.IsInitialized = true; stream.IsInitialized = true;

@ -22,9 +22,9 @@ namespace BDInfo
{ {
public abstract class TSCodecDTSHD public abstract class TSCodecDTSHD
{ {
private static int[] SampleRates = new int[] private static int[] SampleRates = new int[]
{ 0x1F40, 0x3E80, 0x7D00, 0x0FA00, 0x1F400, 0x5622, 0x0AC44, 0x15888, 0x2B110, 0x56220, 0x2EE0, 0x5DC0, 0x0BB80, 0x17700, 0x2EE00, 0x5DC00 }; { 0x1F40, 0x3E80, 0x7D00, 0x0FA00, 0x1F400, 0x5622, 0x0AC44, 0x15888, 0x2B110, 0x56220, 0x2EE0, 0x5DC0, 0x0BB80, 0x17700, 0x2EE00, 0x5DC00 };
public static void Scan( public static void Scan(
TSAudioStream stream, TSAudioStream stream,
TSStreamBuffer buffer, TSStreamBuffer buffer,
@ -131,7 +131,7 @@ namespace BDInfo
else else
{ {
AssetSizes[i] = buffer.ReadBits(16) + 1; AssetSizes[i] = buffer.ReadBits(16) + 1;
} }
} }
for (int i = 0; i < nuNumAssets; i++) for (int i = 0; i < nuNumAssets; i++)
{ {
@ -189,7 +189,7 @@ namespace BDInfo
} }
stream.SampleRate = SampleRates[nuMaxSampleRate]; stream.SampleRate = SampleRates[nuMaxSampleRate];
stream.BitDepth = nuBitResolution; stream.BitDepth = nuBitResolution;
stream.LFE = 0; stream.LFE = 0;
if ((nuSpkrActivityMask & 0x8) == 0x8) if ((nuSpkrActivityMask & 0x8) == 0x8)
{ {
@ -240,7 +240,7 @@ namespace BDInfo
stream.IsInitialized = true; stream.IsInitialized = true;
} }
stream.IsInitialized = (stream.BitRate > 0 ? true : false); stream.IsInitialized = (stream.BitRate > 0 ? true : false);
} }
} }
} }
} }

@ -33,7 +33,7 @@ namespace BDInfo
int pictureParse = 0; int pictureParse = 0;
int sequenceHeaderParse = 0; int sequenceHeaderParse = 0;
int extensionParse = 0; int extensionParse = 0;
int sequenceExtensionParse = 0; int sequenceExtensionParse = 0;
for (int i = 0; i < buffer.Length; i++) for (int i = 0; i < buffer.Length; i++)
{ {
@ -189,7 +189,7 @@ namespace BDInfo
#if DEBUG #if DEBUG
if (sequenceExtensionParse == 0) if (sequenceExtensionParse == 0)
{ {
uint sequenceExtension = uint sequenceExtension =
((parse & 0x8) >> 3); ((parse & 0x8) >> 3);
if (sequenceExtension == 0) if (sequenceExtension == 0)
{ {

@ -36,7 +36,7 @@ namespace BDInfo
for (int i = 0; i < buffer.Length; i++) for (int i = 0; i < buffer.Length; i++)
{ {
sync = (sync << 8) + buffer.ReadByte(); sync = (sync << 8) + buffer.ReadByte();
if (sync == 0xF8726FBA) if (sync == 0xF8726FBA)
{ {
syncFound = true; syncFound = true;
break; break;
@ -63,7 +63,7 @@ namespace BDInfo
int ratebits = buffer.ReadBits(4); int ratebits = buffer.ReadBits(4);
if (ratebits != 0xF) if (ratebits != 0xF)
{ {
stream.SampleRate = stream.SampleRate =
(((ratebits & 8) > 0 ? 44100 : 48000) << (ratebits & 7)); (((ratebits & 8) > 0 ? 44100 : 48000) << (ratebits & 7));
} }
int temp1 = buffer.ReadBits(8); int temp1 = buffer.ReadBits(8);
@ -149,9 +149,9 @@ namespace BDInfo
int peak_bitrate = buffer.ReadBits(15); int peak_bitrate = buffer.ReadBits(15);
peak_bitrate = (peak_bitrate * stream.SampleRate) >> 4; peak_bitrate = (peak_bitrate * stream.SampleRate) >> 4;
double peak_bitdepth = double peak_bitdepth =
(double)peak_bitrate / (double)peak_bitrate /
(stream.ChannelCount + stream.LFE) / (stream.ChannelCount + stream.LFE) /
stream.SampleRate; stream.SampleRate;
if (peak_bitdepth > 14) if (peak_bitdepth > 14)
{ {
@ -164,7 +164,7 @@ namespace BDInfo
#if DEBUG #if DEBUG
System.Diagnostics.Debug.WriteLine(string.Format( System.Diagnostics.Debug.WriteLine(string.Format(
"{0}\t{1}\t{2:F2}", "{0}\t{1}\t{2:F2}",
stream.PID, peak_bitrate, peak_bitdepth)); stream.PID, peak_bitrate, peak_bitdepth));
#endif #endif
/* /*

@ -50,18 +50,18 @@ namespace BDInfo
{ {
if ((parse & 0x80000000) == 0) if ((parse & 0x80000000) == 0)
{ {
pictureType = pictureType =
(uint)((parse & 0x78000000) >> 13); (uint)((parse & 0x78000000) >> 13);
} }
else else
{ {
pictureType = pictureType =
(uint)((parse & 0x3c000000) >> 12); (uint)((parse & 0x3c000000) >> 12);
} }
} }
else else
{ {
pictureType = pictureType =
(uint)((parse & 0xf0000000) >> 14); (uint)((parse & 0xf0000000) >> 14);
} }

@ -42,7 +42,7 @@ namespace BDInfo
public List<double> Chapters = new List<double>(); public List<double> Chapters = new List<double>();
public Dictionary<ushort, TSStream> Streams = public Dictionary<ushort, TSStream> Streams =
new Dictionary<ushort, TSStream>(); new Dictionary<ushort, TSStream>();
public Dictionary<ushort, TSStream> PlaylistStreams = public Dictionary<ushort, TSStream> PlaylistStreams =
new Dictionary<ushort, TSStream>(); new Dictionary<ushort, TSStream>();
@ -50,19 +50,19 @@ namespace BDInfo
new List<TSStreamClip>(); new List<TSStreamClip>();
public List<Dictionary<ushort, TSStream>> AngleStreams = public List<Dictionary<ushort, TSStream>> AngleStreams =
new List<Dictionary<ushort, TSStream>>(); new List<Dictionary<ushort, TSStream>>();
public List<Dictionary<double, TSStreamClip>> AngleClips = public List<Dictionary<double, TSStreamClip>> AngleClips =
new List<Dictionary<double, TSStreamClip>>(); new List<Dictionary<double, TSStreamClip>>();
public int AngleCount = 0; public int AngleCount = 0;
public List<TSStream> SortedStreams = public List<TSStream> SortedStreams =
new List<TSStream>(); new List<TSStream>();
public List<TSVideoStream> VideoStreams = public List<TSVideoStream> VideoStreams =
new List<TSVideoStream>(); new List<TSVideoStream>();
public List<TSAudioStream> AudioStreams = public List<TSAudioStream> AudioStreams =
new List<TSAudioStream>(); new List<TSAudioStream>();
public List<TSTextStream> TextStreams = public List<TSTextStream> TextStreams =
new List<TSTextStream>(); new List<TSTextStream>();
public List<TSGraphicsStream> GraphicsStreams = public List<TSGraphicsStream> GraphicsStreams =
new List<TSGraphicsStream>(); new List<TSGraphicsStream>();
public TSPlaylistFile( public TSPlaylistFile(
@ -388,8 +388,8 @@ namespace BDInfo
#if DEBUG #if DEBUG
Debug.WriteLine(string.Format( Debug.WriteLine(string.Format(
"{0} : {1} -> V:{2} A:{3} PG:{4} IG:{5} 2A:{6} 2V:{7} PIP:{8}", "{0} : {1} -> V:{2} A:{3} PG:{4} IG:{5} 2A:{6} 2V:{7} PIP:{8}",
Name, streamFileName, streamCountVideo, streamCountAudio, streamCountPG, streamCountIG, Name, streamFileName, streamCountVideo, streamCountAudio, streamCountPG, streamCountIG,
streamCountSecondaryAudio, streamCountSecondaryVideo, streamCountPIP)); streamCountSecondaryAudio, streamCountSecondaryVideo, streamCountPIP));
#endif #endif
@ -427,7 +427,7 @@ namespace BDInfo
} }
/* /*
* TODO * TODO
* *
for (int i = 0; i < streamCountPIP; i++) for (int i = 0; i < streamCountPIP; i++)
{ {
TSStream stream = CreatePlaylistStream(data, ref pos); TSStream stream = CreatePlaylistStream(data, ref pos);
@ -955,7 +955,7 @@ namespace BDInfo
} }
public int CompareVideoStreams( public int CompareVideoStreams(
TSVideoStream x, TSVideoStream x,
TSVideoStream y) TSVideoStream y)
{ {
if (x == null && y == null) if (x == null && y == null)
@ -996,7 +996,7 @@ namespace BDInfo
} }
public int CompareAudioStreams( public int CompareAudioStreams(
TSAudioStream x, TSAudioStream x,
TSAudioStream y) TSAudioStream y)
{ {
if (x == y) if (x == y)

@ -109,7 +109,7 @@ namespace BDInfo
public TSDescriptor Clone() public TSDescriptor Clone()
{ {
TSDescriptor descriptor = TSDescriptor descriptor =
new TSDescriptor(Name, (byte)Value.Length); new TSDescriptor(Name, (byte)Value.Length);
Value.CopyTo(descriptor.Value, 0); Value.CopyTo(descriptor.Value, 0);
return descriptor; return descriptor;
@ -153,15 +153,15 @@ namespace BDInfo
private string _LanguageCode; private string _LanguageCode;
public string LanguageCode public string LanguageCode
{ {
get get
{ {
return _LanguageCode; return _LanguageCode;
} }
set set
{ {
_LanguageCode = value; _LanguageCode = value;
LanguageName = LanguageCodes.GetName(value); LanguageName = LanguageCodes.GetName(value);
} }
} }
public bool IsVideoStream public bool IsVideoStream
@ -407,7 +407,7 @@ namespace BDInfo
} }
public abstract TSStream Clone(); public abstract TSStream Clone();
protected void CopyTo(TSStream stream) protected void CopyTo(TSStream stream)
{ {
stream.PID = PID; stream.PID = PID;
@ -435,7 +435,7 @@ namespace BDInfo
public int Width; public int Width;
public int Height; public int Height;
public bool IsInterlaced; public bool IsInterlaced;
public int FrameRateEnumerator; public int FrameRateEnumerator;
public int FrameRateDenominator; public int FrameRateDenominator;
public TSAspectRatio AspectRatio; public TSAspectRatio AspectRatio;
@ -581,7 +581,7 @@ namespace BDInfo
stream.FrameRate = _FrameRate; stream.FrameRate = _FrameRate;
stream.Width = Width; stream.Width = Width;
stream.Height = Height; stream.Height = Height;
stream.IsInterlaced = IsInterlaced; stream.IsInterlaced = IsInterlaced;
stream.FrameRateEnumerator = FrameRateEnumerator; stream.FrameRateEnumerator = FrameRateEnumerator;
stream.FrameRateDenominator = FrameRateDenominator; stream.FrameRateDenominator = FrameRateDenominator;
stream.AspectRatio = AspectRatio; stream.AspectRatio = AspectRatio;

@ -69,7 +69,7 @@ namespace BDInfo
byte[] fileType = new byte[8]; byte[] fileType = new byte[8];
Array.Copy(data, 0, fileType, 0, fileType.Length); Array.Copy(data, 0, fileType, 0, fileType.Length);
FileType = _textEncoding.GetASCIIEncoding().GetString(fileType, 0, fileType.Length); FileType = _textEncoding.GetASCIIEncoding().GetString(fileType, 0, fileType.Length);
if (FileType != "HDMV0100" && if (FileType != "HDMV0100" &&
FileType != "HDMV0200") FileType != "HDMV0200")
@ -78,7 +78,7 @@ namespace BDInfo
"Clip info file {0} has an unknown file type {1}.", "Clip info file {0} has an unknown file type {1}.",
FileInfo.Name, FileType)); FileInfo.Name, FileType));
} }
#if DEBUG #if DEBUG
Debug.WriteLine(string.Format( Debug.WriteLine(string.Format(
"\tFileType: {0}", FileType)); "\tFileType: {0}", FileType));
#endif #endif
@ -110,9 +110,9 @@ namespace BDInfo
TSStream stream = null; TSStream stream = null;
ushort PID = (ushort) ushort PID = (ushort)
((clipData[streamOffset] << 8) + ((clipData[streamOffset] << 8) +
clipData[streamOffset + 1]); clipData[streamOffset + 1]);
streamOffset += 2; streamOffset += 2;
TSStreamType streamType = (TSStreamType) TSStreamType streamType = (TSStreamType)
@ -240,7 +240,7 @@ namespace BDInfo
} }
streamOffset += clipData[streamOffset] + 1; streamOffset += clipData[streamOffset] + 1;
} }
IsValid = true; IsValid = true;
} }
finally finally

@ -391,7 +391,7 @@ namespace BDInfo
} }
Dictionary<ushort, TSStream> playlistStreams = playlist.Streams; Dictionary<ushort, TSStream> playlistStreams = playlist.Streams;
if (clip.AngleIndex > 0 && if (clip.AngleIndex > 0 &&
clip.AngleIndex < playlist.AngleStreams.Count + 1) clip.AngleIndex < playlist.AngleStreams.Count + 1)
{ {
playlistStreams = playlist.AngleStreams[clip.AngleIndex - 1]; playlistStreams = playlist.AngleStreams[clip.AngleIndex - 1];
@ -428,7 +428,7 @@ namespace BDInfo
TSStream stream = Streams[PID]; TSStream stream = Streams[PID];
stream.PayloadBytes += streamState.WindowBytes; stream.PayloadBytes += streamState.WindowBytes;
stream.PacketCount += streamState.WindowPackets; stream.PacketCount += streamState.WindowPackets;
if (stream.IsVideoStream) if (stream.IsVideoStream)
{ {
TSStreamDiagnostics diag = new TSStreamDiagnostics(); TSStreamDiagnostics diag = new TSStreamDiagnostics();
@ -457,7 +457,7 @@ namespace BDInfo
int dataSize = 16384; int dataSize = 16384;
Stream fileStream = null; Stream fileStream = null;
try try
{ {
string fileName; string fileName;
if (BDInfoSettings.EnableSSIF && if (BDInfoSettings.EnableSSIF &&
InterleavedFile != null) InterleavedFile != null)
@ -482,13 +482,13 @@ namespace BDInfo
StreamStates.Clear(); StreamStates.Clear();
StreamDiagnostics.Clear(); StreamDiagnostics.Clear();
TSPacketParser parser = TSPacketParser parser =
new TSPacketParser(); new TSPacketParser();
long fileLength = (uint)fileStream.Length; long fileLength = (uint)fileStream.Length;
byte[] buffer = new byte[dataSize]; byte[] buffer = new byte[dataSize];
int bufferLength = 0; int bufferLength = 0;
while ((bufferLength = while ((bufferLength =
fileStream.Read(buffer, 0, buffer.Length)) > 0) fileStream.Read(buffer, 0, buffer.Length)) > 0)
{ {
int offset = 0; int offset = 0;
@ -598,8 +598,8 @@ namespace BDInfo
parser.StreamState.TransferCount++; parser.StreamState.TransferCount++;
bool isFinished = ScanStream( bool isFinished = ScanStream(
parser.Stream, parser.Stream,
parser.StreamState, parser.StreamState,
parser.StreamState.StreamBuffer); parser.StreamState.StreamBuffer);
if (!isFullScan && isFinished) if (!isFullScan && isFinished)
@ -680,10 +680,10 @@ namespace BDInfo
for (int k = 0; k < (parser.PATOffset - 4); k += 4) for (int k = 0; k < (parser.PATOffset - 4); k += 4)
{ {
uint programNumber = (uint) uint programNumber = (uint)
((parser.PAT[k] << 8) + ((parser.PAT[k] << 8) +
parser.PAT[k + 1]); parser.PAT[k + 1]);
ushort programPID = (ushort) ushort programPID = (ushort)
(((parser.PAT[k + 2] & 0x1F) << 8) + (((parser.PAT[k + 2] & 0x1F) << 8) +
parser.PAT[k + 3]); parser.PAT[k + 3]);
@ -985,7 +985,7 @@ namespace BDInfo
parser.PMTProgramDescriptorLength = buffer[i]; parser.PMTProgramDescriptorLength = buffer[i];
parser.PMTProgramDescriptors.Add( parser.PMTProgramDescriptors.Add(
new TSDescriptor( new TSDescriptor(
parser.PMTProgramDescriptor, parser.PMTProgramDescriptor,
parser.PMTProgramDescriptorLength)); parser.PMTProgramDescriptorLength));
break; break;
} }
@ -998,7 +998,7 @@ namespace BDInfo
parser.PMTProgramDescriptors.Count - 1]; parser.PMTProgramDescriptors.Count - 1];
int valueIndex = int valueIndex =
descriptor.Value.Length - descriptor.Value.Length -
parser.PMTProgramDescriptorLength - 1; parser.PMTProgramDescriptorLength - 1;
descriptor.Value[valueIndex] = buffer[i]; descriptor.Value[valueIndex] = buffer[i];
@ -1020,8 +1020,8 @@ namespace BDInfo
parser.SyncState = false; parser.SyncState = false;
} }
} }
else if (parser.Stream != null && else if (parser.Stream != null &&
parser.StreamState != null && parser.StreamState != null &&
parser.TransportScramblingControl == 0) parser.TransportScramblingControl == 0)
{ {
TSStream stream = parser.Stream; TSStream stream = parser.Stream;
@ -1032,7 +1032,7 @@ namespace BDInfo
if (streamState.TransferState) if (streamState.TransferState)
{ {
if ((bufferLength - i) >= streamState.PacketLength && if ((bufferLength - i) >= streamState.PacketLength &&
streamState.PacketLength > 0) streamState.PacketLength > 0)
{ {
offset = streamState.PacketLength; offset = streamState.PacketLength;
@ -1085,7 +1085,7 @@ namespace BDInfo
--parser.PacketLength; --parser.PacketLength;
bool headerFound = false; bool headerFound = false;
if (stream.IsVideoStream && if (stream.IsVideoStream &&
streamState.Parse == 0x000001FD) streamState.Parse == 0x000001FD)
{ {
headerFound = true; headerFound = true;
@ -1170,18 +1170,18 @@ namespace BDInfo
(byte)(streamState.Parse & 0xFF); (byte)(streamState.Parse & 0xFF);
#endif #endif
break; break;
case 1: case 1:
streamState.PESHeaderFlags = streamState.PESHeaderFlags =
(byte)(streamState.Parse & 0xFF); (byte)(streamState.Parse & 0xFF);
#if DEBUG #if DEBUG
streamState.PESHeader[streamState.PESHeaderIndex++] = streamState.PESHeader[streamState.PESHeaderIndex++] =
(byte)(streamState.Parse & 0xFF); (byte)(streamState.Parse & 0xFF);
#endif #endif
break; break;
case 0: case 0:
streamState.PESHeaderLength = streamState.PESHeaderLength =
(byte)(streamState.Parse & 0xFF); (byte)(streamState.Parse & 0xFF);
#if DEBUG #if DEBUG
streamState.PESHeader[streamState.PESHeaderIndex++] = streamState.PESHeader[streamState.PESHeaderIndex++] =
@ -1211,48 +1211,48 @@ namespace BDInfo
switch (streamState.PTSParse) switch (streamState.PTSParse)
{ {
case 4: case 4:
streamState.PTSTemp = streamState.PTSTemp =
((streamState.Parse & 0xE) << 29); ((streamState.Parse & 0xE) << 29);
#if DEBUG #if DEBUG
streamState.PESHeader[streamState.PESHeaderIndex++] = streamState.PESHeader[streamState.PESHeaderIndex++] =
(byte)(streamState.Parse & 0xff); (byte)(streamState.Parse & 0xff);
#endif #endif
break; break;
case 3: case 3:
streamState.PTSTemp |= streamState.PTSTemp |=
((streamState.Parse & 0xFF) << 22); ((streamState.Parse & 0xFF) << 22);
#if DEBUG #if DEBUG
streamState.PESHeader[streamState.PESHeaderIndex++] = streamState.PESHeader[streamState.PESHeaderIndex++] =
(byte)(streamState.Parse & 0xFF); (byte)(streamState.Parse & 0xFF);
#endif #endif
break; break;
case 2: case 2:
streamState.PTSTemp |= streamState.PTSTemp |=
((streamState.Parse & 0xFE) << 14); ((streamState.Parse & 0xFE) << 14);
#if DEBUG #if DEBUG
streamState.PESHeader[streamState.PESHeaderIndex++] = streamState.PESHeader[streamState.PESHeaderIndex++] =
(byte)(streamState.Parse & 0xFF); (byte)(streamState.Parse & 0xFF);
#endif #endif
break; break;
case 1: case 1:
streamState.PTSTemp |= streamState.PTSTemp |=
((streamState.Parse & 0xFF) << 7); ((streamState.Parse & 0xFF) << 7);
#if DEBUG #if DEBUG
streamState.PESHeader[streamState.PESHeaderIndex++] = streamState.PESHeader[streamState.PESHeaderIndex++] =
(byte)(streamState.Parse & 0xFF); (byte)(streamState.Parse & 0xFF);
#endif #endif
break; break;
case 0: case 0:
streamState.PTSTemp |= streamState.PTSTemp |=
((streamState.Parse & 0xFE) >> 1); ((streamState.Parse & 0xFE) >> 1);
#if DEBUG #if DEBUG
streamState.PESHeader[streamState.PESHeaderIndex++] = streamState.PESHeader[streamState.PESHeaderIndex++] =
(byte)(streamState.Parse & 0xff); (byte)(streamState.Parse & 0xff);
#endif #endif
streamState.PTS = streamState.PTSTemp; streamState.PTS = streamState.PTSTemp;
if (streamState.PTS > streamState.PTSLast) if (streamState.PTS > streamState.PTSLast)
@ -1260,13 +1260,13 @@ namespace BDInfo
if (streamState.PTSLast > 0) if (streamState.PTSLast > 0)
{ {
streamState.PTSTransfer = (streamState.PTS - streamState.PTSLast); streamState.PTSTransfer = (streamState.PTS - streamState.PTSLast);
} }
streamState.PTSLast = streamState.PTS; streamState.PTSLast = streamState.PTS;
} }
streamState.PTSDiff = streamState.PTS - streamState.DTSPrev; streamState.PTSDiff = streamState.PTS - streamState.DTSPrev;
if (streamState.PTSCount > 0 && if (streamState.PTSCount > 0 &&
stream.IsVideoStream) stream.IsVideoStream)
{ {
UpdateStreamBitrates(stream.PID, streamState.PTS, streamState.PTSDiff); UpdateStreamBitrates(stream.PID, streamState.PTS, streamState.PTSDiff);
@ -1280,7 +1280,7 @@ namespace BDInfo
} }
Length = (double)(parser.PTSLast - parser.PTSFirst) / 90000; Length = (double)(parser.PTSLast - parser.PTSFirst) / 90000;
} }
streamState.DTSPrev = streamState.PTS; streamState.DTSPrev = streamState.PTS;
streamState.PTSCount++; streamState.PTSCount++;
if (streamState.PESHeaderLength == 0) if (streamState.PESHeaderLength == 0)
@ -1299,46 +1299,46 @@ namespace BDInfo
switch (streamState.DTSParse) switch (streamState.DTSParse)
{ {
case 9: case 9:
streamState.PTSTemp = streamState.PTSTemp =
((streamState.Parse & 0xE) << 29); ((streamState.Parse & 0xE) << 29);
#if DEBUG #if DEBUG
streamState.PESHeader[streamState.PESHeaderIndex++] = streamState.PESHeader[streamState.PESHeaderIndex++] =
(byte)(streamState.Parse & 0xFF); (byte)(streamState.Parse & 0xFF);
#endif #endif
break; break;
case 8: case 8:
streamState.PTSTemp |= streamState.PTSTemp |=
((streamState.Parse & 0xFF) << 22); ((streamState.Parse & 0xFF) << 22);
#if DEBUG #if DEBUG
streamState.PESHeader[streamState.PESHeaderIndex++] = streamState.PESHeader[streamState.PESHeaderIndex++] =
(byte)(streamState.Parse & 0xFF); (byte)(streamState.Parse & 0xFF);
#endif #endif
break; break;
case 7: case 7:
streamState.PTSTemp |= streamState.PTSTemp |=
((streamState.Parse & 0xFE) << 14); ((streamState.Parse & 0xFE) << 14);
#if DEBUG #if DEBUG
streamState.PESHeader[streamState.PESHeaderIndex++] = streamState.PESHeader[streamState.PESHeaderIndex++] =
(byte)(streamState.Parse & 0xff); (byte)(streamState.Parse & 0xff);
#endif #endif
break; break;
case 6: case 6:
streamState.PTSTemp |= streamState.PTSTemp |=
((streamState.Parse & 0xFF) << 7); ((streamState.Parse & 0xFF) << 7);
#if DEBUG #if DEBUG
streamState.PESHeader[streamState.PESHeaderIndex++] = streamState.PESHeader[streamState.PESHeaderIndex++] =
(byte)(streamState.Parse & 0xFF); (byte)(streamState.Parse & 0xFF);
#endif #endif
break; break;
case 5: case 5:
streamState.PTSTemp |= streamState.PTSTemp |=
((streamState.Parse & 0xFE) >> 1); ((streamState.Parse & 0xFE) >> 1);
#if DEBUG #if DEBUG
streamState.PESHeader[streamState.PESHeaderIndex++] = streamState.PESHeader[streamState.PESHeaderIndex++] =
(byte)(streamState.Parse & 0xff); (byte)(streamState.Parse & 0xff);
#endif #endif
streamState.PTS = streamState.PTSTemp; streamState.PTS = streamState.PTSTemp;
@ -1347,48 +1347,48 @@ namespace BDInfo
streamState.PTSLast = streamState.PTS; streamState.PTSLast = streamState.PTS;
} }
break; break;
case 4: case 4:
streamState.DTSTemp = streamState.DTSTemp =
((streamState.Parse & 0xE) << 29); ((streamState.Parse & 0xE) << 29);
#if DEBUG #if DEBUG
streamState.PESHeader[streamState.PESHeaderIndex++] = streamState.PESHeader[streamState.PESHeaderIndex++] =
(byte)(streamState.Parse & 0xff); (byte)(streamState.Parse & 0xff);
#endif #endif
break; break;
case 3: case 3:
streamState.DTSTemp |= streamState.DTSTemp |=
((streamState.Parse & 0xFF) << 22); ((streamState.Parse & 0xFF) << 22);
#if DEBUG #if DEBUG
streamState.PESHeader[streamState.PESHeaderIndex++] = streamState.PESHeader[streamState.PESHeaderIndex++] =
(byte)(streamState.Parse & 0xff); (byte)(streamState.Parse & 0xff);
#endif #endif
break; break;
case 2: case 2:
streamState.DTSTemp |= streamState.DTSTemp |=
((streamState.Parse & 0xFE) << 14); ((streamState.Parse & 0xFE) << 14);
#if DEBUG #if DEBUG
streamState.PESHeader[streamState.PESHeaderIndex++] = streamState.PESHeader[streamState.PESHeaderIndex++] =
(byte)(streamState.Parse & 0xff); (byte)(streamState.Parse & 0xff);
#endif #endif
break; break;
case 1: case 1:
streamState.DTSTemp |= streamState.DTSTemp |=
((streamState.Parse & 0xFF) << 7); ((streamState.Parse & 0xFF) << 7);
#if DEBUG #if DEBUG
streamState.PESHeader[streamState.PESHeaderIndex++] = streamState.PESHeader[streamState.PESHeaderIndex++] =
(byte)(streamState.Parse & 0xFF); (byte)(streamState.Parse & 0xFF);
#endif #endif
break; break;
case 0: case 0:
streamState.DTSTemp |= streamState.DTSTemp |=
((streamState.Parse & 0xFE) >> 1); ((streamState.Parse & 0xFE) >> 1);
#if DEBUG #if DEBUG
streamState.PESHeader[streamState.PESHeaderIndex++] = streamState.PESHeader[streamState.PESHeaderIndex++] =
(byte)(streamState.Parse & 0xff); (byte)(streamState.Parse & 0xff);
#endif #endif
streamState.PTSDiff = streamState.DTSTemp - streamState.DTSPrev; streamState.PTSDiff = streamState.DTSTemp - streamState.DTSPrev;
@ -1482,8 +1482,8 @@ namespace BDInfo
} }
private TSStream CreateStream( private TSStream CreateStream(
ushort streamPID, ushort streamPID,
byte streamType, byte streamType,
List<TSDescriptor> streamDescriptors) List<TSDescriptor> streamDescriptors)
{ {
TSStream stream = null; TSStream stream = null;
@ -1548,6 +1548,6 @@ namespace BDInfo
} }
return stream; return stream;
} }
} }
} }

@ -68,7 +68,7 @@ namespace DvdLib.Ifo
ProhibitedUserOperations = (UserOperation)br.ReadUInt32(); ProhibitedUserOperations = (UserOperation)br.ReadUInt32();
AudioStreamControl = br.ReadBytes(16); AudioStreamControl = br.ReadBytes(16);
SubpictureStreamControl = br.ReadBytes(128); SubpictureStreamControl = br.ReadBytes(128);
_nextProgramNumber = br.ReadUInt16(); _nextProgramNumber = br.ReadUInt16();
_prevProgramNumber = br.ReadUInt16(); _prevProgramNumber = br.ReadUInt16();
_goupProgramNumber = br.ReadUInt16(); _goupProgramNumber = br.ReadUInt16();

@ -20,7 +20,7 @@ namespace DvdLib.Ifo
public ProgramChain EntryProgramChain { get; private set; } public ProgramChain EntryProgramChain { get; private set; }
public readonly List<ProgramChain> ProgramChains; public readonly List<ProgramChain> ProgramChains;
public readonly List<Chapter> Chapters; public readonly List<Chapter> Chapters;
public Title(uint titleNum) public Title(uint titleNum)
{ {

@ -3,7 +3,7 @@ using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("DvdLib")] [assembly: AssemblyTitle("DvdLib")]
@ -19,11 +19,11 @@ using System.Runtime.InteropServices;
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.1")] [assembly: AssemblyVersion("1.0.1")]

@ -1,6 +1,6 @@
 
namespace Emby.Dlna.Common namespace Emby.Dlna.Common
{ {
public class Argument public class Argument
{ {
public string Name { get; set; } public string Name { get; set; }

@ -77,7 +77,7 @@ namespace Emby.Dlna.ConnectionManager
return action; return action;
} }
private ServiceAction GetCurrentConnectionInfo() private ServiceAction GetCurrentConnectionInfo()
{ {
var action = new ServiceAction var action = new ServiceAction

@ -8,7 +8,7 @@ namespace Emby.Dlna.ContentDirectory
{ {
public string GetXml() public string GetXml()
{ {
return new ServiceXmlBuilder().GetXml(new ServiceActionListBuilder().GetActions(), return new ServiceXmlBuilder().GetXml(new ServiceActionListBuilder().GetActions(),
GetStateVariables()); GetStateVariables());
} }

@ -334,7 +334,7 @@ namespace Emby.Dlna.ContentDirectory
return action; return action;
} }
private ServiceAction GetXSetBookmarkAction() private ServiceAction GetXSetBookmarkAction()
{ {
var action = new ServiceAction var action = new ServiceAction

@ -10,7 +10,7 @@ namespace Emby.Dlna
/// <param name="headers">The headers.</param> /// <param name="headers">The headers.</param>
/// <returns>System.String.</returns> /// <returns>System.String.</returns>
string GetServiceXml(IDictionary<string, string> headers); string GetServiceXml(IDictionary<string, string> headers);
/// <summary> /// <summary>
/// Processes the control request. /// Processes the control request.
/// </summary> /// </summary>

@ -75,11 +75,11 @@ namespace Emby.Dlna.Main
IUserDataManager userDataManager, IUserDataManager userDataManager,
ILocalizationManager localizationManager, ILocalizationManager localizationManager,
IMediaSourceManager mediaSourceManager, IMediaSourceManager mediaSourceManager,
IDeviceDiscovery deviceDiscovery, IDeviceDiscovery deviceDiscovery,
IMediaEncoder mediaEncoder, IMediaEncoder mediaEncoder,
ISocketFactory socketFactory, ISocketFactory socketFactory,
ITimerFactory timerFactory, ITimerFactory timerFactory,
IEnvironmentInfo environmentInfo, IEnvironmentInfo environmentInfo,
INetworkManager networkManager, INetworkManager networkManager,
IUserViewManager userViewManager, IUserViewManager userViewManager,
IXmlReaderSettingsFactory xmlReaderSettingsFactory, IXmlReaderSettingsFactory xmlReaderSettingsFactory,
@ -104,19 +104,19 @@ namespace Emby.Dlna.Main
_networkManager = networkManager; _networkManager = networkManager;
_logger = loggerFactory.CreateLogger("Dlna"); _logger = loggerFactory.CreateLogger("Dlna");
ContentDirectory = new ContentDirectory.ContentDirectory(dlnaManager, ContentDirectory = new ContentDirectory.ContentDirectory(dlnaManager,
userDataManager, userDataManager,
imageProcessor, imageProcessor,
libraryManager, libraryManager,
config, config,
userManager, userManager,
_logger, _logger,
httpClient, httpClient,
localizationManager, localizationManager,
mediaSourceManager, mediaSourceManager,
userViewManager, userViewManager,
mediaEncoder, mediaEncoder,
xmlReaderSettingsFactory, xmlReaderSettingsFactory,
tvSeriesManager); tvSeriesManager);
ConnectionManager = new ConnectionManager.ConnectionManager(dlnaManager, config, _logger, httpClient, xmlReaderSettingsFactory); ConnectionManager = new ConnectionManager.ConnectionManager(dlnaManager, config, _logger, httpClient, xmlReaderSettingsFactory);
@ -271,12 +271,12 @@ namespace Emby.Dlna.Main
var device = new SsdpRootDevice var device = new SsdpRootDevice
{ {
CacheLifetime = TimeSpan.FromSeconds(1800), //How long SSDP clients can cache this info. CacheLifetime = TimeSpan.FromSeconds(1800), //How long SSDP clients can cache this info.
Location = uri, // Must point to the URL that serves your devices UPnP description document. Location = uri, // Must point to the URL that serves your devices UPnP description document.
FriendlyName = "Jellyfin", FriendlyName = "Jellyfin",
Manufacturer = "Jellyfin", Manufacturer = "Jellyfin",
ModelName = "Jellyfin Server", ModelName = "Jellyfin Server",
Uuid = udn Uuid = udn
// This must be a globally unique value that survives reboots etc. Get from storage or embedded hardware etc. // This must be a globally unique value that survives reboots etc. Get from storage or embedded hardware etc.
}; };
SetProperies(device, fullService); SetProperies(device, fullService);
@ -297,7 +297,7 @@ namespace Emby.Dlna.Main
Manufacturer = device.Manufacturer, Manufacturer = device.Manufacturer,
ModelName = device.ModelName, ModelName = device.ModelName,
Uuid = udn Uuid = udn
// This must be a globally unique value that survives reboots etc. Get from storage or embedded hardware etc. // This must be a globally unique value that survives reboots etc. Get from storage or embedded hardware etc.
}; };
SetProperies(embeddedDevice, subDevice); SetProperies(embeddedDevice, subDevice);

@ -739,7 +739,7 @@ namespace Emby.Dlna.PlayTo
if (track == null) if (track == null)
{ {
//If track is null, some vendors do this, use GetMediaInfo instead //If track is null, some vendors do this, use GetMediaInfo instead
return new Tuple<bool, uBaseObject>(true, null); return new Tuple<bool, uBaseObject>(true, null);
} }

@ -25,10 +25,10 @@ namespace Emby.Dlna.PlayTo
_config = config; _config = config;
} }
public async Task<XDocument> SendCommandAsync(string baseUrl, public async Task<XDocument> SendCommandAsync(string baseUrl,
DeviceService service, DeviceService service,
string command, string command,
string postData, string postData,
bool logRequest = true, bool logRequest = true,
string header = null) string header = null)
{ {
@ -62,12 +62,12 @@ namespace Emby.Dlna.PlayTo
} }
private readonly CultureInfo _usCulture = new CultureInfo("en-US"); private readonly CultureInfo _usCulture = new CultureInfo("en-US");
public async Task SubscribeAsync(string url, public async Task SubscribeAsync(string url,
string ip, string ip,
int port, int port,
string localIp, string localIp,
int eventport, int eventport,
int timeOut = 3600) int timeOut = 3600)
{ {
var options = new HttpRequestOptions var options = new HttpRequestOptions
@ -121,9 +121,9 @@ namespace Emby.Dlna.PlayTo
} }
} }
private Task<HttpResponseInfo> PostSoapDataAsync(string url, private Task<HttpResponseInfo> PostSoapDataAsync(string url,
string soapAction, string soapAction,
string postData, string postData,
string header, string header,
bool logRequest, bool logRequest,
CancellationToken cancellationToken) CancellationToken cancellationToken)

@ -171,7 +171,7 @@ namespace Emby.Dlna.PlayTo
if (state != null) if (state != null)
{ {
var sendValue = state.AllowedValues.FirstOrDefault(a => string.Equals(a, commandParameter, StringComparison.OrdinalIgnoreCase)) ?? var sendValue = state.AllowedValues.FirstOrDefault(a => string.Equals(a, commandParameter, StringComparison.OrdinalIgnoreCase)) ??
state.AllowedValues.FirstOrDefault() ?? state.AllowedValues.FirstOrDefault() ??
value; value;
return string.Format("<{0} xmlns:dt=\"urn:schemas-microsoft-com:datatypes\" dt:dt=\"{1}\">{2}</{0}>", argument.Name, state.DataType ?? "string", sendValue); return string.Format("<{0} xmlns:dt=\"urn:schemas-microsoft-com:datatypes\" dt:dt=\"{1}\">{2}</{0}>", argument.Name, state.DataType ?? "string", sendValue);

@ -2,7 +2,7 @@
namespace Emby.Dlna.PlayTo namespace Emby.Dlna.PlayTo
{ {
public class uBaseObject public class uBaseObject
{ {
public string Id { get; set; } public string Id { get; set; }

@ -20,7 +20,7 @@ namespace Emby.Dlna.PlayTo
if (document == null) if (document == null)
return list; return list;
var item = (from result in document.Descendants("Result") select result).FirstOrDefault(); var item = (from result in document.Descendants("Result") select result).FirstOrDefault();
if (item == null) if (item == null)

@ -41,7 +41,7 @@ namespace Emby.Dlna.Profiles
EnableSingleAlbumArtLimit = true; EnableSingleAlbumArtLimit = true;
EnableAlbumArtInDidl = true; EnableAlbumArtInDidl = true;
TranscodingProfiles = new[] TranscodingProfiles = new[]
{ {
new TranscodingProfile new TranscodingProfile

@ -3,7 +3,7 @@ using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Emby.Dlna2")] [assembly: AssemblyTitle("Emby.Dlna2")]
@ -19,11 +19,11 @@ using System.Runtime.InteropServices;
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]

@ -14,7 +14,7 @@ namespace Emby.Dlna.Service
protected BaseService(ILogger logger, IHttpClient httpClient) protected BaseService(ILogger logger, IHttpClient httpClient)
{ {
Logger = logger; Logger = logger;
HttpClient = httpClient; HttpClient = httpClient;
EventManager = new EventManager(Logger, HttpClient); EventManager = new EventManager(Logger, HttpClient);
} }

@ -10,7 +10,7 @@ namespace Emby.Dlna.Service
public class ControlErrorHandler public class ControlErrorHandler
{ {
private const string NS_SOAPENV = "http://schemas.xmlsoap.org/soap/envelope/"; private const string NS_SOAPENV = "http://schemas.xmlsoap.org/soap/envelope/";
public ControlResponse GetResponse(Exception ex) public ControlResponse GetResponse(Exception ex)
{ {
var settings = new XmlWriterSettings var settings = new XmlWriterSettings

@ -83,8 +83,8 @@ namespace Emby.Dlna.Ssdp
{ {
_deviceLocator = new SsdpDeviceLocator(_commsServer, _timerFactory); _deviceLocator = new SsdpDeviceLocator(_commsServer, _timerFactory);
// (Optional) Set the filter so we only see notifications for devices we care about // (Optional) Set the filter so we only see notifications for devices we care about
// (can be any search target value i.e device type, uuid value etc - any value that appears in the // (can be any search target value i.e device type, uuid value etc - any value that appears in the
// DiscoverdSsdpDevice.NotificationType property or that is used with the searchTarget parameter of the Search method). // DiscoverdSsdpDevice.NotificationType property or that is used with the searchTarget parameter of the Search method).
//_DeviceLocator.NotificationFilter = "upnp:rootdevice"; //_DeviceLocator.NotificationFilter = "upnp:rootdevice";

@ -3,7 +3,7 @@ using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Emby.Drawing.Skia")] [assembly: AssemblyTitle("Emby.Drawing.Skia")]
@ -19,7 +19,7 @@ using System.Runtime.InteropServices;
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //

@ -103,7 +103,7 @@ namespace Emby.Drawing
"crw", "crw",
// Remove until supported // Remove until supported
//"nef", //"nef",
"orf", "orf",
"pef", "pef",
"arw", "arw",

@ -1,7 +1,7 @@
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Emby.Drawing")] [assembly: AssemblyTitle("Emby.Drawing")]
@ -13,8 +13,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
@ -24,7 +24,7 @@ using System.Runtime.InteropServices;
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //

@ -48,7 +48,7 @@ namespace IsoMounter
if (disposed) { if (disposed) {
return; return;
} }
if (disposing) { if (disposing) {
// //

@ -29,7 +29,7 @@ namespace Emby.Naming.AudioBook
/// </summary> /// </summary>
/// <value>The alternate versions.</value> /// <value>The alternate versions.</value>
public List<AudioBookFileInfo> AlternateVersions { get; set; } public List<AudioBookFileInfo> AlternateVersions { get; set; }
public AudioBookInfo() public AudioBookInfo()
{ {
Files = new List<AudioBookFileInfo>(); Files = new List<AudioBookFileInfo>();

@ -46,7 +46,7 @@ namespace Emby.Naming.AudioBook
var parsingResult = new AudioBookFilePathParser(_options) var parsingResult = new AudioBookFilePathParser(_options)
.Parse(path, IsDirectory); .Parse(path, IsDirectory);
return new AudioBookFileInfo return new AudioBookFileInfo
{ {
Path = path, Path = path,

@ -282,7 +282,7 @@ namespace Emby.Naming.Common
new EpisodeExpression(@".*(\\|\/)(?<seriesname>((?![Ss]([0-9]+)[][ ._-]*[Ee]([0-9]+))[^\\\/])*)?[Ss](?<seasonnumber>[0-9]+)[][ ._-]*[Ee](?<epnumber>[0-9]+)([^\\/]*)$") new EpisodeExpression(@".*(\\|\/)(?<seriesname>((?![Ss]([0-9]+)[][ ._-]*[Ee]([0-9]+))[^\\\/])*)?[Ss](?<seasonnumber>[0-9]+)[][ ._-]*[Ee](?<epnumber>[0-9]+)([^\\/]*)$")
{ {
IsNamed = true IsNamed = true
}, },
// <!-- foo.ep01, foo.EP_01 --> // <!-- foo.ep01, foo.EP_01 -->
new EpisodeExpression(@"[\._ -]()[Ee][Pp]_?([0-9]+)([^\\/]*)$"), new EpisodeExpression(@"[\._ -]()[Ee][Pp]_?([0-9]+)([^\\/]*)$"),
new EpisodeExpression("([0-9]{4})[\\.-]([0-9]{2})[\\.-]([0-9]{2})", true) new EpisodeExpression("([0-9]{4})[\\.-]([0-9]{2})[\\.-]([0-9]{2})", true)

@ -53,7 +53,7 @@ namespace Emby.Naming.TV
var parsingResult = new EpisodePathParser(_options) var parsingResult = new EpisodePathParser(_options)
.Parse(path, IsDirectory, isNamed, isOptimistic, supportsAbsoluteNumbers, fillExtendedInfo); .Parse(path, IsDirectory, isNamed, isOptimistic, supportsAbsoluteNumbers, fillExtendedInfo);
return new EpisodeInfo return new EpisodeInfo
{ {
Path = path, Path = path,

@ -38,7 +38,7 @@ namespace Emby.Naming.Video
} }
catch (ArgumentException) catch (ArgumentException)
{ {
} }
var result = _options.CleanDateTimeRegexes.Select(i => Clean(name, i)) var result = _options.CleanDateTimeRegexes.Select(i => Clean(name, i))

@ -126,7 +126,7 @@ namespace Emby.Naming.Video
} }
stack.Files.Add(file2.FullName); stack.Files.Add(file2.FullName);
} }
else else
{ {
// Sequel // Sequel
offset = 0; offset = 0;

@ -18,7 +18,7 @@ namespace Emby.Naming.Video
{ {
var result = new StubResult(); var result = new StubResult();
var extension = Path.GetExtension(path) ?? string.Empty; var extension = Path.GetExtension(path) ?? string.Empty;
if (_options.StubFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase)) if (_options.StubFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase))
{ {
result.IsStub = true; result.IsStub = true;

@ -55,7 +55,7 @@ namespace Emby.Naming.Video
/// Gets or sets the type of the stub. /// Gets or sets the type of the stub.
/// </summary> /// </summary>
/// <value>The type of the stub.</value> /// <value>The type of the stub.</value>
public string StubType { get; set; } public string StubType { get; set; }
/// <summary> /// <summary>
/// Gets or sets the type. /// Gets or sets the type.
/// </summary> /// </summary>

@ -32,7 +32,7 @@ namespace Emby.Naming.Video
/// </summary> /// </summary>
/// <value>The alternate versions.</value> /// <value>The alternate versions.</value>
public List<VideoFileInfo> AlternateVersions { get; set; } public List<VideoFileInfo> AlternateVersions { get; set; }
public VideoInfo() public VideoInfo()
{ {
Files = new List<VideoFileInfo>(); Files = new List<VideoFileInfo>();

@ -55,9 +55,9 @@ namespace Emby.Naming.Video
info.Year = info.Files.First().Year; info.Year = info.Files.First().Year;
var extraBaseNames = new List<string> var extraBaseNames = new List<string>
{ {
stack.Name, stack.Name,
Path.GetFileNameWithoutExtension(stack.Files[0]) Path.GetFileNameWithoutExtension(stack.Files[0])
}; };

@ -2,7 +2,7 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Emby.Photos")] [assembly: AssemblyTitle("Emby.Photos")]
@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
@ -25,10 +25,10 @@ using System.Runtime.InteropServices;
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]

@ -15,14 +15,14 @@ namespace Emby.Server.Implementations.Archiving
/// </summary> /// </summary>
public class ZipClient : IZipClient public class ZipClient : IZipClient
{ {
private readonly IFileSystem _fileSystem; private readonly IFileSystem _fileSystem;
public ZipClient(IFileSystem fileSystem) public ZipClient(IFileSystem fileSystem)
{ {
_fileSystem = fileSystem; _fileSystem = fileSystem;
} }
/// <summary> /// <summary>
/// Extracts all. /// Extracts all.
/// </summary> /// </summary>
/// <param name="sourceFile">The source file.</param> /// <param name="sourceFile">The source file.</param>
@ -30,7 +30,7 @@ namespace Emby.Server.Implementations.Archiving
/// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param> /// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
public void ExtractAll(string sourceFile, string targetPath, bool overwriteExistingFiles) public void ExtractAll(string sourceFile, string targetPath, bool overwriteExistingFiles)
{ {
using (var fileStream = _fileSystem.OpenRead(sourceFile)) using (var fileStream = _fileSystem.OpenRead(sourceFile))
{ {
ExtractAll(fileStream, targetPath, overwriteExistingFiles); ExtractAll(fileStream, targetPath, overwriteExistingFiles);
} }
@ -116,7 +116,7 @@ namespace Emby.Server.Implementations.Archiving
/// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param> /// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
public void ExtractAllFrom7z(string sourceFile, string targetPath, bool overwriteExistingFiles) public void ExtractAllFrom7z(string sourceFile, string targetPath, bool overwriteExistingFiles)
{ {
using (var fileStream = _fileSystem.OpenRead(sourceFile)) using (var fileStream = _fileSystem.OpenRead(sourceFile))
{ {
ExtractAllFrom7z(fileStream, targetPath, overwriteExistingFiles); ExtractAllFrom7z(fileStream, targetPath, overwriteExistingFiles);
} }
@ -156,7 +156,7 @@ namespace Emby.Server.Implementations.Archiving
/// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param> /// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
public void ExtractAllFromTar(string sourceFile, string targetPath, bool overwriteExistingFiles) public void ExtractAllFromTar(string sourceFile, string targetPath, bool overwriteExistingFiles)
{ {
using (var fileStream = _fileSystem.OpenRead(sourceFile)) using (var fileStream = _fileSystem.OpenRead(sourceFile))
{ {
ExtractAllFromTar(fileStream, targetPath, overwriteExistingFiles); ExtractAllFromTar(fileStream, targetPath, overwriteExistingFiles);
} }

@ -41,7 +41,7 @@ namespace Emby.Server.Implementations.Browser
} }
catch (NotSupportedException) catch (NotSupportedException)
{ {
} }
catch (Exception) catch (Exception)
{ {

@ -902,7 +902,7 @@ namespace Emby.Server.Implementations.Channels
where T : BaseItem, new() where T : BaseItem, new()
{ {
var id = _libraryManager.GetNewItemId(GetIdToHash(idString, channelName), typeof(T)); var id = _libraryManager.GetNewItemId(GetIdToHash(idString, channelName), typeof(T));
T item = null; T item = null;
try try

@ -70,8 +70,8 @@ namespace Emby.Server.Implementations.Channels
/// </summary> /// </summary>
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers() public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{ {
return new[] { return new[] {
// Every so often // Every so often
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks} new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks}
}; };

@ -4038,7 +4038,7 @@ namespace Emby.Server.Implementations.Data
if (query.PersonIds.Length > 0) if (query.PersonIds.Length > 0)
{ {
// TODO: Should this query with CleanName ? // TODO: Should this query with CleanName ?
var clauses = new List<string>(); var clauses = new List<string>();
var index = 0; var index = 0;
@ -5399,7 +5399,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
var itemIdBlob = itemId.ToGuidBlob(); var itemIdBlob = itemId.ToGuidBlob();
// First delete // First delete
deleteAncestorsStatement.Reset(); deleteAncestorsStatement.Reset();
deleteAncestorsStatement.TryBind("@ItemId", itemIdBlob); deleteAncestorsStatement.TryBind("@ItemId", itemIdBlob);
deleteAncestorsStatement.MoveNext(); deleteAncestorsStatement.MoveNext();
@ -5927,7 +5927,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
var guidBlob = itemId.ToGuidBlob(); var guidBlob = itemId.ToGuidBlob();
// First delete // First delete
db.Execute("delete from ItemValues where ItemId=@Id", guidBlob); db.Execute("delete from ItemValues where ItemId=@Id", guidBlob);
InsertItemValues(guidBlob, values, db); InsertItemValues(guidBlob, values, db);

@ -10,8 +10,8 @@ namespace Emby.Server.Implementations.Devices
public class DeviceId public class DeviceId
{ {
private readonly IApplicationPaths _appPaths; private readonly IApplicationPaths _appPaths;
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IFileSystem _fileSystem; private readonly IFileSystem _fileSystem;
private readonly object _syncLock = new object(); private readonly object _syncLock = new object();
@ -26,7 +26,7 @@ namespace Emby.Server.Implementations.Devices
{ {
lock (_syncLock) lock (_syncLock)
{ {
var value = File.ReadAllText(CachePath, Encoding.UTF8); var value = File.ReadAllText(CachePath, Encoding.UTF8);
Guid guid; Guid guid;
if (Guid.TryParse(value, out guid)) if (Guid.TryParse(value, out guid))
@ -57,7 +57,7 @@ namespace Emby.Server.Implementations.Devices
{ {
var path = CachePath; var path = CachePath;
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
lock (_syncLock) lock (_syncLock)
{ {
@ -92,13 +92,13 @@ namespace Emby.Server.Implementations.Devices
public DeviceId(IApplicationPaths appPaths, ILogger logger, IFileSystem fileSystem) public DeviceId(IApplicationPaths appPaths, ILogger logger, IFileSystem fileSystem)
{ {
if (fileSystem == null) { if (fileSystem == null) {
throw new ArgumentNullException ("fileSystem"); throw new ArgumentNullException ("fileSystem");
} }
_appPaths = appPaths; _appPaths = appPaths;
_logger = logger; _logger = logger;
_fileSystem = fileSystem; _fileSystem = fileSystem;
} }
public string Value public string Value

@ -144,7 +144,7 @@ namespace Emby.Server.Implementations.Devices
HasUser = true HasUser = true
}).Items; }).Items;
// TODO: DeviceQuery doesn't seem to be used from client. Not even Swagger. // TODO: DeviceQuery doesn't seem to be used from client. Not even Swagger.
if (query.SupportsSync.HasValue) if (query.SupportsSync.HasValue)
{ {

@ -471,7 +471,7 @@ namespace Emby.Server.Implementations.EntryPoints
LibraryUpdateTimer.Dispose(); LibraryUpdateTimer.Dispose();
LibraryUpdateTimer = null; LibraryUpdateTimer = null;
} }
_libraryManager.ItemAdded -= libraryManager_ItemAdded; _libraryManager.ItemAdded -= libraryManager_ItemAdded;
_libraryManager.ItemUpdated -= libraryManager_ItemUpdated; _libraryManager.ItemUpdated -= libraryManager_ItemUpdated;
_libraryManager.ItemRemoved -= libraryManager_ItemRemoved; _libraryManager.ItemRemoved -= libraryManager_ItemRemoved;

@ -114,7 +114,7 @@ namespace Emby.Server.Implementations.FFMpeg
{ {
var encoderFilename = Path.GetFileName(info.EncoderPath); var encoderFilename = Path.GetFileName(info.EncoderPath);
var probeFilename = Path.GetFileName(info.ProbePath); var probeFilename = Path.GetFileName(info.ProbePath);
foreach (var directory in _fileSystem.GetDirectoryPaths(rootEncoderPath) foreach (var directory in _fileSystem.GetDirectoryPaths(rootEncoderPath)
.ToList()) .ToList())
{ {

@ -148,7 +148,7 @@ namespace Emby.Server.Implementations.HttpServer
} }
} }
private string[] SkipLogExtensions = new string[] private string[] SkipLogExtensions = new string[]
{ {
".js", ".js",
".html", ".html",

@ -103,7 +103,7 @@ namespace Emby.Server.Implementations.HttpServer
} }
/// <summary> /// <summary>
/// Applies the request filters. Returns whether or not the request has been handled /// Applies the request filters. Returns whether or not the request has been handled
/// and no more processing should be done. /// and no more processing should be done.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>

@ -265,7 +265,7 @@ namespace Emby.Server.Implementations.HttpServer
} }
/// <summary> /// <summary>
/// Returns the optimized result for the IRequestContext. /// Returns the optimized result for the IRequestContext.
/// Does not use or store results in any cache. /// Does not use or store results in any cache.
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="request"></param>

@ -33,7 +33,7 @@ namespace Emby.Server.Implementations.HttpServer
/// </summary> /// </summary>
/// <value>The web socket connecting.</value> /// <value>The web socket connecting.</value>
Action<WebSocketConnectingEventArgs> WebSocketConnecting { get; set; } Action<WebSocketConnectingEventArgs> WebSocketConnecting { get; set; }
/// <summary> /// <summary>
/// Starts this instance. /// Starts this instance.
/// </summary> /// </summary>

@ -115,7 +115,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
{ {
info.Device = tokenInfo.DeviceName; info.Device = tokenInfo.DeviceName;
} }
else if (!string.Equals(info.Device, tokenInfo.DeviceName, StringComparison.OrdinalIgnoreCase)) else if (!string.Equals(info.Device, tokenInfo.DeviceName, StringComparison.OrdinalIgnoreCase))
{ {
if (allowTokenInfoUpdate) if (allowTokenInfoUpdate)

@ -164,7 +164,7 @@ namespace Emby.Server.Implementations.IO
} }
catch (IOException ex) catch (IOException ex)
{ {
// For now swallow and log. // For now swallow and log.
// Research item: If an IOException occurs, the item may be in a disconnected state (media unavailable) // Research item: If an IOException occurs, the item may be in a disconnected state (media unavailable)
// Should we remove it from it's parent? // Should we remove it from it's parent?
Logger.LogError(ex, "Error refreshing {name}", item.Name); Logger.LogError(ex, "Error refreshing {name}", item.Name);

@ -159,7 +159,7 @@ namespace Emby.Server.Implementations.IO
var firstChar = filePath[0]; var firstChar = filePath[0];
if (firstChar == '/') if (firstChar == '/')
{ {
// For this we don't really know. // For this we don't really know.
return filePath; return filePath;
} }
if (firstChar == '\\') //relative path if (firstChar == '\\') //relative path

@ -818,7 +818,7 @@ namespace Emby.Server.Implementations.Library
public BaseItem FindByPath(string path, bool? isFolder) public BaseItem FindByPath(string path, bool? isFolder)
{ {
// If this returns multiple items it could be tricky figuring out which one is correct. // If this returns multiple items it could be tricky figuring out which one is correct.
// In most cases, the newest one will be and the others obsolete but not yet cleaned up // In most cases, the newest one will be and the others obsolete but not yet cleaned up
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))
@ -1699,7 +1699,7 @@ namespace Emby.Server.Implementations.Library
{ {
try try
{ {
// Try to resolve the path into a video // Try to resolve the path into a video
video = ResolvePath(_fileSystem.GetFileSystemInfo(info.Path)) as Video; video = ResolvePath(_fileSystem.GetFileSystemInfo(info.Path)) as Video;
if (video == null) if (video == null)

@ -231,7 +231,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
} }
var firstMedia = resolvedItem.Files.First(); var firstMedia = resolvedItem.Files.First();
var libraryItem = new T var libraryItem = new T
{ {
Path = firstMedia.Path, Path = firstMedia.Path,

@ -42,7 +42,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
{ {
// Behind special folder resolver // Behind special folder resolver
return ResolverPriority.Second; return ResolverPriority.Second;
} }
} }
/// <summary> /// <summary>

@ -41,7 +41,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
{ {
// Behind special folder resolver // Behind special folder resolver
return ResolverPriority.Second; return ResolverPriority.Second;
} }
} }
/// <summary> /// <summary>

@ -48,7 +48,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
where TVideoType : Video, new() where TVideoType : Video, new()
{ {
var namingOptions = ((LibraryManager)LibraryManager).GetNamingOptions(); var namingOptions = ((LibraryManager)LibraryManager).GetNamingOptions();
// If the path is a file check for a matching extensions // If the path is a file check for a matching extensions
var parser = new Emby.Naming.Video.VideoResolver(namingOptions); var parser = new Emby.Naming.Video.VideoResolver(namingOptions);
@ -120,7 +120,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
if (video != null) if (video != null)
{ {
video.Name = parseName ? video.Name = parseName ?
videoInfo.Name : videoInfo.Name :
Path.GetFileName(args.Path); Path.GetFileName(args.Path);
@ -150,7 +150,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
}; };
SetVideoType(video, videoInfo); SetVideoType(video, videoInfo);
video.Name = parseName ? video.Name = parseName ?
videoInfo.Name : videoInfo.Name :
Path.GetFileNameWithoutExtension(args.Path); Path.GetFileNameWithoutExtension(args.Path);
@ -281,7 +281,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
{ {
return string.Equals(name, "video_ts.ifo", StringComparison.OrdinalIgnoreCase); return string.Equals(name, "video_ts.ifo", StringComparison.OrdinalIgnoreCase);
} }
/// <summary> /// <summary>
/// Determines whether [is blu ray directory] [the specified directory name]. /// Determines whether [is blu ray directory] [the specified directory name].
/// </summary> /// </summary>

@ -8,14 +8,14 @@ using MediaBrowser.Model.Entities;
namespace Emby.Server.Implementations.Library.Resolvers.Books namespace Emby.Server.Implementations.Library.Resolvers.Books
{ {
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public class BookResolver : MediaBrowser.Controller.Resolvers.ItemResolver<Book> public class BookResolver : MediaBrowser.Controller.Resolvers.ItemResolver<Book>
{ {
private readonly string[] _validExtensions = { ".pdf", ".epub", ".mobi", ".cbr", ".cbz", ".azw3" }; private readonly string[] _validExtensions = { ".pdf", ".epub", ".mobi", ".cbr", ".cbz", ".azw3" };
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <param name="args"></param> /// <param name="args"></param>
/// <returns></returns> /// <returns></returns>
@ -48,7 +48,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Books
} }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <param name="args"></param> /// <param name="args"></param>
/// <returns></returns> /// <returns></returns>

@ -32,7 +32,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
get get
{ {
// Give plugins a chance to catch iso's first // Give plugins a chance to catch iso's first
// Also since we have to loop through child files looking for videos, // Also since we have to loop through child files looking for videos,
// see if we can avoid some of that by letting other resolvers claim folders first // see if we can avoid some of that by letting other resolvers claim folders first
// Also run after series resolver // Also run after series resolver
return ResolverPriority.Third; return ResolverPriority.Third;

@ -27,7 +27,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
} }
var season = parent as Season; var season = parent as Season;
// Just in case the user decided to nest episodes. // Just in case the user decided to nest episodes.
// Not officially supported but in some cases we can handle it. // Not officially supported but in some cases we can handle it.
if (season == null) if (season == null)
{ {
@ -36,8 +36,8 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
// If the parent is a Season or Series, then this is an Episode if the VideoResolver returns something // If the parent is a Season or Series, then this is an Episode if the VideoResolver returns something
// Also handle flat tv folders // Also handle flat tv folders
if (season != null || if (season != null ||
string.Equals(args.GetCollectionType(), CollectionType.TvShows, StringComparison.OrdinalIgnoreCase) || string.Equals(args.GetCollectionType(), CollectionType.TvShows, StringComparison.OrdinalIgnoreCase) ||
args.HasParent<Series>()) args.HasParent<Series>())
{ {
var episode = ResolveVideo<Episode>(args, false); var episode = ResolveVideo<Episode>(args, false);

@ -282,7 +282,7 @@ namespace Emby.Server.Implementations.Library
if (includeItemTypes.Length == 0) if (includeItemTypes.Length == 0)
{ {
// Handle situations with the grouping setting, e.g. movies showing up in tv, etc. // Handle situations with the grouping setting, e.g. movies showing up in tv, etc.
// Thanks to mixed content libraries included in the UserView // Thanks to mixed content libraries included in the UserView
var hasCollectionType = parents.OfType<UserView>().ToArray(); var hasCollectionType = parents.OfType<UserView>().ToArray();
if (hasCollectionType.Length > 0) if (hasCollectionType.Length > 0)

@ -94,7 +94,7 @@ namespace Emby.Server.Implementations.Library.Validators
{ {
continue; continue;
} }
_logger.LogInformation("Deleting dead {2} {0} {1}.", item.Id.ToString("N"), item.Name, item.GetType().Name); _logger.LogInformation("Deleting dead {2} {0} {1}.", item.Id.ToString("N"), item.Name, item.GetType().Name);
_libraryManager.DeleteItem(item, new DeleteOptions _libraryManager.DeleteItem(item, new DeleteOptions

@ -1055,7 +1055,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{ {
_logger.LogInformation("Streaming Channel " + channelId); _logger.LogInformation("Streaming Channel " + channelId);
var result = string.IsNullOrEmpty(streamId) ? var result = string.IsNullOrEmpty(streamId) ?
null : null :
currentLiveStreams.FirstOrDefault(i => string.Equals(i.OriginalStreamId, streamId, StringComparison.OrdinalIgnoreCase)); currentLiveStreams.FirstOrDefault(i => string.Equals(i.OriginalStreamId, streamId, StringComparison.OrdinalIgnoreCase));

@ -214,13 +214,13 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var outputParam = string.Empty; var outputParam = string.Empty;
var commandLineArgs = string.Format("-i \"{0}\"{5} {2} -map_metadata -1 -threads 0 {3}{4}{6} -y \"{1}\"", var commandLineArgs = string.Format("-i \"{0}\"{5} {2} -map_metadata -1 -threads 0 {3}{4}{6} -y \"{1}\"",
inputTempFile, inputTempFile,
targetFile, targetFile,
videoArgs, videoArgs,
GetAudioArgs(mediaSource), GetAudioArgs(mediaSource),
subtitleArgs, subtitleArgs,
durationParam, durationParam,
outputParam); outputParam);
return inputModifier + " " + commandLineArgs; return inputModifier + " " + commandLineArgs;

@ -1993,7 +1993,7 @@ namespace Emby.Server.Implementations.LiveTv
Name = program.Name, Name = program.Name,
OfficialRating = program.OfficialRating OfficialRating = program.OfficialRating
}; };
} }
if (service == null) if (service == null)
{ {

@ -48,8 +48,8 @@ namespace Emby.Server.Implementations.LiveTv
/// <returns>IEnumerable{BaseTaskTrigger}.</returns> /// <returns>IEnumerable{BaseTaskTrigger}.</returns>
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers() public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{ {
return new[] { return new[] {
// Every so often // Every so often
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks} new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks}
}; };

@ -275,7 +275,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
for (int i = 0; i < model.TunerCount; ++i) for (int i = 0; i < model.TunerCount; ++i)
{ {
var name = String.Format("Tuner {0}", i + 1); var name = String.Format("Tuner {0}", i + 1);
var currentChannel = "none"; /// @todo Get current channel and map back to Station Id var currentChannel = "none"; /// @todo Get current channel and map back to Station Id
var isAvailable = await manager.CheckTunerAvailability(ipInfo, i, cancellationToken).ConfigureAwait(false); var isAvailable = await manager.CheckTunerAvailability(ipInfo, i, cancellationToken).ConfigureAwait(false);
LiveTvTunerStatus status = isAvailable ? LiveTvTunerStatus.Available : LiveTvTunerStatus.LiveTv; LiveTvTunerStatus status = isAvailable ? LiveTvTunerStatus.Available : LiveTvTunerStatus.LiveTv;
tuners.Add(new LiveTvTunerInfo tuners.Add(new LiveTvTunerInfo

@ -32,7 +32,7 @@ namespace Emby.Server.Implementations.Localization
catch (ArgumentException) catch (ArgumentException)
{ {
// will throw if input contains invalid unicode chars // will throw if input contains invalid unicode chars
// https://mnaoumov.wordpress.com/2014/06/14/stripping-invalid-characters-from-utf-16-strings/ // https://mnaoumov.wordpress.com/2014/06/14/stripping-invalid-characters-from-utf-16-strings/
text = StripInvalidUnicodeCharacters(text); text = StripInvalidUnicodeCharacters(text);
return Normalize(text, form, false); return Normalize(text, form, false);
} }

@ -10,11 +10,11 @@ namespace Emby.Server.Implementations.Net
{ {
public class SocketFactory : ISocketFactory public class SocketFactory : ISocketFactory
{ {
// THIS IS A LINKED FILE - SHARED AMONGST MULTIPLE PLATFORMS // THIS IS A LINKED FILE - SHARED AMONGST MULTIPLE PLATFORMS
// Be careful to check any changes compile and work for all platform projects it is shared in. // Be careful to check any changes compile and work for all platform projects it is shared in.
// Not entirely happy with this. Would have liked to have done something more generic/reusable, // Not entirely happy with this. Would have liked to have done something more generic/reusable,
// but that wasn't really the point so kept to YAGNI principal for now, even if the // but that wasn't really the point so kept to YAGNI principal for now, even if the
// interfaces are a bit ugly, specific and make assumptions. // interfaces are a bit ugly, specific and make assumptions.
private readonly ILogger _logger; private readonly ILogger _logger;

@ -8,7 +8,7 @@ using MediaBrowser.Model.Net;
namespace Emby.Server.Implementations.Net namespace Emby.Server.Implementations.Net
{ {
// THIS IS A LINKED FILE - SHARED AMONGST MULTIPLE PLATFORMS // THIS IS A LINKED FILE - SHARED AMONGST MULTIPLE PLATFORMS
// Be careful to check any changes compile and work for all platform projects it is shared in. // Be careful to check any changes compile and work for all platform projects it is shared in.
public sealed class UdpSocket : DisposableManagedObjectBase, ISocket public sealed class UdpSocket : DisposableManagedObjectBase, ISocket

@ -122,28 +122,28 @@ namespace System.Net
} }
/// <summary> /// <summary>
/// ///
/// Reverse a Positive BigInteger ONLY /// Reverse a Positive BigInteger ONLY
/// Bitwise ~ operator /// Bitwise ~ operator
/// ///
/// Input : FF FF FF FF /// Input : FF FF FF FF
/// Width : 4 /// Width : 4
/// Result : 00 00 00 00 /// Result : 00 00 00 00
/// ///
/// ///
/// Input : 00 00 00 00 /// Input : 00 00 00 00
/// Width : 4 /// Width : 4
/// Result : FF FF FF FF /// Result : FF FF FF FF
/// ///
/// Input : FF FF FF FF /// Input : FF FF FF FF
/// Width : 8 /// Width : 8
/// Result : FF FF FF FF 00 00 00 00 /// Result : FF FF FF FF 00 00 00 00
/// ///
/// ///
/// Input : 00 00 00 00 /// Input : 00 00 00 00
/// Width : 8 /// Width : 8
/// Result : FF FF FF FF FF FF FF FF /// Result : FF FF FF FF FF FF FF FF
/// ///
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <param name="width"></param> /// <param name="width"></param>

@ -7,7 +7,7 @@ using System.Text.RegularExpressions;
namespace System.Net namespace System.Net
{ {
/// <summary> /// <summary>
/// IP Network utility class. /// IP Network utility class.
/// Use IPNetwork.Parse to create instances. /// Use IPNetwork.Parse to create instances.
/// </summary> /// </summary>
public class IPNetwork : IComparable<IPNetwork> public class IPNetwork : IComparable<IPNetwork>
@ -210,7 +210,7 @@ namespace System.Net
/// <summary> /// <summary>
/// 192.168.168.100 - 255.255.255.0 /// 192.168.168.100 - 255.255.255.0
/// ///
/// Network : 192.168.168.0 /// Network : 192.168.168.0
/// Netmask : 255.255.255.0 /// Netmask : 255.255.255.0
/// Cidr : 24 /// Cidr : 24
@ -231,7 +231,7 @@ namespace System.Net
/// <summary> /// <summary>
/// 192.168.168.100/24 /// 192.168.168.100/24
/// ///
/// Network : 192.168.168.0 /// Network : 192.168.168.0
/// Netmask : 255.255.255.0 /// Netmask : 255.255.255.0
/// Cidr : 24 /// Cidr : 24
@ -253,7 +253,7 @@ namespace System.Net
/// <summary> /// <summary>
/// 192.168.168.100 255.255.255.0 /// 192.168.168.100 255.255.255.0
/// ///
/// Network : 192.168.168.0 /// Network : 192.168.168.0
/// Netmask : 255.255.255.0 /// Netmask : 255.255.255.0
/// Cidr : 24 /// Cidr : 24
@ -276,7 +276,7 @@ namespace System.Net
/// <summary> /// <summary>
/// 192.168.0.1/24 /// 192.168.0.1/24
/// 192.168.0.1 255.255.255.0 /// 192.168.0.1 255.255.255.0
/// ///
/// Network : 192.168.0.0 /// Network : 192.168.0.0
/// Netmask : 255.255.255.0 /// Netmask : 255.255.255.0
/// Cidr : 24 /// Cidr : 24
@ -303,7 +303,7 @@ namespace System.Net
/// <summary> /// <summary>
/// 192.168.168.100 - 255.255.255.0 /// 192.168.168.100 - 255.255.255.0
/// ///
/// Network : 192.168.168.0 /// Network : 192.168.168.0
/// Netmask : 255.255.255.0 /// Netmask : 255.255.255.0
/// Cidr : 24 /// Cidr : 24
@ -329,7 +329,7 @@ namespace System.Net
/// <summary> /// <summary>
/// 192.168.168.100/24 /// 192.168.168.100/24
/// ///
/// Network : 192.168.168.0 /// Network : 192.168.168.0
/// Netmask : 255.255.255.0 /// Netmask : 255.255.255.0
/// Cidr : 24 /// Cidr : 24
@ -354,7 +354,7 @@ namespace System.Net
/// <summary> /// <summary>
/// 192.168.0.1/24 /// 192.168.0.1/24
/// 192.168.0.1 255.255.255.0 /// 192.168.0.1 255.255.255.0
/// ///
/// Network : 192.168.0.0 /// Network : 192.168.0.0
/// Netmask : 255.255.255.0 /// Netmask : 255.255.255.0
/// Cidr : 24 /// Cidr : 24
@ -379,7 +379,7 @@ namespace System.Net
/// <summary> /// <summary>
/// 192.168.0.1/24 /// 192.168.0.1/24
/// 192.168.0.1 255.255.255.0 /// 192.168.0.1 255.255.255.0
/// ///
/// Network : 192.168.0.0 /// Network : 192.168.0.0
/// Netmask : 255.255.255.0 /// Netmask : 255.255.255.0
/// Cidr : 24 /// Cidr : 24
@ -409,7 +409,7 @@ namespace System.Net
/// <summary> /// <summary>
/// 192.168.168.100 - 255.255.255.0 /// 192.168.168.100 - 255.255.255.0
/// ///
/// Network : 192.168.168.0 /// Network : 192.168.168.0
/// Netmask : 255.255.255.0 /// Netmask : 255.255.255.0
/// Cidr : 24 /// Cidr : 24
@ -520,7 +520,7 @@ namespace System.Net
/// <summary> /// <summary>
/// 192.168.168.100 255.255.255.0 /// 192.168.168.100 255.255.255.0
/// ///
/// Network : 192.168.168.0 /// Network : 192.168.168.0
/// Netmask : 255.255.255.0 /// Netmask : 255.255.255.0
/// Cidr : 24 /// Cidr : 24
@ -578,7 +578,7 @@ namespace System.Net
/// <summary> /// <summary>
/// 192.168.168.100/24 /// 192.168.168.100/24
/// ///
/// Network : 192.168.168.0 /// Network : 192.168.168.0
/// Netmask : 255.255.255.0 /// Netmask : 255.255.255.0
/// Cidr : 24 /// Cidr : 24
@ -962,7 +962,7 @@ namespace System.Net
/// 20180217 lduchosal /// 20180217 lduchosal
/// impossible to reach code, byte cannot be negative : /// impossible to reach code, byte cannot be negative :
/// ///
/// if (cidr < 0) { /// if (cidr < 0) {
/// if (tryParse == false) { /// if (tryParse == false) {
/// throw new ArgumentOutOfRangeException("cidr"); /// throw new ArgumentOutOfRangeException("cidr");
@ -1275,7 +1275,7 @@ namespace System.Net
} }
/// <summary> /// <summary>
/// return true if ipaddress is contained in /// return true if ipaddress is contained in
/// IANA_ABLK_RESERVED1, IANA_BBLK_RESERVED1, IANA_CBLK_RESERVED1 /// IANA_ABLK_RESERVED1, IANA_BBLK_RESERVED1, IANA_CBLK_RESERVED1
/// </summary> /// </summary>
/// <param name="ipaddress"></param> /// <param name="ipaddress"></param>
@ -1294,7 +1294,7 @@ namespace System.Net
} }
/// <summary> /// <summary>
/// return true if ipnetwork is contained in /// return true if ipnetwork is contained in
/// IANA_ABLK_RESERVED1, IANA_BBLK_RESERVED1, IANA_CBLK_RESERVED1 /// IANA_ABLK_RESERVED1, IANA_BBLK_RESERVED1, IANA_CBLK_RESERVED1
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
@ -1395,9 +1395,9 @@ namespace System.Net
/// <summary> /// <summary>
/// Supernet two consecutive cidr equal subnet into a single one /// Supernet two consecutive cidr equal subnet into a single one
/// 192.168.0.0/24 + 192.168.1.0/24 = 192.168.0.0/23 /// 192.168.0.0/24 + 192.168.1.0/24 = 192.168.0.0/23
/// 10.1.0.0/16 + 10.0.0.0/16 = 10.0.0.0/15 /// 10.1.0.0/16 + 10.0.0.0/16 = 10.0.0.0/15
/// 192.168.0.0/24 + 192.168.0.0/25 = 192.168.0.0/24 /// 192.168.0.0/24 + 192.168.0.0/25 = 192.168.0.0/24
/// </summary> /// </summary>
/// <param name="network2"></param> /// <param name="network2"></param>
/// <returns></returns> /// <returns></returns>
@ -1410,9 +1410,9 @@ namespace System.Net
/// <summary> /// <summary>
/// Try to supernet two consecutive cidr equal subnet into a single one /// Try to supernet two consecutive cidr equal subnet into a single one
/// 192.168.0.0/24 + 192.168.1.0/24 = 192.168.0.0/23 /// 192.168.0.0/24 + 192.168.1.0/24 = 192.168.0.0/23
/// 10.1.0.0/16 + 10.0.0.0/16 = 10.0.0.0/15 /// 10.1.0.0/16 + 10.0.0.0/16 = 10.0.0.0/15
/// 192.168.0.0/24 + 192.168.0.0/25 = 192.168.0.0/24 /// 192.168.0.0/24 + 192.168.0.0/25 = 192.168.0.0/24
/// </summary> /// </summary>
/// <param name="network2"></param> /// <param name="network2"></param>
/// <returns></returns> /// <returns></returns>
@ -1841,13 +1841,13 @@ namespace System.Net
#region TryGuessCidr #region TryGuessCidr
/// <summary> /// <summary>
/// ///
/// Class Leading bits Default netmask /// Class Leading bits Default netmask
/// A (CIDR /8) 00 255.0.0.0 /// A (CIDR /8) 00 255.0.0.0
/// A (CIDR /8) 01 255.0.0.0 /// A (CIDR /8) 01 255.0.0.0
/// B (CIDR /16) 10 255.255.0.0 /// B (CIDR /16) 10 255.255.0.0
/// C (CIDR /24) 11 255.255.255.0 /// C (CIDR /24) 11 255.255.255.0
/// ///
/// </summary> /// </summary>
/// <param name="ip"></param> /// <param name="ip"></param>
/// <param name="cidr"></param> /// <param name="cidr"></param>
@ -1931,7 +1931,7 @@ namespace System.Net
/** /**
* Need a better way to do it * Need a better way to do it
* *
#region TrySubstractNetwork #region TrySubstractNetwork
public static bool TrySubstractNetwork(IPNetwork[] ipnetworks, IPNetwork substract, out IEnumerable<IPNetwork> result) { public static bool TrySubstractNetwork(IPNetwork[] ipnetworks, IPNetwork substract, out IEnumerable<IPNetwork> result) {

@ -3,7 +3,7 @@ using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Emby.Server.Implementations")] [assembly: AssemblyTitle("Emby.Server.Implementations")]
@ -19,10 +19,10 @@ using System.Runtime.InteropServices;
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]

@ -35,8 +35,8 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// </summary> /// </summary>
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers() public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{ {
return new[] return new[]
{ {
// Every so often // Every so often
new TaskTriggerInfo new TaskTriggerInfo
{ {

@ -36,8 +36,8 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// <returns>IEnumerable{BaseTaskTrigger}.</returns> /// <returns>IEnumerable{BaseTaskTrigger}.</returns>
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers() public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{ {
return new[] { return new[] {
// Every so often // Every so often
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(12).Ticks} new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(12).Ticks}
}; };

@ -42,8 +42,8 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
/// <returns>IEnumerable{BaseTaskTrigger}.</returns> /// <returns>IEnumerable{BaseTaskTrigger}.</returns>
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers() public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{ {
return new[] { return new[] {
// Every so often // Every so often
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks} new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks}
}; };

@ -38,8 +38,8 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
/// <returns>IEnumerable{BaseTaskTrigger}.</returns> /// <returns>IEnumerable{BaseTaskTrigger}.</returns>
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers() public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{ {
return new[] { return new[] {
// Every so often // Every so often
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks} new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks}
}; };

@ -171,7 +171,7 @@ namespace Emby.Server.Implementations.Security
//build our array //build our array
var lines = new List<string> var lines = new List<string>
{ {
RegKey, RegKey,
// Legacy key // Legacy key
string.Empty string.Empty

@ -21,7 +21,7 @@ namespace Emby.Server.Implementations.Services
return deserializer(requestType, httpReq.InputStream); return deserializer(requestType, httpReq.InputStream);
} }
} }
return Task.FromResult(host.CreateInstance(requestType)); return Task.FromResult(host.CreateInstance(requestType));
} }
public static RestPath FindMatchingRestPath(string httpMethod, string pathInfo, out string contentType) public static RestPath FindMatchingRestPath(string httpMethod, string pathInfo, out string contentType)

@ -39,7 +39,7 @@ namespace Emby.Server.Implementations.Services
public int PathComponentsCount { get; set; } public int PathComponentsCount { get; set; }
/// <summary> /// <summary>
/// The total number of segments after subparts have been exploded ('.') /// The total number of segments after subparts have been exploded ('.')
/// e.g. /path/to/here.ext == 4 /// e.g. /path/to/here.ext == 4
/// </summary> /// </summary>
public int TotalComponentsCount { get; set; } public int TotalComponentsCount { get; set; }

@ -5,7 +5,7 @@ namespace Emby.Server.Implementations.Services
/// <summary> /// <summary>
/// Donated by Ivan Korneliuk from his post: /// Donated by Ivan Korneliuk from his post:
/// http://korneliuk.blogspot.com/2012/08/servicestack-reusing-dtos.html /// http://korneliuk.blogspot.com/2012/08/servicestack-reusing-dtos.html
/// ///
/// Modified to only allow using routes matching the supplied HTTP Verb /// Modified to only allow using routes matching the supplied HTTP Verb
/// </summary> /// </summary>
public static class UrlExtensions public static class UrlExtensions

@ -28,7 +28,7 @@ namespace Emby.Server.Implementations.Sorting
/// </summary> /// </summary>
/// <value>The user data repository.</value> /// <value>The user data repository.</value>
public IUserDataManager UserDataRepository { get; set; } public IUserDataManager UserDataRepository { get; set; }
/// <summary> /// <summary>
/// Compares the specified x. /// Compares the specified x.
/// </summary> /// </summary>

@ -53,7 +53,7 @@ namespace Emby.Server.Implementations.Sorting
/// </summary> /// </summary>
/// <value>The user data repository.</value> /// <value>The user data repository.</value>
public IUserDataManager UserDataRepository { get; set; } public IUserDataManager UserDataRepository { get; set; }
/// <summary> /// <summary>
/// Gets or sets the user manager. /// Gets or sets the user manager.
/// </summary> /// </summary>

@ -32,7 +32,7 @@ namespace Emby.Server.Implementations.Sorting
{ {
return x.PremiereDate.Value; return x.PremiereDate.Value;
} }
if (x.ProductionYear.HasValue) if (x.ProductionYear.HasValue)
{ {
try try

@ -18,7 +18,7 @@ namespace NLangDetect.Core.Extensions
if (end < 0) throw new ArgumentOutOfRangeException("end", "Argument must not be negative."); if (end < 0) throw new ArgumentOutOfRangeException("end", "Argument must not be negative.");
if (end > s.Length) throw new ArgumentOutOfRangeException("end", "Argument must not be greater than the input string's length."); if (end > s.Length) throw new ArgumentOutOfRangeException("end", "Argument must not be greater than the input string's length.");
if (start > end) throw new ArgumentOutOfRangeException("start", "Argument must not be greater than the 'end' argument."); if (start > end) throw new ArgumentOutOfRangeException("start", "Argument must not be greater than the 'end' argument.");
return s.Substring(start, end - start); return s.Substring(start, end - start);
} }
} }

@ -1,15 +1,15 @@
namespace Emby.Server.Implementations.TextEncoding namespace Emby.Server.Implementations.TextEncoding
{ {
// Copyright 2015-2016 Jonathan Bennett <jon@autoitscript.com> // Copyright 2015-2016 Jonathan Bennett <jon@autoitscript.com>
// //
// https://www.autoitscript.com // https://www.autoitscript.com
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // http://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -166,7 +166,7 @@
return encoding; return encoding;
} }
// Now try UTF16 // Now try UTF16
encoding = CheckUtf16NewlineChars(buffer, size); encoding = CheckUtf16NewlineChars(buffer, size);
if (encoding != CharacterEncoding.None) if (encoding != CharacterEncoding.None)
{ {

@ -41,7 +41,7 @@ using System.IO;
namespace UniversalDetector namespace UniversalDetector
{ {
/// <summary> /// <summary>
/// Default implementation of charset detection interface. /// Default implementation of charset detection interface.
/// The detector can be fed by a System.IO.Stream: /// The detector can be fed by a System.IO.Stream:
/// <example> /// <example>
/// <code> /// <code>
@ -52,9 +52,9 @@ namespace UniversalDetector
/// Console.WriteLine("{0}, {1}", cdet.Charset, cdet.Confidence); /// Console.WriteLine("{0}, {1}", cdet.Charset, cdet.Confidence);
/// </code> /// </code>
/// </example> /// </example>
/// ///
/// or by a byte a array: /// or by a byte a array:
/// ///
/// <example> /// <example>
/// <code> /// <code>
/// byte[] buff = new byte[1024]; /// byte[] buff = new byte[1024];
@ -64,23 +64,23 @@ namespace UniversalDetector
/// cdet.DataEnd(); /// cdet.DataEnd();
/// Console.WriteLine("{0}, {1}", cdet.Charset, cdet.Confidence); /// Console.WriteLine("{0}, {1}", cdet.Charset, cdet.Confidence);
/// </code> /// </code>
/// </example> /// </example>
/// </summary> /// </summary>
public class CharsetDetector : Core.UniversalDetector, ICharsetDetector public class CharsetDetector : Core.UniversalDetector, ICharsetDetector
{ {
private string charset; private string charset;
private float confidence; private float confidence;
//public event DetectorFinished Finished; //public event DetectorFinished Finished;
public CharsetDetector() : base(FILTER_ALL) public CharsetDetector() : base(FILTER_ALL)
{ {
} }
public void Feed(Stream stream) public void Feed(Stream stream)
{ {
byte[] buff = new byte[1024]; byte[] buff = new byte[1024];
int read; int read;
while ((read = stream.Read(buff, 0, buff.Length)) > 0 && !done) while ((read = stream.Read(buff, 0, buff.Length)) > 0 && !done)
@ -88,19 +88,19 @@ namespace UniversalDetector
Feed(buff, 0, read); Feed(buff, 0, read);
} }
} }
public bool IsDone() public bool IsDone()
{ {
return done; return done;
} }
public override void Reset() public override void Reset()
{ {
this.charset = null; this.charset = null;
this.confidence = 0.0f; this.confidence = 0.0f;
base.Reset(); base.Reset();
} }
public string Charset { public string Charset {
get { return charset; } get { return charset; }
} }
@ -108,7 +108,7 @@ namespace UniversalDetector
public float Confidence { public float Confidence {
get { return confidence; } get { return confidence; }
} }
protected override void Report(string charset, float confidence) protected override void Report(string charset, float confidence)
{ {
this.charset = charset; this.charset = charset;
@ -118,7 +118,7 @@ namespace UniversalDetector
// } // }
} }
} }
//public delegate void DetectorFinished(string charset, float confidence); //public delegate void DetectorFinished(string charset, float confidence);
} }

@ -44,12 +44,12 @@ namespace UniversalDetector.Core
private CodingStateMachine codingSM; private CodingStateMachine codingSM;
private BIG5DistributionAnalyser distributionAnalyser; private BIG5DistributionAnalyser distributionAnalyser;
private byte[] lastChar = new byte[2]; private byte[] lastChar = new byte[2];
public Big5Prober() public Big5Prober()
{ {
this.codingSM = new CodingStateMachine(new BIG5SMModel()); this.codingSM = new CodingStateMachine(new BIG5SMModel());
this.distributionAnalyser = new BIG5DistributionAnalyser(); this.distributionAnalyser = new BIG5DistributionAnalyser();
this.Reset(); this.Reset();
} }
public override ProbingState HandleData(byte[] buf, int offset, int len) public override ProbingState HandleData(byte[] buf, int offset, int len)
@ -73,7 +73,7 @@ namespace UniversalDetector.Core
lastChar[1] = buf[offset]; lastChar[1] = buf[offset];
distributionAnalyser.HandleOneChar(lastChar, 0, charLen); distributionAnalyser.HandleOneChar(lastChar, 0, charLen);
} else { } else {
distributionAnalyser.HandleOneChar(buf, i-1, charLen); distributionAnalyser.HandleOneChar(buf, i-1, charLen);
} }
} }
} }
@ -84,23 +84,23 @@ namespace UniversalDetector.Core
state = ProbingState.FoundIt; state = ProbingState.FoundIt;
return state; return state;
} }
public override void Reset() public override void Reset()
{ {
codingSM.Reset(); codingSM.Reset();
state = ProbingState.Detecting; state = ProbingState.Detecting;
distributionAnalyser.Reset(); distributionAnalyser.Reset();
} }
public override string GetCharsetName() public override string GetCharsetName()
{ {
return "Big-5"; return "Big-5";
} }
public override float GetConfidence() public override float GetConfidence()
{ {
return distributionAnalyser.GetConfidence(); return distributionAnalyser.GetConfidence();
} }
} }
} }

@ -43,15 +43,15 @@ namespace UniversalDetector.Core
public static int INDEX_SHIFT_4BITS = 3; public static int INDEX_SHIFT_4BITS = 3;
public static int INDEX_SHIFT_8BITS = 2; public static int INDEX_SHIFT_8BITS = 2;
public static int INDEX_SHIFT_16BITS = 1; public static int INDEX_SHIFT_16BITS = 1;
public static int SHIFT_MASK_4BITS = 7; public static int SHIFT_MASK_4BITS = 7;
public static int SHIFT_MASK_8BITS = 3; public static int SHIFT_MASK_8BITS = 3;
public static int SHIFT_MASK_16BITS = 1; public static int SHIFT_MASK_16BITS = 1;
public static int BIT_SHIFT_4BITS = 2; public static int BIT_SHIFT_4BITS = 2;
public static int BIT_SHIFT_8BITS = 3; public static int BIT_SHIFT_8BITS = 3;
public static int BIT_SHIFT_16BITS = 4; public static int BIT_SHIFT_16BITS = 4;
public static int UNIT_MASK_4BITS = 0x0000000F; public static int UNIT_MASK_4BITS = 0x0000000F;
public static int UNIT_MASK_8BITS = 0x000000FF; public static int UNIT_MASK_8BITS = 0x000000FF;
public static int UNIT_MASK_16BITS = 0x0000FFFF; public static int UNIT_MASK_16BITS = 0x0000FFFF;
@ -61,7 +61,7 @@ namespace UniversalDetector.Core
private int bitShift; private int bitShift;
private int unitMask; private int unitMask;
private int[] data; private int[] data;
public BitPackage(int indexShift, int shiftMask, public BitPackage(int indexShift, int shiftMask,
int bitShift, int unitMask, int[] data) int bitShift, int unitMask, int[] data)
{ {
@ -71,27 +71,27 @@ namespace UniversalDetector.Core
this.unitMask = unitMask; this.unitMask = unitMask;
this.data = data; this.data = data;
} }
public static int Pack16bits(int a, int b) public static int Pack16bits(int a, int b)
{ {
return ((b << 16) | a); return ((b << 16) | a);
} }
public static int Pack8bits(int a, int b, int c, int d) public static int Pack8bits(int a, int b, int c, int d)
{ {
return Pack16bits((b << 8) | a, (d << 8) | c); return Pack16bits((b << 8) | a, (d << 8) | c);
} }
public static int Pack4bits(int a, int b, int c, int d, public static int Pack4bits(int a, int b, int c, int d,
int e, int f, int g, int h) int e, int f, int g, int h)
{ {
return Pack8bits((b << 4) | a, (d << 4) | c, return Pack8bits((b << 4) | a, (d << 4) | c,
(f << 4) | e, (h << 4) | g); (f << 4) | e, (h << 4) | g);
} }
public int Unpack(int i) public int Unpack(int i)
{ {
return (data[i >> indexShift] >> return (data[i >> indexShift] >>
((i & shiftMask) << bitShift)) & unitMask; ((i & shiftMask) << bitShift)) & unitMask;
} }
} }

@ -38,12 +38,11 @@
namespace UniversalDetector.Core namespace UniversalDetector.Core
{ {
/// <summary> /// <summary>
/// Base class for the Character Distribution Method, used for /// Base class for the Character Distribution Method, used for
/// the CJK encodings /// the CJK encodings
/// </summary> /// </summary>
public abstract class CharDistributionAnalyser public abstract class CharDistributionAnalyser
{ {
protected const float SURE_YES = 0.99f; protected const float SURE_YES = 0.99f;
protected const float SURE_NO = 0.01f; protected const float SURE_NO = 0.01f;
protected const int MINIMUM_DATA_THRESHOLD = 4; protected const int MINIMUM_DATA_THRESHOLD = 4;
@ -57,19 +56,19 @@ namespace UniversalDetector.Core
//Total character encounted. //Total character encounted.
protected int totalChars; protected int totalChars;
// Mapping table to get frequency order from char order (get from GetOrder()) // Mapping table to get frequency order from char order (get from GetOrder())
protected int[] charToFreqOrder; protected int[] charToFreqOrder;
// Size of above table // Size of above table
protected int tableSize; protected int tableSize;
//This is a constant value varies from language to language, it is used //This is a constant value varies from language to language, it is used
// in calculating confidence. // in calculating confidence.
protected float typicalDistributionRatio; protected float typicalDistributionRatio;
public CharDistributionAnalyser() public CharDistributionAnalyser()
{ {
Reset(); Reset();
} }
@ -77,10 +76,10 @@ namespace UniversalDetector.Core
/// Feed a block of data and do distribution analysis /// Feed a block of data and do distribution analysis
/// </summary> /// </summary>
/// </param> /// </param>
//public abstract void HandleData(byte[] buf, int offset, int len); //public abstract void HandleData(byte[] buf, int offset, int len);
/// <summary> /// <summary>
/// we do not handle character base on its original encoding string, but /// we do not handle character base on its original encoding string, but
/// convert this encoding string to a number, here called order. /// convert this encoding string to a number, here called order.
/// This allow multiple encoding of a language to share one frequency table /// This allow multiple encoding of a language to share one frequency table
/// </summary> /// </summary>
@ -88,9 +87,9 @@ namespace UniversalDetector.Core
/// <param name="offset"></param> /// <param name="offset"></param>
/// <returns></returns> /// <returns></returns>
public abstract int GetOrder(byte[] buf, int offset); public abstract int GetOrder(byte[] buf, int offset);
/// <summary> /// <summary>
/// Feed a character with known length /// Feed a character with known length
/// </summary> /// </summary>
/// <param name="buf">A <see cref="System.Byte"/></param> /// <param name="buf">A <see cref="System.Byte"/></param>
/// <param name="offset">buf offset</param> /// <param name="offset">buf offset</param>
@ -107,13 +106,13 @@ namespace UniversalDetector.Core
} }
} }
public virtual void Reset() public virtual void Reset()
{ {
done = false; done = false;
totalChars = 0; totalChars = 0;
freqChars = 0; freqChars = 0;
} }
/// <summary> /// <summary>
/// return confidence base on received data /// return confidence base on received data
/// </summary> /// </summary>
@ -133,16 +132,16 @@ namespace UniversalDetector.Core
//normalize confidence, (we don't want to be 100% sure) //normalize confidence, (we don't want to be 100% sure)
return SURE_YES; return SURE_YES;
} }
//It is not necessary to receive all data to draw conclusion. For charset detection, //It is not necessary to receive all data to draw conclusion. For charset detection,
// certain amount of data is enough // certain amount of data is enough
public bool GotEnoughData() public bool GotEnoughData()
{ {
return totalChars > ENOUGH_DATA_THRESHOLD; return totalChars > ENOUGH_DATA_THRESHOLD;
} }
} }
public class GB18030DistributionAnalyser : CharDistributionAnalyser public class GB18030DistributionAnalyser : CharDistributionAnalyser
{ {
// GB2312 most frequently used character table // GB2312 most frequently used character table
@ -155,7 +154,7 @@ namespace UniversalDetector.Core
* *
* Idea Distribution Ratio = 0.79135/(1-0.79135) = 3.79 * Idea Distribution Ratio = 0.79135/(1-0.79135) = 3.79
* Random Distribution Ration = 512 / (3755 - 512) = 0.157 * Random Distribution Ration = 512 / (3755 - 512) = 0.157
* *
* Typical Distribution Ratio about 25% of Ideal one, still much higher that RDR * Typical Distribution Ratio about 25% of Ideal one, still much higher that RDR
*****************************************************************************/ *****************************************************************************/
@ -400,8 +399,8 @@ namespace UniversalDetector.Core
381,1638,4592,1020, 516,3214, 458, 947,4575,1432, 211,1514,2926,1865,2142, 189, 381,1638,4592,1020, 516,3214, 458, 947,4575,1432, 211,1514,2926,1865,2142, 189,
852,1221,1400,1486, 882,2299,4036, 351, 28,1122, 700,6479,6480,6481,6482,6483, //last 512 852,1221,1400,1486, 882,2299,4036, 351, 28,1122, 700,6479,6480,6481,6482,6483, //last 512
/*************************************************************************************** /***************************************************************************************
*Everything below is of no interest for detection purpose * *Everything below is of no interest for detection purpose *
*************************************************************************************** ***************************************************************************************
5508,6484,3900,3414,3974,4441,4024,3537,4037,5628,5099,3633,6485,3148,6486,3636, 5508,6484,3900,3414,3974,4441,4024,3537,4037,5628,5099,3633,6485,3148,6486,3636,
@ -601,7 +600,7 @@ namespace UniversalDetector.Core
tableSize = GB2312_TABLE_SIZE; tableSize = GB2312_TABLE_SIZE;
typicalDistributionRatio = GB2312_TYPICAL_DISTRIBUTION_RATIO; typicalDistributionRatio = GB2312_TYPICAL_DISTRIBUTION_RATIO;
} }
/// <summary> /// <summary>
/// for GB2312 encoding, we are interested /// for GB2312 encoding, we are interested
/// first byte range: 0xb0 -- 0xfe /// first byte range: 0xb0 -- 0xfe
@ -609,20 +608,20 @@ namespace UniversalDetector.Core
/// no validation needed here. State machine has done that /// no validation needed here. State machine has done that
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public override int GetOrder(byte[] buf, int offset) public override int GetOrder(byte[] buf, int offset)
{ {
if (buf[offset] >= 0xB0 && buf[offset+1] >= 0xA1) if (buf[offset] >= 0xB0 && buf[offset+1] >= 0xA1)
return 94 * (buf[offset] - 0xb0) + buf[offset+1] - 0xA1; return 94 * (buf[offset] - 0xb0) + buf[offset+1] - 0xA1;
else else
return -1; return -1;
} }
} }
public class EUCTWDistributionAnalyser : CharDistributionAnalyser public class EUCTWDistributionAnalyser : CharDistributionAnalyser
{ {
// EUCTW frequency table // EUCTW frequency table
// Converted from big5 work // Converted from big5 work
// by Taiwan's Mandarin Promotion Council // by Taiwan's Mandarin Promotion Council
// <http://www.edu.tw:81/mandr/> // <http://www.edu.tw:81/mandr/>
/****************************************************************************** /******************************************************************************
* 128 --> 0.42261 * 128 --> 0.42261
@ -633,7 +632,7 @@ namespace UniversalDetector.Core
* *
* Idea Distribution Ratio = 0.74851/(1-0.74851) =2.98 * Idea Distribution Ratio = 0.74851/(1-0.74851) =2.98
* Random Distribution Ration = 512/(5401-512)=0.105 * Random Distribution Ration = 512/(5401-512)=0.105
* *
* Typical Distribution Ratio about 25% of Ideal one, still much higher than RDR * Typical Distribution Ratio about 25% of Ideal one, still much higher than RDR
*****************************************************************************/ *****************************************************************************/
@ -979,8 +978,8 @@ namespace UniversalDetector.Core
890,3614,3864,8110,1877,3732,3402,8111,2183,2353,3403,1652,8112,8113,8114, 941, // 8086 890,3614,3864,8110,1877,3732,3402,8111,2183,2353,3403,1652,8112,8113,8114, 941, // 8086
2294, 208,3499,4057,2019, 330,4294,3865,2892,2492,3733,4295,8115,8116,8117,8118, // 8102 2294, 208,3499,4057,2019, 330,4294,3865,2892,2492,3733,4295,8115,8116,8117,8118, // 8102
/*************************************************************************************** /***************************************************************************************
*Everything below is of no interest for detection purpose * *Everything below is of no interest for detection purpose *
*************************************************************************************** ***************************************************************************************
2515,1613,4582,8119,3312,3866,2516,8120,4058,8121,1637,4059,2466,4583,3867,8122, // 8118 2515,1613,4582,8119,3312,3866,2516,8120,4058,8121,1637,4059,2466,4583,3867,8122, // 8118
@ -1022,7 +1021,7 @@ namespace UniversalDetector.Core
8678,8679,8680,8681,8682,8683,8684,8685,8686,8687,8688,8689,8690,8691,8692,8693, // 8694 8678,8679,8680,8681,8682,8683,8684,8685,8686,8687,8688,8689,8690,8691,8692,8693, // 8694
8694,8695,8696,8697,8698,8699,8700,8701,8702,8703,8704,8705,8706,8707,8708,8709, // 8710 8694,8695,8696,8697,8698,8699,8700,8701,8702,8703,8704,8705,8706,8707,8708,8709, // 8710
8710,8711,8712,8713,8714,8715,8716,8717,8718,8719,8720,8721,8722,8723,8724,8725, // 8726 8710,8711,8712,8713,8714,8715,8716,8717,8718,8719,8720,8721,8722,8723,8724,8725, // 8726
8726,8727,8728,8729,8730,8731,8732,8733,8734,8735,8736,8737,8738,8739,8740,8741, // 8742 //13973 8726,8727,8728,8729,8730,8731,8732,8733,8734,8735,8736,8737,8738,8739,8740,8741, // 8742 //13973
****************************************************************************************/ ****************************************************************************************/
}; };
@ -1038,15 +1037,15 @@ namespace UniversalDetector.Core
/// second byte range: 0xa1 -- 0xfe /// second byte range: 0xa1 -- 0xfe
/// no validation needed here. State machine has done that /// no validation needed here. State machine has done that
/// </summary> /// </summary>
public override int GetOrder(byte[] buf, int offset) public override int GetOrder(byte[] buf, int offset)
{ {
if (buf[offset] >= 0xC4) if (buf[offset] >= 0xC4)
return 94 * (buf[offset] - 0xC4) + buf[offset+1] - 0xA1; return 94 * (buf[offset] - 0xC4) + buf[offset+1] - 0xA1;
else else
return -1; return -1;
} }
} }
public class EUCKRDistributionAnalyser : CharDistributionAnalyser public class EUCKRDistributionAnalyser : CharDistributionAnalyser
{ {
// Sampling from about 20M text materials include literature and computer technology // Sampling from about 20M text materials include literature and computer technology
@ -1215,8 +1214,8 @@ namespace UniversalDetector.Core
2629,2630,2631, 924, 648, 863, 603,2632,2633, 934,1540, 864, 865,2634, 642,1042, 2629,2630,2631, 924, 648, 863, 603,2632,2633, 934,1540, 864, 865,2634, 642,1042,
670,1190,2635,2636,2637,2638, 168,2639, 652, 873, 542,1054,1541,2640,2641,2642, //512, 256 670,1190,2635,2636,2637,2638, 168,2639, 652, 873, 542,1054,1541,2640,2641,2642, //512, 256
/*************************************************************************************** /***************************************************************************************
* Everything below is of no interest for detection purpose * Everything below is of no interest for detection purpose *
*************************************************************************************** ***************************************************************************************
2643,2644,2645,2646,2647,2648,2649,2650,2651,2652,2653,2654,2655,2656,2657,2658, 2643,2644,2645,2646,2647,2648,2649,2650,2651,2652,2653,2654,2655,2656,2657,2658,
@ -1619,32 +1618,32 @@ namespace UniversalDetector.Core
8704,8705,8706,8707,8708,8709,8710,8711,8712,8713,8714,8715,8716,8717,8718,8719, 8704,8705,8706,8707,8708,8709,8710,8711,8712,8713,8714,8715,8716,8717,8718,8719,
8720,8721,8722,8723,8724,8725,8726,8727,8728,8729,8730,8731,8732,8733,8734,8735, 8720,8721,8722,8723,8724,8725,8726,8727,8728,8729,8730,8731,8732,8733,8734,8735,
8736,8737,8738,8739,8740,8741 */ }; 8736,8737,8738,8739,8740,8741 */ };
public EUCKRDistributionAnalyser() public EUCKRDistributionAnalyser()
{ {
charToFreqOrder = EUCKR_CHAR2FREQ_ORDER; charToFreqOrder = EUCKR_CHAR2FREQ_ORDER;
tableSize = EUCKR_TABLE_SIZE; tableSize = EUCKR_TABLE_SIZE;
typicalDistributionRatio = EUCKR_TYPICAL_DISTRIBUTION_RATIO; typicalDistributionRatio = EUCKR_TYPICAL_DISTRIBUTION_RATIO;
} }
/// <summary> /// <summary>
/// first byte range: 0xb0 -- 0xfe /// first byte range: 0xb0 -- 0xfe
/// second byte range: 0xa1 -- 0xfe /// second byte range: 0xa1 -- 0xfe
/// no validation needed here. State machine has done that /// no validation needed here. State machine has done that
/// </summary> /// </summary>
public override int GetOrder(byte[] buf, int offset) public override int GetOrder(byte[] buf, int offset)
{ {
if (buf[offset] >= 0xB0) if (buf[offset] >= 0xB0)
return 94 * (buf[offset] - 0xB0) + buf[offset+1] - 0xA1; return 94 * (buf[offset] - 0xB0) + buf[offset+1] - 0xA1;
else else
return -1; return -1;
} }
} }
public class BIG5DistributionAnalyser : CharDistributionAnalyser public class BIG5DistributionAnalyser : CharDistributionAnalyser
{ {
// Big5 frequency table // Big5 frequency table
// by Taiwan's Mandarin Promotion Council // by Taiwan's Mandarin Promotion Council
// <http://www.edu.tw:81/mandr/> // <http://www.edu.tw:81/mandr/>
/****************************************************************************** /******************************************************************************
* 128 --> 0.42261 * 128 --> 0.42261
@ -1655,7 +1654,7 @@ namespace UniversalDetector.Core
* *
* Idea Distribution Ratio = 0.74851/(1-0.74851) =2.98 * Idea Distribution Ratio = 0.74851/(1-0.74851) =2.98
* Random Distribution Ration = 512/(5401-512)=0.105 * Random Distribution Ration = 512/(5401-512)=0.105
* *
* Typical Distribution Ratio about 25% of Ideal one, still much higher than RDR * Typical Distribution Ratio about 25% of Ideal one, still much higher than RDR
*****************************************************************************/ *****************************************************************************/
@ -2001,8 +2000,8 @@ namespace UniversalDetector.Core
890,3669,3943,5791,1878,3798,3439,5792,2186,2358,3440,1652,5793,5794,5795, 941, // 5360 890,3669,3943,5791,1878,3798,3439,5792,2186,2358,3440,1652,5793,5794,5795, 941, // 5360
2299, 208,3546,4161,2020, 330,4438,3944,2906,2499,3799,4439,4811,5796,5797,5798, // 5376 //last 512 2299, 208,3546,4161,2020, 330,4438,3944,2906,2499,3799,4439,4811,5796,5797,5798, // 5376 //last 512
/*************************************************************************************** /***************************************************************************************
*Everything below is of no interest for detection purpose * *Everything below is of no interest for detection purpose *
*************************************************************************************** ***************************************************************************************
2522,1613,4812,5799,3345,3945,2523,5800,4162,5801,1637,4163,2471,4813,3946,5802, // 5392 2522,1613,4812,5799,3345,3945,2523,5800,4162,5801,1637,4163,2471,4813,3946,5802, // 5392
@ -2545,29 +2544,29 @@ namespace UniversalDetector.Core
13968,13969,13970,13971,13972, //13973 13968,13969,13970,13971,13972, //13973
****************************************************************************************/ ****************************************************************************************/
}; };
public BIG5DistributionAnalyser() public BIG5DistributionAnalyser()
{ {
charToFreqOrder = BIG5_CHAR2FREQ_ORDER; charToFreqOrder = BIG5_CHAR2FREQ_ORDER;
tableSize = BIG5_TABLE_SIZE; tableSize = BIG5_TABLE_SIZE;
typicalDistributionRatio = BIG5_TYPICAL_DISTRIBUTION_RATIO; typicalDistributionRatio = BIG5_TYPICAL_DISTRIBUTION_RATIO;
} }
/// <summary> /// <summary>
/// first byte range: 0xa4 -- 0xfe /// first byte range: 0xa4 -- 0xfe
/// second byte range: 0x40 -- 0x7e , 0xa1 -- 0xfe /// second byte range: 0x40 -- 0x7e , 0xa1 -- 0xfe
/// no validation needed here. State machine has done that /// no validation needed here. State machine has done that
/// </summary> /// </summary>
public override int GetOrder(byte[] buf, int offset) public override int GetOrder(byte[] buf, int offset)
{ {
if (buf[offset] >= 0xA4) { if (buf[offset] >= 0xA4) {
if (buf[offset+1] >= 0xA1) if (buf[offset+1] >= 0xA1)
return 157 * (buf[offset] - 0xA4) + buf[offset+1] - 0xA1 + 63; return 157 * (buf[offset] - 0xA4) + buf[offset+1] - 0xA1 + 63;
else else
return 157 * (buf[offset] - 0xA4) + buf[offset+1] - 0x40; return 157 * (buf[offset] - 0xA4) + buf[offset+1] - 0x40;
} else { } else {
return -1; return -1;
} }
} }
} }
@ -2575,7 +2574,7 @@ namespace UniversalDetector.Core
{ {
//Sampling from about 20M text materials include literature and computer technology //Sampling from about 20M text materials include literature and computer technology
// Japanese frequency table, applied to both S-JIS and EUC-JP // Japanese frequency table, applied to both S-JIS and EUC-JP
//They are sorted in order. //They are sorted in order.
/****************************************************************************** /******************************************************************************
* 128 --> 0.77094 * 128 --> 0.77094
@ -2586,8 +2585,8 @@ namespace UniversalDetector.Core
* *
* Idea Distribution Ratio = 0.92635 / (1-0.92635) = 12.58 * Idea Distribution Ratio = 0.92635 / (1-0.92635) = 12.58
* Random Distribution Ration = 512 / (2965+62+83+86-512) = 0.191 * Random Distribution Ration = 512 / (2965+62+83+86-512) = 0.191
* *
* Typical Distribution Ratio, 25% of IDR * Typical Distribution Ratio, 25% of IDR
*****************************************************************************/ *****************************************************************************/
protected static float SJIS_TYPICAL_DISTRIBUTION_RATIO = 3.0f; protected static float SJIS_TYPICAL_DISTRIBUTION_RATIO = 3.0f;
@ -2869,8 +2868,8 @@ namespace UniversalDetector.Core
1444,1698,2385,2251,3729,1365,2281,2235,1717,6188, 864,3841,2515, 444, 527,2767, // 4352 1444,1698,2385,2251,3729,1365,2281,2235,1717,6188, 864,3841,2515, 444, 527,2767, // 4352
2922,3625, 544, 461,6189, 566, 209,2437,3398,2098,1065,2068,3331,3626,3257,2137, // 4368 //last 512 2922,3625, 544, 461,6189, 566, 209,2437,3398,2098,1065,2068,3331,3626,3257,2137, // 4368 //last 512
/*************************************************************************************** /***************************************************************************************
*Everything below is of no interest for detection purpose * *Everything below is of no interest for detection purpose *
*************************************************************************************** ***************************************************************************************
2138,2122,3730,2888,1995,1820,1044,6190,6191,6192,6193,6194,6195,6196,6197,6198, // 4384 2138,2122,3730,2888,1995,1820,1044,6190,6191,6192,6193,6194,6195,6196,6197,6198, // 4384
@ -3118,31 +3117,31 @@ namespace UniversalDetector.Core
8240,8241,8242,8243,8244,8245,8246,8247,8248,8249,8250,8251,8252,8253,8254,8255, // 8256 8240,8241,8242,8243,8244,8245,8246,8247,8248,8249,8250,8251,8252,8253,8254,8255, // 8256
8256,8257,8258,8259,8260,8261,8262,8263,8264,8265,8266,8267,8268,8269,8270,8271, // 8272 8256,8257,8258,8259,8260,8261,8262,8263,8264,8265,8266,8267,8268,8269,8270,8271, // 8272
****************************************************************************************/ ****************************************************************************************/
}; };
public SJISDistributionAnalyser() public SJISDistributionAnalyser()
{ {
charToFreqOrder = SJIS_CHAR2FREQ_ORDER; charToFreqOrder = SJIS_CHAR2FREQ_ORDER;
tableSize = SJIS_TABLE_SIZE; tableSize = SJIS_TABLE_SIZE;
typicalDistributionRatio = SJIS_TYPICAL_DISTRIBUTION_RATIO; typicalDistributionRatio = SJIS_TYPICAL_DISTRIBUTION_RATIO;
} }
/// <summary> /// <summary>
/// first byte range: 0x81 -- 0x9f , 0xe0 -- 0xfe /// first byte range: 0x81 -- 0x9f , 0xe0 -- 0xfe
/// second byte range: 0x40 -- 0x7e, 0x81 -- oxfe /// second byte range: 0x40 -- 0x7e, 0x81 -- oxfe
/// no validation needed here. State machine has done that /// no validation needed here. State machine has done that
/// </summary> /// </summary>
public override int GetOrder(byte[] buf, int offset) public override int GetOrder(byte[] buf, int offset)
{ {
int order = 0; int order = 0;
if (buf[offset] >= 0x81 && buf[offset] <= 0x9F) if (buf[offset] >= 0x81 && buf[offset] <= 0x9F)
order = 188 * (buf[offset] - 0x81); order = 188 * (buf[offset] - 0x81);
else if (buf[offset] >= 0xE0 && buf[offset] <= 0xEF) else if (buf[offset] >= 0xE0 && buf[offset] <= 0xEF)
order = 188 * (buf[offset] - 0xE0 + 31); order = 188 * (buf[offset] - 0xE0 + 31);
else else
return -1; return -1;
order += buf[offset+1] - 0x40; order += buf[offset+1] - 0x40;
if (buf[offset+1] > 0x7F) if (buf[offset+1] > 0x7F)
order--; order--;
return order; return order;
@ -3154,20 +3153,18 @@ namespace UniversalDetector.Core
public EUCJPDistributionAnalyser() : base() public EUCJPDistributionAnalyser() : base()
{ {
} }
/// <summary> /// <summary>
/// first byte range: 0xa0 -- 0xfe /// first byte range: 0xa0 -- 0xfe
/// second byte range: 0xa1 -- 0xfe /// second byte range: 0xa1 -- 0xfe
/// no validation needed here. State machine has done that /// no validation needed here. State machine has done that
/// </summary> /// </summary>
public override int GetOrder(byte[] buf, int offset) public override int GetOrder(byte[] buf, int offset)
{ {
if (buf[offset] >= 0xA0) if (buf[offset] >= 0xA0)
return 94 * (buf[offset] - 0xA1) + buf[offset+1] - 0xA1; return 94 * (buf[offset] - 0xA1) + buf[offset+1] - 0xA1;
else else
return -1; return -1;
} }
} }
} }

@ -21,7 +21,7 @@
* Contributor(s): * Contributor(s):
* Shy Shalom <shooshX@gmail.com> * Shy Shalom <shooshX@gmail.com>
* Rudi Pettazzi <rudi.pettazzi@gmail.com> (C# port) * Rudi Pettazzi <rudi.pettazzi@gmail.com> (C# port)
* *
* Alternatively, the contents of this file may be used under the terms of * Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or * either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
@ -40,10 +40,10 @@ using System.IO;
namespace UniversalDetector.Core namespace UniversalDetector.Core
{ {
public enum ProbingState { public enum ProbingState {
Detecting = 0, // no sure answer yet, but caller can ask for confidence Detecting = 0, // no sure answer yet, but caller can ask for confidence
FoundIt = 1, // positive answer FoundIt = 1, // positive answer
NotMe = 2 // negative answer NotMe = 2 // negative answer
}; };
public abstract class CharsetProber public abstract class CharsetProber
@ -51,16 +51,16 @@ namespace UniversalDetector.Core
protected const float SHORTCUT_THRESHOLD = 0.95F; protected const float SHORTCUT_THRESHOLD = 0.95F;
protected ProbingState state; protected ProbingState state;
// ASCII codes // ASCII codes
private const byte SPACE = 0x20; private const byte SPACE = 0x20;
private const byte CAPITAL_A = 0x41; private const byte CAPITAL_A = 0x41;
private const byte CAPITAL_Z = 0x5A; private const byte CAPITAL_Z = 0x5A;
private const byte SMALL_A = 0x61; private const byte SMALL_A = 0x61;
private const byte SMALL_Z = 0x7A; private const byte SMALL_Z = 0x7A;
private const byte LESS_THAN = 0x3C; private const byte LESS_THAN = 0x3C;
private const byte GREATER_THAN = 0x3E; private const byte GREATER_THAN = 0x3E;
/// <summary> /// <summary>
/// Feed data to the prober /// Feed data to the prober
/// </summary> /// </summary>
@ -71,44 +71,44 @@ namespace UniversalDetector.Core
/// A <see cref="ProbingState"/> /// A <see cref="ProbingState"/>
/// </returns> /// </returns>
public abstract ProbingState HandleData(byte[] buf, int offset, int len); public abstract ProbingState HandleData(byte[] buf, int offset, int len);
/// <summary> /// <summary>
/// Reset prober state /// Reset prober state
/// </summary> /// </summary>
public abstract void Reset(); public abstract void Reset();
public abstract string GetCharsetName(); public abstract string GetCharsetName();
public abstract float GetConfidence(); public abstract float GetConfidence();
public virtual ProbingState GetState() public virtual ProbingState GetState()
{ {
return state; return state;
} }
public virtual void SetOption() public virtual void SetOption()
{ {
} }
public virtual void DumpStatus() public virtual void DumpStatus()
{ {
} }
// //
// Helper functions used in the Latin1 and Group probers // Helper functions used in the Latin1 and Group probers
// //
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <returns>filtered buffer</returns> /// <returns>filtered buffer</returns>
protected static byte[] FilterWithoutEnglishLetters(byte[] buf, int offset, int len) protected static byte[] FilterWithoutEnglishLetters(byte[] buf, int offset, int len)
{ {
byte[] result = null; byte[] result = null;
using (MemoryStream ms = new MemoryStream(buf.Length)) { using (MemoryStream ms = new MemoryStream(buf.Length)) {
bool meetMSB = false; bool meetMSB = false;
int max = offset + len; int max = offset + len;
int prev = offset; int prev = offset;
@ -140,8 +140,8 @@ namespace UniversalDetector.Core
} }
/// <summary> /// <summary>
/// Do filtering to reduce load to probers (Remove ASCII symbols, /// Do filtering to reduce load to probers (Remove ASCII symbols,
/// collapse spaces). This filter applies to all scripts which contain /// collapse spaces). This filter applies to all scripts which contain
/// both English characters and upper ASCII characters. /// both English characters and upper ASCII characters.
/// </summary> /// </summary>
/// <returns>a filtered copy of the input buffer</returns> /// <returns>a filtered copy of the input buffer</returns>
@ -150,16 +150,16 @@ namespace UniversalDetector.Core
byte[] result = null; byte[] result = null;
using (MemoryStream ms = new MemoryStream(buf.Length)) { using (MemoryStream ms = new MemoryStream(buf.Length)) {
bool inTag = false; bool inTag = false;
int max = offset + len; int max = offset + len;
int prev = offset; int prev = offset;
int cur = offset; int cur = offset;
while (cur < max) { while (cur < max) {
byte b = buf[cur]; byte b = buf[cur];
if (b == GREATER_THAN) if (b == GREATER_THAN)
inTag = false; inTag = false;
else if (b == LESS_THAN) else if (b == LESS_THAN)
@ -177,7 +177,7 @@ namespace UniversalDetector.Core
cur++; cur++;
} }
// If the current segment contains more than just a symbol // If the current segment contains more than just a symbol
// and it is not inside a tag then keep it. // and it is not inside a tag then keep it.
if (!inTag && cur > prev) if (!inTag && cur > prev)
ms.Write(buf, prev, cur - prev); ms.Write(buf, prev, cur - prev);

@ -20,7 +20,7 @@
* *
* Contributor(s): * Contributor(s):
* Rudi Pettazzi <rudi.pettazzi@gmail.com> (C# port) * Rudi Pettazzi <rudi.pettazzi@gmail.com> (C# port)
* *
* Alternatively, the contents of this file may be used under the terms of * Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or * either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
@ -40,47 +40,47 @@ namespace UniversalDetector.Core
public static class Charsets public static class Charsets
{ {
public const string ASCII = "ASCII"; public const string ASCII = "ASCII";
public const string UTF8 = "UTF-8"; public const string UTF8 = "UTF-8";
public const string UTF16_LE = "UTF-16LE"; public const string UTF16_LE = "UTF-16LE";
public const string UTF16_BE = "UTF-16BE"; public const string UTF16_BE = "UTF-16BE";
public const string UTF32_BE = "UTF-32BE"; public const string UTF32_BE = "UTF-32BE";
public const string UTF32_LE = "UTF-32LE"; public const string UTF32_LE = "UTF-32LE";
/// <summary> /// <summary>
/// Unusual BOM (3412 order) /// Unusual BOM (3412 order)
/// </summary> /// </summary>
public const string UCS4_3412 = "X-ISO-10646-UCS-4-3412"; public const string UCS4_3412 = "X-ISO-10646-UCS-4-3412";
/// <summary> /// <summary>
/// Unusual BOM (2413 order) /// Unusual BOM (2413 order)
/// </summary> /// </summary>
public const string UCS4_2413 = "X-ISO-10646-UCS-4-2413"; public const string UCS4_2413 = "X-ISO-10646-UCS-4-2413";
/// <summary> /// <summary>
/// Cyrillic (based on bulgarian and russian data) /// Cyrillic (based on bulgarian and russian data)
/// </summary> /// </summary>
public const string WIN1251 = "windows-1251"; public const string WIN1251 = "windows-1251";
/// <summary> /// <summary>
/// Latin-1, almost identical to ISO-8859-1 /// Latin-1, almost identical to ISO-8859-1
/// </summary> /// </summary>
public const string WIN1252 = "windows-1252"; public const string WIN1252 = "windows-1252";
/// <summary> /// <summary>
/// Greek /// Greek
/// </summary> /// </summary>
public const string WIN1253 = "windows-1253"; public const string WIN1253 = "windows-1253";
/// <summary> /// <summary>
/// Logical hebrew (includes ISO-8859-8-I and most of x-mac-hebrew) /// Logical hebrew (includes ISO-8859-8-I and most of x-mac-hebrew)
/// </summary> /// </summary>
public const string WIN1255 = "windows-1255"; public const string WIN1255 = "windows-1255";
/// <summary> /// <summary>
/// Traditional chinese /// Traditional chinese
/// </summary> /// </summary>
@ -89,7 +89,7 @@ namespace UniversalDetector.Core
public const string EUCKR = "EUC-KR"; public const string EUCKR = "EUC-KR";
public const string EUCJP = "EUC-JP"; public const string EUCJP = "EUC-JP";
public const string EUCTW = "EUC-TW"; public const string EUCTW = "EUC-TW";
/// <summary> /// <summary>
@ -98,11 +98,11 @@ namespace UniversalDetector.Core
public const string GB18030 = "gb18030"; public const string GB18030 = "gb18030";
public const string ISO2022_JP = "ISO-2022-JP"; public const string ISO2022_JP = "ISO-2022-JP";
public const string ISO2022_CN = "ISO-2022-CN"; public const string ISO2022_CN = "ISO-2022-CN";
public const string ISO2022_KR = "ISO-2022-KR"; public const string ISO2022_KR = "ISO-2022-KR";
/// <summary> /// <summary>
/// Simplified chinese /// Simplified chinese
/// </summary> /// </summary>
@ -111,15 +111,15 @@ namespace UniversalDetector.Core
public const string SHIFT_JIS = "Shift-JIS"; public const string SHIFT_JIS = "Shift-JIS";
public const string MAC_CYRILLIC = "x-mac-cyrillic"; public const string MAC_CYRILLIC = "x-mac-cyrillic";
public const string KOI8R = "KOI8-R"; public const string KOI8R = "KOI8-R";
public const string IBM855 = "IBM855"; public const string IBM855 = "IBM855";
public const string IBM866 = "IBM866"; public const string IBM866 = "IBM866";
/// <summary> /// <summary>
/// East-Europe. Disabled because too similar to windows-1252 /// East-Europe. Disabled because too similar to windows-1252
/// (latin-1). Should use tri-grams models to discriminate between /// (latin-1). Should use tri-grams models to discriminate between
/// these two charsets. /// these two charsets.
/// </summary> /// </summary>
@ -141,9 +141,9 @@ namespace UniversalDetector.Core
public const string ISO8859_8 = "ISO-8859-8"; public const string ISO8859_8 = "ISO-8859-8";
/// <summary> /// <summary>
/// Thai. This recognizer is not enabled yet. /// Thai. This recognizer is not enabled yet.
/// </summary> /// </summary>
public const string TIS620 = "TIS620"; public const string TIS620 = "TIS620";
} }
} }

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save