Skip to content

Commit

Permalink
Fixing warnings and build
Browse files Browse the repository at this point in the history
  • Loading branch information
buldo committed Dec 7, 2023
1 parent a7a723c commit 4d0f91f
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 62 deletions.
8 changes: 8 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ bash --version 2>&1 | head -n 1
set -eo pipefail
SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)

###########################################################################
# Cloudsmith
###########################################################################

pip install --user cloudsmith-cli

###########################################################################

###########################################################################
# CONFIGURATION
###########################################################################
Expand Down
12 changes: 6 additions & 6 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ public Build()

public static int Main () => Execute<Build>(x => x.Publish);

[PathExecutable("dpkg-deb")]
[PathVariable("dpkg-deb")]
readonly Tool DpkgDeb;

[PathExecutable("cloudsmith")]
[PathVariable("cloudsmith")]
readonly Tool Cloudsmith;

[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
Expand Down Expand Up @@ -86,7 +86,7 @@ protected override void OnBuildInitialized()
.Before(Restore)
.Executes(() =>
{
EnsureCleanDirectory(OutputPath);
OutputPath.CreateOrCleanDirectory();
});

Target Restore => _ => _
Expand Down Expand Up @@ -121,7 +121,7 @@ protected override void OnBuildInitialized()
var linuxArc = ToLinuxArc(arc);
var packageFolderName = $"{PackageName}_{CurrentVersion}_{linuxArc}";
var debPackDirectory = DebBuildPath / packageFolderName;
EnsureExistingDirectory(debPackDirectory);
debPackDirectory.CreateOrCleanDirectory();

var serviceTargetDirectory = debPackDirectory / "usr" / "local" / "share" / "openhd" / "web-ui";
CopyDirectoryRecursively(
Expand All @@ -130,11 +130,11 @@ protected override void OnBuildInitialized()
excludeFile: info => info.Name == "appsettings.Development.json");

var packSystemDDir = debPackDirectory / "etc" / "systemd" / "system";
EnsureExistingDirectory(packSystemDDir);
packSystemDDir.CreateOrCleanDirectory();
CopyFile(RootDirectory / "openhd-web-ui.service", packSystemDDir / "openhd-web-ui.service");

var debianDirectory = debPackDirectory / "DEBIAN";
EnsureExistingDirectory(debianDirectory);
debianDirectory.CreateOrCleanDirectory();
CreateControlFile(RootDirectory / "control.template", debianDirectory / "control", CurrentVersion, linuxArc);

CopyDebFile(debianDirectory, "postinst");
Expand Down
8 changes: 6 additions & 2 deletions src/OpenHdWebUi.FileSystem/FileSystemHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@ public static void EnsureFolderCreated(string fullPath)
if (Environment.OSVersion.Platform == PlatformID.Unix)
{
var dirInfo = new DirectoryInfo(fullPath);
#pragma warning disable CA1416
dirInfo.UnixFileMode = Consts.Mode0777;
#pragma warning restore CA1416
}

return;
}

if (Environment.OSVersion.Platform == PlatformID.Unix)
{
#pragma warning disable CA1416
Directory.CreateDirectory(fullPath, Consts.Mode0777);
#pragma warning restore CA1416
}
else
{
Expand All @@ -33,7 +37,7 @@ public static void EnsureCurrentDirectoryIsBinaryDirectory()

private static string GetExeDirectory()
{
var exeFileName = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
return Path.GetDirectoryName(exeFileName);
var exeFileName = System.Diagnostics.Process.GetCurrentProcess().MainModule!.FileName;
return Path.GetDirectoryName(exeFileName)!;
}
}
4 changes: 3 additions & 1 deletion src/OpenHdWebUi.Server/Configuration/ServiceConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using JetBrains.Annotations;
#nullable disable warnings
// ReSharper disable NotNullOrRequiredMemberIsNotInitialized
// ReSharper disable CollectionNeverUpdated.Global

namespace OpenHdWebUi.Server.Configuration;

[UsedImplicitly]
public class ServiceConfiguration
{
Expand Down
4 changes: 2 additions & 2 deletions src/OpenHdWebUi.Server/Controllers/FilesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public FilesController(
}

[HttpGet]
public async Task<IEnumerable<ServerFileInfo>> Get()
public IEnumerable<ServerFileInfo> Get()
{
var fullPath = _mediaService.MediaDirectoryFullPath;

Expand All @@ -47,7 +47,7 @@ public async Task<IEnumerable<ServerFileInfo>> Get()
}

[HttpDelete("{fileName}")]
public async Task Delete(string fileName)
public void Delete(string fileName)
{
_mediaService.DeleteFile(fileName);
}
Expand Down
97 changes: 48 additions & 49 deletions src/OpenHdWebUi.Server/Controllers/VideoController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,69 +3,68 @@
using Microsoft.AspNetCore.Mvc;
using OpenHdWebUi.Server.Services.AirGround;

namespace OpenHdWebUi.Server.Controllers
namespace OpenHdWebUi.Server.Controllers;

[Route("api/video")]
[ApiController]
public class VideoController : ControllerBase
{
[Route("api/video")]
[ApiController]
public class VideoController : ControllerBase
private readonly IRtpRestreamerControl _control;
private readonly AirGroundService _airGroundService;

public VideoController(
IRtpRestreamerControl control,
AirGroundService airGroundService)
{
private readonly IRtpRestreamerControl _control;
private readonly AirGroundService _airGroundService;
_control = control;
_airGroundService = airGroundService;
}

public VideoController(
IRtpRestreamerControl control,
AirGroundService airGroundService)
{
_control = control;
_airGroundService = airGroundService;
}
[HttpPost("stop")]
public async Task Stop()
{
await _control.StopAsync();
}

[HttpPost("stop")]
public async Task Stop()
[HttpPost("sdp")]
[Produces("application/sdp")]
[Consumes("application/sdp")]
public async Task Post()
{
if (!_airGroundService.IsGroundMode)
{
await _control.StopAsync();
return;
}

[HttpPost("sdp")]
[Produces("application/sdp")]
[Consumes("application/sdp")]
public async Task Post()
using var streamReader = new StreamReader(Request.Body, Encoding.UTF8);
var sdpString = await streamReader.ReadToEndAsync();
if (!string.IsNullOrWhiteSpace(sdpString))
{
if (!_airGroundService.IsGroundMode)
{
return;
}

using var streamReader = new StreamReader(Request.Body, Encoding.UTF8);
var sdpString = await streamReader.ReadToEndAsync();
if (!string.IsNullOrWhiteSpace(sdpString))
{
Response.StatusCode = StatusCodes.Status400BadRequest;
return;
}
Response.StatusCode = StatusCodes.Status400BadRequest;
return;
}

var answer = await _control.AppendClient();
var answer = await _control.AppendClient();

Response.StatusCode = StatusCodes.Status201Created;
Response.Headers.Location = $"api/video/sdp/{answer.PeerId}";
await Response.WriteAsync(answer.Sdp, Encoding.UTF8);
}
Response.StatusCode = StatusCodes.Status201Created;
Response.Headers.Location = $"api/video/sdp/{answer.PeerId}";
await Response.WriteAsync(answer.Sdp, Encoding.UTF8);
}

[HttpPatch("sdp/{peerId}")]
[Consumes("application/sdp")]
public async Task Patch([FromRoute] Guid peerId)
[HttpPatch("sdp/{peerId}")]
[Consumes("application/sdp")]
public async Task Patch([FromRoute] Guid peerId)
{
if (!_airGroundService.IsGroundMode)
{
if (!_airGroundService.IsGroundMode)
{
return;
}
return;
}

using var streamReader = new StreamReader(Request.Body, Encoding.UTF8);
var sdpString = await streamReader.ReadToEndAsync();
using var streamReader = new StreamReader(Request.Body, Encoding.UTF8);
var sdpString = await streamReader.ReadToEndAsync();

await _control.ProcessClientAnswerAsync(peerId, sdpString);
await _control.ProcessClientAnswerAsync(peerId, sdpString);

Response.StatusCode = StatusCodes.Status200OK;
}
Response.StatusCode = StatusCodes.Status200OK;
}
}
4 changes: 2 additions & 2 deletions src/OpenHdWebUi.Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Program
{
public static async Task Main(string[] args)
{
await PrestartAsync();
Prestart();

var builder = WebApplication.CreateBuilder(args);

Expand Down Expand Up @@ -84,7 +84,7 @@ public static async Task Main(string[] args)
app.Run();
}

private static async Task PrestartAsync()
private static void Prestart()
{
FileSystemHelpers.EnsureCurrentDirectoryIsBinaryDirectory();
}
Expand Down

0 comments on commit 4d0f91f

Please sign in to comment.