update stream sorting

pull/702/head
Luke Pulverenti 10 years ago
parent 8921e152ea
commit 7e312e75bb

@ -413,6 +413,9 @@
<Compile Include="..\MediaBrowser.Model\Dlna\StreamInfo.cs"> <Compile Include="..\MediaBrowser.Model\Dlna\StreamInfo.cs">
<Link>Dlna\StreamInfo.cs</Link> <Link>Dlna\StreamInfo.cs</Link>
</Compile> </Compile>
<Compile Include="..\MediaBrowser.Model\Dlna\StreamInfoSorter.cs">
<Link>Dlna\StreamInfoSorter.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Dlna\SubtitleDeliveryMethod.cs"> <Compile Include="..\MediaBrowser.Model\Dlna\SubtitleDeliveryMethod.cs">
<Link>Dlna\SubtitleDeliveryMethod.cs</Link> <Link>Dlna\SubtitleDeliveryMethod.cs</Link>
</Compile> </Compile>

@ -378,6 +378,9 @@
<Compile Include="..\MediaBrowser.Model\Dlna\StreamInfo.cs"> <Compile Include="..\MediaBrowser.Model\Dlna\StreamInfo.cs">
<Link>Dlna\StreamInfo.cs</Link> <Link>Dlna\StreamInfo.cs</Link>
</Compile> </Compile>
<Compile Include="..\MediaBrowser.Model\Dlna\StreamInfoSorter.cs">
<Link>Dlna\StreamInfoSorter.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Dlna\SubtitleDeliveryMethod.cs"> <Compile Include="..\MediaBrowser.Model\Dlna\SubtitleDeliveryMethod.cs">
<Link>Dlna\SubtitleDeliveryMethod.cs</Link> <Link>Dlna\SubtitleDeliveryMethod.cs</Link>
</Compile> </Compile>

@ -89,29 +89,7 @@ namespace MediaBrowser.Model.Dlna
private StreamInfo GetOptimalStream(List<StreamInfo> streams) private StreamInfo GetOptimalStream(List<StreamInfo> streams)
{ {
// Grab the first one that can be direct streamed streams = StreamInfoSorter.SortMediaSources(streams);
// 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;
}
}
foreach (StreamInfo stream in streams) foreach (StreamInfo stream in streams)
{ {

@ -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<StreamInfo> SortMediaSources(List<StreamInfo> 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();
}
}
}

@ -126,6 +126,7 @@
<Compile Include="Devices\DevicesOptions.cs" /> <Compile Include="Devices\DevicesOptions.cs" />
<Compile Include="Dlna\EncodingContext.cs" /> <Compile Include="Dlna\EncodingContext.cs" />
<Compile Include="Dlna\ILocalPlayer.cs" /> <Compile Include="Dlna\ILocalPlayer.cs" />
<Compile Include="Dlna\StreamInfoSorter.cs" />
<Compile Include="Dlna\NullLocalPlayer.cs" /> <Compile Include="Dlna\NullLocalPlayer.cs" />
<Compile Include="Dlna\PlaybackErrorCode.cs" /> <Compile Include="Dlna\PlaybackErrorCode.cs" />
<Compile Include="Dlna\PlaybackException.cs" /> <Compile Include="Dlna\PlaybackException.cs" />

@ -268,8 +268,6 @@ namespace MediaBrowser.Server.Implementations.Drawing
originalImage.CurrentImage.CompressionQuality = quality; originalImage.CurrentImage.CompressionQuality = quality;
originalImage.SaveImage(cacheFilePath); originalImage.SaveImage(cacheFilePath);
return cacheFilePath;
} }
} }
else else
@ -286,8 +284,6 @@ namespace MediaBrowser.Server.Implementations.Drawing
wand.CurrentImage.CompressionQuality = quality; wand.CurrentImage.CompressionQuality = quality;
wand.SaveImage(cacheFilePath); wand.SaveImage(cacheFilePath);
return cacheFilePath;
} }
} }
} }
@ -296,6 +292,8 @@ namespace MediaBrowser.Server.Implementations.Drawing
{ {
semaphore.Release(); semaphore.Release();
} }
return cacheFilePath;
} }
private ImageFormat GetOutputFormat(ImageFormat requestedFormat) private ImageFormat GetOutputFormat(ImageFormat requestedFormat)

@ -223,8 +223,8 @@ namespace MediaBrowser.Server.Implementations.Photos
protected virtual List<BaseItem> GetFinalItems(List<BaseItem> items, int limit) protected virtual List<BaseItem> GetFinalItems(List<BaseItem> items, int limit)
{ {
// Rotate the images no more than once per week // Rotate the images once every 7 days
var random = new Random(GetWeekOfYear()).Next(); var random = DateTime.Now.DayOfYear % 7;
return items return items
.OrderBy(i => (random + "" + items.IndexOf(i)).GetMD5()) .OrderBy(i => (random + "" + items.IndexOf(i)).GetMD5())
@ -233,18 +233,6 @@ namespace MediaBrowser.Server.Implementations.Photos
.ToList(); .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 public int Order
{ {
get get

@ -51,6 +51,7 @@ namespace MediaBrowser.Server.Implementations.Udp
AddMessageResponder("who is MediaBrowserServer?", RespondToV1Message); AddMessageResponder("who is MediaBrowserServer?", RespondToV1Message);
AddMessageResponder("who is MediaBrowserServer_v2?", RespondToV2Message); AddMessageResponder("who is MediaBrowserServer_v2?", RespondToV2Message);
AddMessageResponder("who is EmbyServer_v2?", RespondToV2Message);
} }
private void AddMessageResponder(string message, Action<string> responder) private void AddMessageResponder(string message, Action<string> responder)

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Common.Internal</id> <id>MediaBrowser.Common.Internal</id>
<version>3.0.598</version> <version>3.0.599</version>
<title>MediaBrowser.Common.Internal</title> <title>MediaBrowser.Common.Internal</title>
<authors>Luke</authors> <authors>Luke</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description> <description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
<copyright>Copyright © Media Browser 2013</copyright> <copyright>Copyright © Media Browser 2013</copyright>
<dependencies> <dependencies>
<dependency id="MediaBrowser.Common" version="3.0.598" /> <dependency id="MediaBrowser.Common" version="3.0.599" />
<dependency id="NLog" version="3.2.0.0" /> <dependency id="NLog" version="3.2.0.0" />
<dependency id="SimpleInjector" version="2.7.0" /> <dependency id="SimpleInjector" version="2.7.0" />
</dependencies> </dependencies>

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Common</id> <id>MediaBrowser.Common</id>
<version>3.0.598</version> <version>3.0.599</version>
<title>MediaBrowser.Common</title> <title>MediaBrowser.Common</title>
<authors>Media Browser Team</authors> <authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Model.Signed</id> <id>MediaBrowser.Model.Signed</id>
<version>3.0.598</version> <version>3.0.599</version>
<title>MediaBrowser.Model - Signed Edition</title> <title>MediaBrowser.Model - Signed Edition</title>
<authors>Media Browser Team</authors> <authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Server.Core</id> <id>MediaBrowser.Server.Core</id>
<version>3.0.598</version> <version>3.0.599</version>
<title>Media Browser.Server.Core</title> <title>Media Browser.Server.Core</title>
<authors>Media Browser Team</authors> <authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains core components required to build plugins for Media Browser Server.</description> <description>Contains core components required to build plugins for Media Browser Server.</description>
<copyright>Copyright © Media Browser 2013</copyright> <copyright>Copyright © Media Browser 2013</copyright>
<dependencies> <dependencies>
<dependency id="MediaBrowser.Common" version="3.0.598" /> <dependency id="MediaBrowser.Common" version="3.0.599" />
</dependencies> </dependencies>
</metadata> </metadata>
<files> <files>

@ -1,4 +1,4 @@
using System.Reflection; using System.Reflection;
//[assembly: AssemblyVersion("3.0.*")] [assembly: AssemblyVersion("3.0.*")]
[assembly: AssemblyVersion("3.0.5557.20000")] //[assembly: AssemblyVersion("3.0.5557.20000")]

Loading…
Cancel
Save