Handle only source stream
This commit is contained in:
@ -33,19 +33,28 @@ public class SrsController : Controller
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (req.App.EndsWith("/source"))
|
||||||
|
{
|
||||||
if (req.Action == "on_publish")
|
if (req.Action == "on_publish")
|
||||||
{
|
{
|
||||||
await _streamManager.StreamStarted(req.Stream);
|
await _streamManager.StreamStarted(req.Stream);
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.Action == "on_unpublish")
|
if (req.Action == "on_unpublish")
|
||||||
{
|
{
|
||||||
await _streamManager.StreamStopped(req.Stream);
|
await _streamManager.StreamStopped(req.Stream);
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.Action == "on_hls" && req.Duration.HasValue && !string.IsNullOrEmpty(req.ClientId))
|
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();
|
return new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,9 +56,8 @@ public class StreamManager
|
|||||||
await PublishEvent(user, ev);
|
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);
|
var user = await GetUserFromStreamKey(streamKey);
|
||||||
if (user == default) throw new Exception("No stream key found");
|
if (user == default) throw new Exception("No stream key found");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user