mirror of
https://github.com/BililiveRecorder/BililiveRecorder.git
synced 2024-11-16 11:42:22 +08:00
Add stream host to stats
This commit is contained in:
parent
bcc39843c1
commit
cbcbd840f0
|
@ -4,6 +4,11 @@ namespace BililiveRecorder.Core.Event
|
||||||
{
|
{
|
||||||
public sealed class IOStatsEventArgs : EventArgs
|
public sealed class IOStatsEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 直播服务器域名
|
||||||
|
/// </summary>
|
||||||
|
public string? StreamHost { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前统计区间的开始时间
|
/// 当前统计区间的开始时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -157,6 +157,7 @@ namespace BililiveRecorder.Core.Recording
|
||||||
|
|
||||||
this.OnIOStats(new IOStatsEventArgs
|
this.OnIOStats(new IOStatsEventArgs
|
||||||
{
|
{
|
||||||
|
StreamHost = streamHost,
|
||||||
NetworkBytesDownloaded = networkDownloadBytes,
|
NetworkBytesDownloaded = networkDownloadBytes,
|
||||||
Duration = durationDiff,
|
Duration = durationDiff,
|
||||||
StartTime = startTime,
|
StartTime = startTime,
|
||||||
|
|
|
@ -353,6 +353,7 @@ namespace BililiveRecorder.Core
|
||||||
{
|
{
|
||||||
this.logger.Verbose("IO stats: {@stats}", e);
|
this.logger.Verbose("IO stats: {@stats}", e);
|
||||||
|
|
||||||
|
this.Stats.StreamHost = e.StreamHost;
|
||||||
this.Stats.StartTime = e.StartTime;
|
this.Stats.StartTime = e.StartTime;
|
||||||
this.Stats.EndTime = e.EndTime;
|
this.Stats.EndTime = e.EndTime;
|
||||||
this.Stats.Duration = e.Duration;
|
this.Stats.Duration = e.Duration;
|
||||||
|
|
|
@ -9,6 +9,7 @@ namespace BililiveRecorder.Core
|
||||||
public class RoomStats : INotifyPropertyChanged
|
public class RoomStats : INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
#region IO Stats Fields
|
#region IO Stats Fields
|
||||||
|
private string? ___StreamHost;
|
||||||
private DateTimeOffset ___StartTime;
|
private DateTimeOffset ___StartTime;
|
||||||
private DateTimeOffset ___EndTime;
|
private DateTimeOffset ___EndTime;
|
||||||
private TimeSpan ___Duration;
|
private TimeSpan ___Duration;
|
||||||
|
@ -54,6 +55,11 @@ namespace BililiveRecorder.Core
|
||||||
|
|
||||||
#region IO Stats Properties
|
#region IO Stats Properties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 直播服务器域名
|
||||||
|
/// </summary>
|
||||||
|
public string? StreamHost { get => this.___StreamHost; set => this.SetField(ref this.___StreamHost, value); }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前统计区间的开始时间
|
/// 当前统计区间的开始时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -207,6 +213,8 @@ namespace BililiveRecorder.Core
|
||||||
|
|
||||||
// ------------------------------
|
// ------------------------------
|
||||||
|
|
||||||
|
this.StreamHost = null;
|
||||||
|
|
||||||
this.StartTime = default;
|
this.StartTime = default;
|
||||||
this.EndTime = default;
|
this.EndTime = default;
|
||||||
this.Duration = default;
|
this.Duration = default;
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
<TextBlock Visibility="{Binding Stats.DurationRatio,Converter={StaticResource IsNaNToVisibilityCollapsedConverter}}"
|
<TextBlock Visibility="{Binding Stats.DurationRatio,Converter={StaticResource IsNaNToVisibilityCollapsedConverter}}"
|
||||||
TextAlignment="Center" Text="{l:Loc RoomCard_Status_SpeedIndicator_NoData}"/>
|
TextAlignment="Center" Text="{l:Loc RoomCard_Status_SpeedIndicator_NoData}"/>
|
||||||
<StackPanel Visibility="{Binding Stats.DurationRatio,Converter={StaticResource InvertIsNaNToVisibilityCollapsedConverter}}">
|
<StackPanel Visibility="{Binding Stats.DurationRatio,Converter={StaticResource InvertIsNaNToVisibilityCollapsedConverter}}">
|
||||||
|
<TextBlock Text="{Binding Stats.StreamHost,StringFormat=直播服务器: {0}}"/>
|
||||||
<TextBlock>
|
<TextBlock>
|
||||||
<TextBlock.Text>
|
<TextBlock.Text>
|
||||||
<MultiBinding Converter="{l:StringFormatConverter}">
|
<MultiBinding Converter="{l:StringFormatConverter}">
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
l:ResxLocalizationProvider.DefaultDictionary="Strings"
|
l:ResxLocalizationProvider.DefaultDictionary="Strings"
|
||||||
xmlns:local="clr-namespace:BililiveRecorder.WPF.Controls"
|
xmlns:local="clr-namespace:BililiveRecorder.WPF.Controls"
|
||||||
xmlns:core="clr-namespace:BililiveRecorder.Core;assembly=BililiveRecorder.Core"
|
xmlns:core="clr-namespace:BililiveRecorder.Core;assembly=BililiveRecorder.Core"
|
||||||
d:DataContext="{d:DesignInstance core:Room}"
|
d:DataContext="{d:DesignInstance core:IRoom}"
|
||||||
d:DesignWidth="220" d:DesignHeight="110"
|
d:DesignWidth="220" d:DesignHeight="110"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<Border Background="{DynamicResource SystemControlBackgroundAltHighBrush}"
|
<Border Background="{DynamicResource SystemControlBackgroundAltHighBrush}"
|
||||||
|
|
|
@ -145,14 +145,14 @@ namespace BililiveRecorder.Web.Api
|
||||||
#region Get Room Stats
|
#region Get Room Stats
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 读取直播间统计信息
|
/// 读取直播间录制统计信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="roomId"></param>
|
/// <param name="roomId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("{roomId:int}/stats")]
|
[HttpGet("{roomId:int}/stats")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(typeof(RestApiError), StatusCodes.Status404NotFound)]
|
[ProducesResponseType(typeof(RestApiError), StatusCodes.Status404NotFound)]
|
||||||
public ActionResult<RoomRecordingStatsDto> GetRoomStats(int roomId)
|
public ActionResult<RoomRecordingStatsDto> GetRoomRecordingStats(int roomId)
|
||||||
{
|
{
|
||||||
var room = this.FetchRoom(roomId);
|
var room = this.FetchRoom(roomId);
|
||||||
if (room is null)
|
if (room is null)
|
||||||
|
@ -161,14 +161,14 @@ namespace BililiveRecorder.Web.Api
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 读取直播间统计信息
|
/// 读取直播间录制统计信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="objectId"></param>
|
/// <param name="objectId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("{objectId:guid}/stats")]
|
[HttpGet("{objectId:guid}/stats")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(typeof(RestApiError), StatusCodes.Status404NotFound)]
|
[ProducesResponseType(typeof(RestApiError), StatusCodes.Status404NotFound)]
|
||||||
public ActionResult<RoomRecordingStatsDto> GetRoomStats(Guid objectId)
|
public ActionResult<RoomRecordingStatsDto> GetRoomRecordingStats(Guid objectId)
|
||||||
{
|
{
|
||||||
var room = this.FetchRoom(objectId);
|
var room = this.FetchRoom(objectId);
|
||||||
if (room is null)
|
if (room is null)
|
||||||
|
@ -176,6 +176,38 @@ namespace BililiveRecorder.Web.Api
|
||||||
return this.mapper.Map<RoomRecordingStatsDto>(room.Stats);
|
return this.mapper.Map<RoomRecordingStatsDto>(room.Stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 读取直播间 IO 统计信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="roomId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("{roomId:int}/ioStats")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(typeof(RestApiError), StatusCodes.Status404NotFound)]
|
||||||
|
public ActionResult<RoomIOStatsDto> GetRoomIOStats(int roomId)
|
||||||
|
{
|
||||||
|
var room = this.FetchRoom(roomId);
|
||||||
|
if (room is null)
|
||||||
|
return this.NotFound(new RestApiError { Code = RestApiErrorCode.RoomNotFound, Message = "Room not found" });
|
||||||
|
return this.mapper.Map<RoomIOStatsDto>(room.Stats);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 读取直播间 IO 统计信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="objectId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("{objectId:guid}/ioStats")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(typeof(RestApiError), StatusCodes.Status404NotFound)]
|
||||||
|
public ActionResult<RoomIOStatsDto> GetRoomIOStats(Guid objectId)
|
||||||
|
{
|
||||||
|
var room = this.FetchRoom(objectId);
|
||||||
|
if (room is null)
|
||||||
|
return this.NotFound(new RestApiError { Code = RestApiErrorCode.RoomNotFound, Message = "Room not found" });
|
||||||
|
return this.mapper.Map<RoomIOStatsDto>(room.Stats);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
#region Room Config
|
#region Room Config
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ namespace BililiveRecorder.Web.Models.Graphql
|
||||||
{
|
{
|
||||||
public IOStatsType()
|
public IOStatsType()
|
||||||
{
|
{
|
||||||
|
this.Field(x => x.StreamHost, nullable: true);
|
||||||
this.Field(x => x.StartTime);
|
this.Field(x => x.StartTime);
|
||||||
this.Field(x => x.EndTime);
|
this.Field(x => x.EndTime);
|
||||||
this.Field(x => x.Duration, type: typeof(TimeSpanMillisecondsGraphType));
|
this.Field(x => x.Duration, type: typeof(TimeSpanMillisecondsGraphType));
|
||||||
|
|
|
@ -4,6 +4,11 @@ namespace BililiveRecorder.Web.Models.Rest
|
||||||
{
|
{
|
||||||
public class RoomIOStatsDto
|
public class RoomIOStatsDto
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 直播服务器域名
|
||||||
|
/// </summary>
|
||||||
|
public string? StreamHost { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前统计区间的开始时间
|
/// 当前统计区间的开始时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user