Add platform switch for session recorder.

This commit is contained in:
Jared Goodwin 2020-03-10 12:37:44 -07:00
parent f88f1ad76c
commit 538f79d7c4
5 changed files with 52 additions and 24 deletions

View File

@ -184,10 +184,7 @@ namespace Remotely.Agent.Services
var whoSplit = whoLine.Split(' ', StringSplitOptions.RemoveEmptyEntries);
username = whoSplit[0];
display = whoSplit.Last().Trim('(').Trim(')');
if (string.IsNullOrWhiteSpace(xauthority))
{
xauthority = $"/home/{username}/.Xauthority";
}
xauthority = $"/home/{username}/.Xauthority";
args = $"-u {username} {args}";
}

View File

@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Hosting;
using Remotely.Server.Data;
using Remotely.Server.Models;
using Remotely.Shared.Services;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@ -62,7 +63,20 @@ namespace Remotely.Server.Services
var ffmpegProc = new Process();
SessionStates[frame.ViewerID].FfmpegProcess = ffmpegProc;
ffmpegProc.StartInfo.FileName = "ffmpeg.exe";
switch (OSUtils.Platform)
{
case Shared.Enums.Platform.Windows:
ffmpegProc.StartInfo.FileName = "ffmpeg.exe";
break;
case Shared.Enums.Platform.Linux:
ffmpegProc.StartInfo.FileName = "ffmpeg";
break;
case Shared.Enums.Platform.OSX:
case Shared.Enums.Platform.Unknown:
default:
return;
}
ffmpegProc.StartInfo.Arguments = $"-y -f image2pipe -i pipe:.jpg -r 5 \"{saveFile}\"";
ffmpegProc.StartInfo.UseShellExecute = false;
ffmpegProc.StartInfo.RedirectStandardInput = true;

14
Shared/Enums/Platform.cs Normal file
View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Remotely.Shared.Enums
{
public enum Platform
{
Windows,
Linux,
OSX,
Unknown
}
}

View File

@ -16,8 +16,6 @@ namespace Remotely.Shared.Services
{
public static async Task<Device> Create(string deviceID, string orgID)
{
OSPlatform platform = OSUtils.GetPlatform();
DriveInfo systemDrive;
if (OSUtils.IsWindows)
@ -40,7 +38,7 @@ namespace Remotely.Shared.Services
{
ID = deviceID,
DeviceName = Environment.MachineName,
Platform = platform.ToString(),
Platform = OSUtils.Platform.ToString(),
ProcessorCount = Environment.ProcessorCount,
OSArchitecture = RuntimeInformation.OSArchitecture,
OSDescription = RuntimeInformation.OSDescription,

View File

@ -1,4 +1,5 @@
using System;
using Remotely.Shared.Enums;
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
@ -56,23 +57,26 @@ namespace Remotely.Shared.Services
}
}
public static OSPlatform GetPlatform()
public static Platform Platform
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
get
{
return OSPlatform.Windows;
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return OSPlatform.Linux;
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
return OSPlatform.OSX;
}
else
{
return OSPlatform.Create("Unknown");
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return Platform.Windows;
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return Platform.Linux;
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
return Platform.OSX;
}
else
{
return Platform.Unknown;
}
}
}
@ -92,5 +96,6 @@ namespace Remotely.Shared.Services
return proc.StandardOutput.ReadToEnd();
}
}
}