Skip to content

Commit

Permalink
Fix monitor switching in stream mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Nov 14, 2020
1 parent 7769ed9 commit ce345ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 7 additions & 1 deletion Desktop.Core/Services/WebRtcSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Remotely.Shared.Models.RemoteControlDtos;
using Remotely.Shared.Utilities;
using System;
using System.Drawing;
using System.Linq;
using System.Threading.Tasks;

Expand Down Expand Up @@ -174,14 +175,19 @@ private void GetCaptureFrame(in FrameRequest request)
{
try
{
if (!IsVideoTrackConnected)
{
return;
}

using var currentFrame = Viewer.Capturer.GetNextFrame();
if (currentFrame == null)
{
return;
}

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

Expand Down
5 changes: 3 additions & 2 deletions Desktop.Win/Services/ScreenCapturerWin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ public Bitmap GetNextFrame()
{
var (result, frame) = GetDirectXFrame();

if (result == GetDirectXFrameResult.Success)
if (result == GetDirectXFrameResult.Success ||
result == GetDirectXFrameResult.Timeout)
{
return frame;
}
Expand Down Expand Up @@ -289,11 +290,11 @@ private void InitDirectX()
using (var factory = new Factory1())
{
foreach (var adapter in factory.Adapters1.Where(x => (x.Outputs?.Length ?? 0) > 0))
foreach (var output in adapter.Outputs)
{
try
{
var device = new SharpDX.Direct3D11.Device(adapter);
var output = adapter.Outputs.FirstOrDefault();
var output1 = output.QueryInterface<Output1>();

var bounds = output1.Description.DesktopBounds;
Expand Down

0 comments on commit ce345ed

Please sign in to comment.