mirror of https://github.com/ErsatzTV/ErsatzTV.git
5 changed files with 66 additions and 4 deletions
@ -0,0 +1,7 @@
@@ -0,0 +1,7 @@
|
||||
namespace ErsatzTV.Core.FFmpeg; |
||||
|
||||
public record HlsSessionModel( |
||||
string ChannelNumber, |
||||
string State, |
||||
DateTimeOffset TranscodedUntil, |
||||
DateTimeOffset LastAccess); |
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
using ErsatzTV.Core.FFmpeg; |
||||
using ErsatzTV.Core.Interfaces.FFmpeg; |
||||
using Microsoft.AspNetCore.Mvc; |
||||
|
||||
namespace ErsatzTV.Controllers.Api; |
||||
|
||||
[ApiController] |
||||
public class SessionController(IFFmpegSegmenterService ffmpegSegmenterService) |
||||
{ |
||||
[HttpGet("api/sessions")] |
||||
public List<HlsSessionModel> GetSessions() |
||||
{ |
||||
return ffmpegSegmenterService.SessionWorkers.Values.Map(w => w.GetModel()).ToList(); |
||||
} |
||||
|
||||
[HttpDelete("api/session/{channelNumber}")] |
||||
public async Task<IActionResult> StopSession(string channelNumber, CancellationToken cancellationToken) |
||||
{ |
||||
if (ffmpegSegmenterService.SessionWorkers.TryGetValue(channelNumber, out IHlsSessionWorker worker)) |
||||
{ |
||||
await worker.Cancel(cancellationToken); |
||||
return new NoContentResult(); |
||||
} |
||||
|
||||
return new NotFoundResult(); |
||||
} |
||||
} |
Loading…
Reference in new issue