aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-07-11 22:31:08 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-07-11 22:31:08 -0400
commitb5641013cea8542d3a992fb11811347e761a1f50 (patch)
treeedf14d9448f57e7e567668b6b1915844d9c5de58 /MediaBrowser.Api
parent59de5c0d14fbf0c09926e37dce0c2e6de69000dd (diff)
Add api key functions
Diffstat (limited to 'MediaBrowser.Api')
-rw-r--r--MediaBrowser.Api/Playback/BaseStreamingService.cs8
-rw-r--r--MediaBrowser.Api/SessionsService.cs56
2 files changed, 60 insertions, 4 deletions
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs
index 094a9034da..5d772527c1 100644
--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs
+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Common.Extensions;
+using MediaBrowser.Api.Playback.Hls;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Configuration;
@@ -317,7 +318,7 @@ namespace MediaBrowser.Api.Playback
switch (qualitySetting)
{
case EncodingQuality.HighSpeed:
- param = "-preset ultrafast";
+ param = "-preset superfast";
break;
case EncodingQuality.HighQuality:
param = "-preset superfast";
@@ -945,7 +946,8 @@ namespace MediaBrowser.Api.Playback
}
// Allow a small amount of time to buffer a little
- if (state.IsInputVideo)
+ // But not with HLS because it already has it's own wait
+ if (state.IsInputVideo && TranscodingJobType != TranscodingJobType.Hls)
{
await Task.Delay(500, cancellationTokenSource.Token).ConfigureAwait(false);
}
diff --git a/MediaBrowser.Api/SessionsService.cs b/MediaBrowser.Api/SessionsService.cs
index ed7db626f9..8017f35231 100644
--- a/MediaBrowser.Api/SessionsService.cs
+++ b/MediaBrowser.Api/SessionsService.cs
@@ -1,5 +1,6 @@
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Net;
+using MediaBrowser.Controller.Security;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Session;
using ServiceStack;
@@ -241,6 +242,25 @@ namespace MediaBrowser.Api
{
}
+ [Route("/Auth/Keys", "GET")]
+ public class GetApiKeys
+ {
+ }
+
+ [Route("/Auth/Keys/{Key}", "DELETE")]
+ public class RevokeKey
+ {
+ [ApiMember(Name = "Key", Description = "Auth Key", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
+ public string Key { get; set; }
+ }
+
+ [Route("/Auth/Keys", "POST")]
+ public class CreateKey
+ {
+ [ApiMember(Name = "App", Description = "App", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")]
+ public string App { get; set; }
+ }
+
/// <summary>
/// Class SessionsService
/// </summary>
@@ -253,19 +273,43 @@ namespace MediaBrowser.Api
private readonly IUserManager _userManager;
private readonly IAuthorizationContext _authContext;
+ private readonly IAuthenticationRepository _authRepo;
/// <summary>
/// Initializes a new instance of the <see cref="SessionsService" /> class.
/// </summary>
/// <param name="sessionManager">The session manager.</param>
/// <param name="userManager">The user manager.</param>
- public SessionsService(ISessionManager sessionManager, IUserManager userManager, IAuthorizationContext authContext)
+ /// <param name="authContext">The authentication context.</param>
+ /// <param name="authRepo">The authentication repo.</param>
+ public SessionsService(ISessionManager sessionManager, IUserManager userManager, IAuthorizationContext authContext, IAuthenticationRepository authRepo)
{
_sessionManager = sessionManager;
_userManager = userManager;
_authContext = authContext;
+ _authRepo = authRepo;
+ }
+
+ public void Delete(RevokeKey request)
+ {
+ var task = _sessionManager.RevokeToken(request.Key);
+
+ Task.WaitAll(task);
}
+ public void Post(CreateKey request)
+ {
+ var task = _authRepo.Create(new AuthenticationInfo
+ {
+ AppName = request.App,
+ IsActive = true,
+ AccessToken = Guid.NewGuid().ToString("N"),
+ DateCreated = DateTime.UtcNow
+
+ }, CancellationToken.None);
+
+ Task.WaitAll(task);
+ }
public void Post(ReportSessionEnded request)
{
@@ -274,6 +318,16 @@ namespace MediaBrowser.Api
_sessionManager.Logout(auth.Token);
}
+ public object Get(GetApiKeys request)
+ {
+ var result = _authRepo.Get(new AuthenticationInfoQuery
+ {
+ IsActive = true
+ });
+
+ return ToOptimizedResult(result);
+ }
+
/// <summary>
/// Gets the specified request.
/// </summary>