mirror of
https://github.com/BililiveRecorder/BililiveRecorder.git
synced 2024-11-15 19:22:19 +08:00
Core: Rename NetworkingStats to IOStats
This commit is contained in:
parent
3fc90d4f57
commit
98b751e8c6
|
@ -2,7 +2,7 @@ using System;
|
|||
|
||||
namespace BililiveRecorder.Core.Event
|
||||
{
|
||||
public class NetworkingStatsEventArgs : EventArgs
|
||||
public class IOStatsEventArgs : EventArgs
|
||||
{
|
||||
public DateTimeOffset StartTime { get; set; }
|
||||
|
||||
|
@ -10,8 +10,8 @@ namespace BililiveRecorder.Core.Event
|
|||
|
||||
public TimeSpan Duration { get; set; }
|
||||
|
||||
public int BytesDownloaded { get; set; }
|
||||
public int NetworkBytesDownloaded { get; set; }
|
||||
|
||||
public double Mbps { get; set; }
|
||||
public double NetworkMbps { get; set; }
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ namespace BililiveRecorder.Core
|
|||
event EventHandler<AggregatedRoomEventArgs<RecordSessionEndedEventArgs>>? RecordSessionEnded;
|
||||
event EventHandler<AggregatedRoomEventArgs<RecordFileOpeningEventArgs>>? RecordFileOpening;
|
||||
event EventHandler<AggregatedRoomEventArgs<RecordFileClosedEventArgs>>? RecordFileClosed;
|
||||
event EventHandler<AggregatedRoomEventArgs<NetworkingStatsEventArgs>>? NetworkingStats;
|
||||
event EventHandler<AggregatedRoomEventArgs<IOStatsEventArgs>>? IOStats;
|
||||
event EventHandler<AggregatedRoomEventArgs<RecordingStatsEventArgs>>? RecordingStats;
|
||||
|
||||
void AddRoom(int roomid);
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace BililiveRecorder.Core
|
|||
event EventHandler<RecordFileOpeningEventArgs>? RecordFileOpening;
|
||||
event EventHandler<RecordFileClosedEventArgs>? RecordFileClosed;
|
||||
event EventHandler<RecordingStatsEventArgs>? RecordingStats;
|
||||
event EventHandler<NetworkingStatsEventArgs>? NetworkingStats;
|
||||
event EventHandler<IOStatsEventArgs>? IOStats;
|
||||
|
||||
void StartRecord();
|
||||
void StopRecord();
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace BililiveRecorder.Core
|
|||
public event EventHandler<AggregatedRoomEventArgs<RecordSessionEndedEventArgs>>? RecordSessionEnded;
|
||||
public event EventHandler<AggregatedRoomEventArgs<RecordFileOpeningEventArgs>>? RecordFileOpening;
|
||||
public event EventHandler<AggregatedRoomEventArgs<RecordFileClosedEventArgs>>? RecordFileClosed;
|
||||
public event EventHandler<AggregatedRoomEventArgs<NetworkingStatsEventArgs>>? NetworkingStats;
|
||||
public event EventHandler<AggregatedRoomEventArgs<IOStatsEventArgs>>? IOStats;
|
||||
public event EventHandler<AggregatedRoomEventArgs<RecordingStatsEventArgs>>? RecordingStats;
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
|
@ -80,7 +80,7 @@ namespace BililiveRecorder.Core
|
|||
room.RecordSessionEnded += this.Room_RecordSessionEnded;
|
||||
room.RecordFileOpening += this.Room_RecordFileOpening;
|
||||
room.RecordFileClosed += this.Room_RecordFileClosed;
|
||||
room.NetworkingStats += this.Room_NetworkingStats;
|
||||
room.IOStats += this.Room_IOStats;
|
||||
room.RecordingStats += this.Room_RecordingStats;
|
||||
room.PropertyChanged += this.Room_PropertyChanged;
|
||||
|
||||
|
@ -120,10 +120,10 @@ namespace BililiveRecorder.Core
|
|||
|
||||
#region Events
|
||||
|
||||
private void Room_NetworkingStats(object sender, NetworkingStatsEventArgs e)
|
||||
private void Room_IOStats(object sender, IOStatsEventArgs e)
|
||||
{
|
||||
var room = (IRoom)sender;
|
||||
NetworkingStats?.Invoke(this, new AggregatedRoomEventArgs<NetworkingStatsEventArgs>(room, e));
|
||||
IOStats?.Invoke(this, new AggregatedRoomEventArgs<IOStatsEventArgs>(room, e));
|
||||
}
|
||||
|
||||
private void Room_RecordingStats(object sender, RecordingStatsEventArgs e)
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace BililiveRecorder.Core.Recording
|
|||
{
|
||||
Guid SessionId { get; }
|
||||
|
||||
event EventHandler<NetworkingStatsEventArgs>? NetworkingStats;
|
||||
event EventHandler<IOStatsEventArgs>? IOStats;
|
||||
event EventHandler<RecordingStatsEventArgs>? RecordingStats;
|
||||
event EventHandler<RecordFileOpeningEventArgs>? RecordFileOpening;
|
||||
event EventHandler<RecordFileClosedEventArgs>? RecordFileClosed;
|
||||
|
|
|
@ -46,20 +46,20 @@ namespace BililiveRecorder.Core.Recording
|
|||
|
||||
this.ct = this.cts.Token;
|
||||
|
||||
this.timer.Elapsed += this.Timer_Elapsed_TriggerNetworkStats;
|
||||
this.timer.Elapsed += this.Timer_Elapsed_TriggerIOStats;
|
||||
}
|
||||
|
||||
public Guid SessionId { get; } = Guid.NewGuid();
|
||||
|
||||
#region Events
|
||||
|
||||
public event EventHandler<NetworkingStatsEventArgs>? NetworkingStats;
|
||||
public event EventHandler<IOStatsEventArgs>? IOStats;
|
||||
public event EventHandler<RecordingStatsEventArgs>? RecordingStats;
|
||||
public event EventHandler<RecordFileOpeningEventArgs>? RecordFileOpening;
|
||||
public event EventHandler<RecordFileClosedEventArgs>? RecordFileClosed;
|
||||
public event EventHandler? RecordSessionEnded;
|
||||
|
||||
protected void OnNetworkingStats(NetworkingStatsEventArgs e) => NetworkingStats?.Invoke(this, e);
|
||||
protected void OnIOStats(IOStatsEventArgs e) => IOStats?.Invoke(this, e);
|
||||
protected void OnRecordingStats(RecordingStatsEventArgs e) => RecordingStats?.Invoke(this, e);
|
||||
protected void OnRecordFileOpening(RecordFileOpeningEventArgs e) => RecordFileOpening?.Invoke(this, e);
|
||||
protected void OnRecordFileClosed(RecordFileClosedEventArgs e) => RecordFileClosed?.Invoke(this, e);
|
||||
|
@ -116,7 +116,7 @@ namespace BililiveRecorder.Core.Recording
|
|||
|
||||
protected abstract void StartRecordingLoop(Stream stream);
|
||||
|
||||
private void Timer_Elapsed_TriggerNetworkStats(object sender, ElapsedEventArgs e)
|
||||
private void Timer_Elapsed_TriggerIOStats(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
int bytes;
|
||||
TimeSpan diff;
|
||||
|
@ -135,19 +135,19 @@ namespace BililiveRecorder.Core.Recording
|
|||
|
||||
var mbps = bytes * (8d / 1024d / 1024d) / diff.TotalSeconds;
|
||||
|
||||
this.OnNetworkingStats(new NetworkingStatsEventArgs
|
||||
this.OnIOStats(new IOStatsEventArgs
|
||||
{
|
||||
BytesDownloaded = bytes,
|
||||
NetworkBytesDownloaded = bytes,
|
||||
Duration = diff,
|
||||
StartTime = start,
|
||||
EndTime = end,
|
||||
Mbps = mbps
|
||||
NetworkMbps = mbps
|
||||
});
|
||||
|
||||
if ((!this.timeoutTriggered) && (this.durationSinceNoDataReceived.TotalMilliseconds > this.room.RoomConfig.TimingWatchdogTimeout))
|
||||
{
|
||||
this.timeoutTriggered = true;
|
||||
this.logger.Warning("直播服务器未断开连接但停止发送直播数据,将会主动断开连接");
|
||||
this.logger.Warning("检测到录制卡住,可能是网络或硬盘原因,将会主动断开连接");
|
||||
this.RequestStop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace BililiveRecorder.Core
|
|||
public event EventHandler<RecordSessionEndedEventArgs>? RecordSessionEnded;
|
||||
public event EventHandler<RecordFileOpeningEventArgs>? RecordFileOpening;
|
||||
public event EventHandler<RecordFileClosedEventArgs>? RecordFileClosed;
|
||||
public event EventHandler<NetworkingStatsEventArgs>? NetworkingStats;
|
||||
public event EventHandler<IOStatsEventArgs>? IOStats;
|
||||
public event EventHandler<RecordingStatsEventArgs>? RecordingStats;
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
|
@ -219,7 +219,7 @@ namespace BililiveRecorder.Core
|
|||
return;
|
||||
|
||||
var task = this.recordTaskFactory.CreateRecordTask(this);
|
||||
task.NetworkingStats += this.RecordTask_NetworkingStats;
|
||||
task.IOStats += this.RecordTask_IOStats;
|
||||
task.RecordingStats += this.RecordTask_RecordingStats;
|
||||
task.RecordFileOpening += this.RecordTask_RecordFileOpening;
|
||||
task.RecordFileClosed += this.RecordTask_RecordFileClosed;
|
||||
|
@ -349,13 +349,13 @@ namespace BililiveRecorder.Core
|
|||
#region Event Handlers
|
||||
|
||||
///
|
||||
private void RecordTask_NetworkingStats(object sender, NetworkingStatsEventArgs e)
|
||||
private void RecordTask_IOStats(object sender, IOStatsEventArgs e)
|
||||
{
|
||||
this.logger.Verbose("Networking stats: {@stats}", e);
|
||||
this.logger.Verbose("IO stats: {@stats}", e);
|
||||
|
||||
this.Stats.NetworkMbps = e.Mbps;
|
||||
this.Stats.NetworkMbps = e.NetworkMbps;
|
||||
|
||||
NetworkingStats?.Invoke(this, e);
|
||||
IOStats?.Invoke(this, e);
|
||||
}
|
||||
|
||||
///
|
||||
|
|
Loading…
Reference in New Issue
Block a user