Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Core/Api/StreamSessionService.CompositeAudio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics;
using OpenStreamMS.Core.Helpers;
using OpenStreamMS.Services;
using OpenStreamMS.Services.Localization;

namespace OpenStreamMS.Core.Api;

Expand Down Expand Up @@ -53,12 +54,12 @@ private void EnsureCompositeAudio(StreamSession c)
int play = launcher.LaunchInSession(owner.RdpSessionId, exe, $"--audio-relay play {pipe}");
int send = launcher.LaunchInSession(m.RdpSessionId, exe, $"--audio-relay send {pipe}");
relays[m.Id] = new AudioRelayProcs(owner.RdpSessionId, m.RdpSessionId, play, send);
Logger.Log($"[{c.Name}] Sonido de '{m.Name}' reenviado a la sesión del teclado '{owner.Name}'.", c.Id);
Logger.Log(BackendText.Get("compositeAudio.forwarded", c.Name, m.Name, owner.Name), c.Id);
}
catch (Exception ex)
{
relays.TryRemove(m.Id, out _);
Logger.Warning($"[{c.Name}] No se pudo reenviar el sonido de '{m.Name}': {ex.Message}", c.Id);
Logger.Warning(BackendText.Get("compositeAudio.forwardFailed", c.Name, m.Name, ex.Message), c.Id);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions Core/Api/StreamSessionService.CompositeInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void SetCompositeInputTarget(Guid compositeId, Guid memberId)
var owner = c.CompositeInput ?? c.Composite![0].Session;
if (memberId == owner) _compositeInputTarget.TryRemove(c.Id, out _);
else _compositeInputTarget[c.Id] = memberId;
Logger.Log($"[{c.Name}] Teclado y ratón a '{m.Name}' (sesión de Windows {m.RdpSessionId}).", c.Id);
Logger.Log(BackendText.Get("compositeInput.routed", c.Name, m.Name, m.RdpSessionId), c.Id);
EnsureCompositeInput(c);
}

Expand Down Expand Up @@ -91,7 +91,7 @@ private void EnsureCompositeInput(StreamSession c)
}
catch (Exception ex)
{
Logger.Warning($"[{c.Name}] No se pudo pasar el teclado y el ratón a '{target.Name}': {ex.Message}", c.Id);
Logger.Warning(BackendText.Get("compositeInput.routeFailed", c.Name, target.Name, ex.Message), c.Id);
DeleteInputFile(c, path);
return;
}
Expand All @@ -109,14 +109,14 @@ private void EnsureCompositeInput(StreamSession c)
}
catch (Exception ex)
{
Logger.Warning($"[{c.Name}] No se pudo escribir {MosaicLayout.InputFileName}: {ex.Message}", c.Id);
Logger.Warning(BackendText.Get("compositeInput.writeFailed", c.Name, MosaicLayout.InputFileName, ex.Message), c.Id);
}
}

private static void DeleteInputFile(StreamSession c, string path)
{
try { if (File.Exists(path)) File.Delete(path); }
catch (Exception ex) { Logger.Warning($"[{c.Name}] No se pudo borrar {MosaicLayout.InputFileName}: {ex.Message}", c.Id); }
catch (Exception ex) { Logger.Warning(BackendText.Get("compositeInput.deleteFailed", c.Name, MosaicLayout.InputFileName, ex.Message), c.Id); }
}

private void StopInputRelay(Guid compositeId)
Expand Down
13 changes: 7 additions & 6 deletions Services/Audio/AudioRelay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using NAudio.CoreAudioApi;
using NAudio.Wave;
using OpenStreamMS.Services.Seats;
using OpenStreamMS.Services.Localization;

namespace OpenStreamMS.Services.Audio;

Expand Down Expand Up @@ -38,7 +39,7 @@ public static int Run(string[] args)
}
catch (Exception ex)
{
Logger.Warning($"[AudioRelay] {args[1]} {args[2]}: {ex.Message}");
Logger.Warning(BackendText.Get("audioRelay.operationFailed", args[1], args[2], ex.Message));
return 1;
}
}
Expand Down Expand Up @@ -83,7 +84,7 @@ private static void Send(string pipeName)
};
cap.RecordingStopped += (_, _) => broken.Set();
cap.StartRecording();
Logger.Log($"[AudioRelay] Enviando el audio de la sesión de Windows {System.Diagnostics.Process.GetCurrentProcess().SessionId}: {f}");
Logger.Log(BackendText.Get("audioRelay.sending", System.Diagnostics.Process.GetCurrentProcess().SessionId, f));
while (!_stopping && !broken.Wait(500)) { }
try { cap.StopRecording(); } catch { }
}
Expand Down Expand Up @@ -112,23 +113,23 @@ private static void Receive(NamedPipeServerStream pipe)
{
var header = new byte[16];
pipe.ReadExactly(header);
if (!header.AsSpan(0, 4).SequenceEqual(Magic)) throw new IOException("cabecera no válida");
if (!header.AsSpan(0, 4).SequenceEqual(Magic)) throw new IOException(BackendText.Get("audioRelay.invalidHeader"));
int rate = BitConverter.ToInt32(header, 4), channels = BitConverter.ToInt32(header, 8), bits = BitConverter.ToInt32(header, 12);
var wf = bits > 0 ? WaveFormat.CreateIeeeFloatWaveFormat(rate, channels) : new WaveFormat(rate, -bits, channels);

MMDevice? dev = DefaultOutput() ?? throw new IOException("la sesión del teclado no tiene salida de audio");
MMDevice? dev = DefaultOutput() ?? throw new IOException(BackendText.Get("audioRelay.noOutputDevice"));
var buffer = new SeatJitterBuffer(wf);
using var output = new WasapiOut(dev, AudioClientShareMode.Shared, true, 10);
output.Init(buffer);
output.Play();
Logger.Log($"[AudioRelay] Reproduciendo en '{dev.FriendlyName}': {wf}");
Logger.Log(BackendText.Get("audioRelay.playing", dev.FriendlyName, wf));

var len = new byte[4];
while (!_stopping)
{
pipe.ReadExactly(len);
int n = BitConverter.ToInt32(len);
if (n <= 0 || n > 1 << 20) throw new IOException("bloque no válido");
if (n <= 0 || n > 1 << 20) throw new IOException(BackendText.Get("audioRelay.invalidBlock"));
var data = new byte[n];
pipe.ReadExactly(data);
buffer.Add(data);
Expand Down
9 changes: 5 additions & 4 deletions Services/Input/InputRelay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Runtime.InteropServices;
using System.Security.AccessControl;
using System.Security.Principal;
using OpenStreamMS.Services.Localization;

namespace OpenStreamMS.Services.Input;

Expand Down Expand Up @@ -32,7 +33,7 @@ public static int Run()
var security = new PipeSecurity();
security.AddAccessRule(new PipeAccessRule(new SecurityIdentifier(WellKnownSidType.LocalSystemSid, null),
PipeAccessRights.FullControl, AccessControlType.Allow));
Logger.Log($"[InputRelay] Teclado y ratón de la compuesta para la sesión de Windows {session} ({name}).");
Logger.Log(BackendText.Get("inputRelay.started", session, name));

int failures = 0;
while (true)
Expand All @@ -52,7 +53,7 @@ public static int Run()
// Otro proceso ya tiene ese nombre (otro relé de esta sesión): se reintenta un rato.
if (++failures >= 30)
{
Logger.Warning($"[InputRelay] No se pudo crear {name}: {ex.Message}");
Logger.Warning(BackendText.Get("inputRelay.createFailed", name, ex.Message));
return 3;
}
Thread.Sleep(1000);
Expand All @@ -72,9 +73,9 @@ private static void Receive(NamedPipeServerStream pipe)
while (true)
{
pipe.ReadExactly(header);
if (BitConverter.ToUInt32(header, 0) != Magic) throw new EndOfStreamException("cabecera no válida");
if (BitConverter.ToUInt32(header, 0) != Magic) throw new EndOfStreamException(BackendText.Get("inputRelay.invalidHeader"));
int count = (int)BitConverter.ToUInt32(header, 4);
if (count is <= 0 or > MaxBatch) throw new EndOfStreamException("lote no válido");
if (count is <= 0 or > MaxBatch) throw new EndOfStreamException(BackendText.Get("inputRelay.invalidBatch"));
if (buffer.Length < count * size) buffer = new byte[count * size];
if (inputs.Length < count) inputs = new INPUT[count];
pipe.ReadExactly(buffer, 0, count * size);
Expand Down
23 changes: 23 additions & 0 deletions Services/Localization/Locales/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,29 @@
"rdpwrap.singleSession": "Този компютър позволява само една сесия наведнъж",
"rdpwrap.remoteIddOff": "RemoteIdd е изключен: {0}. Работните места използват RDP дисплея на Windows. OpenStreamMS опитва RemoteIdd отново при всяко обновяване или преинсталиране.",
"composite.reconnecting": "Свързване отново…",
"audioMuter.coInitializeFailed": "Грешка в CoInitializeEx: 0x{0:X8}",
"audioMuter.noSessionsFound": "PID {0} не предостави аудиосесия в рамките на {1} ms.",
"audioMuter.persistentThreadEnded": "Постоянната нишка за заглушаване приключи: {0}",
"audioMuter.persistentThreadStarted": "Стартирана е постоянна нишка за заглушаване за PID {0}.",
"audioMuter.sessionsMuted": "PID {0}: заглушени аудиосесии: {1}.",
"audioMuter.sessionsMutedOnAttempt": "PID {0}: заглушени аудиосесии: {1} (опит {2}).",
"audioMuter.tryMuteFailed": "Грешка в TryMuteOnce: {0}",
"audioRelay.invalidBlock": "Невалиден аудиоблок.",
"audioRelay.invalidHeader": "Невалиден заглавен блок на аудио канала.",
"audioRelay.noOutputDevice": "В сесията на клавиатурата няма аудиоизход.",
"audioRelay.operationFailed": "[AudioRelay] {0} {1}: {2}",
"audioRelay.playing": "[AudioRelay] Възпроизвеждане на „{0}“: {1}",
"audioRelay.sending": "[AudioRelay] Изпращане на аудио от сесия на Windows {0}: {1}",
"compositeAudio.forwardFailed": "[{0}] Звукът от „{1}“ не можа да бъде препратен: {2}",
"compositeAudio.forwarded": "[{0}] Звукът от „{1}“ е препратен към сесията на клавиатурата „{2}“.",
"compositeInput.deleteFailed": "[{0}] Неуспешно изтриване на {1}: {2}",
"compositeInput.routeFailed": "[{0}] Клавиатурата и мишката не могат да бъдат пренасочени към „{1}“: {2}",
"compositeInput.routed": "[{0}] Клавиатурата и мишката са пренасочени към „{1}“ (сесия на Windows {2}).",
"compositeInput.writeFailed": "[{0}] Неуспешен запис на {1}: {2}",
"inputRelay.createFailed": "[InputRelay] {0} не може да бъде създаден: {1}",
"inputRelay.invalidBatch": "Невалиден пакет от входни данни.",
"inputRelay.invalidHeader": "Невалиден заглавен блок на канала за вход.",
"inputRelay.started": "[InputRelay] Пренасочване на клавиатурата и мишката за съставната сесия на Windows {0} ({1}).",
"rdpwrap.openSessionsPreventRestart": "Има отворени сесии ({0}): TermService не се рестартира сега; промяната влиза в сила при рестарт.",
"rdpwrap.termServiceRestarted": "TermService рестартиран.",
"driver.bundledInstaller": "Използван е включеният инсталатор: {0}",
Expand Down
23 changes: 23 additions & 0 deletions Services/Localization/Locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,29 @@
"rdpwrap.singleSession": "Tento počítač umožňuje jen jednu relaci najednou",
"rdpwrap.remoteIddOff": "RemoteIdd je vypnutý: {0}. Pracovní místa používají displej RDP systému Windows. OpenStreamMS zkusí RemoteIdd znovu při každé aktualizaci nebo přeinstalaci.",
"composite.reconnecting": "Znovu se připojuje…",
"audioMuter.coInitializeFailed": "CoInitializeEx selhalo: 0x{0:X8}",
"audioMuter.noSessionsFound": "PID {0} nezpřístupnil žádnou zvukovou relaci během {1} ms.",
"audioMuter.persistentThreadEnded": "Trvalé vlákno ztlumení skončilo: {0}",
"audioMuter.persistentThreadStarted": "Spuštěno trvalé vlákno ztlumení pro PID {0}.",
"audioMuter.sessionsMuted": "PID {0}: ztlumeno {1} zvukových relací.",
"audioMuter.sessionsMutedOnAttempt": "PID {0}: ztlumeno {1} zvukových relací při pokusu {2}.",
"audioMuter.tryMuteFailed": "TryMuteOnce selhalo: {0}",
"audioRelay.invalidBlock": "Neplatný zvukový blok.",
"audioRelay.invalidHeader": "Neplatná hlavička zvukového přenosu.",
"audioRelay.noOutputDevice": "Relace klávesnice nemá zvukové výstupní zařízení.",
"audioRelay.operationFailed": "[AudioRelay] {0} {1}: {2}",
"audioRelay.playing": "[AudioRelay] Přehrávání na „{0}“: {1}",
"audioRelay.sending": "[AudioRelay] Odesílání zvuku z relace Windows {0}: {1}",
"compositeAudio.forwardFailed": "[{0}] Zvuk z „{1}“ se nepodařilo předat: {2}",
"compositeAudio.forwarded": "[{0}] Zvuk z „{1}“ byl předán do relace klávesnice „{2}“.",
"compositeInput.deleteFailed": "[{0}] Nepodařilo se odstranit {1}: {2}",
"compositeInput.routeFailed": "[{0}] Klávesnici a myš se nepodařilo přesměrovat do „{1}“: {2}",
"compositeInput.routed": "[{0}] Klávesnice a myš byly přesměrovány do „{1}“ (relace Windows {2}).",
"compositeInput.writeFailed": "[{0}] Nepodařilo se zapsat {1}: {2}",
"inputRelay.createFailed": "[InputRelay] Nepodařilo se vytvořit {0}: {1}",
"inputRelay.invalidBatch": "Neplatná dávka vstupu.",
"inputRelay.invalidHeader": "Neplatná hlavička přenosu vstupu.",
"inputRelay.started": "[InputRelay] Přenos klávesnice a myši složené relace pro relaci Windows {0} ({1}).",
"rdpwrap.openSessionsPreventRestart": "Existují otevřené relace ({0}): TermService se nerestartuje nyní; změna se projeví po restartu.",
"rdpwrap.termServiceRestarted": "TermService restartován.",
"driver.bundledInstaller": "Používán vestavěný instalátor: {0}",
Expand Down
23 changes: 23 additions & 0 deletions Services/Localization/Locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,29 @@
"rdpwrap.singleSession": "Dieser PC erlaubt nur eine Sitzung gleichzeitig",
"rdpwrap.remoteIddOff": "RemoteIdd ist deaktiviert: {0}. Die Arbeitsplätze verwenden die RDP-Anzeige von Windows. OpenStreamMS versucht RemoteIdd bei jedem Update oder jeder Neuinstallation erneut.",
"composite.reconnecting": "Verbindung wird wiederhergestellt…",
"audioMuter.coInitializeFailed": "CoInitializeEx fehlgeschlagen: 0x{0:X8}",
"audioMuter.noSessionsFound": "PID {0} hat innerhalb von {1} ms keine Audiositzung bereitgestellt.",
"audioMuter.persistentThreadEnded": "Der dauerhafte Stummschaltungsthread wurde beendet: {0}",
"audioMuter.persistentThreadStarted": "Dauerhafter Stummschaltungsthread für PID {0} gestartet.",
"audioMuter.sessionsMuted": "PID {0}: {1} Audiositzung(en) stummgeschaltet.",
"audioMuter.sessionsMutedOnAttempt": "PID {0}: {1} Audiositzung(en) bei Versuch {2} stummgeschaltet.",
"audioMuter.tryMuteFailed": "TryMuteOnce fehlgeschlagen: {0}",
"audioRelay.invalidBlock": "Ungültiger Audioblock.",
"audioRelay.invalidHeader": "Ungültiger Audio-Relay-Header.",
"audioRelay.noOutputDevice": "In der Tastatursitzung ist kein Audioausgabegerät vorhanden.",
"audioRelay.operationFailed": "[AudioRelay] {0} {1}: {2}",
"audioRelay.playing": "[AudioRelay] Wiedergabe auf „{0}“: {1}",
"audioRelay.sending": "[AudioRelay] Audio wird aus Windows-Sitzung {0} gesendet: {1}",
"compositeAudio.forwardFailed": "[{0}] Audio von „{1}“ konnte nicht weitergeleitet werden: {2}",
"compositeAudio.forwarded": "[{0}] Audio von „{1}“ an die Tastatursitzung „{2}“ weitergeleitet.",
"compositeInput.deleteFailed": "[{0}] {1} konnte nicht gelöscht werden: {2}",
"compositeInput.routeFailed": "[{0}] Tastatur und Maus konnten nicht an „{1}“ weitergeleitet werden: {2}",
"compositeInput.routed": "[{0}] Tastatur und Maus an „{1}“ weitergeleitet (Windows-Sitzung {2}).",
"compositeInput.writeFailed": "[{0}] {1} konnte nicht geschrieben werden: {2}",
"inputRelay.createFailed": "[InputRelay] {0} konnte nicht erstellt werden: {1}",
"inputRelay.invalidBatch": "Ungültiger Eingabebatch.",
"inputRelay.invalidHeader": "Ungültiger Input-Relay-Header.",
"inputRelay.started": "[InputRelay] Tastatur- und Mausweiterleitung der zusammengesetzten Sitzung für Windows-Sitzung {0} ({1}).",
"rdpwrap.openSessionsPreventRestart": "Es gibt offene Sitzungen ({0}): TermService wird jetzt nicht neu gestartet; die Änderung wird nach dem Neustart wirksam.",
"rdpwrap.termServiceRestarted": "TermService neu gestartet.",
"driver.bundledInstaller": "Bundled Installer wird verwendet: {0}",
Expand Down
23 changes: 23 additions & 0 deletions Services/Localization/Locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,29 @@
"rdpwrap.singleSession": "This PC only allows one session at a time",
"rdpwrap.remoteIddOff": "RemoteIdd is turned off: {0}. Seats use Windows' own RDP display instead. OpenStreamMS tries RemoteIdd again whenever it's updated or reinstalled.",
"composite.reconnecting": "Reconnecting…",
"audioMuter.coInitializeFailed": "CoInitializeEx failed: 0x{0:X8}",
"audioMuter.noSessionsFound": "PID {0} did not expose any audio sessions within {1} ms.",
"audioMuter.persistentThreadEnded": "Persistent mute thread ended: {0}",
"audioMuter.persistentThreadStarted": "Persistent mute thread started for PID {0}.",
"audioMuter.sessionsMuted": "PID {0}: muted {1} audio session(s).",
"audioMuter.sessionsMutedOnAttempt": "PID {0}: muted {1} audio session(s) on attempt {2}.",
"audioMuter.tryMuteFailed": "TryMuteOnce failed: {0}",
"audioRelay.invalidBlock": "Invalid audio block.",
"audioRelay.invalidHeader": "Invalid audio relay header.",
"audioRelay.noOutputDevice": "The keyboard session has no audio output device.",
"audioRelay.operationFailed": "[AudioRelay] {0} {1}: {2}",
"audioRelay.playing": "[AudioRelay] Playing on '{0}': {1}",
"audioRelay.sending": "[AudioRelay] Sending audio from Windows session {0}: {1}",
"compositeAudio.forwardFailed": "[{0}] Could not forward audio from '{1}': {2}",
"compositeAudio.forwarded": "[{0}] Audio from '{1}' forwarded to the keyboard session '{2}'.",
"compositeInput.deleteFailed": "[{0}] Could not delete {1}: {2}",
"compositeInput.routeFailed": "[{0}] Could not route keyboard and mouse to '{1}': {2}",
"compositeInput.routed": "[{0}] Keyboard and mouse routed to '{1}' (Windows session {2}).",
"compositeInput.writeFailed": "[{0}] Could not write {1}: {2}",
"inputRelay.createFailed": "[InputRelay] Could not create {0}: {1}",
"inputRelay.invalidBatch": "Invalid input batch.",
"inputRelay.invalidHeader": "Invalid input relay header.",
"inputRelay.started": "[InputRelay] Composite keyboard and mouse relay for Windows session {0} ({1}).",
"rdpwrap.openSessionsPreventRestart": "There are open sessions ({0}): TermService will not be restarted now; the change applies on reboot.",
"rdpwrap.termServiceRestarted": "TermService restarted.",
"driver.bundledInstaller": "Using bundled installer: {0}",
Expand Down
Loading
Loading