From 2b977a5eeda311b988bbbc8e6507de777aba8793 Mon Sep 17 00:00:00 2001
From: Sebastiii <sebastiii@team-mediaportal.com>
Date: Fri, 19 Jul 2019 09:29:27 +0200
Subject: [PATCH] Master : Trying to make new MediaInfo.Wrapper.dll working for
 MovingPictures.

---
 External/MediaPortal/Common.GUIPlugins.dll    | Bin 162816 -> 163840 bytes
 External/MediaPortal/Common.Utils.dll         | Bin 23552 -> 24576 bytes
 External/MediaPortal/Core.dll                 | Bin 2651648 -> 2753536 bytes
 External/MediaPortal/Databases.dll            | Bin 323584 -> 355840 bytes
 External/MediaPortal/Dialogs.dll              | Bin 53248 -> 54784 bytes
 External/MediaPortal/DirectShowLib.dll        | Bin 364544 -> 343552 bytes
 External/MediaPortal/GUIVideos.dll            | Bin 172544 -> 187904 bytes
 External/MediaPortal/MediaInfo.Wrapper.dll    | Bin 0 -> 183808 bytes
 External/MediaPortal/MediaPortal.Support.dll  | Bin 20992 -> 20992 bytes
 External/MediaPortal/RemotePlugins.dll        | Bin 162304 -> 193536 bytes
 External/MediaPortal/Utils.dll                | Bin 102912 -> 112640 bytes
 MovingPictures/Database/DBLocalMedia.cs       |  21 +++++++++---------
 .../LocalMediaManagement/VideoUtility.cs      |  12 +++++++---
 MovingPictures/MovingPictures.csproj          |   6 ++---
 14 files changed, 23 insertions(+), 16 deletions(-)
 create mode 100644 External/MediaPortal/MediaInfo.Wrapper.dll

diff --git a/External/MediaPortal/Common.GUIPlugins.dll b/External/MediaPortal/Common.GUIPlugins.dll
index cf863225ad8f3f843ad8cd9c1a2c97d97afd79ff..e883afe5da9bc658a1e4373e6a26909beade2b63 100644
GIT binary patch
diff --git a/External/MediaPortal/Common.Utils.dll b/External/MediaPortal/Common.Utils.dll
index 35022766ebac15349890f2a71fdf32b82421b7da..bfec1d0b58a1313813b24d3ee2d09b064a83ad5a 100644
GIT binary patch
diff --git a/External/MediaPortal/Core.dll b/External/MediaPortal/Core.dll
index 2af6c0725c3a5ce160e4e0c137bbb32b6e199538..233177d89983e958f5554cfce947dd81fb76817f 100644
GIT binary patch
diff --git a/External/MediaPortal/Databases.dll b/External/MediaPortal/Databases.dll
index d7b0270c12d970dec8aa0bc7e323eec5b29d496e..637371fedecd906f899cca7ad17ba8a641d58535 100644
GIT binary patch
diff --git a/External/MediaPortal/Dialogs.dll b/External/MediaPortal/Dialogs.dll
index e6d3543923f93d1051921e7bcedfe67dc192f33e..838df678c93ff2d0ea5ded179edd41ab75684760 100644
GIT binary patch
diff --git a/External/MediaPortal/DirectShowLib.dll b/External/MediaPortal/DirectShowLib.dll
index 42af08726ca2cc7e14467c5758e49b77a6ceb56f..2c3c249227c9afba9ab6fe44948f8db123584e4e 100644
GIT binary patch
diff --git a/External/MediaPortal/GUIVideos.dll b/External/MediaPortal/GUIVideos.dll
index 91f560549d0bafe4aba0e01dc8270704b2334b9b..8f637c1d697d3495835a4919da5e423aada62b0c 100644
GIT binary patch
diff --git a/External/MediaPortal/MediaInfo.Wrapper.dll b/External/MediaPortal/MediaInfo.Wrapper.dll
new file mode 100644
index 0000000000000000000000000000000000000000..1b4b1a54f3f01d31d47d94bcfd6fe7f66afca0a3
GIT binary patch
diff --git a/External/MediaPortal/MediaPortal.Support.dll b/External/MediaPortal/MediaPortal.Support.dll
index 60f8deb6fbfdc6ea18889219bd1db85a69645659..9f3676d72c274d02e35c574c1329c08fd5bfeafd 100644
GIT binary patch
diff --git a/External/MediaPortal/RemotePlugins.dll b/External/MediaPortal/RemotePlugins.dll
index 3961f1c649de6e619f49e32e8dc5410e75c44a3a..c89b44965133b17dc7c95bf3bb8e930b70ba9a62 100644
GIT binary patch
diff --git a/External/MediaPortal/Utils.dll b/External/MediaPortal/Utils.dll
index 295037d219076675cd8ace166468fe00ee21bdc9..1eb3acbfeddf8e7ea3f359b2dc4f91373d986e5a 100644
GIT binary patch
diff --git a/MovingPictures/Database/DBLocalMedia.cs b/MovingPictures/Database/DBLocalMedia.cs
index b4bb4208ea..4a12f1d126 100644
--- a/MovingPictures/Database/DBLocalMedia.cs
+++ b/MovingPictures/Database/DBLocalMedia.cs
@@ -6,7 +6,9 @@ using Cornerstone.Extensions.IO;
 using Cornerstone.Database;
 using Cornerstone.Database.CustomTypes;
 using Cornerstone.Database.Tables;
+using MediaInfo;
 using MediaPortal.Plugins.MovingPictures.LocalMediaManagement;
+using MediaPortal.Services;
 using NLog;
 
 namespace MediaPortal.Plugins.MovingPictures.Database {
@@ -399,10 +401,10 @@ namespace MediaPortal.Plugins.MovingPictures.Database {
         } private string _videoCodec;
 
         [DBFieldAttribute(AllowManualFilterInput = false)]
-        public int VideoBitrate {
+        public double VideoBitrate {
             get { return _videoBitRate; }
             set {
-                _videoBitRate = value;
+                _videoBitRate = (int)value;
                 commitNeeded = true;
             }
         } private int _videoBitRate;
@@ -444,10 +446,10 @@ namespace MediaPortal.Plugins.MovingPictures.Database {
         } private string _audioChannels;
 
         [DBFieldAttribute(AllowManualFilterInput = false)]
-        public int AudioBitRate {
+        public double AudioBitRate {
             get { return _audioBitRate; }
             set {
-                _audioBitRate = value;
+                _audioBitRate = (int)value;
                 commitNeeded = true;
             }
         } private int _audioBitRate;
@@ -579,13 +581,12 @@ namespace MediaPortal.Plugins.MovingPictures.Database {
             }
 
             // Get the path to the video file
-            string videoPath = this.GetVideoPath();           
+            string videoPath = this.GetVideoPath();
             
             // Start to update media info
             try {
                 logger.Debug("Updating media info for '{0}'", videoPath);
                 MediaInfoWrapper mInfoWrapper = this.VideoFormat.GetMediaInfo(videoPath);
-
                 this.Duration = mInfoWrapper.Duration;
                 this.VideoWidth = mInfoWrapper.Width;
                 this.VideoHeight = mInfoWrapper.Height;
@@ -594,16 +595,16 @@ namespace MediaPortal.Plugins.MovingPictures.Database {
                 this.Is3D = mInfoWrapper.Is3D;
                 this.IsInterlaced = mInfoWrapper.IsInterlaced;
                 this.VideoCodec = mInfoWrapper.VideoCodec;
-                this.VideoBitrate = mInfoWrapper.VideoBitrate;
+                this.VideoBitrate = mInfoWrapper.BestVideoStream.Bitrate;
                 this.AudioCodec = mInfoWrapper.AudioCodec;
                 this.VideoResolution = mInfoWrapper.VideoResolution;
                 this.AudioChannels = mInfoWrapper.AudioChannelsFriendly;
-                this.AudioBitRate = mInfoWrapper.AudioBitRate;
+                this.AudioBitRate = mInfoWrapper.BestAudioStream.Bitrate;
                 this.AudioSampleRate = mInfoWrapper.AudioSampleRate;
                 this.AudioCodec = mInfoWrapper.AudioCodec;
                 this.VideoAspectRatio = mInfoWrapper.AspectRatio;
-                this.IsHDR = mInfoWrapper.IsHDR;
-                this.FileSize = mInfoWrapper.FileSize;
+                this.IsHDR = mInfoWrapper.IsHdr;
+                this.FileSize = mInfoWrapper.Size;
 
                 return UpdateMediaInfoResults.Success;
             }
diff --git a/MovingPictures/LocalMediaManagement/VideoUtility.cs b/MovingPictures/LocalMediaManagement/VideoUtility.cs
index 2ebd46da92..ca04f00618 100644
--- a/MovingPictures/LocalMediaManagement/VideoUtility.cs
+++ b/MovingPictures/LocalMediaManagement/VideoUtility.cs
@@ -7,6 +7,8 @@ using DirectShowLib;
 using DirectShowLib.Dvd;
 using Cornerstone.Extensions;
 using Cornerstone.Extensions.IO;
+using MediaInfo;
+using MediaPortal.Services;
 using NLog;
 
 namespace MediaPortal.Plugins.MovingPictures.LocalMediaManagement {
@@ -170,6 +172,7 @@ namespace MediaPortal.Plugins.MovingPictures.LocalMediaManagement {
         /// <returns>MediaInfoWrapper object for this video</returns>
         public static MediaInfoWrapper GetMediaInfo(this VideoFormat self, string videoPath) {
             string mainFeatureFile;
+            var milog = GlobalServiceProvider.Get<MediaInfo.ILogger>();
             if (self == VideoFormat.DVD) {
                 // because dvds have multiple files
                 // we must build a list of all IFO files, and loop through them.
@@ -185,7 +188,7 @@ namespace MediaPortal.Plugins.MovingPictures.LocalMediaManagement {
             if (videoPath != mainFeatureFile)
                 logger.Debug("Format={0}, FeatureFilmFile='{1}'", self, mainFeatureFile);
 
-            return new MediaInfoWrapper(mainFeatureFile);
+            return new MediaInfoWrapper(mainFeatureFile, milog);
         }
 
         /// <summary>
@@ -410,9 +413,12 @@ namespace MediaPortal.Plugins.MovingPictures.LocalMediaManagement {
         public static string FindFeatureFilm(List<string> files) {
             if (files.Count == 1) return files[0];
 
+            var milog = GlobalServiceProvider.Get<MediaInfo.ILogger>();
+
             Dictionary<string, MediaInfoWrapper> mediaInfos = new Dictionary<string, MediaInfoWrapper>();
-            foreach (string file in files) {
-                mediaInfos.Add(file, new MediaInfoWrapper(file));
+            foreach (string file in files)
+            {
+              mediaInfos.Add(file, new MediaInfoWrapper(file, milog));
             }
 
             // first filter out the fullscreen files if there are widescreen files present
diff --git a/MovingPictures/MovingPictures.csproj b/MovingPictures/MovingPictures.csproj
index f73b6c19d5..20b8fe6607 100644
--- a/MovingPictures/MovingPictures.csproj
+++ b/MovingPictures/MovingPictures.csproj
@@ -89,6 +89,9 @@
       <SpecificVersion>False</SpecificVersion>
       <HintPath>..\External\MediaPortal\DirectShowLib.dll</HintPath>
     </Reference>
+    <Reference Include="MediaInfo.Wrapper">
+      <HintPath>..\External\MediaPortal\MediaInfo.Wrapper.dll</HintPath>
+    </Reference>
     <Reference Include="MediaPortal.Support, Version=1.1.6.0, Culture=neutral, processorArchitecture=x86">
       <SpecificVersion>False</SpecificVersion>
       <HintPath>..\External\MediaPortal\MediaPortal.Support.dll</HintPath>
@@ -372,9 +375,6 @@
     <Compile Include="LocalMediaManagement\MovieResources\Cover.cs" />
     <Compile Include="LocalMediaManagement\MovieResources\FileBasedResource.cs" />
     <Compile Include="Database\FilterHelperDBMovieInfo.cs" />
-    <Compile Include="LocalMediaManagement\MediaInfoWrapper.cs">
-      <SubType>Code</SubType>
-    </Compile>
     <Compile Include="Database\MovingPicturesDBTable.cs" />
     <Compile Include="DataProviders\InternalProvider.cs" />
     <Compile Include="DataProviders\MovieMeterProvider.cs" />
-- 
2.17.0.windows.1

