[Approved] FrameGrabber enhancements (adding support for UI) (1 Viewer)

Lightning303

MP Donator
  • Premium Supporter
  • September 12, 2009
    798
    577
    Home Country
    Germany Germany
    Hey,

    Currently the FrameGrabber event OnNewFrame is only called when the video player is rendering frames. Therefore only frames from videos can be retrieved with the grabber.
    I made a small patch that adds the ability to also grab frames of the MediaPortal menu/ui.

    In the case of the AtmoLight plugin, this adds the possiblity to grab a frame and change the colors of the leds according to the menu/ui.

    I have been using this patch for some month now and did not have any problems.

    Patch is based on master branch.

    Thanks :)
     

    Attachments

    • 0001-Added-UI-capture-for-AtmoLight-FrameGrabber (Combined).patch
      3.2 KB

    popy

    MP Donator
  • Premium Supporter
  • July 3, 2011
    617
    141
    Hey guys, then we discuss it here :p

    Currently the patch does the following:
    • No Media is playing -> grab frames of UI and use it for atmolight
    • when media is playing -> grab frames of media and use it for atmolight -> it doesnt matter if the user has the UI in foreground, the frame data is ALWAYS used from the media running in the background.
    But isnt it wrong from a users point of view?
    The user see something on the screen and the atmolight should "extend" the tv screen.
    So when a media is running in the background and he is bringing the GUI to front, why not use the gui framedata?
    Just when media is running in fullscreen the media framedata should be used.
    So ill think its a better experience because in/on every situation/screen atmolight shows the right data at the right time.

    pOpY
     

    Lightning303

    MP Donator
  • Premium Supporter
  • September 12, 2009
    798
    577
    Home Country
    Germany Germany
    Just to be clear from the start, AtmoLight is the only plugin that uses this feature atm, but that does not mean this is a AtmoLight specific feature. So when we talk about this, we should not just think about that one specfic area where the FrameGrabber can be used.

    Before this patch the FrameGrabber event was only raised by the video player renderer. In this patch i added in that the event gets also raised by the gui rendering. Something interesting here is, that while a video is playing, the "normal" gui rendering methods are not used, even when the video is not in fullscreen. Without having looked any deeper into the code now, my guess is the videoplayer is rendering the gui in this instance aswell. Somehow, somewhere.

    Talking about ambilight, i agree that it would be better/consistent that when a video is not in fullscreen, the video frame should not be used, but the whole screen frame. However changing that would also possibly interfere with other plugins that use the framegrabber and rely on how it is acting while video playback. E.g. i know that the the ViewModeSwitcher plugin uses the framegrabber.

    Lastly, i dont think i will be doing anything on this anymore. I just dont feel like it. Sorry. Still, thanks for testing and giving feedback :).
     

    popy

    MP Donator
  • Premium Supporter
  • July 3, 2011
    617
    141
    Had a look at the source code, what about this in PlaneScene.cs at line ~505:

    old:
    Code:
              // 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);

    new:

    Code:
              // Alert the frame grabber that it has a chance to grab a frame
              // if it likes (method returns immediately otherwise)
              if(GUIGraphicsContext.IsFullScreenVideo)
                grabber.OnFrame(width, height, arWidth, arHeight, pSurface);

    I am not so deep in the MP code, so icant say that it has any side effects.
    Is the frame grabber also used for other plugins then atmolight?

    pOpY
     

    Lightning303

    MP Donator
  • Premium Supporter
  • September 12, 2009
    798
    577
    Home Country
    Germany Germany
    Well, if you implement that, the outcome should be that when you have video running and have it not in fullscreen, no new frames get passed to the framegrabber. But, build it, and test it ;).

    Is the frame grabber also used for other plugins then atmolight?
    As i said, at least ViewModeSwitcher is using it to check if a video has black borders.
     

    popy

    MP Donator
  • Premium Supporter
  • July 3, 2011
    617
    141
    you was faster ;)
    Just read your answer regarding ViewModeSwitcher, which is also using framegrabber! Then my code could not be used :(
    Ill think the current implementation of grabbing ui frames doesnt make much sense, because most of the time there runs a media in the background.
    (you start tv, browsing series....)

    pOpY
     

    popy

    MP Donator
  • Premium Supporter
  • July 3, 2011
    617
    141
    Another idea -> pass a "frame source" argument to the function OnFrame() so the receiver can decide if he want to process the frame or drop it.

    pOpY
     

    popy

    MP Donator
  • Premium Supporter
  • July 3, 2011
    617
    141
    @Lightning303: i have made two patches now, one for mediaportal 1.11pre (master branch) & for the atmolight plugin itself.
    On my HTPC the patch is working like it should -> when the video is minimized, now the gui frame data is used ;)
    My patch also include changes in VideoModeSwitcher so it doesnt use frame data when video is playing and is minimized -> because without the patch it has switched aspect ratio depending on the GUI frame data.

    Why Atmolight patch is needed? -> it isnt really needed BUT i have added the IsFullScreenVideo bool flag to the NewFrameHandler, so when atmolight plugin or any other (new) plugin grabs frame data and want to know if frame data is a fullscreenvideo or is gui frame data. So the plugin can decide itself if it uses the data or drop it.

    Changelog:
    • if video is playing not in fullscreen the current GUI frame data is used for the NewFrameHandler event
    • added is "IsFullScreenVideo" bool to Event NewFrameHandler (thats the reason why atmolight plugin needs to be patched)
    • VideoModeSwitcher is not using the GUI frame data
    attached in the zip you can find the patched core.dll, mediaportal.exe, ProcessPlugins.dll & Atmolight plugin which uses the new OnNewFrame handler event. The two unified patches (mediaportal & atmolight plugin) are also attached.

    Can you please test it and report back if it also works for you?
    Would be nice if the patches are finds its way into the next release :p

    pOpY
     

    Attachments

    • AtmoLight.MediaPortal1.Plugin.patch
      1,002 bytes
    • Atmolight_patch_1.11pre.zip
      1.8 MB
    • mediaportal_atmolight_gui.patch
      5.2 KB

    Users who are viewing this thread

    Top Bottom