[Approved] - FrameGrabber enhancements (adding support for UI)

Discussion in 'Submit: code patches (MediaPortal/TV-Server/etc.)' started by Lightning303, November 19, 2014.

  1. 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
    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 :)
     

    Attached Files:

    • Like Like x 4
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. 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
  4. HomeY
    • Team MediaPortal

    HomeY Test Group

    Joined:
    February 23, 2008
    Messages:
    6,460
    Likes Received:
    2,627
    Gender:
    Male
    Occupation:
    Network Engineer
    Location:
    ::1
    Ratings:
    +4,737 / 16
    Home Country:
    Netherlands Netherlands
    Show System Specs
  5. popy
    • Super User

    popy Super User

    Joined:
    July 3, 2011
    Messages:
    616
    Likes Received:
    83
    Ratings:
    +141 / 2
    Show System Specs
    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
     
  6. 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
    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 :).
     
    • Like Like x 1
  7. popy
    • Super User

    popy Super User

    Joined:
    July 3, 2011
    Messages:
    616
    Likes Received:
    83
    Ratings:
    +141 / 2
    Show System Specs
    Had a look at the source code, what about this in PlaneScene.cs at line ~505:

    old:
    Code (Text):
    1.           // Alert the frame grabber that it has a chance to grab a frame
    2.           // if it likes (method returns immediately otherwise)
    3.           grabber.OnFrame(width, height, arWidth, arHeight, pSurface);
    new:

    Code (Text):
    1.           // Alert the frame grabber that it has a chance to grab a frame
    2.           // if it likes (method returns immediately otherwise)
    3.           if(GUIGraphicsContext.IsFullScreenVideo)
    4.             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
     
  8. 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
    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 ;).

    As i said, at least ViewModeSwitcher is using it to check if a video has black borders.
     
  9. popy
    • Super User

    popy Super User

    Joined:
    July 3, 2011
    Messages:
    616
    Likes Received:
    83
    Ratings:
    +141 / 2
    Show System Specs
    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
     
  10. popy
    • Super User

    popy Super User

    Joined:
    July 3, 2011
    Messages:
    616
    Likes Received:
    83
    Ratings:
    +141 / 2
    Show System Specs
    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
     
  11. popy
    • Super User

    popy Super User

    Joined:
    July 3, 2011
    Messages:
    616
    Likes Received:
    83
    Ratings:
    +141 / 2
    Show System Specs
    @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
     

    Attached Files:

    • 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!