better bitrate syncing

This commit is contained in:
Luke Pulverenti
2013-08-29 22:13:58 -04:00
parent 87c4d447f8
commit a5fa31cf94
5 changed files with 52 additions and 23 deletions

View File

@@ -659,6 +659,32 @@ namespace MediaBrowser.Api.Playback
}
}
protected int? GetVideoBitrateParam(StreamState state)
{
if (state.VideoRequest.VideoBitRate.HasValue)
{
// Make sure we don't request a bitrate higher than the source
var currentBitrate = state.VideoStream == null ? state.VideoRequest.VideoBitRate.Value : state.VideoStream.BitRate ?? state.VideoRequest.VideoBitRate.Value;
return Math.Min(currentBitrate, state.VideoRequest.VideoBitRate.Value);
}
return null;
}
protected int? GetAudioBitrateParam(StreamState state)
{
if (state.Request.AudioBitRate.HasValue)
{
// Make sure we don't request a bitrate higher than the source
var currentBitrate = state.AudioStream == null ? state.Request.AudioBitRate.Value : state.AudioStream.BitRate ?? state.Request.AudioBitRate.Value;
return Math.Min(currentBitrate, state.Request.AudioBitRate.Value);
}
return null;
}
/// <summary>
/// Gets the user agent param.
/// </summary>