update stream selection

This commit is contained in:
Luke Pulverenti
2016-04-14 15:12:00 -04:00
parent e34dc6701b
commit 57e3bb72f9
5 changed files with 48 additions and 13 deletions

View File

@@ -55,7 +55,7 @@ namespace MediaBrowser.Model.Dlna
stream.DeviceProfileId = options.Profile.Id;
}
return GetOptimalStream(streams);
return GetOptimalStream(streams, options.GetMaxBitrate());
}
public StreamInfo BuildVideoItem(VideoOptions options)
@@ -88,12 +88,12 @@ namespace MediaBrowser.Model.Dlna
stream.DeviceProfileId = options.Profile.Id;
}
return GetOptimalStream(streams);
return GetOptimalStream(streams, options.GetMaxBitrate());
}
private StreamInfo GetOptimalStream(List<StreamInfo> streams)
private StreamInfo GetOptimalStream(List<StreamInfo> streams, int? maxBitrate)
{
streams = StreamInfoSorter.SortMediaSources(streams);
streams = StreamInfoSorter.SortMediaSources(streams, maxBitrate);
foreach (StreamInfo stream in streams)
{
@@ -424,7 +424,7 @@ namespace MediaBrowser.Model.Dlna
playlistItem.EstimateContentLength = transcodingProfile.EstimateContentLength;
playlistItem.TranscodeSeekInfo = transcodingProfile.TranscodeSeekInfo;
// TODO: We should probably preserve the full list and sent it tp the server that way
// TODO: We should probably preserve the full list and sent it to the server that way
string[] supportedAudioCodecs = transcodingProfile.AudioCodec.Split(',');
string inputAudioCodec = audioStream == null ? null : audioStream.Codec;
foreach (string supportedAudioCodec in supportedAudioCodecs)

View File

@@ -7,7 +7,7 @@ namespace MediaBrowser.Model.Dlna
{
public class StreamInfoSorter
{
public static List<StreamInfo> SortMediaSources(List<StreamInfo> streams)
public static List<StreamInfo> SortMediaSources(List<StreamInfo> streams, int? maxBitrate)
{
return streams.OrderBy(i =>
{
@@ -41,6 +41,23 @@ namespace MediaBrowser.Model.Dlna
return 1;
}
}).ThenBy(i =>
{
if (maxBitrate.HasValue)
{
if (i.MediaSource.Bitrate.HasValue)
{
if (i.MediaSource.Bitrate.Value <= maxBitrate.Value)
{
return 0;
}
return 2;
}
}
return 1;
}).ToList();
}
}