locked
Get hWnd for XAML control in Metro? RRS feed

Answers

  • Hello Kellen,

    If you are targeting C++ you can pull the raw bits out of your library and blt them to a D3D texture / surface. You can then use the D3D surface in your C++ application like you would any D3D surface. If you are targeting XAML you should be able to use a writeable bitmap to blt the bits to directly for use in your XAML environment. Keep in mind that if you are using a managed environment such as C# you will likely not get the performance that you expect. This is due in large part to non deterministic finalization. A link to my blog that discussed this effect in managed environments can be found below.

    If you wish to use the VLC library I would highly recommend that you forget about using C# or any other managed language due to the major performance limitations. C++ Cx is going to be your best bet. However, the native XAML stack for C++ Cx is new and I can't vouch for it's performance at this time. I'm hopeful that it will be very performant but I just don't know. Using C++ with WinRT and D3D is certainly going to be your best bet and give you the best cross platform performance.

    Calling the Format SDK, DirectShow, Media Foundation or the WASAPI from managed code (C#, VB.net)

    http://blogs.msdn.com/b/mediasdkstuff/archive/2009/04/01/calling-the-format-sdk-directshow-media-foundation-or-the-wasapi-from-managed-code-c-vb-net.aspx

    I hope this helps,

    James


    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Friday, March 9, 2012 11:20 PM
    Moderator

All replies

  • No, this won't be possible. Metro style apps have no understanding or interaction with HWNDs. Your dll will need to be rewritten to use a different technique. You might want to look at D3D interop if you can't just provide the video stream to a MediaElement.

    --Rob

    Friday, March 9, 2012 6:08 PM
    Moderator
  • Alright interesting.  I'm trying to see if I can get libvlc to work in a metro style app.  Maybe I'll investigate getting vlc to output to a d3d frame in metro.

    Any other advice?  

    Friday, March 9, 2012 8:35 PM
  • Any other advice?  

    You might want to look at the Media Foundation APIs to see if they help with this.

    Ashish Shetty, Program Manager, Microsoft | http://nerddawg.blogspot.com

    Friday, March 9, 2012 9:49 PM
  • Hello Kellen,

    If you are targeting C++ you can pull the raw bits out of your library and blt them to a D3D texture / surface. You can then use the D3D surface in your C++ application like you would any D3D surface. If you are targeting XAML you should be able to use a writeable bitmap to blt the bits to directly for use in your XAML environment. Keep in mind that if you are using a managed environment such as C# you will likely not get the performance that you expect. This is due in large part to non deterministic finalization. A link to my blog that discussed this effect in managed environments can be found below.

    If you wish to use the VLC library I would highly recommend that you forget about using C# or any other managed language due to the major performance limitations. C++ Cx is going to be your best bet. However, the native XAML stack for C++ Cx is new and I can't vouch for it's performance at this time. I'm hopeful that it will be very performant but I just don't know. Using C++ with WinRT and D3D is certainly going to be your best bet and give you the best cross platform performance.

    Calling the Format SDK, DirectShow, Media Foundation or the WASAPI from managed code (C#, VB.net)

    http://blogs.msdn.com/b/mediasdkstuff/archive/2009/04/01/calling-the-format-sdk-directshow-media-foundation-or-the-wasapi-from-managed-code-c-vb-net.aspx

    I hope this helps,

    James


    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Friday, March 9, 2012 11:20 PM
    Moderator
  • Note that with the Consumer Preview, you can use the Direct3D surface James mentions underneath your Xaml UI. See DirectX and XAML interop and the Windows.UI::Xaml::Controls::SwapChainBackgroundPanel

    --Rob

    Saturday, March 10, 2012 12:13 AM
    Moderator
  • Just to jump on the bandwagon. "SwapChainBackgroundPanel" is new in the CP and blows the doors off of XAML. This is an amazing new feature that I really hope developers learn how to leverage successfully. If you get this to work with your media application please let me know. I would love to track "SwapChainBackgroundPanel" success stories.

    -James


    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Saturday, March 10, 2012 1:31 AM
    Moderator
  • Wow great info, pretty awesome to get some sdes and a program manager commenting on a random forum post.

    I'm a big fan of XAML for UI layout, and I'd like to learn something new so I'll play around with C++/Cx DirectX interop.  I'd actually never heard of it before this thread.

    Seems like as far as creating a Metro VLC app C++ WinRT and D3D might be a good way to go.

    I must say this is a little more work than I was hoping it would be though.  I created this WPF app in win7 that took about 30 minutes and has really good performance.  http://kellen.im/wpfvlc.zip  It's not marshalling frame data back and forth so there's no overhead there.  All the decoding is done in a native thread, which should mitigate the risk of overrun/underrun due to the garbage collector freezing managed threads.

     Blog post is interesting, seems like a great use case for Async GC.

    Saturday, March 10, 2012 2:52 AM