aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.MediaEncoding/BdInfo
diff options
context:
space:
mode:
authorStanislav Ionascu <stanislav.ionascu@gmail.com>2019-10-13 11:21:20 +0200
committerStanislav Ionascu <stanislav.ionascu@gmail.com>2019-11-17 20:56:13 +0100
commit9989b7b68fb6d87d3a2bf7f271e8fe0c8c3e41ab (patch)
tree7471662374b6bd34b6417a969da9f20f8b425ae3 /MediaBrowser.MediaEncoding/BdInfo
parentc87f459ec2f0882483716363b35c8a371c00d55a (diff)
Replace BDInfo plugin with nupkg and UHD/Atmos/DTS:X support
Diffstat (limited to 'MediaBrowser.MediaEncoding/BdInfo')
-rw-r--r--MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs74
-rw-r--r--MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs4
-rw-r--r--MediaBrowser.MediaEncoding/BdInfo/BdInfoFileInfo.cs40
3 files changed, 116 insertions, 2 deletions
diff --git a/MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs b/MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs
new file mode 100644
index 000000000..91c8b2792
--- /dev/null
+++ b/MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs
@@ -0,0 +1,74 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using BDInfo.IO;
+using MediaBrowser.Model.IO;
+
+namespace MediaBrowser.MediaEncoding.BdInfo
+{
+ class BdInfoDirectoryInfo : BDInfo.IO.IDirectoryInfo
+ {
+ IFileSystem _fileSystem = null;
+
+ FileSystemMetadata _impl = null;
+
+ public string Name => _impl.Name;
+
+ public string FullName => _impl.FullName;
+
+ public IDirectoryInfo Parent
+ {
+ get
+ {
+ var parentFolder = System.IO.Path.GetDirectoryName(_impl.FullName);
+ if (parentFolder != null)
+ {
+ return new BdInfoDirectoryInfo(_fileSystem, parentFolder);
+ }
+ return null;
+ }
+ }
+
+ public BdInfoDirectoryInfo(IFileSystem fileSystem, string path)
+ {
+ _fileSystem = fileSystem;
+ _impl = _fileSystem.GetDirectoryInfo(path);
+ }
+
+ private BdInfoDirectoryInfo(IFileSystem fileSystem, FileSystemMetadata impl)
+ {
+ _fileSystem = fileSystem;
+ _impl = impl;
+ }
+
+ public IDirectoryInfo[] GetDirectories()
+ {
+ return Array.ConvertAll(_fileSystem.GetDirectories(_impl.FullName).ToArray(),
+ x => new BdInfoDirectoryInfo(_fileSystem, x));
+ }
+
+ public IFileInfo[] GetFiles()
+ {
+ return Array.ConvertAll(_fileSystem.GetFiles(_impl.FullName).ToArray(),
+ x => new BdInfoFileInfo(_fileSystem, x));
+ }
+
+ public IFileInfo[] GetFiles(string searchPattern)
+ {
+ return Array.ConvertAll(_fileSystem.GetFiles(_impl.FullName, new[] { searchPattern }, false, false).ToArray(),
+ x => new BdInfoFileInfo(_fileSystem, x));
+ }
+
+ public IFileInfo[] GetFiles(string searchPattern, System.IO.SearchOption searchOption)
+ {
+ return Array.ConvertAll(_fileSystem.GetFiles(_impl.FullName, new[] { searchPattern }, false,
+ searchOption.HasFlag(System.IO.SearchOption.AllDirectories)).ToArray(),
+ x => new BdInfoFileInfo(_fileSystem, x));
+ }
+
+ public static IDirectoryInfo FromFileSystemPath(Model.IO.IFileSystem fs, string path)
+ {
+ return new BdInfoDirectoryInfo(fs, path);
+ }
+ }
+}
diff --git a/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs b/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs
index 3b6b91684..3260f3051 100644
--- a/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs
+++ b/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using BDInfo;
@@ -32,7 +32,7 @@ namespace MediaBrowser.MediaEncoding.BdInfo
throw new ArgumentNullException(nameof(path));
}
- var bdrom = new BDROM(path, _fileSystem);
+ var bdrom = new BDROM(BdInfoDirectoryInfo.FromFileSystemPath(_fileSystem, path));
bdrom.Scan();
diff --git a/MediaBrowser.MediaEncoding/BdInfo/BdInfoFileInfo.cs b/MediaBrowser.MediaEncoding/BdInfo/BdInfoFileInfo.cs
new file mode 100644
index 000000000..de9d7cb78
--- /dev/null
+++ b/MediaBrowser.MediaEncoding/BdInfo/BdInfoFileInfo.cs
@@ -0,0 +1,40 @@
+using MediaBrowser.Model.IO;
+
+namespace MediaBrowser.MediaEncoding.BdInfo
+{
+ class BdInfoFileInfo : BDInfo.IO.IFileInfo
+ {
+ IFileSystem _fileSystem = null;
+
+ FileSystemMetadata _impl = null;
+
+ public string Name => _impl.Name;
+
+ public string FullName => _impl.FullName;
+
+ public string Extension => _impl.Extension;
+
+ public long Length => _impl.Length;
+
+ public bool IsDir => _impl.IsDirectory;
+
+ public BdInfoFileInfo(IFileSystem fileSystem, FileSystemMetadata impl)
+ {
+ _fileSystem = fileSystem;
+ _impl = impl;
+ }
+
+ public System.IO.Stream OpenRead()
+ {
+ return _fileSystem.GetFileStream(FullName,
+ FileOpenMode.Open,
+ FileAccessMode.Read,
+ FileShareMode.Read);
+ }
+
+ public System.IO.StreamReader OpenText()
+ {
+ return new System.IO.StreamReader(OpenRead());
+ }
+ }
+}