Skip to content

Commit

Permalink
Handle errors in CreateFromArgb32Callback.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Aug 7, 2020
1 parent 23ada6e commit 0027d9e
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 20 deletions.
50 changes: 31 additions & 19 deletions Desktop.Core/Services/WebRtcSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,29 +207,41 @@ private void DataChannel_BufferingChanged(ulong previous, ulong current, ulong l

private void GetCaptureFrame(in FrameRequest request)
{
using (var currentFrame = Viewer.Capturer.GetNextFrame())
try
{
var bitmapData = currentFrame.LockBits(
Viewer.Capturer.CurrentScreenBounds,
System.Drawing.Imaging.ImageLockMode.ReadOnly,
System.Drawing.Imaging.PixelFormat.Format32bppArgb);

try
using (var currentFrame = Viewer.Capturer.GetNextFrame())
{
var frame = new Argb32VideoFrame()
if (currentFrame == null)
{
data = bitmapData.Scan0,
height = (uint)currentFrame.Height,
width = (uint)currentFrame.Width,
stride = bitmapData.Stride
};
request.CompleteRequest(in frame);
}
finally
{
currentFrame.UnlockBits(bitmapData);
}
return;
}

var bitmapData = currentFrame.LockBits(
Viewer.Capturer.CurrentScreenBounds,
System.Drawing.Imaging.ImageLockMode.ReadOnly,
System.Drawing.Imaging.PixelFormat.Format32bppArgb);

try
{
var frame = new Argb32VideoFrame()
{
data = bitmapData.Scan0,
height = (uint)currentFrame.Height,
width = (uint)currentFrame.Width,
stride = bitmapData.Stride
};
request.CompleteRequest(in frame);
}
finally
{
currentFrame.UnlockBits(bitmapData);
}

}
}
catch (Exception ex)
{
Logger.Write(ex);
}

}
Expand Down
5 changes: 5 additions & 0 deletions Server/wwwroot/scripts/DataGrid.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Server/wwwroot/scripts/DataGrid.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Server/wwwroot/scripts/DataGrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export function AddOrUpdateDevices(devices: Array<Device>) {
AddOrUpdateDevice(x, false);
});
ApplyFilter();
UpdateDeviceCounts();
}

export function AddOrUpdateDevice(device: Device, sortDevices: boolean) {
Expand All @@ -42,10 +43,17 @@ export function AddOrUpdateDevice(device: Device, sortDevices: boolean) {
}

if (sortDevices) {
var selectedDevices = GetSelectedDevices();

UI.DeviceGrid.querySelectorAll(".record-row").forEach(row => {
row.remove();
});
AddOrUpdateDevices(DataSource);

selectedDevices.forEach(x => {
document.getElementById(x.ID).classList.add("row-selected");
});

return;
}

Expand Down

0 comments on commit 0027d9e

Please sign in to comment.