From a36c6c434cd77dae46eba225bd867950d9fae636 Mon Sep 17 00:00:00 2001 From: Kieran Date: Tue, 11 Jul 2023 20:54:52 +0100 Subject: [PATCH] Handle only source stream --- NostrStreamer/Controllers/SRSController.cs | 29 ++++++++++++++-------- NostrStreamer/Services/StreamManager.cs | 3 +-- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/NostrStreamer/Controllers/SRSController.cs b/NostrStreamer/Controllers/SRSController.cs index 55f78c6..8a08a5e 100644 --- a/NostrStreamer/Controllers/SRSController.cs +++ b/NostrStreamer/Controllers/SRSController.cs @@ -33,19 +33,28 @@ public class SrsController : Controller }; } - if (req.Action == "on_publish") + if (req.App.EndsWith("/source")) { - await _streamManager.StreamStarted(req.Stream); - return new(); + if (req.Action == "on_publish") + { + await _streamManager.StreamStarted(req.Stream); + return new(); + } + + if (req.Action == "on_unpublish") + { + await _streamManager.StreamStopped(req.Stream); + return new(); + } + + if (req.Action == "on_hls" && req.Duration.HasValue && !string.IsNullOrEmpty(req.ClientId)) + { + await _streamManager.ConsumeQuota(req.Stream, req.Duration.Value, req.ClientId); + return new(); + } } - if (req.Action == "on_unpublish") + else { - await _streamManager.StreamStopped(req.Stream); - return new(); - } - if (req.Action == "on_hls" && req.Duration.HasValue && !string.IsNullOrEmpty(req.ClientId)) - { - await _streamManager.ConsumeQuota(req.Stream, req.Duration.Value, req.ClientId, req.App); return new(); } } diff --git a/NostrStreamer/Services/StreamManager.cs b/NostrStreamer/Services/StreamManager.cs index 61f0b24..d2ea7c1 100644 --- a/NostrStreamer/Services/StreamManager.cs +++ b/NostrStreamer/Services/StreamManager.cs @@ -56,9 +56,8 @@ public class StreamManager await PublishEvent(user, ev); } - public async Task ConsumeQuota(string streamKey, double duration, string clientId, string app) + public async Task ConsumeQuota(string streamKey, double duration, string clientId) { - if (!app.EndsWith("/source")) return; var user = await GetUserFromStreamKey(streamKey); if (user == default) throw new Exception("No stream key found");