feat(oglvoice): Firestorm WebRTC LLSD gateway, signed media exchange and remote speaker wire (#121)
* feat(oglvoice): include separately enabled signed Firestorm media gateway in grid provider discovery * feat(oglvoice): gate advertised Firestorm WebRTC capability behind central provider media URL * feat(oglvoice): gate advertised Firestorm WebRTC capability behind central provider media URL * feat(oglvoice): encode Firestorm JSEP/ICE media contract and remote speaker data-channel messages * feat(oglvoice): register Firestorm LLSD voice CAPS, verify scene admission and proxy JSEP/ICE to signed media bridge * fix(oglvoice): ensure viewer CAP validates scene admission before constructing media payload * docs(config): opt-in Firestorm media gateway centrally at Robust; no implicit LiveKit URL shortcut * docs(config): opt-in Firestorm media gateway centrally at Robust; no implicit LiveKit URL shortcut * docs(config): document Firestorm LLSD voice CAPS inherited from Robust or explicit Standalone mode * test(oglvoice): verify Firestorm SDP and ICE contract plus all-avatar speaker data-channel frames * test(oglvoice): verify Firestorm SDP and ICE contract plus all-avatar speaker data-channel frames * test(oglvoice): guard disabled-by-default Firestorm voice CAPS, signed bridge and remote speaker protocol * ci(oglvoice): execute Firestorm SDP/ICE and remote-speaking data-channel regressions * feat(oglvoice): separately authenticate bounded Firestorm SDP/ICE exchanges with large-payload media proof * fix(oglvoice): support real SDP-sized signed exchanges and stream-limit media gateway responses * test(oglvoice): compile media HMAC authentication contract in regression project * test(oglvoice): assert SDP-sized authenticated media payloads, expiry and node binding * ci(oglvoice): check domain-separated media proof rather than 4KiB session-mint proof * docs(oglvoice): define exact Firestorm JSEP/ICE backend exchange, speaking-orb frames and unfulfilled media gates * docs(oglvoice): mark Firestorm CAPS and speaker wire foundations without claiming functional media * docs(oglvoice): mark Firestorm CAPS and speaker wire foundations without claiming functional media * fix(oglvoice): bind Firestorm session to active region AgentSessionID and prevent cross-region admission * test(oglvoice): verify per-region current circuit binding on viewer session requests * fix(ci): link core admission DTO dependencies into Firestorm wire regression project
This commit is contained in:
1 parent
ac6a165563
commit
5d5371c192
16 files changed
+954
-2
No files matched your search
@@ -338,6 +338,14 @@ jobs:
|
||||
shell: bash
|
||||
run: dotnet run --configuration Release --project tools/ci/OglVoiceSessionRegression/OglVoiceSessionRegression.csproj
|
||||
|
||||
- name: Verify Firestorm LLSD voice capabilities and speaker-orb integration
|
||||
shell: bash
|
||||
run: python3 tools/ci/verify_oglvoice_firestorm_caps.py
|
||||
|
||||
- name: Regression-test Firestorm WebRTC media and speaker data channel wire
|
||||
shell: bash
|
||||
run: dotnet run --configuration Release --project tools/ci/OglVoiceFirestormRegression/OglVoiceFirestormRegression.csproj
|
||||
|
||||
- name: Verify Firestorm bridge bootstrap compatibility
|
||||
shell: bash
|
||||
run: python3 tools/ci/verify_firestorm_bridge_bootstrap.py
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace NexVerse.Core.Voice
|
||||
public bool hypergrid_guests { get; set; }
|
||||
public string media_transport { get; set; } = "livekit-webrtc";
|
||||
public string viewer_capability { get; set; } = "not-yet-implemented";
|
||||
public string media_gateway_url { get; set; }
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
@@ -23,6 +24,16 @@ namespace NexVerse.Core.Voice
|
||||
throw new ArgumentException("Unsupported OGLVoice provider protocol");
|
||||
if (!OglVoiceDiscoveryProof.IsSafeServiceUri(provider_url))
|
||||
throw new ArgumentException("OGLVoice provider URL must use HTTPS or local loopback HTTP");
|
||||
if (viewer_capability != "not-yet-implemented" &&
|
||||
viewer_capability != "firestorm-webrtc-v1")
|
||||
throw new ArgumentException("Unsupported OGLVoice viewer bridge contract");
|
||||
if (!string.IsNullOrWhiteSpace(media_gateway_url) &&
|
||||
(!OglVoiceDiscoveryProof.IsSafeServiceUri(media_gateway_url) ||
|
||||
media_gateway_url.Length > 1024))
|
||||
throw new ArgumentException("Invalid OGLVoice media bridge URL");
|
||||
if (viewer_capability == "firestorm-webrtc-v1" &&
|
||||
string.IsNullOrWhiteSpace(media_gateway_url))
|
||||
throw new ArgumentException("WebRTC viewer capability requires an explicit media gateway");
|
||||
if (string.IsNullOrEmpty(tenant_id) || tenant_id.Length > 96 ||
|
||||
!Regex.IsMatch(tenant_id, @"^[a-zA-Z0-9][a-zA-Z0-9_.-]*$"))
|
||||
throw new ArgumentException("Invalid OGLVoice tenant ID");
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace NexVerse.Core.Voice
|
||||
{
|
||||
/// <summary>
|
||||
/// Narrow, versioned JSON contract for an external OGLVoice media bridge
|
||||
/// that MUST terminate Firestorm's SDP/ICE and SCTP data channel itself.
|
||||
/// A LiveKit JWT alone cannot answer a Firestorm JSEP offer.
|
||||
/// </summary>
|
||||
public sealed class OglVoiceMediaExchange
|
||||
{
|
||||
public const string Protocol = "oglvoice-firestorm-media-v1";
|
||||
public string protocol { get; set; } = Protocol;
|
||||
public string operation { get; set; } // offer, trickle, leave
|
||||
public OglVoiceAdmission admission { get; set; }
|
||||
public string sdp_offer { get; set; }
|
||||
public string viewer_session { get; set; }
|
||||
public OglVoiceIceCandidate[] candidates { get; set; }
|
||||
public bool ice_completed { get; set; }
|
||||
}
|
||||
|
||||
public sealed class OglVoiceIceCandidate
|
||||
{
|
||||
public string candidate { get; set; }
|
||||
public string sdpMid { get; set; }
|
||||
public int sdpMLineIndex { get; set; }
|
||||
}
|
||||
|
||||
public sealed class OglVoiceMediaReply
|
||||
{
|
||||
public string protocol { get; set; }
|
||||
public string sdp_answer { get; set; }
|
||||
public string viewer_session { get; set; }
|
||||
public string status { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The *actual* Firestorm voice visualizer data channel protocol, keyed by
|
||||
/// the avatar UUID seen by that viewer (NOT hashed LiveKit participant id).
|
||||
/// Deliver on each listener's WebRTC SCTP data channel to visualize all
|
||||
/// remote speakers. Does not itself establish a WebRTC data channel.
|
||||
/// </summary>
|
||||
public static class OglVoiceFirestormWire
|
||||
{
|
||||
public const int MaximumSdpBytes = 32_768;
|
||||
public const int MaximumCandidateBytes = 1_024;
|
||||
public const int MaximumCandidates = 32;
|
||||
public const int MaximumResponseBytes = 48_000;
|
||||
|
||||
public static void ValidateOffer(string sdp)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(sdp) ||
|
||||
Encoding.UTF8.GetByteCount(sdp) > MaximumSdpBytes ||
|
||||
!sdp.StartsWith("v=0", StringComparison.Ordinal) ||
|
||||
!sdp.Contains("m=audio", StringComparison.Ordinal))
|
||||
throw new ArgumentException("Invalid or excessive Firestorm audio SDP offer");
|
||||
}
|
||||
|
||||
public static void ValidateCandidates(IReadOnlyList<OglVoiceIceCandidate> candidates,
|
||||
bool completed)
|
||||
{
|
||||
if (candidates == null || candidates.Count > MaximumCandidates ||
|
||||
(candidates.Count == 0 && !completed))
|
||||
throw new ArgumentException("Empty or oversized ICE update");
|
||||
foreach (OglVoiceIceCandidate candidate in candidates)
|
||||
if (candidate == null || string.IsNullOrWhiteSpace(candidate.candidate) ||
|
||||
Encoding.UTF8.GetByteCount(candidate.candidate) > MaximumCandidateBytes ||
|
||||
candidate.sdpMLineIndex < 0 || candidate.sdpMLineIndex > 16 ||
|
||||
candidate.sdpMid?.Length > 32)
|
||||
throw new ArgumentException("Invalid ICE candidate");
|
||||
}
|
||||
|
||||
public static void ValidateViewerSession(string session)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(session) || session.Length > 128 ||
|
||||
!System.Text.RegularExpressions.Regex.IsMatch(session,
|
||||
@"^[a-zA-Z0-9_.:-]+$"))
|
||||
throw new ArgumentException("Invalid media viewer_session");
|
||||
}
|
||||
|
||||
public static OglVoiceMediaReply ParseAnswer(byte[] response, bool expectSdp)
|
||||
{
|
||||
if (response == null || response.Length == 0 ||
|
||||
response.Length > MaximumResponseBytes)
|
||||
throw new ArgumentException("Missing or oversized media gateway response");
|
||||
OglVoiceMediaReply reply;
|
||||
try { reply = JsonSerializer.Deserialize<OglVoiceMediaReply>(response); }
|
||||
catch (JsonException ex) { throw new ArgumentException("Invalid media gateway JSON", ex); }
|
||||
if (reply == null || reply.protocol != OglVoiceMediaExchange.Protocol)
|
||||
throw new ArgumentException("Unexpected media gateway protocol");
|
||||
if (expectSdp)
|
||||
{
|
||||
ValidateViewerSession(reply.viewer_session);
|
||||
if (string.IsNullOrWhiteSpace(reply.sdp_answer) ||
|
||||
Encoding.UTF8.GetByteCount(reply.sdp_answer) > MaximumSdpBytes ||
|
||||
!reply.sdp_answer.StartsWith("v=0", StringComparison.Ordinal) ||
|
||||
!reply.sdp_answer.Contains("m=audio", StringComparison.Ordinal))
|
||||
throw new ArgumentException("Invalid WebRTC SDP answer");
|
||||
}
|
||||
return reply;
|
||||
}
|
||||
|
||||
public static string Join(Guid avatarId, bool primary = true) =>
|
||||
JsonSerializer.Serialize(new Dictionary<string, object>
|
||||
{
|
||||
[RequireAvatar(avatarId)] = new { j = new { p = primary } }
|
||||
});
|
||||
|
||||
public static string Speaking(Guid avatarId, float audioLevel, bool isSpeaking)
|
||||
{
|
||||
if (!float.IsFinite(audioLevel) || audioLevel < 0 || audioLevel > 1)
|
||||
throw new ArgumentOutOfRangeException(nameof(audioLevel));
|
||||
return JsonSerializer.Serialize(new Dictionary<string, object>
|
||||
{
|
||||
[RequireAvatar(avatarId)] = new
|
||||
{
|
||||
p = Math.Clamp((int)Math.Round(audioLevel * 128f), 0, 128),
|
||||
v = isSpeaking
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static string Leave(Guid avatarId) =>
|
||||
JsonSerializer.Serialize(new Dictionary<string, object>
|
||||
{
|
||||
[RequireAvatar(avatarId)] = new { l = true }
|
||||
});
|
||||
|
||||
private static string RequireAvatar(Guid avatarId)
|
||||
{
|
||||
if (avatarId == Guid.Empty)
|
||||
throw new ArgumentException("An avatar UUID is required");
|
||||
return avatarId.ToString("D");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace NexVerse.Core.Voice
|
||||
{
|
||||
/// <summary>
|
||||
/// Separate domain for Firestorm SDP/ICE media gateway requests.
|
||||
/// SDP offers and batched ICE can be larger than the 4KiB token-minting
|
||||
/// request protocol. The receiving gateway MUST bind known NodeIds,
|
||||
/// reject replayed nonces and enforce the same timestamp window.
|
||||
/// </summary>
|
||||
public static class OglVoiceMediaProof
|
||||
{
|
||||
public const int MaximumPayloadBytes = 64 * 1024;
|
||||
private static readonly Regex s_Node = new(
|
||||
@"^[a-zA-Z0-9][a-zA-Z0-9_.-]{0,127}$", RegexOptions.CultureInvariant);
|
||||
private static readonly Regex s_Nonce = new(@"^[a-f0-9]{32}$", RegexOptions.CultureInvariant);
|
||||
private static readonly Regex s_Signature = new(@"^[a-f0-9]{64}$", RegexOptions.CultureInvariant);
|
||||
|
||||
public static string Sign(string key, string node, long stamp, string nonce, byte[] body)
|
||||
{
|
||||
OglVoiceDiscoveryProof.ValidateKey(key);
|
||||
if (string.IsNullOrEmpty(node) || !s_Node.IsMatch(node) ||
|
||||
string.IsNullOrEmpty(nonce) || !s_Nonce.IsMatch(nonce) ||
|
||||
stamp <= 0 || body == null || body.Length == 0 ||
|
||||
body.Length > MaximumPayloadBytes)
|
||||
throw new ArgumentException("Invalid or oversized media proof");
|
||||
string digest = Convert.ToHexString(SHA256.HashData(body)).ToLowerInvariant();
|
||||
string message = "oglvoice-media-v1\n" + node + "\n" +
|
||||
stamp.ToString(CultureInfo.InvariantCulture) + "\n" + nonce + "\n" + digest;
|
||||
return Convert.ToHexString(HMACSHA256.HashData(
|
||||
Encoding.UTF8.GetBytes(key), Encoding.UTF8.GetBytes(message))).ToLowerInvariant();
|
||||
}
|
||||
|
||||
public static bool Verify(string key, string node, string timestamp, string nonce,
|
||||
byte[] body, string signature, DateTimeOffset now)
|
||||
{
|
||||
if (!long.TryParse(timestamp, NumberStyles.None,
|
||||
CultureInfo.InvariantCulture, out long stamp) ||
|
||||
Math.Abs(now.ToUnixTimeSeconds() - stamp) > 60 ||
|
||||
string.IsNullOrEmpty(signature) || !s_Signature.IsMatch(signature))
|
||||
return false;
|
||||
try
|
||||
{
|
||||
byte[] expected = Convert.FromHexString(Sign(key, node, stamp, nonce, body));
|
||||
return CryptographicOperations.FixedTimeEquals(
|
||||
expected, Convert.FromHexString(signature));
|
||||
}
|
||||
catch (ArgumentException) { return false; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,402 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using log4net;
|
||||
using Mono.Addins;
|
||||
using NexVerse.Core.Voice;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using Caps = OpenSim.Framework.Capabilities.Caps;
|
||||
|
||||
namespace NexVerse.RegionModules.Voice
|
||||
{
|
||||
/// <summary>
|
||||
/// Firestorm-compatible LLSD voice CAPS to a trusted, independently
|
||||
/// operated OGLVoice WebRTC media gateway. The gateway MUST terminate
|
||||
/// Firestorm SDP/ICE/DTLS/SRTP/SCTP and bridge media to LiveKit. Merely
|
||||
/// configuring a LiveKit SFU URL is not sufficient.
|
||||
///
|
||||
/// The module never distributes LiveKit administrator credentials.
|
||||
/// No CAPS or VoiceServerType are advertised until an authenticated
|
||||
/// provider explicitly enables the compatible media gateway.
|
||||
/// </summary>
|
||||
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule",
|
||||
Id = "OglVoiceFirestormCapsModule")]
|
||||
public sealed class OglVoiceFirestormCapsModule : INonSharedRegionModule
|
||||
{
|
||||
private static readonly ILog m_Log = LogManager.GetLogger(typeof(OglVoiceFirestormCapsModule));
|
||||
private sealed class VoiceSession
|
||||
{
|
||||
public string ViewerSession;
|
||||
public Guid AgentSessionId;
|
||||
}
|
||||
|
||||
private readonly ConcurrentDictionary<UUID, VoiceSession> m_Sessions = new();
|
||||
private readonly SemaphoreSlim m_Requests = new(16, 16);
|
||||
private static readonly byte[] s_Undefined = Encoding.UTF8.GetBytes("<llsd><undef /></llsd>");
|
||||
private Scene m_Scene;
|
||||
private HttpClient m_Http;
|
||||
private ISimulatorFeaturesModule m_Features;
|
||||
private bool m_Enabled;
|
||||
private string m_NodeId;
|
||||
private string m_Key;
|
||||
|
||||
public string Name => "OGLVoice Firestorm WebRTC Capability Bridge";
|
||||
public Type ReplaceableInterface => null;
|
||||
|
||||
public void Initialise(IConfigSource source)
|
||||
{
|
||||
IConfig options = source.Configs["OGLVoiceViewer"];
|
||||
if (options?.GetBoolean("Enabled", true) == false)
|
||||
return;
|
||||
IConfig node = source.Configs["NexVerseNodeAgent"];
|
||||
IConfig ogl = source.Configs["OGLVoice"];
|
||||
bool grid = node?.GetBoolean("Enabled", false) == true;
|
||||
bool standalone = ogl?.GetBoolean("Enabled", false) == true &&
|
||||
string.Equals(ogl.GetString("Mode", ""), "Standalone",
|
||||
StringComparison.OrdinalIgnoreCase);
|
||||
if (!grid && !standalone)
|
||||
return;
|
||||
try
|
||||
{
|
||||
m_NodeId = grid
|
||||
? node.GetString("NodeId", Environment.MachineName).Trim()
|
||||
: Environment.GetEnvironmentVariable("OGLVOICE_MEDIA_BRIDGE_NODE_ID")?.Trim()
|
||||
?? Environment.MachineName;
|
||||
m_Key = grid
|
||||
? node.GetString("SharedKey", "")
|
||||
: Environment.GetEnvironmentVariable("OGLVOICE_MEDIA_BRIDGE_SHARED_KEY");
|
||||
OglVoiceMediaProof.Sign(m_Key, m_NodeId,
|
||||
DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
|
||||
OglVoiceDiscoveryProof.NewNonce(), new byte[] { 1 });
|
||||
m_Http = new HttpClient(new HttpClientHandler
|
||||
{
|
||||
AllowAutoRedirect = false,
|
||||
UseCookies = false
|
||||
})
|
||||
{
|
||||
Timeout = TimeSpan.FromSeconds(6)
|
||||
};
|
||||
m_Enabled = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
m_Log.Warn("[OGL-VOICE]: Firestorm-CAPS bleiben deaktiviert: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddRegion(Scene scene)
|
||||
{
|
||||
if (!m_Enabled || scene == null)
|
||||
return;
|
||||
m_Scene = scene;
|
||||
scene.EventManager.OnRegisterCaps += RegisterCaps;
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
{
|
||||
if (!m_Enabled || m_Scene != scene)
|
||||
return;
|
||||
m_Features = scene.RequestModuleInterface<ISimulatorFeaturesModule>();
|
||||
if (m_Features != null)
|
||||
m_Features.OnSimulatorFeaturesRequest += OnSimulatorFeaturesRequest;
|
||||
}
|
||||
|
||||
public void PostInitialise() { }
|
||||
|
||||
public void RemoveRegion(Scene scene)
|
||||
{
|
||||
if (m_Scene != scene)
|
||||
return;
|
||||
scene.EventManager.OnRegisterCaps -= RegisterCaps;
|
||||
if (m_Features != null)
|
||||
m_Features.OnSimulatorFeaturesRequest -= OnSimulatorFeaturesRequest;
|
||||
m_Features = null;
|
||||
m_Scene = null;
|
||||
m_Sessions.Clear();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
if (m_Scene != null)
|
||||
RemoveRegion(m_Scene);
|
||||
m_Http?.Dispose();
|
||||
m_Enabled = false;
|
||||
m_Key = null;
|
||||
}
|
||||
|
||||
private OglVoiceProviderDescriptor ReadyProvider()
|
||||
{
|
||||
if (!m_Enabled || m_Scene == null || m_Http == null)
|
||||
return null;
|
||||
OglVoiceProviderDescriptor provider =
|
||||
m_Scene.RequestModuleInterface<IOglVoiceProviderLookup>()?.CurrentProvider;
|
||||
if (provider?.viewer_capability != "firestorm-webrtc-v1" ||
|
||||
!OglVoiceDiscoveryProof.IsSafeServiceUri(provider.media_gateway_url))
|
||||
return null;
|
||||
return provider;
|
||||
}
|
||||
|
||||
private void OnSimulatorFeaturesRequest(UUID avatar, ref OSDMap features)
|
||||
{
|
||||
OglVoiceProviderDescriptor provider = ReadyProvider();
|
||||
if (provider == null)
|
||||
return;
|
||||
if (OglVoiceRegionAdmission.TryCreate(m_Scene, avatar,
|
||||
provider.tenant_id, provider.hypergrid_guests, out _))
|
||||
features["VoiceServerType"] = OSD.FromString("webrtc");
|
||||
}
|
||||
|
||||
private void RegisterCaps(UUID avatar, Caps caps)
|
||||
{
|
||||
if (ReadyProvider() == null)
|
||||
return;
|
||||
caps.RegisterSimpleHandler("ProvisionVoiceAccountRequest",
|
||||
new SimpleStreamHandler("/" + UUID.Random(),
|
||||
(req, resp) => Handle(req, resp, avatar, "provision")));
|
||||
caps.RegisterSimpleHandler("VoiceSignalingRequest",
|
||||
new SimpleStreamHandler("/" + UUID.Random(),
|
||||
(req, resp) => Handle(req, resp, avatar, "signal")));
|
||||
}
|
||||
|
||||
private void Handle(IOSHttpRequest request, IOSHttpResponse response,
|
||||
UUID avatar, string operation)
|
||||
{
|
||||
response.ContentType = "application/llsd+xml";
|
||||
response.KeepAlive = false;
|
||||
response.AddHeader("Cache-Control", "no-store");
|
||||
if (request.HttpMethod != "POST")
|
||||
{
|
||||
Error(response, HttpStatusCode.MethodNotAllowed);
|
||||
return;
|
||||
}
|
||||
|
||||
OglVoiceProviderDescriptor provider = ReadyProvider();
|
||||
if (provider == null || m_Scene == null ||
|
||||
!OglVoiceRegionAdmission.TryCreate(m_Scene, avatar,
|
||||
provider.tenant_id, provider.hypergrid_guests,
|
||||
out OglVoiceAdmission admission))
|
||||
{
|
||||
Error(response, HttpStatusCode.Forbidden);
|
||||
return;
|
||||
}
|
||||
if (!m_Requests.Wait(0))
|
||||
{
|
||||
Error(response, HttpStatusCode.ServiceUnavailable);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Read a bounded LLSD document; never proxy untrusted raw XML.
|
||||
using MemoryStream stream = new();
|
||||
byte[] buffer = new byte[4096];
|
||||
int n;
|
||||
while ((n = request.InputStream.Read(buffer, 0, buffer.Length)) > 0)
|
||||
{
|
||||
if (stream.Length + n > 64 * 1024)
|
||||
{
|
||||
Error(response, HttpStatusCode.RequestEntityTooLarge);
|
||||
return;
|
||||
}
|
||||
stream.Write(buffer, 0, n);
|
||||
}
|
||||
|
||||
stream.Position = 0;
|
||||
if (OSDParser.DeserializeLLSDXml(stream) is not OSDMap map ||
|
||||
!map.TryGetValue("voice_server_type", out OSD type) ||
|
||||
type.AsString() != "webrtc")
|
||||
{
|
||||
Error(response, HttpStatusCode.BadRequest);
|
||||
return;
|
||||
}
|
||||
|
||||
OglVoiceMediaExchange message = new()
|
||||
{
|
||||
admission = admission,
|
||||
operation = operation == "signal" ? "trickle" : "offer"
|
||||
};
|
||||
|
||||
if (operation == "provision")
|
||||
{
|
||||
if (map.TryGetValue("logout", out OSD logout) && logout.AsBoolean())
|
||||
{
|
||||
if (!m_Sessions.TryGetValue(avatar, out VoiceSession existing) ||
|
||||
existing.AgentSessionId != admission.SessionId ||
|
||||
!map.TryGetValue("viewer_session", out OSD exitSession) ||
|
||||
exitSession.AsString() != existing.ViewerSession)
|
||||
{
|
||||
Error(response, HttpStatusCode.Forbidden);
|
||||
return;
|
||||
}
|
||||
message.operation = "leave";
|
||||
message.viewer_session = existing.ViewerSession;
|
||||
m_Sessions.TryRemove(avatar, out _);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!map.TryGetValue("channel_type", out OSD channel) ||
|
||||
channel.AsString() != "local" ||
|
||||
!map.TryGetValue("jsep", out OSD jsep) ||
|
||||
jsep is not OSDMap offer ||
|
||||
!offer.TryGetValue("type", out OSD offerType) ||
|
||||
offerType.AsString() != "offer" ||
|
||||
!offer.TryGetValue("sdp", out OSD sdp))
|
||||
{
|
||||
Error(response, HttpStatusCode.BadRequest);
|
||||
return;
|
||||
}
|
||||
message.sdp_offer = sdp.AsString();
|
||||
OglVoiceFirestormWire.ValidateOffer(message.sdp_offer);
|
||||
// Viewer-supplied parcel IDs never choose the voice room:
|
||||
// the receiving Scene's verified avatar position does.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_Sessions.TryGetValue(avatar, out VoiceSession existing) ||
|
||||
existing.AgentSessionId != admission.SessionId ||
|
||||
!map.TryGetValue("viewer_session", out OSD viewerSession) ||
|
||||
viewerSession.AsString() != existing.ViewerSession)
|
||||
{
|
||||
Error(response, HttpStatusCode.Forbidden);
|
||||
return;
|
||||
}
|
||||
message.viewer_session = existing.ViewerSession;
|
||||
List<OglVoiceIceCandidate> candidates = new();
|
||||
if (map.TryGetValue("candidates", out OSD values) && values is OSDArray ice)
|
||||
{
|
||||
if (ice.Count > OglVoiceFirestormWire.MaximumCandidates)
|
||||
{
|
||||
Error(response, HttpStatusCode.RequestEntityTooLarge);
|
||||
return;
|
||||
}
|
||||
foreach (OSD item in ice)
|
||||
{
|
||||
if (item is not OSDMap entry)
|
||||
throw new ArgumentException("ICE entry is not a map");
|
||||
candidates.Add(new OglVoiceIceCandidate
|
||||
{
|
||||
candidate = entry["candidate"].AsString(),
|
||||
sdpMid = entry["sdpMid"].AsString(),
|
||||
sdpMLineIndex = entry["sdpMLineIndex"].AsInteger()
|
||||
});
|
||||
}
|
||||
}
|
||||
bool completed = map.TryGetValue("candidate", out OSD done) &&
|
||||
done is OSDMap completedMap &&
|
||||
completedMap.TryGetValue("completed", out OSD flag) && flag.AsBoolean();
|
||||
OglVoiceFirestormWire.ValidateCandidates(candidates, completed);
|
||||
message.candidates = candidates.ToArray();
|
||||
message.ice_completed = completed;
|
||||
}
|
||||
|
||||
byte[] payload = JsonSerializer.SerializeToUtf8Bytes(message);
|
||||
if (payload.Length > OglVoiceMediaProof.MaximumPayloadBytes)
|
||||
throw new ArgumentException("Voice media exchange exceeds bounded request");
|
||||
// Separate HTTPS media service verifies the authenticated
|
||||
// node+body. No LiveKit API secret is sent through this CAP.
|
||||
using HttpRequestMessage backend = new(
|
||||
HttpMethod.Post, new Uri(provider.media_gateway_url));
|
||||
backend.Content = new ByteArrayContent(payload);
|
||||
backend.Content.Headers.ContentType =
|
||||
new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
|
||||
long stamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
|
||||
string nonce = OglVoiceDiscoveryProof.NewNonce();
|
||||
backend.Headers.TryAddWithoutValidation("X-OGLVoice-Node", m_NodeId);
|
||||
backend.Headers.TryAddWithoutValidation("X-OGLVoice-Timestamp",
|
||||
stamp.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
backend.Headers.TryAddWithoutValidation("X-OGLVoice-Nonce", nonce);
|
||||
backend.Headers.TryAddWithoutValidation("X-OGLVoice-Signature",
|
||||
OglVoiceMediaProof.Sign(m_Key, m_NodeId, stamp, nonce, payload));
|
||||
|
||||
using HttpResponseMessage result = m_Http.Send(
|
||||
backend, HttpCompletionOption.ResponseHeadersRead);
|
||||
if (!result.IsSuccessStatusCode)
|
||||
{
|
||||
Error(response, result.StatusCode == HttpStatusCode.Conflict
|
||||
? HttpStatusCode.Conflict : HttpStatusCode.ServiceUnavailable);
|
||||
return;
|
||||
}
|
||||
if (result.Content.Headers.ContentLength > OglVoiceFirestormWire.MaximumResponseBytes)
|
||||
throw new ArgumentException("Oversized media response");
|
||||
byte[] answer;
|
||||
using (Stream incoming = result.Content.ReadAsStream())
|
||||
using (MemoryStream bounded = new())
|
||||
{
|
||||
byte[] chunk = new byte[4096];
|
||||
int count;
|
||||
while ((count = incoming.Read(chunk, 0, chunk.Length)) > 0)
|
||||
{
|
||||
if (bounded.Length + count > OglVoiceFirestormWire.MaximumResponseBytes)
|
||||
throw new ArgumentException("Oversized media response");
|
||||
bounded.Write(chunk, 0, count);
|
||||
}
|
||||
answer = bounded.ToArray();
|
||||
}
|
||||
OglVoiceMediaReply media =
|
||||
OglVoiceFirestormWire.ParseAnswer(answer, message.operation == "offer");
|
||||
|
||||
if (message.operation == "offer")
|
||||
{
|
||||
m_Sessions[avatar] = new VoiceSession
|
||||
{
|
||||
ViewerSession = media.viewer_session,
|
||||
AgentSessionId = admission.SessionId
|
||||
};
|
||||
response.RawBuffer = Encoding.UTF8.GetBytes(
|
||||
OSDParser.SerializeLLSDXmlString(new OSDMap
|
||||
{
|
||||
["jsep"] = new OSDMap
|
||||
{
|
||||
["type"] = OSD.FromString("answer"),
|
||||
["sdp"] = OSD.FromString(media.sdp_answer)
|
||||
},
|
||||
["viewer_session"] = OSD.FromString(media.viewer_session)
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
response.RawBuffer = s_Undefined;
|
||||
}
|
||||
response.StatusCode = (int)HttpStatusCode.OK;
|
||||
}
|
||||
catch (Exception ex) when (ex is ArgumentException ||
|
||||
ex is System.Xml.XmlException ||
|
||||
ex is JsonException)
|
||||
{
|
||||
Error(response, HttpStatusCode.BadRequest);
|
||||
}
|
||||
catch (Exception ex) when (ex is HttpRequestException ||
|
||||
ex is TaskCanceledException ||
|
||||
ex is IOException)
|
||||
{
|
||||
m_Log.Warn("[OGL-VOICE]: WebRTC media bridge unavailable: " + ex.GetType().Name);
|
||||
Error(response, HttpStatusCode.ServiceUnavailable);
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_Requests.Release();
|
||||
}
|
||||
}
|
||||
|
||||
private static void Error(IOSHttpResponse resp, HttpStatusCode code)
|
||||
{
|
||||
resp.StatusCode = (int)code;
|
||||
resp.RawBuffer = s_Undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,13 @@ namespace NexVerse.RegionModules.Voice
|
||||
{
|
||||
provider_url = local.GetString("ServiceUrl", string.Empty).Trim(),
|
||||
tenant_id = local.GetString("TenantId", string.Empty).Trim(),
|
||||
hypergrid_guests = local.GetBoolean("IncludeHypergridGuests", true)
|
||||
hypergrid_guests = local.GetBoolean("IncludeHypergridGuests", true),
|
||||
media_gateway_url = local.GetBoolean("EnableFirestormGateway", false)
|
||||
? local.GetString("MediaGatewayUrl", "").Trim()
|
||||
: null,
|
||||
viewer_capability = local.GetBoolean("EnableFirestormGateway", false)
|
||||
? "firestorm-webrtc-v1"
|
||||
: "not-yet-implemented"
|
||||
};
|
||||
standalone.Validate();
|
||||
m_Current = standalone;
|
||||
|
||||
@@ -234,7 +234,13 @@ namespace NexVerse.Server.Api
|
||||
{
|
||||
provider_url = oglVoiceConfig.GetString("ServiceUrl", string.Empty).Trim(),
|
||||
tenant_id = oglVoiceConfig.GetString("TenantId", string.Empty).Trim(),
|
||||
hypergrid_guests = oglVoiceConfig.GetBoolean("IncludeHypergridGuests", true)
|
||||
hypergrid_guests = oglVoiceConfig.GetBoolean("IncludeHypergridGuests", true),
|
||||
media_gateway_url = oglVoiceConfig.GetBoolean("EnableFirestormGateway", false)
|
||||
? oglVoiceConfig.GetString("MediaGatewayUrl", "").Trim()
|
||||
: null,
|
||||
viewer_capability = oglVoiceConfig.GetBoolean("EnableFirestormGateway", false)
|
||||
? "firestorm-webrtc-v1"
|
||||
: "not-yet-implemented"
|
||||
};
|
||||
provider.Validate();
|
||||
|
||||
|
||||
@@ -1237,6 +1237,19 @@
|
||||
; ServiceUrl = "https://voice.stadt-nexverse.de"
|
||||
; TenantId = "my-standalone-grid"
|
||||
; IncludeHypergridGuests = true
|
||||
; ; Standalone: nur nach Bereitstellung eines kompatiblen Medien-Gateways.
|
||||
; EnableFirestormGateway = true
|
||||
; MediaGatewayUrl = "https://voice.example.org/internal/webrtc/v1/exchange"
|
||||
;
|
||||
; ; Auf Robust-Grids erfolgt diese Provider-URL zentral ueber die
|
||||
; ; signierte Discovery. KEIN Eintrag je Simulator erforderlich.
|
||||
; ; Die Medienanfragen werden mit dem bestehenden NexBus SharedKey
|
||||
; ; signiert. Standalone: OGLVOICE_MEDIA_BRIDGE_SHARED_KEY und
|
||||
; ; optional OGLVOICE_MEDIA_BRIDGE_NODE_ID als Umgebungsvariablen.
|
||||
;
|
||||
;[OGLVoiceViewer]
|
||||
; ; Modul bleibt ohne authentifizierten Provider/Bridge inaktiv.
|
||||
; Enabled = true
|
||||
;
|
||||
; IM GRID explizit deaktivieren: [OGLVoice] Enabled = false
|
||||
; Alternativer Robust-Endpunkt nur bei Reverse-Proxy-Sonderroute:
|
||||
|
||||
@@ -691,6 +691,13 @@
|
||||
EnableSessionAuthority = false
|
||||
AllowedNodes = ""
|
||||
|
||||
; Firestorm voice CAPS verwenden einen separaten, protokollkompatiblen
|
||||
; WebRTC Media Bridge. LiveKit SFU URL / Webportal sind KEIN SDP Gateway.
|
||||
; Erst einschalten, wenn der Dienst SDP/ICE, SCTP Sprecher-Roster
|
||||
; und die LiveKit-Bruecke nachweislich bereitstellt.
|
||||
EnableFirestormGateway = false
|
||||
MediaGatewayUrl = ""
|
||||
|
||||
|
||||
; Die eingehende interne Route ist
|
||||
; /internal/oglvoice/v1/provider (NexBus-HMAC + Replay-Schutz).
|
||||
|
||||
@@ -603,6 +603,13 @@
|
||||
EnableSessionAuthority = false
|
||||
AllowedNodes = ""
|
||||
|
||||
; Firestorm voice CAPS verwenden einen separaten, protokollkompatiblen
|
||||
; WebRTC Media Bridge. LiveKit SFU URL / Webportal sind KEIN SDP Gateway.
|
||||
; Erst einschalten, wenn der Dienst SDP/ICE, SCTP Sprecher-Roster
|
||||
; und die LiveKit-Bruecke nachweislich bereitstellt.
|
||||
EnableFirestormGateway = false
|
||||
MediaGatewayUrl = ""
|
||||
|
||||
|
||||
; Die eingehende interne Route ist
|
||||
; /internal/oglvoice/v1/provider (NexBus-HMAC + Replay-Schutz).
|
||||
|
||||
@@ -58,6 +58,12 @@ Der Simulator muss die Admission **direkt aus seiner Scene**, nicht aus Formular
|
||||
|
||||
**Noch ausdrücklich offen:** Die interne Admission wird noch **nicht** automatisch per Simulator-CAPS an die Token-Authority weitergeleitet. Es existiert weder ein LiveKit-Medien-/Signalisierungsadapter für den unveränderten Firestorm noch Spatial-Mischung, Avatar-Voice-Kugel, speaking roster, serverseitige Sitzungsentfernung bei Teleport/Logout, ein produktives Tenant-Abrechnungssystem oder ein Operator-Live-Test. Die **ausgestellten JWTs sind Tokenbausteine**, keine funktionierende Voice-Verbindung für den Viewer. Solange diese Komponenten fehlen, OGLVoice-Session-Authority und Viewer-CAPS deaktiviert lassen.
|
||||
|
||||
## Neuer Firestorm LLSD-/CAPS-Adapter (0.9.3.10 Dev)
|
||||
|
||||
Der C#-Simulatoradapter fuer `ProvisionVoiceAccountRequest` (SDP/JSEP), `VoiceSignalingRequest` (ICE-Trickle) und `VoiceServerType=webrtc` ist als opt-in Quellcode vorhanden. Die zentrale Robust-Discovery verteilt eine signierte `MediaGatewayUrl` an alle Simulatoren, sodass keine URL pro Sim konfiguriert werden muss. `OglVoiceFirestormWire` erzeugt Firestorm-konforme Datenkanalnachrichten fuer Beitritt/Sprechpegel/Abreise aller sichtbaren Avatare.
|
||||
|
||||
**Entscheidende Grenze:** Der Adapter stellt noch keine eigene WebRTC-Medienengine dar. Ohne eine tatsaechliche separate SDP-/DTLS-/SRTP-/SCTP-Media-Bridge mit LiveKit-Anbindung gibt es weiterhin kein Firestorm-Audio und keine sichtbaren fremden Sprecher. Ausfuehrlicher Wire Contract und Abnahmekriterien: [OGLVOICE_FIRESTORM_MEDIA_BRIDGE.md](OGLVOICE_FIRESTORM_MEDIA_BRIDGE.md).
|
||||
|
||||
## 1. Produktziel
|
||||
|
||||
**OGLVoice** ersetzt die im Server entfernten Vivox-/FreeSwitch-Implementierungen durch einen selbst betriebenen, **zentralen, mandantenfähigen WebRTC-Voice-Dienst**. Das operative Prinzip entspricht einem externen zentralen Voice-Provider: Eine ganze virtuelle Welt kann einen einzigen Voice-Provider verwenden; es wird **kein Voice-Medienserver je Simulator** verlangt.
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
# OGLVoice ↔ Firestorm WebRTC Media Bridge v1
|
||||
|
||||
**Status:** Gateway-Adapter in OpenGenesisLINK 0.9.3.10 Dev, **kein lauffaehiger eigenstaendiger SDP-/LiveKit-Medienserver**. Kein Stable-/RC-Claim. Standardmaessig deaktiviert.
|
||||
|
||||
## Zweck
|
||||
|
||||
Die originalen Firestorm-WebRTC-Clients koennen bei `VoiceServerType = webrtc` die OpenSim-Region-CAPS `ProvisionVoiceAccountRequest` und `VoiceSignalingRequest` nutzen. Die Region vermittelt **LLSD/XML** und authentifizierte Avatar-/Estate-/Parcel-Sitzung zur **zentralen externen OGLVoice Media Bridge**. Der Medienserver muss den WebRTC-SDP/ICE/DTLS/SRTP/SCTP-Vertrag wirklich bedienen und die Audio-Medien mit unserem LiveKit-Netz verbinden. LiveKit-SFU-Tokens sind **nicht** dasselbe wie eine WebRTC-SDP-Answer fuer den unveraenderten Firestorm.
|
||||
|
||||
Der neue Quellcode enthaelt:
|
||||
- `NexVerse/RegionModules/Voice/OglVoiceFirestormCapsModule.cs` mit Firestorm-`SimulatorFeatures` und den beiden LLSD-Viewer-CAPS.
|
||||
- `NexVerse/Core/Voice/OglVoiceFirestormWire.cs` mit Protokollvalidierung und **originalem Firestorm-Sprecher-Datenkanalformat**.
|
||||
- `NexVerse/Core/Voice/OglVoiceMediaProof.cs` mit auf 64KiB begrenzter, HMAC-SHA256-signierter Media-Exchange, `node`/`nonce`/`timestamp`/`SHA256(body)` und abweichendem Prefix `oglvoice-media-v1`.
|
||||
- Die signierte `OglVoiceProviderDescriptor`-Discovery enthaelt nur bei ausdruecklich aktiviertem Mediengateway `viewer_capability = "firestorm-webrtc-v1"` und `media_gateway_url`.
|
||||
- Die private LiveKit-JWT-Session-Authority aus PR #119 bleibt unveraendert; die Media Bridge muss ihre eigene autorisierte LiveKit-Integration entwickeln.
|
||||
|
||||
## Inbetriebnahme und Grenzen
|
||||
|
||||
**Robust/HG-Modus:** In `Robust.HG.ini` oder `Robust.ini` nach bestaetigtem Gateway-Test:
|
||||
```ini
|
||||
[OGLVoice]
|
||||
Enabled = true
|
||||
Mode = "GridAuthority"
|
||||
ServiceUrl = "https://voice.stadt-nexverse.de"
|
||||
TenantId = "nexverse"
|
||||
IncludeHypergridGuests = true
|
||||
EnableFirestormGateway = true
|
||||
MediaGatewayUrl = "https://VOICE-MEDIA-BRIDGE-HOST/internal/webrtc/v1/exchange"
|
||||
```
|
||||
Die URL mit `VOICE-MEDIA-BRIDGE-HOST` ist **ein Platzhalter, kein existierender Endpunkt**. Es muss eine wirklich installierte, kompatible und hinter HTTPS betriebene OGLVoice Media Bridge geben. Dann uebernehmen alle Simulatoren mit aktivem `[NexVerseNodeAgent]` und dem passenden NexBus-SharedKey diese Provider-Konfiguration aus Robust. Der neue `OglVoiceFirestormCapsModule` ist in solchen Simulatoren automatisch aktiv und wirbt `VoiceServerType=webrtc` fuer berechtigte Avatar-Sitzungen, sobald signierte und frische Discoverydaten mit Gateway-URL vorliegen. **Kein API-Schluessel pro Simulator in der INI**.
|
||||
|
||||
**Standalone:** `[OGLVoice] Mode="Standalone"`, `ServiceUrl`, `TenantId`, `EnableFirestormGateway=true`, `MediaGatewayUrl`. Die gesonderte Authentisierung nutzt `OGLVOICE_MEDIA_BRIDGE_SHARED_KEY` (mindestens 32 UTF-8-Bytes) und optional `OGLVOICE_MEDIA_BRIDGE_NODE_ID` aus der geschuetzten Simulatorumgebung. **Keine LiveKit-Signing-Keys auf Simulatoren**.
|
||||
|
||||
Bei fehlendem Provider, ungueltigem HTTPS-Gateway, fehlendem Node-Trust oder abgelehnten Estate-/Parcel-Rechten werden keine neuen Viewer-CAPS angekuendigt und kein WebRTC als verfuegbar beworben. Ein abgeschaltetes Gateway darf weder Inworld-Text-IM noch Login/Teleport blockieren. Voice kann aber erst nach dem naechsten CAPS-/Feature-Abruf sichtbar werden, wenn Discovery nach einem Regionstart verzoegert erfolgt.
|
||||
|
||||
## Firestorm ↔ Region CAPS (LLSD/XML)
|
||||
|
||||
**1. SimulatorFeatures:** `VoiceServerType: "webrtc"` nur bei signiertem `firestorm-webrtc-v1`-Provider und zugelassenem Agenten.
|
||||
|
||||
**2. ProvisionVoiceAccountRequest, `POST`:**
|
||||
```xml
|
||||
<llsd><map>
|
||||
<key>voice_server_type</key><string>webrtc</string>
|
||||
<key>channel_type</key><string>local</string>
|
||||
<key>jsep</key><map>
|
||||
<key>type</key><string>offer</string>
|
||||
<key>sdp</key><string>v=0 ...m=audio...</string>
|
||||
</map>
|
||||
</map></llsd>
|
||||
```
|
||||
Die Region prueft den Agent-Circuit, den Root-Agent, Estate-`AllowVoice`, Parcel-`AllowVoiceChat` und HG-Gast-Policy. Die angeforderte `parcel_local_id` darf **nicht** als Raumzugriffserlaubnis gelten: die Position in der Scene bestimmt den zulaessigen Raum. Der Medienserver antwortet mit einer *echten* SDP-Answer:
|
||||
```xml
|
||||
<llsd><map>
|
||||
<key>viewer_session</key><string>opaque-session-id</string>
|
||||
<key>jsep</key><map>
|
||||
<key>type</key><string>answer</string>
|
||||
<key>sdp</key><string>v=0 ...m=audio...</string>
|
||||
</map>
|
||||
</map></llsd>
|
||||
```
|
||||
|
||||
**3. VoiceSignalingRequest, `POST`:** `viewer_session`, `voice_server_type=webrtc`, `candidates: [{candidate,sdpMid,sdpMLineIndex}]` oder `candidate: {completed:true}` werden gebunden an den in derselben Region ausgegebenen `viewer_session` weitergeleitet. Logout wird als `ProvisionVoiceAccountRequest { logout: true, viewer_session: ...}` gehandhabt. Der Medienserver MUSS Sitzungen bei Logout, Regionwechsel, Agent-Timeout und Berechtigungsaenderung ebenfalls invalidieren; der aktuelle Adapter bietet **keine vollstaendige aktive zentrale Revocation**.
|
||||
|
||||
## Region → zentrale Media Bridge (JSON)
|
||||
|
||||
Der Simulator sendet an die **exakt konfigurierte HTTPS-MediaGatewayUrl** eine JSON-Struktur:
|
||||
```json
|
||||
{
|
||||
"protocol": "oglvoice-firestorm-media-v1",
|
||||
"operation": "offer",
|
||||
"admission": {
|
||||
"TenantId": "nexverse",
|
||||
"RegionId": "00000000-0000-0000-0000-000000000001",
|
||||
"AvatarId": "00000000-0000-0000-0000-000000000002",
|
||||
"SessionId": "00000000-0000-0000-0000-000000000003",
|
||||
"HomeGridOrigin": null,
|
||||
"IsHypergridGuest": false,
|
||||
"VoiceAllowed": true
|
||||
},
|
||||
"sdp_offer": "v=0\\r\\n...m=audio..."
|
||||
}
|
||||
```
|
||||
Fuer ICE: `operation: trickle`, `viewer_session`, `candidates`, `ice_completed`. Fuer Logout: `operation: leave`, `viewer_session`.
|
||||
|
||||
Die Bridge muss folgende Header validieren:
|
||||
- `X-OGLVoice-Node`: per ACL zugelassene Simulator-NodeId.
|
||||
- `X-OGLVoice-Timestamp`: Unix-Sekunden, Abweichung maximal 60 Sekunden.
|
||||
- `X-OGLVoice-Nonce`: 16 Byte hex, innerhalb Zeitfenster nur **einmal** verwendbar; Node+Nonce getrennt speichern.
|
||||
- `X-OGLVoice-Signature`: lowercase hex HMAC-SHA256 ueber UTF-8-String `oglvoice-media-v1\n<node>\n<timestamp>\n<nonce>\n<lowercase-sha256-of-exact-json-bytes>`, mit dem Grid-/Node-spezifischen vorab provisionierten SharedKey.
|
||||
|
||||
**Maximaler Body: 64 KiB**; SDP maximal 32768 UTF-8-Bytes, Kandidaten maximal 32 pro Anfrage, je Kandidat maximal 1024 Bytes. Die Bridge darf **niemals** eine frei im Body behauptete Mandanten- oder Avataridentitaet ohne vertrauenswuerdige Node-/Grid-Zuordnung und gepruefte Simulatorsitzung uebernehmen. `nexverse` und Unlimited sind ausschliesslich serverseitig zugeordnete Rechte.
|
||||
|
||||
Antwort auf `offer`:
|
||||
```json
|
||||
{
|
||||
"protocol": "oglvoice-firestorm-media-v1",
|
||||
"viewer_session": "opaque-session-id",
|
||||
"sdp_answer": "v=0\\r\\n...m=audio..."
|
||||
}
|
||||
```
|
||||
`trickle`/`leave` benoetigen eine gueltige `protocol`-Antwort. Die Region antwortet dem Viewer in diesen Faellen mit `<llsd><undef /></llsd>`.
|
||||
|
||||
## Remote Voice-Kugeln und Firestorm SCTP-Datenkanal
|
||||
|
||||
Die **zentrale Media Bridge** muss ueber den von ihr terminiertem **WebRTC-SCTP-Datenkanal** an **jeden Viewer** Meldungen schicken, deren oberster JSON-Key die tatsaechlich im Viewer sichtbare **Avatar-UUID** ist (nicht die gehashte LiveKit-Identitaet).
|
||||
|
||||
- Beitritt: `{"<avatar-uuid>":{"j":{"p":true}}}`. Die Kugel erscheint, auch wenn der Avatar gerade schweigt.
|
||||
- Aktives Sprechen: `{"<avatar-uuid>":{"p":64,"v":true}}`. Der Pegel `p` ist `round(linearLevel*128)`, auf 0..128 beschraenkt.
|
||||
- Stille: `{"<avatar-uuid>":{"p":0,"v":false}}`. Die Kugel bleibt grau.
|
||||
- Verlassen: `{"<avatar-uuid>":{"l":true}}`. Die Kugel verschwindet.
|
||||
|
||||
Die Media Bridge **muss** jeden Join, die Pegel/VAD-Events und Leave-Nachrichten an alle zur selben Region/Parzelle berechtigten Teilnehmer senden, einschliesslich HG-Gaesten. Bei PTT/Mute/Disconnect/Stille muessen Speaking-Zustaende zeitnah zurueckgesetzt werden. Firestorm kann die Darstellung seiner Visualizer benutzerseitig abschalten. Die Nachrichtengeneratoren `OglVoiceFirestormWire.Join/Speaking/Leave` und ihre .NET-Tests existieren; **die tatsaechliche LiveKit-Mischung, das Weiterleiten dieser Daten ueber reale SCTP-Kanaele und die Abnahme mit zwei Firestorm-Clients stehen noch aus**.
|
||||
|
||||
## Zwingende fehlende Komponenten fuer 0.9.3.10 Stable
|
||||
|
||||
1. Eine **echte** OGLVoice Media Bridge, welche Firestorms SDP/ICE/DTLS/SRTP/SCTP annimmt und Audio zu/von LiveKit vermittelt. Das vorhandene LiveKit-SFU allein bietet diesen Firestorm-Protokollvertrag nicht.
|
||||
2. Spatial-Audio-Wiedergabe pro Zuhoerer (Entfernung, Richtung, Parcel/Estate, Grenzuebertritte), lebende Teilnehmerliste inkl. HG und tatsaechlich ausgestrahlte Data-Channel-Frames.
|
||||
3. Serverseitige langlebige Session-/Room-Registry, Event-getriebene Join/Leave-Revocation, Schutz gegen stale/duplizierte Medien-Sitzungen, Mandantenisolation und Paketlimits; NexVerse first-party `Unlimited` ohne kuenstliche Quoten.
|
||||
4. LiveKit-Server-Integration auf `voice.stadt-nexverse.de` oder dem vorgesehenen separaten Media-Host und erreichbare ICE/STUN/TURN-Routen.
|
||||
5. End-to-End-Test mit zwei lokalen Firestorm-Viewern und mindestens einem Hypergrid-Besucher: Audio beide Richtungen, graue Kugeln ueber **allen** Avataren, animierte Wellen nur am Sprecher, PTT, mute, Abstand, Teleport, Rechtewechsel und Restart.
|
||||
6. Wiederholbare Integration-/Performance-/Sicherheits-Livetests und erst dann RC1/Stable-Abnahme.
|
||||
|
||||
Es wird **weder** ein Existieren des oben beispielhaft genannten Media-Gateway-Endpunkts **noch** eine funktionierende Audioverbindung oder Stable-Freigabe behauptet.
|
||||
@@ -29,6 +29,8 @@ Das Release bündelt den gesamten geplanten Meilenstein **0.9.3.9** (OGLVoice un
|
||||
- [ ] HG-Gast-Präsenz und Home-Grid-Identität, Rechte des besuchten Grids, Session-TTL und Leave/Teleport-Revoke.
|
||||
- [x] HG-Identitaetskern: kanonische Heim-Grid-Origin + Original-Avatar-UUID (SHA-256), C#-Regressionstests. **Noch keine authentifizierte HG-Session-/Voice-Anbindung.**
|
||||
- [ ] Firestorm-WebRTC-CAPS-/Signalisierungs-/Media-Gateway mit funktionierendem Audio, nicht nur Browser-Demo.
|
||||
- [x] **Firestorm-LLSD-CAPS/SDP/ICE-Adapter:** `ProvisionVoiceAccountRequest`, `VoiceSignalingRequest`, `VoiceServerType=webrtc` bei signierter und ausdruecklich freigeschalteter MediaGatewayUrl; signierte, beschraenkte JSON-Media-Exchange und .NET-Protokoll-Regressionen. Default `EnableFirestormGateway=false`. **Eine tatsaechliche kompatible SDP/DTLS/SRTP/SCTP-/LiveKit-Media-Bridge existiert dadurch noch NICHT.**
|
||||
- [x] **Remote-Speaker-Wire-Format:** Firestorm-konforme JSON-Nachrichten `j`/ `p` / `v` / `l` nach wahrer Avatar-UUID samt Tests. **Noch keine LiveKit-Mediaquelle, die diese Nachrichten in echte WebRTC-Datenkanaele sendet.**
|
||||
- [ ] Spatial-/Parcel-Voice mit Autorität des Simulators, Echtzeitpositionen und Distanz-/Richtungsmodell.
|
||||
- [ ] Eigene **graue Voice-Kugel über allen hör- und sichtbar verbundenen Avataren**; Remote-Speaking-Wellen auf dem tatsächlichen Sprecher, inklusive HG-Gästen; Viewerpräferenz respektieren.
|
||||
- [ ] Group Voice, Direktanruf, Push-to-Talk, Mute, Moderation, Parcel-/Regionwechsel.
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>disable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="../../../NexVerse/Core/Voice/OglVoiceFirestormWire.cs" Link="OglVoiceFirestormWire.cs" />
|
||||
<Compile Include="../../../NexVerse/Core/Voice/OglVoiceDiscoveryProof.cs" Link="OglVoiceDiscoveryProof.cs" />
|
||||
<Compile Include="../../../NexVerse/Core/Voice/OglVoiceMediaProof.cs" Link="OglVoiceMediaProof.cs" />
|
||||
<Compile Include="../../../NexVerse/Core/Voice/OglVoiceHypergridIdentity.cs" Link="OglVoiceHypergridIdentity.cs" />
|
||||
<Compile Include="../../../NexVerse/Core/Voice/OglVoiceLiveKitTokenIssuer.cs" Link="OglVoiceLiveKitTokenIssuer.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using NexVerse.Core.Voice;
|
||||
|
||||
static void Check(bool ok, string reason)
|
||||
{
|
||||
if (!ok) throw new Exception("OGLVoice Firestorm regression: " + reason);
|
||||
}
|
||||
static void Rejected(Action action, string reason)
|
||||
{
|
||||
try { action(); }
|
||||
catch (ArgumentException) { return; }
|
||||
throw new Exception("Should reject " + reason);
|
||||
}
|
||||
|
||||
string offer = "v=0\r\no=- 123 1 IN IP4 127.0.0.1\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111\r\na=ice-ufrag:abc\r\n";
|
||||
OglVoiceFirestormWire.ValidateOffer(offer);
|
||||
Rejected(() => OglVoiceFirestormWire.ValidateOffer("video only"), "wrong SDP");
|
||||
Rejected(() => OglVoiceFirestormWire.ValidateOffer("v=0\r\nm=video 9 UDP/TLS/RTP/SAVPF 96"), "missing audio");
|
||||
Rejected(() => OglVoiceFirestormWire.ValidateOffer("v=0\r\nm=audio " +
|
||||
new string('X', OglVoiceFirestormWire.MaximumSdpBytes)), "oversized SDP");
|
||||
OglVoiceFirestormWire.ValidateCandidates(new[] {
|
||||
new OglVoiceIceCandidate {
|
||||
candidate="candidate:1 1 UDP 1 127.0.0.1 1234 typ host",
|
||||
sdpMid="audio", sdpMLineIndex=0
|
||||
}
|
||||
}, false);
|
||||
OglVoiceFirestormWire.ValidateCandidates(Array.Empty<OglVoiceIceCandidate>(), true);
|
||||
Rejected(() => OglVoiceFirestormWire.ValidateCandidates(Array.Empty<OglVoiceIceCandidate>(), false),
|
||||
"empty ICE without completed");
|
||||
Rejected(() => OglVoiceFirestormWire.ValidateCandidates(new[] {
|
||||
new OglVoiceIceCandidate { candidate="bad", sdpMLineIndex=-1 }
|
||||
}, false), "invalid mline");
|
||||
Rejected(() => OglVoiceFirestormWire.ValidateCandidates(new[] {
|
||||
new OglVoiceIceCandidate { candidate=new string('X', 2048), sdpMLineIndex=0 }
|
||||
}, false), "oversized candidate");
|
||||
|
||||
byte[] encoded = JsonSerializer.SerializeToUtf8Bytes(new OglVoiceMediaReply {
|
||||
protocol=OglVoiceMediaExchange.Protocol,
|
||||
viewer_session="webRtcSession-123",
|
||||
sdp_answer=offer
|
||||
});
|
||||
OglVoiceMediaReply answer = OglVoiceFirestormWire.ParseAnswer(encoded, true);
|
||||
Check(answer.sdp_answer == offer && answer.viewer_session == "webRtcSession-123",
|
||||
"JSEP answer envelope");
|
||||
Rejected(() => OglVoiceFirestormWire.ParseAnswer(
|
||||
Encoding.UTF8.GetBytes("{\"protocol\":\"rogue\",\"viewer_session\":\"one\",\"sdp_answer\":\"v=0\\r\\nm=audio 9\"}"), true),
|
||||
"wrong protocol");
|
||||
Rejected(() => OglVoiceFirestormWire.ParseAnswer(
|
||||
Encoding.UTF8.GetBytes("{\"protocol\":\"oglvoice-firestorm-media-v1\",\"viewer_session\":\"bad/token\",\"sdp_answer\":\"v=0\\r\\nm=audio 9\"}"), true),
|
||||
"untrusted viewer session");
|
||||
Rejected(() => OglVoiceFirestormWire.ParseAnswer(new byte[OglVoiceFirestormWire.MaximumResponseBytes+1], true),
|
||||
"large backend response");
|
||||
Guid alice=Guid.NewGuid(), bob=Guid.NewGuid();
|
||||
using JsonDocument join = JsonDocument.Parse(OglVoiceFirestormWire.Join(alice));
|
||||
Check(join.RootElement.GetProperty(alice.ToString("D")).GetProperty("j").GetProperty("p").GetBoolean(),
|
||||
"joined avatar remote orb");
|
||||
using JsonDocument speak=JsonDocument.Parse(OglVoiceFirestormWire.Speaking(bob, 0.5f, true));
|
||||
JsonElement bobObj=speak.RootElement.GetProperty(bob.ToString("D"));
|
||||
Check(bobObj.GetProperty("v").GetBoolean() && bobObj.GetProperty("p").GetInt32()==64,
|
||||
"remote speaking orb power");
|
||||
using JsonDocument silence=JsonDocument.Parse(OglVoiceFirestormWire.Speaking(bob, 0, false));
|
||||
Check(!silence.RootElement.GetProperty(bob.ToString("D")).GetProperty("v").GetBoolean(),
|
||||
"remote speaking silence");
|
||||
using JsonDocument leave=JsonDocument.Parse(OglVoiceFirestormWire.Leave(alice));
|
||||
Check(leave.RootElement.GetProperty(alice.ToString("D")).GetProperty("l").GetBoolean(),
|
||||
"remote orb removal");
|
||||
Rejected(() => OglVoiceFirestormWire.Speaking(Guid.Empty, .5f, true), "empty avatar UUID");
|
||||
Rejected(() => OglVoiceFirestormWire.Speaking(bob, float.NaN, true), "nonfinite level");
|
||||
|
||||
OglVoiceProviderDescriptor safe = new() {
|
||||
provider_url="https://voice.example.test",
|
||||
media_gateway_url="https://bridge.example.test/internal/voice/v1",
|
||||
tenant_id="nexverse", viewer_capability="firestorm-webrtc-v1"
|
||||
};
|
||||
safe.Validate();
|
||||
Rejected(() => new OglVoiceProviderDescriptor {
|
||||
provider_url="https://voice.example.test",
|
||||
tenant_id="nexverse", viewer_capability="firestorm-webrtc-v1"
|
||||
}.Validate(), "voice enabled without actual media gateway URL");
|
||||
Rejected(() => new OglVoiceProviderDescriptor {
|
||||
provider_url="https://voice.example.test",
|
||||
media_gateway_url="http://public.example.org/gateway",
|
||||
tenant_id="nexverse", viewer_capability="firestorm-webrtc-v1"
|
||||
}.Validate(), "insecure bridge");
|
||||
const string sharedSecret = "ci-test-media-signed-key-over-32bytes";
|
||||
string challenge = OglVoiceDiscoveryProof.NewNonce();
|
||||
long now = 1791568800;
|
||||
byte[] largeSdpRequest = Encoding.UTF8.GetBytes(new string('a', 8192));
|
||||
string signedMedia = OglVoiceMediaProof.Sign(sharedSecret, "sim-freiburg", now, challenge, largeSdpRequest);
|
||||
Check(OglVoiceMediaProof.Verify(sharedSecret, "sim-freiburg", now.ToString(), challenge,
|
||||
largeSdpRequest, signedMedia, DateTimeOffset.FromUnixTimeSeconds(now)), "large SDP envelope HMAC");
|
||||
largeSdpRequest[10] ^= 1;
|
||||
Check(!OglVoiceMediaProof.Verify(sharedSecret, "sim-freiburg", now.ToString(), challenge,
|
||||
largeSdpRequest, signedMedia, DateTimeOffset.FromUnixTimeSeconds(now)), "media integrity");
|
||||
Check(!OglVoiceMediaProof.Verify(sharedSecret, "sim-stuttgart", now.ToString(), challenge,
|
||||
Encoding.UTF8.GetBytes(new string('a', 8192)), signedMedia,
|
||||
DateTimeOffset.FromUnixTimeSeconds(now)), "simulator node HMAC binding");
|
||||
Check(!OglVoiceMediaProof.Verify(sharedSecret, "sim-freiburg", now.ToString(), challenge,
|
||||
Encoding.UTF8.GetBytes(new string('a', 8192)), signedMedia,
|
||||
DateTimeOffset.FromUnixTimeSeconds(now + 70)), "media signature expires");
|
||||
Rejected(() => OglVoiceMediaProof.Sign(sharedSecret, "sim-freiburg", now, challenge,
|
||||
new byte[OglVoiceMediaProof.MaximumPayloadBytes + 1]), "unbounded media request");
|
||||
Console.WriteLine("Firestorm SDP/ICE, CAPS answer, speaker data channel and secure grid provider gating: OK");
|
||||
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Contract guard: Firestorm WebRTC viewer capabilities are opt-in and secure."""
|
||||
from pathlib import Path
|
||||
|
||||
root=Path(__file__).resolve().parents[2]
|
||||
region=(root/"NexVerse/RegionModules/Voice/OglVoiceFirestormCapsModule.cs").read_text()
|
||||
wire=(root/"NexVerse/Core/Voice/OglVoiceFirestormWire.cs").read_text()
|
||||
provider=(root/"NexVerse/Core/Voice/OglVoiceDiscoveryProof.cs").read_text()
|
||||
robust=(root/"NexVerse/Server/Api/NexVerseWorldApiConnector.cs").read_text()
|
||||
node=(root/"NexVerse/RegionModules/Voice/OglVoiceRegionDiscoveryModule.cs").read_text()
|
||||
for expected in ("OnRegisterCaps += RegisterCaps",
|
||||
"OnSimulatorFeaturesRequest += OnSimulatorFeaturesRequest",
|
||||
"VoiceServerType", 'OSD.FromString("webrtc")',
|
||||
'"ProvisionVoiceAccountRequest"', '"VoiceSignalingRequest"',
|
||||
"OSDParser.DeserializeLLSDXml",
|
||||
"OSDParser.SerializeLLSDXmlString",
|
||||
'offerType.AsString() != "offer"',
|
||||
"OglVoiceFirestormWire.ValidateOffer",
|
||||
"OglVoiceFirestormWire.ValidateCandidates",
|
||||
"OglVoiceMediaProof.Sign",
|
||||
"OglVoiceRegionAdmission.TryCreate",
|
||||
"AgentSessionId",
|
||||
"m_Sessions", "m_Requests.Wait(0)",
|
||||
"OglVoiceMediaExchange", "HttpClientHandler"):
|
||||
assert expected in region, expected
|
||||
for expected in ("media_gateway_url", "firestorm-webrtc-v1", "IsSafeServiceUri"):
|
||||
assert expected in provider, expected
|
||||
assert "EnableFirestormGateway" in robust
|
||||
assert "EnableFirestormGateway" in node
|
||||
assert "Firestorm" in wire
|
||||
assert "oglvoice-media-v1" in (root/"NexVerse/Core/Voice/OglVoiceMediaProof.cs").read_text()
|
||||
for word in ('["jsep"]','["viewer_session"]', 'viewer_session', 'candidate'):
|
||||
assert word in region
|
||||
for word in ("p = Math.Clamp", "v = isSpeaking", "l = true", "j = new", "MaximumSdpBytes"):
|
||||
assert word in wire, word
|
||||
for conf in ("bin/Robust.HG.ini.example","bin/Robust.ini.example"):
|
||||
section=(root/conf).read_text().split("[OGLVoice]",1)[1].split("\n[",1)[0]
|
||||
assert "EnableFirestormGateway = false" in section
|
||||
assert 'MediaGatewayUrl = ""' in section
|
||||
assert "EnableFirestormGateway = true" in (root/"bin/OpenSim.ini.example").read_text()
|
||||
assert "OGLVOICE_LIVEKIT_API_SECRET" not in region
|
||||
assert "OGLVOICE_LIVEKIT_API_KEY" not in region
|
||||
assert "ChatSessionRequest" not in region # no false group voice support
|
||||
assert "existing.AgentSessionId != admission.SessionId" in region
|
||||
assert "OglVoiceMediaProof.Sign" in region
|
||||
print("OGLVoice Firestorm LLSD CAPS and speaking-orb security guard: OK")
|
||||
Reference in new issue
Block a user