mediaportal/Core/Player/FrameGrabber.cs | 34 +++++++++++++++-------
mediaportal/Core/Player/PlaneScene.cs | 12 ++++++--
mediaportal/MediaPortal.Application/MediaPortal.cs | 9 ++++--
3 files changed, 40 insertions(+), 15 deletions(-)
diff --git a/mediaportal/Core/Player/FrameGrabber.cs b/mediaportal/Core/Player/FrameGrabber.cs
index 99dea51..ebf7475 100644
--- a/mediaportal/Core/Player/FrameGrabber.cs
+++ b/mediaportal/Core/Player/FrameGrabber.cs
@@ -42,6 +42,14 @@ namespace MediaPortal
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
+ //FrameSource enum for NewFrameHandler
+ public enum FrameSource
+ {
+ undefined = -1,
+ GUI = 0,
+ Video
+ }
+
private static FrameGrabber instance = null;
private FrameGrabber()
@@ -49,7 +57,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, int iFrameSource = (int)FrameSource.undefined);
public event NewFrameHandler OnNewFrame;
// MP1-4248 : End* Ambilight Capture
@@ -120,30 +128,30 @@ namespace MediaPortal
}
///
- /// Callback that gives the framegrabber a chance to grab the frame
+ /// Callback that gives the framegrabber a chance to grab a GUI frame
///
- public void OnFrame()
+ public void OnFrameGUI()
{
- if (OnNewFrame != null)
+ if ((OnNewFrame != null) && (!GUIGraphicsContext.IsFullScreenVideo))
{
using (Surface surface = GUIGraphicsContext.DX9Device.GetBackBuffer(0, 0, BackBufferType.Mono))
{
- OnFrame(surface);
+ OnFrameGUI(surface);
}
}
}
///
- /// Callback that gives the framegrabber a chance to grab the frame
+ /// Callback that gives the framegrabber a chance to grab a GUI frame
///
///
- public void OnFrame(Surface surface)
+ public void OnFrameGUI(Surface surface)
{
- if (OnNewFrame != null)
+ if ((OnNewFrame != null) && (!GUIGraphicsContext.IsFullScreenVideo))
{
unsafe
{
- OnFrame((Int16)surface.Description.Width, (Int16)surface.Description.Height, 0, 0, (uint)surface.UnmanagedComPointer);
+ OnFrame((Int16)surface.Description.Width, (Int16)surface.Description.Height, 0, 0, (uint)surface.UnmanagedComPointer, FrameSource.GUI);
}
}
}
@@ -156,14 +164,15 @@ namespace MediaPortal
///
///
///
- public void OnFrame(Int16 width, Int16 height, Int16 arWidth, Int16 arHeight, uint pSurface)
+ public void OnFrame(Int16 width, Int16 height, Int16 arWidth, Int16 arHeight, uint pSurface, FrameSource FrameSource)
{
// MP1-4248 :Start* Line Code for Ambilight System Capture (Atmolight)
if (OnNewFrame != null)
{
try
{
- OnNewFrame(width, height, arWidth, arHeight, pSurface);
+ //raise event to any subcribers for event NewFrameHandler
+ OnNewFrame(width, height, arWidth, arHeight, pSurface, (int)FrameSource);
}
catch (Exception)
{
@@ -171,6 +180,9 @@ namespace MediaPortal
}
// MP1-4248 :End* Ambilight Capture code
+ //Dont pass GUI frames to GetCurrentImage() -> VideoModeSwitcher is using it
+ if (FrameSource == FrameGrabber.FrameSource.GUI) return;
+
// Is GetCurrentImage() requesting a frame grab?
if (!grabSample || width == 0 || height == 0)
{
diff --git a/mediaportal/Core/Player/PlaneScene.cs b/mediaportal/Core/Player/PlaneScene.cs
index bf79601..b370932 100644
--- a/mediaportal/Core/Player/PlaneScene.cs
+++ b/mediaportal/Core/Player/PlaneScene.cs
@@ -502,9 +502,9 @@ namespace MediaPortal.Player
{
try
{
- // Alert the frame grabber that it has a chance to grab a frame
+ // Alert the frame grabber that it has a chance to grab a video frame
// if it likes (method returns immediately otherwise
- grabber.OnFrame(width, height, arWidth, arHeight, pSurface);
+ grabber.OnFrame(width, height, arWidth, arHeight, pSurface, FrameGrabber.FrameSource.Video);
_textureAddress = pTexture;
@@ -696,6 +696,10 @@ namespace MediaPortal.Player
GUIGraphicsContext.Render3DMode == GUIGraphicsContext.eRender3DMode.TopAndBottomTo2D)
{
// old output path or force 3D material to 2D by blitting only left/top halp
+
+ // Alert the frame grabber that it has a chance to grab a GUI frame
+ // if it likes (method returns immediately otherwise
+ grabber.OnFrameGUI();
GUIGraphicsContext.Render3DModeHalf = GUIGraphicsContext.eRender3DModeHalf.None;
@@ -730,6 +734,10 @@ namespace MediaPortal.Player
// 3D output either SBS or TAB
Surface backbuffer = GUIGraphicsContext.DX9Device.GetBackBuffer(0, 0, BackBufferType.Mono);
+
+ // Alert the frame grabber that it has a chance to grab a GUI frame
+ // if it likes (method returns immediately otherwise
+ grabber.OnFrameGUI(backbuffer);
// create texture/surface for preparation for 3D output if they don't exist
diff --git a/mediaportal/MediaPortal.Application/MediaPortal.cs b/mediaportal/MediaPortal.Application/MediaPortal.cs
index 647bee1..b360a63 100644
--- a/mediaportal/MediaPortal.Application/MediaPortal.cs
+++ b/mediaportal/MediaPortal.Application/MediaPortal.cs
@@ -3141,7 +3141,10 @@ public class MediaPortalApp : D3D, IRender
GUIGraphicsContext.Render3DMode == GUIGraphicsContext.eRender3DMode.SideBySideTo2D ||
GUIGraphicsContext.Render3DMode == GUIGraphicsContext.eRender3DMode.TopAndBottomTo2D)
{
- grabber.OnFrame();
+
+ // Alert the frame grabber that it has a chance to grab a GUI frame
+ // if it likes (method returns immediately otherwise
+ grabber.OnFrameGUI();
// clear the surface
GUIGraphicsContext.DX9Device.Clear(ClearFlags.Target, Color.Black, 1.0f, 0);
@@ -3176,7 +3179,9 @@ public class MediaPortalApp : D3D, IRender
Surface backbuffer = GUIGraphicsContext.DX9Device.GetBackBuffer(0, 0, BackBufferType.Mono);
- grabber.OnFrame(backbuffer);
+ // Alert the frame grabber that it has a chance to grab a GUI frame
+ // if it likes (method returns immediately otherwise
+ grabber.OnFrameGUI(backbuffer);
// create texture/surface for preparation for 3D output if they don't exist