diff --git a/Pages/Admin.cshtml b/Pages/Admin.cshtml
index 46eff1b..5d30412 100644
--- a/Pages/Admin.cshtml
+++ b/Pages/Admin.cshtml
@@ -51,7 +51,7 @@
var uptime = TimeSpan.FromMilliseconds(StreamUtils.GetClientTime(user.PrivateAccessKey, stats)).StripMilliseconds();
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) {
}
@@ -186,4 +186,4 @@ function prepareDeleteUserModal(target) {
-
\ No newline at end of file
+
diff --git a/Pages/Dashboard.cshtml b/Pages/Dashboard.cshtml
index d9d1ff7..7e0aeeb 100644
--- a/Pages/Dashboard.cshtml
+++ b/Pages/Dashboard.cshtml
@@ -117,8 +117,8 @@ else {
else if (user.IsPrivate && StreamUtils.IsLive(user.PrivateAccessKey, stats)) {
var uptime = TimeSpan.FromMilliseconds(StreamUtils.GetClientTime(user.PrivateAccessKey, stats)).StripMilliseconds();
if (user.AllowRestream && !string.IsNullOrWhiteSpace(user.RestreamTargets)) {
- if (StreamUtils.GetClientTime(user.Username, stats) > 5000) {
- var restreams = StreamUtils.CountLiveRestreams(user.PrivateAccessKey, stats);
+ if (StreamUtils.GetClientTime(user.PrivateAccessKey, stats) > 5000) {
+ var restreams = StreamUtils.CountLiveRestreams(user.Username, user.PrivateAccessKey, stats);
if (restreams > 0) {
}
@@ -268,4 +268,4 @@ else {
$.ajax({method: 'POST', data: {action: action, target: target, value: value, '__RequestVerificationToken' : '@tokenSet.RequestToken'}, success: function () { location.reload() }})
}
-}
\ No newline at end of file
+}
diff --git a/StreamUtils.cs b/StreamUtils.cs
index b5c595c..eca9945 100644
--- a/StreamUtils.cs
+++ b/StreamUtils.cs
@@ -33,6 +33,18 @@ namespace RTMPDash {
== 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 ListLiveUsers() => GetStatsObject()
.Server.Applications.First(p => p.Name == "ingress")
.MethodLive.Streams.Select(p => p.Name)
@@ -139,4 +151,4 @@ namespace RTMPDash {
[XmlElement(ElementName = "channels", IsNullable = true)] public string Channels { get; set; }
[XmlElement(ElementName = "sample_rate", IsNullable = true)] public string SampleRate { get; set; }
}
-}
\ No newline at end of file
+}