mediaportal/Core/Player/FrameGrabber.cs | 16 ++++++++++++---- mediaportal/Core/Player/PlaneScene.cs | 13 +++++++++++-- .../ProcessPlugins/ViewModeSwitcher/ViewModeSwitcher.cs | 5 +++-- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/mediaportal/Core/Player/FrameGrabber.cs b/mediaportal/Core/Player/FrameGrabber.cs index 99dea51..d8141d9 100644 --- a/mediaportal/Core/Player/FrameGrabber.cs +++ b/mediaportal/Core/Player/FrameGrabber.cs @@ -40,7 +40,8 @@ namespace MediaPortal private Surface rgbSurface = null; // surface used to hold frame grabs private bool grabSucceeded = false; // indicates success/failure of framegrabs private bool grabSample = false; // flag to indicate that a frame must be grabbed - private readonly object grabNotifier = new object(); // Wait/Notify object for waiting for the grab to complete + private bool grabIsFullScreenVideo = false; // indicates if the frame was grabbed from fullscreen video + private readonly object grabNotifier = new object(); // Wait/Notify object for waiting for the grab to complete private static FrameGrabber instance = null; @@ -49,7 +50,7 @@ namespace MediaPortal } // MP1-4248 : Start* Line Code for Ambilight System Capture (Atmolight) - public delegate void NewFrameHandler(Int16 width, Int16 height, Int16 arWidth, Int16 arHeight, uint pSurface); + public delegate void NewFrameHandler(Int16 width, Int16 height, Int16 arWidth, Int16 arHeight, uint pSurface, bool IsFullScreenVideo); public event NewFrameHandler OnNewFrame; // MP1-4248 : End* Ambilight Capture @@ -68,8 +69,9 @@ namespace MediaPortal /// from the VMR9 and return it as an RGB image /// /// Returns null on failure or a Bitmap object - public Bitmap GetCurrentImage() + public Bitmap GetCurrentImage(out bool IsFullScreenVideo) { + IsFullScreenVideo = false; try { //Log.Debug("GetCurrentImage called"); @@ -77,6 +79,7 @@ namespace MediaPortal lock (grabNotifier) { grabSucceeded = false; + grabIsFullScreenVideo = false; grabSample = true; if (!Monitor.Wait(grabNotifier, 500)) { @@ -93,6 +96,10 @@ namespace MediaPortal // IMPORTANT: Closes and disposes the stream // If this is not done we get a memory leak! stream.Close(); + + //return if we are in fullscreen video + IsFullScreenVideo = grabIsFullScreenVideo; + return b; } } @@ -163,7 +170,7 @@ namespace MediaPortal { try { - OnNewFrame(width, height, arWidth, arHeight, pSurface); + OnNewFrame(width, height, arWidth, arHeight, pSurface, GUIGraphicsContext.IsFullScreenVideo); } catch (Exception) { @@ -199,6 +206,7 @@ namespace MediaPortal { grabSample = false; grabSucceeded = true; + grabIsFullScreenVideo = GUIGraphicsContext.IsFullScreenVideo; Monitor.Pulse(grabNotifier); } } diff --git a/mediaportal/Core/Player/PlaneScene.cs b/mediaportal/Core/Player/PlaneScene.cs index bf79601..a471077 100644 --- a/mediaportal/Core/Player/PlaneScene.cs +++ b/mediaportal/Core/Player/PlaneScene.cs @@ -503,8 +503,17 @@ namespace MediaPortal.Player try { // Alert the frame grabber that it has a chance to grab a frame - // if it likes (method returns immediately otherwise - grabber.OnFrame(width, height, arWidth, arHeight, pSurface); + // if it likes (method returns immediately otherwise + if (GUIGraphicsContext.IsFullScreenVideo) + { + //we are in fullscreen mode -> use video surface + grabber.OnFrame(width, height, arWidth, arHeight, pSurface); + } + else + { + //If we are not in fullscreen, call OnFrame without parameter to use the actual GUI backbuffer + grabber.OnFrame(); + } _textureAddress = pTexture; diff --git a/mediaportal/ProcessPlugins/ViewModeSwitcher/ViewModeSwitcher.cs b/mediaportal/ProcessPlugins/ViewModeSwitcher/ViewModeSwitcher.cs index 4230600..5158120 100644 --- a/mediaportal/ProcessPlugins/ViewModeSwitcher/ViewModeSwitcher.cs +++ b/mediaportal/ProcessPlugins/ViewModeSwitcher/ViewModeSwitcher.cs @@ -649,6 +649,7 @@ namespace ProcessPlugins.ViewModeSwitcher private void SingleCrop() { bool updateCrop = false; + bool IsFullScreenVideo = false; if (LastSwitchedAspectRatio < 0.1f) { @@ -662,9 +663,9 @@ namespace ProcessPlugins.ViewModeSwitcher return; } - Bitmap frame = grabber.GetCurrentImage(); + Bitmap frame = grabber.GetCurrentImage(out IsFullScreenVideo); - if (frame == null || frame.Height == 0 || frame.Width == 0) + if (frame == null || frame.Height == 0 || frame.Width == 0 || IsFullScreenVideo == false) { LastDetectionResult = false; return;