From 7e312e75bbb1324748319b29c9353716ed93a8da Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 26 Mar 2015 16:31:57 -0400 Subject: [PATCH] update stream sorting --- .../MediaBrowser.Model.Portable.csproj | 3 ++ .../MediaBrowser.Model.net35.csproj | 3 ++ MediaBrowser.Model/Dlna/StreamBuilder.cs | 24 +---------- MediaBrowser.Model/Dlna/StreamInfoSorter.cs | 40 +++++++++++++++++++ MediaBrowser.Model/MediaBrowser.Model.csproj | 1 + .../Drawing/ImageProcessor.cs | 6 +-- .../Photos/BaseDynamicImageProvider.cs | 16 +------- .../Udp/UdpServer.cs | 1 + Nuget/MediaBrowser.Common.Internal.nuspec | 4 +- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Model.Signed.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- SharedVersion.cs | 4 +- 13 files changed, 61 insertions(+), 49 deletions(-) create mode 100644 MediaBrowser.Model/Dlna/StreamInfoSorter.cs diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj index 118e5659ad..ab77dc271b 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -413,6 +413,9 @@ Dlna\StreamInfo.cs + + Dlna\StreamInfoSorter.cs + Dlna\SubtitleDeliveryMethod.cs diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj index a97bf2a8c6..b772e17539 100644 --- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj +++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj @@ -378,6 +378,9 @@ Dlna\StreamInfo.cs + + Dlna\StreamInfoSorter.cs + Dlna\SubtitleDeliveryMethod.cs diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index 7338f604c0..62ac321fe3 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -89,29 +89,7 @@ namespace MediaBrowser.Model.Dlna private StreamInfo GetOptimalStream(List streams) { - // Grab the first one that can be direct streamed - // If that doesn't produce anything, just take the first - foreach (StreamInfo i in streams) - { - if (i.PlayMethod == PlayMethod.DirectPlay && i.MediaSource.Protocol == MediaProtocol.File) - { - return i; - } - } - foreach (StreamInfo i in streams) - { - if (i.PlayMethod == PlayMethod.DirectPlay) - { - return i; - } - } - foreach (StreamInfo i in streams) - { - if (i.PlayMethod == PlayMethod.DirectStream) - { - return i; - } - } + streams = StreamInfoSorter.SortMediaSources(streams); foreach (StreamInfo stream in streams) { diff --git a/MediaBrowser.Model/Dlna/StreamInfoSorter.cs b/MediaBrowser.Model/Dlna/StreamInfoSorter.cs new file mode 100644 index 0000000000..80eca193f5 --- /dev/null +++ b/MediaBrowser.Model/Dlna/StreamInfoSorter.cs @@ -0,0 +1,40 @@ +using MediaBrowser.Model.MediaInfo; +using MediaBrowser.Model.Session; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace MediaBrowser.Model.Dlna +{ + public class StreamInfoSorter + { + public static List SortMediaSources(List streams) + { + return streams.OrderBy(i => + { + switch (i.PlayMethod) + { + case PlayMethod.DirectPlay: + return 0; + case PlayMethod.DirectStream: + return 1; + case PlayMethod.Transcode: + return 2; + default: + throw new ArgumentException("Unrecognized PlayMethod"); + } + + }).ThenBy(i => + { + switch (i.MediaSource.Protocol) + { + case MediaProtocol.File: + return 0; + default: + return 1; + } + + }).ToList(); + } + } +} diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 30eec434db..fe67038df9 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -126,6 +126,7 @@ + diff --git a/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs b/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs index a9affe1ec0..5474892e81 100644 --- a/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs +++ b/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs @@ -268,8 +268,6 @@ namespace MediaBrowser.Server.Implementations.Drawing originalImage.CurrentImage.CompressionQuality = quality; originalImage.SaveImage(cacheFilePath); - - return cacheFilePath; } } else @@ -286,8 +284,6 @@ namespace MediaBrowser.Server.Implementations.Drawing wand.CurrentImage.CompressionQuality = quality; wand.SaveImage(cacheFilePath); - - return cacheFilePath; } } } @@ -296,6 +292,8 @@ namespace MediaBrowser.Server.Implementations.Drawing { semaphore.Release(); } + + return cacheFilePath; } private ImageFormat GetOutputFormat(ImageFormat requestedFormat) diff --git a/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs b/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs index 6fb02358e4..eac0cd96d9 100644 --- a/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs +++ b/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs @@ -223,8 +223,8 @@ namespace MediaBrowser.Server.Implementations.Photos protected virtual List GetFinalItems(List items, int limit) { - // Rotate the images no more than once per week - var random = new Random(GetWeekOfYear()).Next(); + // Rotate the images once every 7 days + var random = DateTime.Now.DayOfYear % 7; return items .OrderBy(i => (random + "" + items.IndexOf(i)).GetMD5()) @@ -233,18 +233,6 @@ namespace MediaBrowser.Server.Implementations.Photos .ToList(); } - private int GetWeekOfYear() - { - return DateTime.Now.Second; - var usCulture = new CultureInfo("en-US"); - var weekNo = usCulture.Calendar.GetWeekOfYear( - DateTime.Now, - usCulture.DateTimeFormat.CalendarWeekRule, - usCulture.DateTimeFormat.FirstDayOfWeek); - - return weekNo; - } - public int Order { get diff --git a/MediaBrowser.Server.Implementations/Udp/UdpServer.cs b/MediaBrowser.Server.Implementations/Udp/UdpServer.cs index 9dbffa9222..966129f4b9 100644 --- a/MediaBrowser.Server.Implementations/Udp/UdpServer.cs +++ b/MediaBrowser.Server.Implementations/Udp/UdpServer.cs @@ -51,6 +51,7 @@ namespace MediaBrowser.Server.Implementations.Udp AddMessageResponder("who is MediaBrowserServer?", RespondToV1Message); AddMessageResponder("who is MediaBrowserServer_v2?", RespondToV2Message); + AddMessageResponder("who is EmbyServer_v2?", RespondToV2Message); } private void AddMessageResponder(string message, Action responder) diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 5f1c138b81..d229302bde 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.598 + 3.0.599 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index b5a0f3bba0..65205fa250 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.598 + 3.0.599 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Model.Signed.nuspec b/Nuget/MediaBrowser.Model.Signed.nuspec index 085408f2e2..2e829b436a 100644 --- a/Nuget/MediaBrowser.Model.Signed.nuspec +++ b/Nuget/MediaBrowser.Model.Signed.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Model.Signed - 3.0.598 + 3.0.599 MediaBrowser.Model - Signed Edition Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index dca8aa61a0..f5d5b788bb 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.598 + 3.0.599 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - + diff --git a/SharedVersion.cs b/SharedVersion.cs index 7528d4060b..fa4ca1ac7e 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,4 +1,4 @@ using System.Reflection; -//[assembly: AssemblyVersion("3.0.*")] -[assembly: AssemblyVersion("3.0.5557.20000")] +[assembly: AssemblyVersion("3.0.*")] +//[assembly: AssemblyVersion("3.0.5557.20000")]