-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtils.cs
33 lines (28 loc) · 906 Bytes
/
Utils.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using DotNetEnv;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.FileProviders;
namespace RtspHlsRelay;
public class Utils
{
public static StaticFileOptions GetStaticFileOptions()
{
string streamCache = Env.GetString("STREAM_CACHE", string.Empty);
FileExtensionContentTypeProvider typeProvider = new();
typeProvider.Mappings[".m3u8"] = "application/vnd.apple.mpegurl";
typeProvider.Mappings[".ts"] = "video/mp2t";
return new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(streamCache),
RequestPath = string.Empty,
ContentTypeProvider = typeProvider
};
}
public static bool HasMissingEnvVar(out string missingKey)
{
string[] required = ["STREAM_URI", "STREAM_CACHE"];
missingKey = required.FirstOrDefault(key =>
string.IsNullOrEmpty(Env.GetString(key, string.Empty)))
?? string.Empty;
return missingKey != string.Empty;
}
}