handle bitrate overflow

pull/1154/head
Luke Pulverenti 8 years ago
parent 4c08d26ad4
commit 6066619138

@ -4,7 +4,7 @@ namespace Emby.Server.Implementations.Sync
{
public class SyncHelper
{
public static int? AdjustBitrate(int? profileBitrate, string quality)
public static long? AdjustBitrate(long? profileBitrate, string quality)
{
if (profileBitrate.HasValue)
{

@ -227,7 +227,7 @@ namespace MediaBrowser.Api.Playback
PlaybackInfoResponse result,
DeviceProfile profile,
AuthorizationInfo auth,
int? maxBitrate,
long? maxBitrate,
long startTimeTicks,
string mediaSourceId,
int? audioStreamIndex,
@ -249,7 +249,7 @@ namespace MediaBrowser.Api.Playback
MediaSourceInfo mediaSource,
DeviceProfile profile,
AuthorizationInfo auth,
int? maxBitrate,
long? maxBitrate,
long startTimeTicks,
string mediaSourceId,
int? audioStreamIndex,
@ -383,7 +383,7 @@ namespace MediaBrowser.Api.Playback
}
}
private int? GetMaxBitrate(int? clientMaxBitrate)
private long? GetMaxBitrate(long? clientMaxBitrate)
{
var maxBitrate = clientMaxBitrate;
var remoteClientMaxBitrate = _config.Configuration.RemoteClientBitrateLimit;
@ -425,7 +425,7 @@ namespace MediaBrowser.Api.Playback
}
}
private void SortMediaSources(PlaybackInfoResponse result, int? maxBitrate)
private void SortMediaSources(PlaybackInfoResponse result, long? maxBitrate)
{
var originalList = result.MediaSources.ToList();

@ -93,13 +93,9 @@ namespace MediaBrowser.Api.Playback
{
return 3;
}
return 6;
}
if (!RunTimeTicks.HasValue)
{
return 3;
}
return 3;
}
}

@ -41,7 +41,7 @@ namespace MediaBrowser.Model.Dlna
/// <summary>
/// The application's configured quality setting
/// </summary>
public int? MaxBitrate { get; set; }
public long? MaxBitrate { get; set; }
/// <summary>
/// Gets or sets the context.
@ -59,7 +59,7 @@ namespace MediaBrowser.Model.Dlna
/// Gets the maximum bitrate.
/// </summary>
/// <returns>System.Nullable&lt;System.Int32&gt;.</returns>
public int? GetMaxBitrate(bool isAudio)
public long? GetMaxBitrate(bool isAudio)
{
if (MaxBitrate.HasValue)
{

@ -51,8 +51,8 @@ namespace MediaBrowser.Model.Dlna
public int? MaxIconWidth { get; set; }
public int? MaxIconHeight { get; set; }
public int? MaxStreamingBitrate { get; set; }
public int? MaxStaticBitrate { get; set; }
public long? MaxStreamingBitrate { get; set; }
public long? MaxStaticBitrate { get; set; }
public int? MusicStreamingTranscodingBitrate { get; set; }
public int? MaxStaticMusicBitrate { get; set; }

@ -93,7 +93,7 @@ namespace MediaBrowser.Model.Dlna
return GetOptimalStream(streams, options.GetMaxBitrate(false));
}
private StreamInfo GetOptimalStream(List<StreamInfo> streams, int? maxBitrate)
private StreamInfo GetOptimalStream(List<StreamInfo> streams, long? maxBitrate)
{
streams = StreamInfoSorter.SortMediaSources(streams, maxBitrate);
@ -277,25 +277,26 @@ namespace MediaBrowser.Model.Dlna
playlistItem.MaxAudioChannels = Math.Min(options.MaxAudioChannels.Value, currentValue);
}
int transcodingBitrate = options.AudioTranscodingBitrate ??
long transcodingBitrate = options.AudioTranscodingBitrate ??
options.Profile.MusicStreamingTranscodingBitrate ??
128000;
int? configuredBitrate = options.GetMaxBitrate(true);
var configuredBitrate = options.GetMaxBitrate(true);
if (configuredBitrate.HasValue)
{
transcodingBitrate = Math.Min(configuredBitrate.Value, transcodingBitrate);
}
playlistItem.AudioBitrate = Math.Min(transcodingBitrate, playlistItem.AudioBitrate ?? transcodingBitrate);
var longBitrate = Math.Min(transcodingBitrate, playlistItem.AudioBitrate ?? transcodingBitrate);
playlistItem.AudioBitrate = longBitrate > int.MaxValue ? int.MaxValue : Convert.ToInt32(longBitrate);
}
return playlistItem;
}
private int? GetBitrateForDirectPlayCheck(MediaSourceInfo item, AudioOptions options, bool isAudio)
private long? GetBitrateForDirectPlayCheck(MediaSourceInfo item, AudioOptions options, bool isAudio)
{
if (item.Protocol == MediaProtocol.File)
{
@ -583,11 +584,11 @@ namespace MediaBrowser.Model.Dlna
int audioBitrate = GetAudioBitrate(playlistItem.SubProtocol, options.GetMaxBitrate(false), playlistItem.TargetAudioChannels, playlistItem.TargetAudioCodec, audioStream);
playlistItem.AudioBitrate = Math.Min(playlistItem.AudioBitrate ?? audioBitrate, audioBitrate);
int? maxBitrateSetting = options.GetMaxBitrate(false);
var maxBitrateSetting = options.GetMaxBitrate(false);
// Honor max rate
if (maxBitrateSetting.HasValue)
{
int videoBitrate = maxBitrateSetting.Value;
var videoBitrate = maxBitrateSetting.Value;
if (playlistItem.AudioBitrate.HasValue)
{
@ -595,15 +596,16 @@ namespace MediaBrowser.Model.Dlna
}
// Make sure the video bitrate is lower than bitrate settings but at least 64k
int currentValue = playlistItem.VideoBitrate ?? videoBitrate;
playlistItem.VideoBitrate = Math.Max(Math.Min(videoBitrate, currentValue), 64000);
long currentValue = playlistItem.VideoBitrate ?? videoBitrate;
var longBitrate = Math.Max(Math.Min(videoBitrate, currentValue), 64000);
playlistItem.VideoBitrate = longBitrate > int.MaxValue ? int.MaxValue : Convert.ToInt32(longBitrate);
}
}
return playlistItem;
}
private int GetAudioBitrate(string subProtocol, int? maxTotalBitrate, int? targetAudioChannels, string targetAudioCodec, MediaStream audioStream)
private int GetAudioBitrate(string subProtocol, long? maxTotalBitrate, int? targetAudioChannels, string targetAudioCodec, MediaStream audioStream)
{
int defaultBitrate = audioStream == null ? 192000 : audioStream.BitRate ?? 192000;
// Reduce the bitrate if we're downmixing
@ -865,7 +867,7 @@ namespace MediaBrowser.Model.Dlna
}
private bool IsEligibleForDirectPlay(MediaSourceInfo item,
int? maxBitrate,
long? maxBitrate,
MediaStream subtitleStream,
VideoOptions options,
PlayMethod playMethod)
@ -960,7 +962,7 @@ namespace MediaBrowser.Model.Dlna
return null;
}
private bool IsAudioEligibleForDirectPlay(MediaSourceInfo item, int? maxBitrate)
private bool IsAudioEligibleForDirectPlay(MediaSourceInfo item, long? maxBitrate)
{
if (!maxBitrate.HasValue)
{

@ -7,7 +7,7 @@ namespace MediaBrowser.Model.Dlna
{
public class StreamInfoSorter
{
public static List<StreamInfo> SortMediaSources(List<StreamInfo> streams, int? maxBitrate)
public static List<StreamInfo> SortMediaSources(List<StreamInfo> streams, long? maxBitrate)
{
return streams.OrderBy(i =>
{

@ -7,7 +7,7 @@ namespace MediaBrowser.Model.MediaInfo
public string OpenToken { get; set; }
public string UserId { get; set; }
public string PlaySessionId { get; set; }
public int? MaxStreamingBitrate { get; set; }
public long? MaxStreamingBitrate { get; set; }
public long? StartTimeTicks { get; set; }
public int? AudioStreamIndex { get; set; }
public int? SubtitleStreamIndex { get; set; }

@ -8,7 +8,7 @@ namespace MediaBrowser.Model.MediaInfo
public string UserId { get; set; }
public int? MaxStreamingBitrate { get; set; }
public long? MaxStreamingBitrate { get; set; }
public long? StartTimeTicks { get; set; }

Loading…
Cancel
Save