aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Model
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2016-04-14 22:42:29 -0400
committerLuke <luke.pulverenti@gmail.com>2016-04-14 22:42:29 -0400
commitfd72bdab5c693aea590f390eb137c5204bd96bf3 (patch)
tree53300edb3c49c348d200d50d799ac2fabe3dec45 /MediaBrowser.Model
parenta47271321f0483139905a2896814e79f9ac2236f (diff)
parent7f2b2e1b9aa5011413c6f9dc1098d547ea415fde (diff)
Merge pull request #1649 from MediaBrowser/dev
Dev
Diffstat (limited to 'MediaBrowser.Model')
-rw-r--r--MediaBrowser.Model/Dlna/StreamBuilder.cs10
-rw-r--r--MediaBrowser.Model/Dlna/StreamInfoSorter.cs19
2 files changed, 23 insertions, 6 deletions
diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs
index 09d762aae..1e6b7c729 100644
--- a/MediaBrowser.Model/Dlna/StreamBuilder.cs
+++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs
@@ -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)
diff --git a/MediaBrowser.Model/Dlna/StreamInfoSorter.cs b/MediaBrowser.Model/Dlna/StreamInfoSorter.cs
index 0cccd8080..293054e5b 100644
--- a/MediaBrowser.Model/Dlna/StreamInfoSorter.cs
+++ b/MediaBrowser.Model/Dlna/StreamInfoSorter.cs
@@ -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();
}
}