update bdinfo portable targeting

This commit is contained in:
Luke Pulverenti 2016-10-30 02:36:14 -04:00
parent fd04fddca0
commit b5673f4e16
9 changed files with 117 additions and 18378 deletions

View File

@ -2,7 +2,7 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{88AE38DF-19D7-406F-A6A9-09527719A21E}</ProjectGuid>
@ -13,9 +13,8 @@
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile7</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -61,6 +60,12 @@
<Compile Include="TSStreamClipFile.cs" />
<Compile Include="TSStreamFile.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">
<Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project>
<Name>MediaBrowser.Model</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -20,19 +20,22 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.TextEncoding;
namespace BDInfo
{
public class BDROM
{
public DirectoryInfo DirectoryRoot = null;
public DirectoryInfo DirectoryBDMV = null;
public DirectoryInfo DirectoryBDJO = null;
public DirectoryInfo DirectoryCLIPINF = null;
public DirectoryInfo DirectoryPLAYLIST = null;
public DirectoryInfo DirectorySNP = null;
public DirectoryInfo DirectorySSIF = null;
public DirectoryInfo DirectorySTREAM = null;
public FileSystemMetadata DirectoryRoot = null;
public FileSystemMetadata DirectoryBDMV = null;
public FileSystemMetadata DirectoryBDJO = null;
public FileSystemMetadata DirectoryCLIPINF = null;
public FileSystemMetadata DirectoryPLAYLIST = null;
public FileSystemMetadata DirectorySNP = null;
public FileSystemMetadata DirectorySSIF = null;
public FileSystemMetadata DirectorySTREAM = null;
public string VolumeLabel = null;
public ulong Size = 0;
@ -43,6 +46,8 @@ namespace BDInfo
public bool Is3D = false;
public bool Is50Hz = false;
private readonly IFileSystem _fileSystem;
public Dictionary<string, TSPlaylistFile> PlaylistFiles =
new Dictionary<string, TSPlaylistFile>();
public Dictionary<string, TSStreamClipFile> StreamClipFiles =
@ -70,8 +75,9 @@ namespace BDInfo
public event OnPlaylistFileScanError PlaylistFileScanError;
public BDROM(
string path)
string path, IFileSystem fileSystem, IEncoding textEncoding)
{
_fileSystem = fileSystem;
//
// Locate BDMV directories.
//
@ -85,7 +91,7 @@ namespace BDInfo
}
DirectoryRoot =
DirectoryBDMV.Parent;
_fileSystem.GetDirectoryInfo(Path.GetDirectoryName(DirectoryBDMV.FullName));
DirectoryBDJO =
GetDirectory("BDJO", DirectoryBDMV, 0);
DirectoryCLIPINF =
@ -126,24 +132,24 @@ namespace BDInfo
}
if (DirectoryBDJO != null &&
DirectoryBDJO.GetFiles().Length > 0)
_fileSystem.GetFiles(DirectoryBDJO.FullName).Any())
{
IsBDJava = true;
}
if (DirectorySNP != null &&
(DirectorySNP.GetFiles("*.mnv").Length > 0 || DirectorySNP.GetFiles("*.MNV").Length > 0))
GetFiles(DirectorySNP.FullName, ".mnv").Any())
{
IsPSP = true;
}
if (DirectorySSIF != null &&
DirectorySSIF.GetFiles().Length > 0)
_fileSystem.GetFiles(DirectorySSIF.FullName).Any())
{
Is3D = true;
}
if (File.Exists(Path.Combine(DirectoryRoot.FullName, "FilmIndex.xml")))
if (_fileSystem.FileExists(Path.Combine(DirectoryRoot.FullName, "FilmIndex.xml")))
{
IsDBOX = true;
}
@ -154,54 +160,38 @@ namespace BDInfo
if (DirectoryPLAYLIST != null)
{
FileInfo[] files = DirectoryPLAYLIST.GetFiles("*.mpls");
if (files.Length == 0)
{
files = DirectoryPLAYLIST.GetFiles("*.MPLS");
}
foreach (FileInfo file in files)
FileSystemMetadata[] files = GetFiles(DirectoryPLAYLIST.FullName, ".mpls").ToArray();
foreach (FileSystemMetadata file in files)
{
PlaylistFiles.Add(
file.Name.ToUpper(), new TSPlaylistFile(this, file));
file.Name.ToUpper(), new TSPlaylistFile(this, file, _fileSystem, textEncoding));
}
}
if (DirectorySTREAM != null)
{
FileInfo[] files = DirectorySTREAM.GetFiles("*.m2ts");
if (files.Length == 0)
{
files = DirectoryPLAYLIST.GetFiles("*.M2TS");
}
foreach (FileInfo file in files)
FileSystemMetadata[] files = GetFiles(DirectorySTREAM.FullName, ".m2ts").ToArray();
foreach (FileSystemMetadata file in files)
{
StreamFiles.Add(
file.Name.ToUpper(), new TSStreamFile(file));
file.Name.ToUpper(), new TSStreamFile(file, _fileSystem));
}
}
if (DirectoryCLIPINF != null)
{
FileInfo[] files = DirectoryCLIPINF.GetFiles("*.clpi");
if (files.Length == 0)
{
files = DirectoryPLAYLIST.GetFiles("*.CLPI");
}
foreach (FileInfo file in files)
FileSystemMetadata[] files = GetFiles(DirectoryCLIPINF.FullName, ".clpi").ToArray();
foreach (FileSystemMetadata file in files)
{
StreamClipFiles.Add(
file.Name.ToUpper(), new TSStreamClipFile(file));
file.Name.ToUpper(), new TSStreamClipFile(file, _fileSystem, textEncoding));
}
}
if (DirectorySSIF != null)
{
FileInfo[] files = DirectorySSIF.GetFiles("*.ssif");
if (files.Length == 0)
{
files = DirectorySSIF.GetFiles("*.SSIF");
}
foreach (FileInfo file in files)
FileSystemMetadata[] files = GetFiles(DirectorySSIF.FullName, ".ssif").ToArray();
foreach (FileSystemMetadata file in files)
{
InterleavedFiles.Add(
file.Name.ToUpper(), new TSInterleavedFile(file));
@ -209,6 +199,11 @@ namespace BDInfo
}
}
private IEnumerable<FileSystemMetadata> GetFiles(string path, string extension)
{
return _fileSystem.GetFiles(path).Where(i => string.Equals(i.Extension, extension, StringComparison.OrdinalIgnoreCase));
}
public void Scan()
{
List<TSStreamClipFile> errorStreamClipFiles = new List<TSStreamClipFile>();
@ -328,10 +323,10 @@ namespace BDInfo
}
}
private DirectoryInfo GetDirectoryBDMV(
private FileSystemMetadata GetDirectoryBDMV(
string path)
{
DirectoryInfo dir = new DirectoryInfo(path);
FileSystemMetadata dir = _fileSystem.GetDirectoryInfo(path);
while (dir != null)
{
@ -339,21 +334,21 @@ namespace BDInfo
{
return dir;
}
dir = dir.Parent;
dir = _fileSystem.GetDirectoryInfo(Path.GetDirectoryName(dir.FullName));
}
return GetDirectory("BDMV", new DirectoryInfo(path), 0);
return GetDirectory("BDMV", _fileSystem.GetDirectoryInfo(path), 0);
}
private DirectoryInfo GetDirectory(
private FileSystemMetadata GetDirectory(
string name,
DirectoryInfo dir,
FileSystemMetadata dir,
int searchDepth)
{
if (dir != null)
{
DirectoryInfo[] children = dir.GetDirectories();
foreach (DirectoryInfo child in children)
FileSystemMetadata[] children = _fileSystem.GetDirectories(dir.FullName).ToArray();
foreach (FileSystemMetadata child in children)
{
if (child.Name == name)
{
@ -362,7 +357,7 @@ namespace BDInfo
}
if (searchDepth > 0)
{
foreach (DirectoryInfo child in children)
foreach (FileSystemMetadata child in children)
{
GetDirectory(
name, child, searchDepth - 1);
@ -372,14 +367,14 @@ namespace BDInfo
return null;
}
private long GetDirectorySize(DirectoryInfo directoryInfo)
private long GetDirectorySize(FileSystemMetadata directoryInfo)
{
long size = 0;
//if (!ExcludeDirs.Contains(directoryInfo.Name.ToUpper())) // TODO: Keep?
{
FileInfo[] pathFiles = directoryInfo.GetFiles();
foreach (FileInfo pathFile in pathFiles)
FileSystemMetadata[] pathFiles = _fileSystem.GetFiles(directoryInfo.FullName).ToArray();
foreach (FileSystemMetadata pathFile in pathFiles)
{
if (pathFile.Extension.ToUpper() == ".SSIF")
{
@ -388,8 +383,8 @@ namespace BDInfo
size += pathFile.Length;
}
DirectoryInfo[] pathChildren = directoryInfo.GetDirectories();
foreach (DirectoryInfo pathChild in pathChildren)
FileSystemMetadata[] pathChildren = _fileSystem.GetDirectories(directoryInfo.FullName).ToArray();
foreach (FileSystemMetadata pathChild in pathChildren)
{
size += GetDirectorySize(pathChild);
}
@ -398,7 +393,7 @@ namespace BDInfo
return size;
}
private string GetVolumeLabel(DirectoryInfo dir)
private string GetVolumeLabel(FileSystemMetadata dir)
{
return dir.Name;
}

View File

@ -9,7 +9,6 @@ namespace BDInfo
using System.Diagnostics;
using System.Text;
using System;
using Microsoft.Win32;
/// <devdoc>
/// <para>Provides a simple light bit vector with easy integer or Boolean access to
@ -69,11 +68,6 @@ namespace BDInfo
}
set
{
#if DEBUG
if ((value & section.Mask) != value) {
Debug.Fail("Value out of bounds on BitVector32 Section Set!");
}
#endif
value <<= section.Offset;
int offsetMask = (0xFFFF & (int)section.Mask) << section.Offset;
data = (data & ~(uint)offsetMask) | ((uint)value & (uint)offsetMask);

View File

@ -18,6 +18,7 @@
//=============================================================================
using System.IO;
using MediaBrowser.Model.IO;
// TODO: Do more interesting things here...
@ -25,10 +26,10 @@ namespace BDInfo
{
public class TSInterleavedFile
{
public FileInfo FileInfo = null;
public FileSystemMetadata FileInfo = null;
public string Name = null;
public TSInterleavedFile(FileInfo fileInfo)
public TSInterleavedFile(FileSystemMetadata fileInfo)
{
FileInfo = fileInfo;
Name = fileInfo.Name.ToUpper();

View File

@ -22,12 +22,16 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.TextEncoding;
namespace BDInfo
{
public class TSPlaylistFile
{
private FileInfo FileInfo = null;
private readonly IFileSystem _fileSystem;
private readonly IEncoding _textEncoding;
private FileSystemMetadata FileInfo = null;
public string FileType = null;
public bool IsInitialized = false;
public string Name = null;
@ -63,20 +67,24 @@ namespace BDInfo
public TSPlaylistFile(
BDROM bdrom,
FileInfo fileInfo)
FileSystemMetadata fileInfo, IFileSystem fileSystem, IEncoding textEncoding)
{
BDROM = bdrom;
FileInfo = fileInfo;
_fileSystem = fileSystem;
_textEncoding = textEncoding;
Name = fileInfo.Name.ToUpper();
}
public TSPlaylistFile(
BDROM bdrom,
string name,
List<TSStreamClip> clips)
List<TSStreamClip> clips, IFileSystem fileSystem, IEncoding textEncoding)
{
BDROM = bdrom;
Name = name;
_fileSystem = fileSystem;
_textEncoding = textEncoding;
IsCustom = true;
foreach (TSStreamClip clip in clips)
{
@ -221,7 +229,7 @@ namespace BDInfo
Dictionary<string, TSStreamFile> streamFiles,
Dictionary<string, TSStreamClipFile> streamClipFiles)
{
FileStream fileStream = null;
Stream fileStream = null;
BinaryReader fileReader = null;
try
@ -229,7 +237,7 @@ namespace BDInfo
Streams.Clear();
StreamClips.Clear();
fileStream = File.OpenRead(FileInfo.FullName);
fileStream = _fileSystem.OpenRead(FileInfo.FullName);
fileReader = new BinaryReader(fileStream);
byte[] data = new byte[fileStream.Length];
@ -1239,7 +1247,7 @@ namespace BDInfo
ref int pos)
{
string val =
ASCIIEncoding.ASCII.GetString(data, pos, count);
_textEncoding.GetASCIIString(data, pos, count);
pos += count;

View File

@ -22,12 +22,16 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.TextEncoding;
namespace BDInfo
{
public class TSStreamClipFile
{
public FileInfo FileInfo = null;
private readonly IFileSystem _fileSystem;
private readonly IEncoding _textEncoding;
public FileSystemMetadata FileInfo = null;
public string FileType = null;
public bool IsValid = false;
public string Name = null;
@ -36,15 +40,17 @@ namespace BDInfo
new Dictionary<ushort,TSStream>();
public TSStreamClipFile(
FileInfo fileInfo)
FileSystemMetadata fileInfo, IFileSystem fileSystem, IEncoding textEncoding)
{
FileInfo = fileInfo;
_fileSystem = fileSystem;
_textEncoding = textEncoding;
Name = fileInfo.Name.ToUpper();
}
public void Scan()
{
FileStream fileStream = null;
Stream fileStream = null;
BinaryReader fileReader = null;
try
@ -55,7 +61,7 @@ namespace BDInfo
#endif
Streams.Clear();
fileStream = File.OpenRead(FileInfo.FullName);
fileStream = _fileSystem.OpenRead(FileInfo.FullName);
fileReader = new BinaryReader(fileStream);
byte[] data = new byte[fileStream.Length];
@ -64,7 +70,7 @@ namespace BDInfo
byte[] fileType = new byte[8];
Array.Copy(data, 0, fileType, 0, fileType.Length);
FileType = ASCIIEncoding.ASCII.GetString(fileType);
FileType = _textEncoding.GetASCIIString(fileType, 0, fileType.Length);
if (FileType != "HDMV0100" &&
FileType != "HDMV0200")
{
@ -161,7 +167,7 @@ namespace BDInfo
Array.Copy(clipData, streamOffset + 3,
languageBytes, 0, languageBytes.Length);
string languageCode =
ASCIIEncoding.ASCII.GetString(languageBytes);
_textEncoding.GetASCIIString(languageBytes, 0, languageBytes.Length);
TSChannelLayout channelLayout = (TSChannelLayout)
(clipData[streamOffset + 2] >> 4);
@ -192,9 +198,9 @@ namespace BDInfo
Array.Copy(clipData, streamOffset + 2,
languageBytes, 0, languageBytes.Length);
string languageCode =
ASCIIEncoding.ASCII.GetString(languageBytes);
_textEncoding.GetASCIIString(languageBytes, 0, languageBytes.Length);
stream = new TSGraphicsStream();
stream = new TSGraphicsStream();
stream.LanguageCode = languageCode;
#if DEBUG
Debug.WriteLine(string.Format(
@ -212,7 +218,7 @@ namespace BDInfo
Array.Copy(clipData, streamOffset + 3,
languageBytes, 0, languageBytes.Length);
string languageCode =
ASCIIEncoding.ASCII.GetString(languageBytes);
_textEncoding.GetASCIIString(languageBytes, 0, languageBytes.Length);
#if DEBUG
Debug.WriteLine(string.Format(
"\t{0} {1} {2}",
@ -220,7 +226,7 @@ namespace BDInfo
streamType,
languageCode));
#endif
stream = new TSTextStream();
stream = new TSTextStream();
stream.LanguageCode = languageCode;
}
break;

View File

@ -21,6 +21,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using MediaBrowser.Model.IO;
namespace BDInfo
{
@ -152,7 +153,7 @@ namespace BDInfo
public class TSStreamFile
{
public FileInfo FileInfo = null;
public FileSystemMetadata FileInfo = null;
public string Name = null;
public long Size = 0;
public double Length = 0;
@ -170,9 +171,12 @@ namespace BDInfo
private List<TSPlaylistFile> Playlists = null;
public TSStreamFile(FileInfo fileInfo)
private readonly IFileSystem _fileSystem;
public TSStreamFile(FileSystemMetadata fileInfo, IFileSystem fileSystem)
{
FileInfo = fileInfo;
_fileSystem = fileSystem;
Name = fileInfo.Name.ToUpper();
}
@ -451,7 +455,7 @@ namespace BDInfo
Playlists = playlists;
int dataSize = 16384;
FileStream fileStream = null;
Stream fileStream = null;
try
{
string fileName;
@ -464,12 +468,12 @@ namespace BDInfo
{
fileName = FileInfo.FullName;
}
fileStream = new FileStream(
fileStream = _fileSystem.GetFileStream(
fileName,
FileMode.Open,
FileAccess.Read,
FileShare.Read,
dataSize, false);
FileOpenMode.Open,
FileAccessMode.Read,
FileShareMode.Read,
false);
Size = 0;
Length = 0;

View File

@ -1,16 +1,7 @@
{
"supports": {
"net46.app": {},
"uwp.10.0.app": {},
"dnxcore50.app": {}
},
"dependencies": {
"Microsoft.NETCore": "5.0.0",
"Microsoft.NETCore.Portable.Compatibility": "1.0.1"
},
{
"supports": {},
"dependencies": {},
"frameworks": {
"dotnet": {
"imports": "portable-net452+win81"
}
".NETPortable,Version=v4.5,Profile=Profile7": {}
}
}

File diff suppressed because it is too large Load Diff