[Approved] - Framegrabber improvement - Capture from UI when Video is minimized or running in Mini-display | Page 3

Discussion in 'Submit: code patches (MediaPortal/TV-Server/etc.)' started by popy, February 24, 2015.

  1. popy
    • Super User

    popy Super User

    Joined:
    July 3, 2011
    Messages:
    616
    Likes Received:
    83
    Ratings:
    +141 / 2
    Show System Specs
    thx, for testing and your feedback.
    I have done this in one of the first patches. The plugin tries to subscribe to an event in an try catch. When something goes wrong it uses the old event.
    Now we have just one event. Ill must test if the old code also works with one event but different parameters.
    If not, ill think we must add some MP installation version check and try to use the right event.



    Will look at it later this evening and come back here.

    pOpY
     
    • Like Like x 1
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. popy
    • Super User

    popy Super User

    Joined:
    July 3, 2011
    Messages:
    616
    Likes Received:
    83
    Ratings:
    +141 / 2
    Show System Specs
    Not so easy as i thought :(
    I have tried it that way:
    • make enum private and copied it to the plugin.cs
    • define FrameSource parameter as int and optional like this:
    Code (Text):
    1.  private void AtmolightPlugin_OnNewFrame(short width, short height, short arWidth, short arHeight, uint pSurface, int iFrameSource = (int)FrameSource.NotSupported)
    doesnt work with old v1.11pre -> MP does close without any exception message in the error log :(
    I have also read some reports from other C# users says that the delegate itself must contain the optional parameter. Older MP versions doesnt have this needed parameter optional declared, so ill think we have to go the other way and check which MP version the user has installed and then subscribe to the correct delegate method. We then need 2 methods, one with the new FrameSource and the old one without it.

    Will try it tomorrow
    pOpY
     
    Last edited: March 11, 2015
  4. Lightning303
    • Premium Supporter

    Lightning303 MP Donator

    Joined:
    September 12, 2009
    Messages:
    798
    Likes Received:
    384
    Gender:
    Male
    Ratings:
    +578 / 0
    Home Country:
    Germany Germany
    Show System Specs
    I played around a bit and tried my hand with overloading the AtmolightPlugin_OnNewFrame method. However it seems that the enum crashes MP when its not present (MP before your changes) in MP. Not sure if this can be worked around. But if we/you would to use an int instead of an enum in the FrameGrabber as you said in your post, its not a big problem to implement.

    Code (Text):
    1.     private void AtmolightPlugin_OnNewFrame(short width, short height, short arWidth, short arHeight, uint pSurface, int FrameSource)
    2.     {
    3.       if (coreObject.GetCurrentEffect() != ContentEffect.MediaPortalLiveMode || !coreObject.IsConnected() || !coreObject.IsAtmoLightOn() || width == 0 || height == 0)
    4.       {
    5.         return;
    6.       }
    7.  
    8.       //Drop any frames?
    9.       if (Settings.trueGrabbing)
    10.       {
    11.         //GUI grabbing while video is minimized activated
    12.         if (g_Player.Playing && (!GUIGraphicsContext.IsFullScreenVideo) && (FrameSource == 1))
    13.         {
    14.           //Drop Video frames when user has set TrueGrabbing & video is playing minimized -> just GUI frames will pass
    15.           return;
    16.         }
    17.       }
    18.       else
    19.       {
    20.         //GUI grabbing while video is minimized deactivated
    21.         if ((g_Player.Playing) && (FrameSource == 0))
    22.         {
    23.           //Drop GUI frames when user has NOT set TrueGrabbing & video is playing -> just video frames will pass
    24.          
    25.           return;
    26.         }
    27.       }
    28.       AtmolightPlugin_OnNewFrame(width, height, arWidth, arHeight, pSurface);
    29.     }
    The original AtmolightPlugin_OnNewFrame stays untouched (no FrameSource parameter and no frame elimination code). Then new MP versions will use the above method that will forward the frames to the old method, and old MP versions will directly use the old method as before.
     
    • Thank You! Thank You! x 1
  5. popy
    • Super User

    popy Super User

    Joined:
    July 3, 2011
    Messages:
    616
    Likes Received:
    83
    Ratings:
    +141 / 2
    Show System Specs
    I ahve also tried it this way but cant get the "old" pre v1.11 get to work.
    the new one works.
    the exception what is thrown by the old MP isnt in the error.log i have found it in event viewer:

    Code (Text):
    1. Anwendung: MediaPortal.exe
    2. Frameworkversion: v4.0.30319
    3. Beschreibung: Der Prozess wurde aufgrund einer unbehandelten Ausnahme beendet.
    4. Ausnahmeinformationen: System.AccessViolationException
    5. Stapel:
    6.    bei AtmoLight.Plugin.VideoSurfaceToRGBSurfaceExt(IntPtr, Int32, Int32, IntPtr, Int32, Int32)
    7.    bei AtmoLight.Plugin.AtmolightPlugin_OnNewFrame(Int16, Int16, Int16, Int16, UInt32)
    8.    bei AtmoLight.Plugin.AtmolightPlugin_OnNewFrame(Int16, Int16, Int16, Int16, UInt32, Int32)
    9.    bei MediaPortal.FrameGrabber.OnFrame(Int16, Int16, Int16, Int16, UInt32)
    10.    bei MediaPortal.FrameGrabber.OnFrame(Microsoft.DirectX.Direct3D.Surface)
    11.    bei MediaPortal.FrameGrabber.OnFrame()
    12.    bei MediaPortalApp.Render(Single)
    13.    bei MediaPortal.D3D.FullRender()
    14.    bei MediaPortal.D3D.OnIdle(System.Object, System.EventArgs)
    15.    bei System.Windows.Forms.Application+ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32)
    16.    bei System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr, Int32, Int32)
    17.    bei System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms.ApplicationContext)
    18.    bei System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, System.Windows.Forms.ApplicationContext)
    19.    bei System.Windows.Forms.Application.Run(System.Windows.Forms.Form)
    20.    bei MediaPortalApp.Main(System.String[])
    it seems that AtmoDXUtil.dll is causing now an issue!?
    but when ill copy over the new core.dll & mediaportal.exe the plugin works.

    Do you have any idea?
    Can you try the new patches on your machine?
    attached my current patches of MP & plugin.

    pOpY
     

    Attached Files:

  6. popy
    • Super User

    popy Super User

    Joined:
    July 3, 2011
    Messages:
    616
    Likes Received:
    83
    Ratings:
    +141 / 2
    Show System Specs
    Update: Ill think it has todo with overloading the function:
    • When ill compile the plugin against the 1.11pre core -> it works with it but not with the new core :(
    • When ill compile the plugin against the new core -> it works with it but not with the old 1.11pre core :(
    Any idea?

    popY
     
  7. Lightning303
    • Premium Supporter

    Lightning303 MP Donator

    Joined:
    September 12, 2009
    Messages:
    798
    Likes Received:
    384
    Gender:
    Male
    Ratings:
    +578 / 0
    Home Country:
    Germany Germany
    Show System Specs
    As i said, no idea if and how it would work with keeping the enum. But if you get rid of the enum completly and use an int, or bool or whatever, it works without any porblems (no default values for parameters).
    No idea about the AtmoDX, maybe it gets wrong parameters for some reason?
     
  8. popy
    • Super User

    popy Super User

    Joined:
    July 3, 2011
    Messages:
    616
    Likes Received:
    83
    Ratings:
    +141 / 2
    Show System Specs
    Have tried with an int but also doesnt work.
    Can you please provide me your patches so i also can test.

    pOpY
     
  9. Lightning303
    • Premium Supporter

    Lightning303 MP Donator

    Joined:
    September 12, 2009
    Messages:
    798
    Likes Received:
    384
    Gender:
    Male
    Ratings:
    +578 / 0
    Home Country:
    Germany Germany
    Show System Specs
    Sorry, my mistake, even with an int i get problems. I mixed something up it seems :(.
     
  10. popy
    • Super User

    popy Super User

    Joined:
    July 3, 2011
    Messages:
    616
    Likes Received:
    83
    Ratings:
    +141 / 2
    Show System Specs
    N. P.

    So it seems the only way to keep compatibility is to make an second event, but this is not the best for the core performance because on every frame it has to do two null checks.

    I'll think it's better to stay on the last patches and write down in the release notes that there is no compatibility.

    What's your thinkings about that ?

    pOpY
     
  11. Lightning303
    • Premium Supporter

    Lightning303 MP Donator

    Joined:
    September 12, 2009
    Messages:
    798
    Likes Received:
    384
    Gender:
    Male
    Ratings:
    +578 / 0
    Home Country:
    Germany Germany
    Show System Specs
    I agree that keeping one event is the better way, even if we loose compability. Maybe there is a way to still keep compability, but my C# knowledge leaves me at this point.
    I also double checked ViewModeSwitcher that this plugin wont be effected, and made sure the Auto3D plugin is not effected aswell. As both use GrabCurrentImage instead of the event, all should be fine :). But im going to actually test those thing in the next few days.
     
    • Like Like x 1
Loading...

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!