diff --git a/.gitignore b/.gitignore index 6a296ad..75a42c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,86 @@ +# ────────────────────────────────────────────── +# .NET +# ────────────────────────────────────────────── +bin/ +obj/ +*.user +*.suo +*.userosscache +*.sln.docstats +*.userprefs +*.csproj.user +**/Debug/ +**/Release/ + +# NuGet +packages/ +*.nupkg +**/[Pp]ackages/* +!**/[Pp]ackages/build/ +*.nuget.props +*.nuget.targets +.nuget/ + +# Test results +TestResults/ +coverage/ +*.trx +*.coverage +*.coveragexml + +# ────────────────────────────────────────────── +# Node.js / npm (Playwright tests, JS interop) +# ────────────────────────────────────────────── +node_modules/ +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Playwright +playwright-report/ +test-results/ + +# ────────────────────────────────────────────── +# Docker +# ────────────────────────────────────────────── +docker-compose.override.yml +docker/data/ +docker/pgdata/ +docker/recordings/ + +# ────────────────────────────────────────────── +# IDE +# ────────────────────────────────────────────── +.vs/ +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# Rider +.idea/ +*.sln.iml + +# ────────────────────────────────────────────── +# OS +# ────────────────────────────────────────────── +.DS_Store +Thumbs.db +*.log + +# ────────────────────────────────────────────── +# OpenCode +# ────────────────────────────────────────────── .opencode/local/ +.opencode/local/heartbeat-*.json +.opencode/local/current-session.json +.opencode/local/locks/ +.opencode/local/mail/ +.opencode/local/tasks/ + +# ────────────────────────────────────────────── +# Application data (created at runtime) +# ────────────────────────────────────────────── +wwwroot/uploads/ +logs/ diff --git a/.gitmodules b/.gitmodules index a0f2b7d..1f4946f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ [submodule ".opencode"] path = .opencode url = https://forgejo.tordais.cc/nonobis/opencode.git + branch = main diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..b5c3a31 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,24 @@ + + + net10.0 + enable + enable + true + latest-Recommended + true + $(NoWarn);NU1903;CA1848;CA1727 + + false + + + + + false + + + + + true + false + + diff --git a/Heimdall.slnx b/Heimdall.slnx new file mode 100644 index 0000000..d511a3b --- /dev/null +++ b/Heimdall.slnx @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/implementation.md b/docs/implementation.md index ec0f199..4808b0f 100644 --- a/docs/implementation.md +++ b/docs/implementation.md @@ -187,6 +187,7 @@ Mais orientée : * Worker Service * Communication API * Camera management +* **WebRTC streaming** (SIPSorcery + SIPSorceryMedia.FFmpeg) --- @@ -568,6 +569,162 @@ Implémentation : --- +# Phase 8b - WebRTC Streaming + +Ajoutée après Phase 8 (Video Pipeline) — dépend de FFmpeg et de l'Agent. + +## Objectif + +Permettre la visualisation en direct des caméras depuis le navigateur via WebRTC P2P. + +## Architecture + +```text +Agent (SIPSorcery) ◄═════ WebRTC P2P (SRTP/H264) ═════► Navigateur (Blazor) + │ │ + │ SignalR (SDP + ICE candidates) │ + └────────────────── Heimdall API ────────────────────────┘ +``` + +## Dépendances NuGet (Agent) + +``` +dotnet add package SIPSorcery +dotnet add package SIPSorceryMedia.FFmpeg +``` + +Dépendances côté Central : + +* SignalR (déjà dans ASP.NET Core) + +## Étapes d'implémentation + +### 8b.1 — SignalR Hub de signaling + +Créer dans `Heimdall.Api` : + +```csharp +public class StreamingHub : Hub +{ + // Agent → Central : enregistrement des flux disponibles + // Browser → Central : demande de flux + // Central relay SDP / ICE entre Agent et Browser +} +``` + +Tests : + +``` +Agent can register camera stream +Browser requests stream +SDP offer is relayed to browser +ICE candidates are exchanged +``` + +--- + +### 8b.2 — WebRTC Peer dans l'Agent (SIPSorcery) + +Créer dans `Heimdall.Agent` : + +```csharp +IWebRtcStreamingService + +RunAsync() // Démarre le pipeline +AddCameraTrack() // Ajoute un flux H264 depuis FFmpeg +CreateOffer() // Génère l'offre SDP +SetAnswer() // Reçoit l'answer du navigateur +AddIceCandidate() // Ajoute un ICE candidate +``` + +Utilise SIPSorcery : + +```csharp +var pc = new RTCPeerConnection(null); + +var ffmpegSource = new FFmpegVideoSource(rtspUrl); +ffmpegSource.OnVideoSourceEncodedSample += pc.SendVideo; + +var track = new MediaStreamTrack( + ffmpegSource.GetVideoSourceFormats(), + MediaStreamStatusEnum.SendOnly); +pc.addTrack(track); + +pc.onconnectionstatechange += async (state) => { ... }; +``` + +Tests : + +``` +RTSP stream produces H264 frames +WebRTC offer contains H264 codec +ICE candidates are generated +Connection state transitions correctly +``` + +--- + +### 8b.3 — Client Blazor WebRTC + +Dans `Heimdall.Web` : + +```typescript +// wwwroot/js/liveStream.js +const pc = new RTCPeerConnection({ + iceServers: [{ urls: 'stun:stun.l.google.com:19302' }] +}); + +pc.ontrack = (evt) => { + video.srcObject = evt.streams[0]; +}; + +// Connexion SignalR au hub /hubs/streaming +// Échange SDP + ICE +// Lecture du flux dans