mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-22 10:04:44 +01:00
update stream selection
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user