Fix restreams on private streams
This commit is contained in:
parent
c097947164
commit
a5f66216c9
|
@ -51,7 +51,7 @@
|
||||||
var uptime = TimeSpan.FromMilliseconds(StreamUtils.GetClientTime(user.PrivateAccessKey, stats)).StripMilliseconds();
|
var uptime = TimeSpan.FromMilliseconds(StreamUtils.GetClientTime(user.PrivateAccessKey, stats)).StripMilliseconds();
|
||||||
|
|
||||||
if (user.AllowRestream && !string.IsNullOrWhiteSpace(user.RestreamTargets)) {
|
if (user.AllowRestream && !string.IsNullOrWhiteSpace(user.RestreamTargets)) {
|
||||||
var restreams = StreamUtils.CountLiveRestreams(user.PrivateAccessKey, stats);
|
var restreams = StreamUtils.CountLiveRestreams(user.Username, user.PrivateAccessKey, stats);
|
||||||
if (restreams > 0) {
|
if (restreams > 0) {
|
||||||
<button class="btn btn-dark" role="button" style="width:18ch" disabled>Restreaming (@restreams)</button>
|
<button class="btn btn-dark" role="button" style="width:18ch" disabled>Restreaming (@restreams)</button>
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,8 +117,8 @@ else {
|
||||||
else if (user.IsPrivate && StreamUtils.IsLive(user.PrivateAccessKey, stats)) {
|
else if (user.IsPrivate && StreamUtils.IsLive(user.PrivateAccessKey, stats)) {
|
||||||
var uptime = TimeSpan.FromMilliseconds(StreamUtils.GetClientTime(user.PrivateAccessKey, stats)).StripMilliseconds();
|
var uptime = TimeSpan.FromMilliseconds(StreamUtils.GetClientTime(user.PrivateAccessKey, stats)).StripMilliseconds();
|
||||||
if (user.AllowRestream && !string.IsNullOrWhiteSpace(user.RestreamTargets)) {
|
if (user.AllowRestream && !string.IsNullOrWhiteSpace(user.RestreamTargets)) {
|
||||||
if (StreamUtils.GetClientTime(user.Username, stats) > 5000) {
|
if (StreamUtils.GetClientTime(user.PrivateAccessKey, stats) > 5000) {
|
||||||
var restreams = StreamUtils.CountLiveRestreams(user.PrivateAccessKey, stats);
|
var restreams = StreamUtils.CountLiveRestreams(user.Username, user.PrivateAccessKey, stats);
|
||||||
if (restreams > 0) {
|
if (restreams > 0) {
|
||||||
<button class="btn btn-success" role="button" style="width:20ch" disabled>Live & restreaming</button>
|
<button class="btn btn-success" role="button" style="width:20ch" disabled>Live & restreaming</button>
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,18 @@ namespace RTMPDash {
|
||||||
== target.Replace("rtmp://", ""))));
|
== target.Replace("rtmp://", ""))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int CountLiveRestreams(string user, string privateAccesskey, StatsObject stats) {
|
||||||
|
var db = new AppDb.DbConn();
|
||||||
|
var dbUser = db.Users.First(p => p.Username == user);
|
||||||
|
return dbUser.RestreamTargets.Split(",")
|
||||||
|
.Count(target => stats.Server.Applications.First(p => p.Name == "ingress")
|
||||||
|
.MethodLive.Streams
|
||||||
|
.Any(p => p.Name == privateAccesskey
|
||||||
|
&& p.Clients.Any(c => c.Address
|
||||||
|
== target.Replace("rtmp://", ""))));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static List<string> ListLiveUsers() => GetStatsObject()
|
public static List<string> ListLiveUsers() => GetStatsObject()
|
||||||
.Server.Applications.First(p => p.Name == "ingress")
|
.Server.Applications.First(p => p.Name == "ingress")
|
||||||
.MethodLive.Streams.Select(p => p.Name)
|
.MethodLive.Streams.Select(p => p.Name)
|
||||||
|
|
Loading…
Reference in a new issue