aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Model
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-04-14 15:12:00 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-04-14 15:12:00 -0400
commit57e3bb72f93baca695ba2b6670faec8ee0e1796b (patch)
treedee4f216be7867c6890f9ca4eb3bf811152464d8 /MediaBrowser.Model
parente34dc6701be6ba5a2354a3766ec124764f15c531 (diff)
update stream selection
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();
}
}