add endpoint to estimate bitrate

This commit is contained in:
Luke Pulverenti 2015-04-30 11:06:37 -04:00
parent 213182dd97
commit a4e28a60a4
2 changed files with 31 additions and 0 deletions

View File

@ -45,6 +45,19 @@ namespace MediaBrowser.Api.Playback
public string LiveStreamId { get; set; }
}
[Route("/Playback/BitrateTest", "GET")]
public class GetBitrateTestBytes : IReturn<PlaybackInfoResponse>
{
[ApiMember(Name = "Size", Description = "Size", IsRequired = true, DataType = "int", ParameterType = "query", Verb = "GET")]
public long Size { get; set; }
public GetBitrateTestBytes()
{
// 100k
Size = 102400;
}
}
[Authenticated]
public class MediaInfoService : BaseApiService
{
@ -63,6 +76,18 @@ namespace MediaBrowser.Api.Playback
_networkManager = networkManager;
}
public object Get(GetBitrateTestBytes request)
{
var bytes = new byte[request.Size];
for (var i = 0; i < bytes.Length; i++)
{
bytes[i] = 0;
}
return ResultFactory.GetResult(bytes, "application/octet-stream");
}
public async Task<object> Get(GetPlaybackInfo request)
{
var result = await GetPlaybackInfo(request.Id, request.UserId, new[] { MediaType.Audio, MediaType.Video }).ConfigureAwait(false);

View File

@ -1499,5 +1499,11 @@ namespace MediaBrowser.Model.ApiClient
/// <param name="itemIds">The item ids.</param>
/// <returns>Task.</returns>
Task CancelSyncLibraryItems(string targetId, IEnumerable<string> itemIds);
/// <summary>
/// Gets the supported bitrate.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task&lt;System.Int32&gt;.</returns>
Task<int> GetSupportedBitrate(CancellationToken cancellationToken);
}
}