Handle only source stream

This commit is contained in:
2023-07-11 20:54:52 +01:00
parent 12989857a1
commit a36c6c434c
2 changed files with 20 additions and 12 deletions

View File

@ -33,19 +33,28 @@ public class SrsController : Controller
};
}
if (req.App.EndsWith("/source"))
{
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, req.App);
await _streamManager.ConsumeQuota(req.Stream, req.Duration.Value, req.ClientId);
return new();
}
}
else
{
return new();
}
}

View File

@ -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");