aboutsummaryrefslogtreecommitdiff
path: root/BDInfo
diff options
context:
space:
mode:
Diffstat (limited to 'BDInfo')
-rw-r--r--BDInfo/BDInfo.csproj11
-rw-r--r--BDInfo/BdInfoExaminer.cs169
2 files changed, 176 insertions, 4 deletions
diff --git a/BDInfo/BDInfo.csproj b/BDInfo/BDInfo.csproj
index 4e57d9e08d..234050ed30 100644
--- a/BDInfo/BDInfo.csproj
+++ b/BDInfo/BDInfo.csproj
@@ -32,13 +32,10 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
- <Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
- <Reference Include="System.Data" />
- <Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="BdInfoExaminer.cs" />
<Compile Include="BDInfoSettings.cs" />
<Compile Include="BDROM.cs" />
<Compile Include="LanguageCodes.cs" />
@@ -63,6 +60,12 @@
<ItemGroup>
<Content Include="ReadMe.txt" />
</ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">
+ <Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project>
+ <Name>MediaBrowser.Model</Name>
+ </ProjectReference>
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.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.
diff --git a/BDInfo/BdInfoExaminer.cs b/BDInfo/BdInfoExaminer.cs
new file mode 100644
index 0000000000..cfa9a946bb
--- /dev/null
+++ b/BDInfo/BdInfoExaminer.cs
@@ -0,0 +1,169 @@
+using MediaBrowser.Model.Entities;
+using MediaBrowser.Model.MediaInfo;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace BDInfo
+{
+ /// <summary>
+ /// Class BdInfoExaminer
+ /// </summary>
+ public class BdInfoExaminer : IBlurayExaminer
+ {
+ /// <summary>
+ /// Gets the disc info.
+ /// </summary>
+ /// <param name="path">The path.</param>
+ /// <returns>BlurayDiscInfo.</returns>
+ public BlurayDiscInfo GetDiscInfo(string path)
+ {
+ var bdrom = new BDROM(path);
+
+ bdrom.Scan();
+
+ // Get the longest playlist
+ var playlist = bdrom.PlaylistFiles.Values.OrderByDescending(p => p.TotalLength).FirstOrDefault(p => p.IsValid);
+
+ var outputStream = new BlurayDiscInfo
+ {
+ MediaStreams = new List<MediaStream>()
+ };
+
+ if (playlist == null)
+ {
+ return outputStream;
+ }
+
+ outputStream.Chapters = playlist.Chapters;
+
+ outputStream.RunTimeTicks = TimeSpan.FromSeconds(playlist.TotalLength).Ticks;
+
+ var mediaStreams = new List<MediaStream> { };
+
+ foreach (var stream in playlist.SortedStreams)
+ {
+ var videoStream = stream as TSVideoStream;
+
+ if (videoStream != null)
+ {
+ AddVideoStream(mediaStreams, videoStream);
+ continue;
+ }
+
+ var audioStream = stream as TSAudioStream;
+
+ if (audioStream != null)
+ {
+ AddAudioStream(mediaStreams, audioStream);
+ continue;
+ }
+
+ var textStream = stream as TSTextStream;
+
+ if (textStream != null)
+ {
+ AddSubtitleStream(mediaStreams, textStream);
+ continue;
+ }
+
+ var graphicsStream = stream as TSGraphicsStream;
+
+ if (graphicsStream != null)
+ {
+ AddSubtitleStream(mediaStreams, graphicsStream);
+ }
+ }
+
+ outputStream.MediaStreams = mediaStreams;
+
+ if (playlist.StreamClips != null && playlist.StreamClips.Any())
+ {
+ // Get the files in the playlist
+ outputStream.Files = playlist.StreamClips.Select(i => i.StreamFile.Name).ToList();
+ }
+
+ return outputStream;
+ }
+
+ /// <summary>
+ /// Adds the video stream.
+ /// </summary>
+ /// <param name="streams">The streams.</param>
+ /// <param name="videoStream">The video stream.</param>
+ private void AddVideoStream(List<MediaStream> streams, TSVideoStream videoStream)
+ {
+ var mediaStream = new MediaStream
+ {
+ BitRate = Convert.ToInt32(videoStream.BitRate),
+ Width = videoStream.Width,
+ Height = videoStream.Height,
+ Codec = videoStream.CodecShortName,
+ ScanType = videoStream.IsInterlaced ? "interlaced" : "progressive",
+ Type = MediaStreamType.Video,
+ Index = streams.Count
+ };
+
+ if (videoStream.FrameRateDenominator > 0)
+ {
+ float frameRateEnumerator = videoStream.FrameRateEnumerator;
+ float frameRateDenominator = videoStream.FrameRateDenominator;
+
+ mediaStream.AverageFrameRate = mediaStream.RealFrameRate = frameRateEnumerator / frameRateDenominator;
+ }
+
+ streams.Add(mediaStream);
+ }
+
+ /// <summary>
+ /// Adds the audio stream.
+ /// </summary>
+ /// <param name="streams">The streams.</param>
+ /// <param name="audioStream">The audio stream.</param>
+ private void AddAudioStream(List<MediaStream> streams, TSAudioStream audioStream)
+ {
+ streams.Add(new MediaStream
+ {
+ BitRate = Convert.ToInt32(audioStream.BitRate),
+ Codec = audioStream.CodecShortName,
+ Language = audioStream.LanguageCode,
+ Channels = audioStream.ChannelCount,
+ SampleRate = audioStream.SampleRate,
+ Type = MediaStreamType.Audio,
+ Index = streams.Count
+ });
+ }
+
+ /// <summary>
+ /// Adds the subtitle stream.
+ /// </summary>
+ /// <param name="streams">The streams.</param>
+ /// <param name="textStream">The text stream.</param>
+ private void AddSubtitleStream(List<MediaStream> streams, TSTextStream textStream)
+ {
+ streams.Add(new MediaStream
+ {
+ Language = textStream.LanguageCode,
+ Codec = textStream.CodecShortName,
+ Type = MediaStreamType.Subtitle,
+ Index = streams.Count
+ });
+ }
+
+ /// <summary>
+ /// Adds the subtitle stream.
+ /// </summary>
+ /// <param name="streams">The streams.</param>
+ /// <param name="textStream">The text stream.</param>
+ private void AddSubtitleStream(List<MediaStream> streams, TSGraphicsStream textStream)
+ {
+ streams.Add(new MediaStream
+ {
+ Language = textStream.LanguageCode,
+ Codec = textStream.CodecShortName,
+ Type = MediaStreamType.Subtitle,
+ Index = streams.Count
+ });
+ }
+ }
+}