-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
139 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using OpenMediaServer.Interfaces.Endpoints; | ||
using OpenMediaServer.Interfaces.Services; | ||
|
||
namespace OpenMediaServer.Endpoints; | ||
|
||
public class ApiEndpoints : IApiEndpoints | ||
{ | ||
private readonly ILogger<ApiEndpoints> _logger; | ||
private readonly IInventoryService _inventoryService; | ||
|
||
public ApiEndpoints(ILogger<ApiEndpoints> logger, IInventoryService inventoryService) | ||
{ | ||
_logger = logger; | ||
_inventoryService = inventoryService; | ||
} | ||
|
||
public void Map(WebApplication app) | ||
{ | ||
var group = app.MapGroup("/api"); | ||
|
||
group.MapGet("/categories", ListCategories); | ||
group.MapGet("/items", ListItems); | ||
group.MapGet("/item", GetItem); | ||
} | ||
|
||
public async Task<IResult> ListCategories() | ||
{ | ||
var categories = await _inventoryService.ListCategories(); | ||
|
||
return Results.Ok(categories); | ||
} | ||
|
||
public async Task<IResult> ListItems(string category) | ||
{ | ||
var items = await _inventoryService.ListItems(category); | ||
|
||
return Results.Ok(items); | ||
} | ||
|
||
public async Task<IResult> GetItem(string category, string id) | ||
{ | ||
var item = await _inventoryService.GetItem(id: id, category: category); | ||
|
||
return Results.Ok(item); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using OpenMediaServer.Interfaces.Endpoints; | ||
using OpenMediaServer.Interfaces.Services; | ||
|
||
namespace OpenMediaServer.Endpoints; | ||
|
||
public class StreamingEndpoints : IStreamingEndpoints | ||
{ | ||
private readonly ILogger<StreamingEndpoints> _logger; | ||
private readonly IStreamingService _streamingService; | ||
|
||
public StreamingEndpoints(ILogger<StreamingEndpoints> logger, IStreamingService streamingService) | ||
{ | ||
_logger = logger; | ||
_streamingService = streamingService; | ||
} | ||
|
||
public void Map(WebApplication app) | ||
{ | ||
var group = app.MapGroup("/stream"); | ||
|
||
group.MapGet("/{category}/{id}", StreamContent); | ||
} | ||
|
||
public async Task<IResult> StreamContent(string id, string category) | ||
{ | ||
using var stream = await _streamingService.GetMediaStream(id, category); | ||
|
||
return Results.Stream(stream, enableRangeProcessing: true, contentType: "video/webm"); // TODO content type | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using System; | ||
|
||
namespace OpenMediaServer.Interfaces.Endpoints; | ||
|
||
public interface IStreamingEndpoints | ||
{ | ||
public void Map(WebApplication app); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using System; | ||
|
||
namespace OpenMediaServer.Interfaces.Services; | ||
|
||
public interface IStreamingService | ||
{ | ||
public Task<Stream> GetMediaStream(string id, string category); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using OpenMediaServer.Interfaces.Services; | ||
|
||
namespace OpenMediaServer.Services; | ||
|
||
public class StreamingService : IStreamingService | ||
{ | ||
private readonly ILogger<StreamingService> _logger; | ||
|
||
public StreamingService(ILogger<StreamingService> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public async Task<Stream> GetMediaStream(string id, string category) | ||
{ | ||
// TODO Implement | ||
|
||
throw new NotImplementedException(); | ||
} | ||
} |