|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Xml.Serialization;
|
|
|
|
|
|
|
|
|
|
namespace RTMPDash.Backend;
|
|
|
|
@ -22,7 +22,7 @@ public static class StreamUtils {
|
|
|
|
|
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 == user && p.Clients.Any(c => c.Address == target.Replace("rtmp://", ""))));
|
|
|
|
|
.MethodLive.Streams.Any(p => p.Name == user && p.Clients.Any(c => c.Address == target.Replace("rtmp://", ""))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static int CountLiveRestreams(string user, string privateAccesskey, StatsObject stats) {
|
|
|
|
@ -30,13 +30,13 @@ public static class StreamUtils {
|
|
|
|
|
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://", ""))));
|
|
|
|
|
.MethodLive.Streams.Any(p => p.Name == privateAccesskey && p.Clients.Any(c => c.Address == target.Replace("rtmp://", ""))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static List<string> ListLiveUsers() => GetStatsObject().Server.Applications.First(p => p.Name == "ingress").MethodLive.Streams.Select(p => p.Name).ToList();
|
|
|
|
|
|
|
|
|
|
public static StatsObject GetStatsObject() {
|
|
|
|
|
var obj = (StatsObject)Serializer.Deserialize(new WebClient().OpenRead(Program.RtmpStatsUrl)!);
|
|
|
|
|
var obj = (StatsObject)Serializer.Deserialize(new HttpClient().GetStreamAsync(Program.RtmpStatsUrl).Result);
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|