Added monitoring and throttling of WebRTC output buffer.

This commit is contained in:
Jared Goodwin 2020-01-16 19:32:29 -08:00
parent 2a8d718243
commit 071fe5df29
3 changed files with 10 additions and 1 deletions

View File

@ -96,6 +96,12 @@ namespace Remotely.ScreenCast.Core.Capture
continue;
}
if (viewer.RtcSession?.CurrentBuffer > 100_000)
{
Debug.WriteLine($"Throttling output due to WebRTC buffer. Size: {viewer.RtcSession.CurrentBuffer}");
await Task.Delay((int)(viewer.RtcSession.CurrentBuffer - 100_000));
}
capturer.GetNextFrame();
var diffArea = ImageUtils.GetDiffArea(capturer.CurrentFrame, capturer.PreviousFrame, capturer.CaptureFullscreen);

View File

@ -16,6 +16,8 @@ namespace Remotely.ScreenCast.Core.Communication
public event EventHandler<string> LocalSdpReady;
public ulong CurrentBuffer { get; private set; }
public bool IsDataChannelOpen => CaptureChannel?.State == DataChannel.ChannelState.Open;
private DataChannel CaptureChannel { get; set; }
private PeerConnection PeerConnection { get; set; }
@ -84,6 +86,7 @@ namespace Remotely.ScreenCast.Core.Communication
private void DataChannel_BufferingChanged(ulong previous, ulong current, ulong limit)
{
Debug.WriteLine($"DataChannel buffering changed. Previous: {previous}. Current: {current}. Limit: {limit}.");
CurrentBuffer = current;
}
private void PeerConnection_Connected()

View File

@ -19,7 +19,7 @@
</div>
</div>
</div>
<table id="deviceGrid" class="table table-responsive table-hover table-striped">
<table id="deviceGrid" class="table table-hover table-striped">
<thead>
<tr>
<th>Online</th>