mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-16 12:40:27 +01:00
update stream sorting
This commit is contained in:
@@ -89,29 +89,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
|
||||
private StreamInfo GetOptimalStream(List<StreamInfo> 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)
|
||||
{
|
||||
|
||||
40
MediaBrowser.Model/Dlna/StreamInfoSorter.cs
Normal file
40
MediaBrowser.Model/Dlna/StreamInfoSorter.cs
Normal file
@@ -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="Dlna\EncodingContext.cs" />
|
||||
<Compile Include="Dlna\ILocalPlayer.cs" />
|
||||
<Compile Include="Dlna\StreamInfoSorter.cs" />
|
||||
<Compile Include="Dlna\NullLocalPlayer.cs" />
|
||||
<Compile Include="Dlna\PlaybackErrorCode.cs" />
|
||||
<Compile Include="Dlna\PlaybackException.cs" />
|
||||
|
||||
Reference in New Issue
Block a user