home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 2
Plugin Development
AtmoLight 2.1.0.0 for MediaPortal2 [2015-01-21]
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Lightning303" data-source="post: 1077222" data-attributes="member: 97876"><p>To be honest, you lost me there already <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite3" alt=":(" title="Frown :(" loading="lazy" data-shortname=":(" />. But no hurry, maybe when you are on you pc and have a spare 5 minutes you could look at this. I will try to explain what we are using right now for MP1. However, i did not build this, i just inharited it, especially the framegrabber part.</p><p></p><p>In MP1 we use an event handler, like this:</p><p>[CODE=C#] FrameGrabber.GetInstance().OnNewFrame += new FrameGrabber.NewFrameHandler(AtmolightPlugin_OnNewFrame);</p><p></p><p> private void AtmolightPlugin_OnNewFrame(short width, short height, short arWidth, short arHeight, uint pSurface)</p><p> {</p><p> if (playbackEffect != ContentEffect.MediaPortalLiveMode || atmoOff || atmoCtrl == null || width == 0 || height == 0 || reInitializeLock)</p><p> {</p><p> return;</p><p> }</p><p></p><p> if (rgbSurface == null)</p><p> {</p><p> rgbSurface = GUIGraphicsContext.DX9Device.CreateRenderTarget(captureWidth, captureHeight, Format.A8R8G8B8,</p><p> MultiSampleType.None, 0, true);</p><p> }</p><p> unsafe</p><p> {</p><p> try</p><p> {</p><p> if (AtmolightSettings.sbs3dOn)</p><p> {</p><p> VideoSurfaceToRGBSurfaceExt(new IntPtr(pSurface), width / 2, height, (IntPtr)rgbSurface.UnmanagedComPointer,</p><p> captureWidth, captureHeight);</p><p> }</p><p> else</p><p> {</p><p> VideoSurfaceToRGBSurfaceExt(new IntPtr(pSurface), width, height, (IntPtr)rgbSurface.UnmanagedComPointer,</p><p> captureWidth, captureHeight);</p><p> }</p><p></p><p> Microsoft.DirectX.GraphicsStream stream = SurfaceLoader.SaveToStream(ImageFileFormat.Bmp, rgbSurface);</p><p></p><p> BinaryReader reader = new BinaryReader(stream);</p><p> stream.Position = 0; // ensure that what start at the beginning of the stream.</p><p> reader.ReadBytes(14); // skip bitmap file info header</p><p> byte[] bmiInfoHeader = reader.ReadBytes(4 + 4 + 4 + 2 + 2 + 4 + 4 + 4 + 4 + 4 + 4);</p><p></p><p> int rgbL = (int)(stream.Length - stream.Position);</p><p> int rgb = (int)(rgbL / (captureWidth * captureHeight));</p><p></p><p> byte[] pixelData = reader.ReadBytes((int)(stream.Length - stream.Position));</p><p></p><p> byte[] h1pixelData = new byte[captureWidth * rgb];</p><p> byte[] h2pixelData = new byte[captureWidth * rgb];</p><p> //now flip horizontally, we do it always to prevent microstudder</p><p> int i;</p><p> for (i = 0; i < ((captureHeight / 2) - 1); i++)</p><p> {</p><p> Array.Copy(pixelData, i * captureWidth * rgb, h1pixelData, 0, captureWidth * rgb);</p><p> Array.Copy(pixelData, (captureHeight - i - 1) * captureWidth * rgb, h2pixelData, 0, captureWidth * rgb);</p><p> Array.Copy(h1pixelData, 0, pixelData, (captureHeight - i - 1) * captureWidth * rgb, captureWidth * rgb);</p><p> Array.Copy(h2pixelData, 0, pixelData, i * captureWidth * rgb, captureWidth * rgb);</p><p> }</p><p> //send scaled and fliped frame to atmowin</p><p> if (!AtmolightSettings.lowCPU ||</p><p> (((Win32API.GetTickCount() - lastFrame) > AtmolightSettings.lowCPUTime) && AtmolightSettings.lowCPU))</p><p> {</p><p> if (AtmolightSettings.lowCPU)</p><p> {</p><p> lastFrame = Win32API.GetTickCount();</p><p> }</p><p> atmoLiveViewCtrl.setPixelData(bmiInfoHeader, pixelData);</p><p> }</p><p> stream.Close();</p><p> stream.Dispose();</p><p> }</p><p> catch (Exception ex)</p><p> {</p><p> Log.Error("AtmoLight: Error in AtmolightPlugin_OnNewFrame.");</p><p> Log.Error("AtmoLight: Exception: {0}", ex.Message);</p><p></p><p> rgbSurface.Dispose();</p><p> rgbSurface = null;</p><p> }</p><p> }</p><p> }[/CODE]</p><p></p><p>That hooks into <a href="https://github.com/MediaPortal/MediaPortal-1/blob/master/mediaportal/Core/Player/FrameGrabber.cs" target="_blank">https://github.com/MediaPortal/MediaPortal-1/blob/master/mediaportal/Core/Player/FrameGrabber.cs</a></p><p></p><p>I would need something similar in MP2.</p><p></p><p>Thanks for your help <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile :)" loading="lazy" data-shortname=":)" /></p></blockquote><p></p>
[QUOTE="Lightning303, post: 1077222, member: 97876"] To be honest, you lost me there already :(. But no hurry, maybe when you are on you pc and have a spare 5 minutes you could look at this. I will try to explain what we are using right now for MP1. However, i did not build this, i just inharited it, especially the framegrabber part. In MP1 we use an event handler, like this: [CODE=C#] FrameGrabber.GetInstance().OnNewFrame += new FrameGrabber.NewFrameHandler(AtmolightPlugin_OnNewFrame); private void AtmolightPlugin_OnNewFrame(short width, short height, short arWidth, short arHeight, uint pSurface) { if (playbackEffect != ContentEffect.MediaPortalLiveMode || atmoOff || atmoCtrl == null || width == 0 || height == 0 || reInitializeLock) { return; } if (rgbSurface == null) { rgbSurface = GUIGraphicsContext.DX9Device.CreateRenderTarget(captureWidth, captureHeight, Format.A8R8G8B8, MultiSampleType.None, 0, true); } unsafe { try { if (AtmolightSettings.sbs3dOn) { VideoSurfaceToRGBSurfaceExt(new IntPtr(pSurface), width / 2, height, (IntPtr)rgbSurface.UnmanagedComPointer, captureWidth, captureHeight); } else { VideoSurfaceToRGBSurfaceExt(new IntPtr(pSurface), width, height, (IntPtr)rgbSurface.UnmanagedComPointer, captureWidth, captureHeight); } Microsoft.DirectX.GraphicsStream stream = SurfaceLoader.SaveToStream(ImageFileFormat.Bmp, rgbSurface); BinaryReader reader = new BinaryReader(stream); stream.Position = 0; // ensure that what start at the beginning of the stream. reader.ReadBytes(14); // skip bitmap file info header byte[] bmiInfoHeader = reader.ReadBytes(4 + 4 + 4 + 2 + 2 + 4 + 4 + 4 + 4 + 4 + 4); int rgbL = (int)(stream.Length - stream.Position); int rgb = (int)(rgbL / (captureWidth * captureHeight)); byte[] pixelData = reader.ReadBytes((int)(stream.Length - stream.Position)); byte[] h1pixelData = new byte[captureWidth * rgb]; byte[] h2pixelData = new byte[captureWidth * rgb]; //now flip horizontally, we do it always to prevent microstudder int i; for (i = 0; i < ((captureHeight / 2) - 1); i++) { Array.Copy(pixelData, i * captureWidth * rgb, h1pixelData, 0, captureWidth * rgb); Array.Copy(pixelData, (captureHeight - i - 1) * captureWidth * rgb, h2pixelData, 0, captureWidth * rgb); Array.Copy(h1pixelData, 0, pixelData, (captureHeight - i - 1) * captureWidth * rgb, captureWidth * rgb); Array.Copy(h2pixelData, 0, pixelData, i * captureWidth * rgb, captureWidth * rgb); } //send scaled and fliped frame to atmowin if (!AtmolightSettings.lowCPU || (((Win32API.GetTickCount() - lastFrame) > AtmolightSettings.lowCPUTime) && AtmolightSettings.lowCPU)) { if (AtmolightSettings.lowCPU) { lastFrame = Win32API.GetTickCount(); } atmoLiveViewCtrl.setPixelData(bmiInfoHeader, pixelData); } stream.Close(); stream.Dispose(); } catch (Exception ex) { Log.Error("AtmoLight: Error in AtmolightPlugin_OnNewFrame."); Log.Error("AtmoLight: Exception: {0}", ex.Message); rgbSurface.Dispose(); rgbSurface = null; } } }[/CODE] That hooks into [url]https://github.com/MediaPortal/MediaPortal-1/blob/master/mediaportal/Core/Player/FrameGrabber.cs[/url] I would need something similar in MP2. Thanks for your help :) [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 2
Plugin Development
AtmoLight 2.1.0.0 for MediaPortal2 [2015-01-21]
Contact us
RSS
Top
Bottom