locked
How to Dynamically Config an Effect MFT used in MediaCapture? RRS feed

  • Question

  • Hi,

        I am working on a webcam Metro style APP. I use MediaCapture to implement the webcam preview/recording features. I also implement webcam effects as an effect MFT, and add it to MediaCapture by MediaCapture.AddEffectAsync.

        I can now pass initial parameters to MFT by the IPropertySet parameter, but I further need to config the effect MFT dynamically at runtime.

        I referenced another post, and tried the follwoing cases: 

            1. Inserting the effect instance at the property set for JS APP to access it; and

            2. Registering for MapChanged event in MFT.

        However, I found that these methods work for HTML5 Video msInsertVideoEffect method, but not for MediaCapture.AddEffectAsync method. For case 1, my JS APP can get an object, but cannot access its properties (At VS debugger, the object contains properties whose names are showed as "?"). For case 2, I got an E_NOINTERFACE error at IObservableMap::add_MapChanged call. I guess MediaCapture does not implement something, but I am not sure.

        Can anyone share some experience?

    Thanks.

     

     

     

    Tuesday, November 8, 2011 9:14 AM

Answers

All replies

  • Hi Jay,

    I am working to get you an answer on this.  I am not sure you can do what you are trying to do but I will update you when I know something further.

    -Jeff


    Jeff Sanders (MSFT)
    Thursday, November 10, 2011 9:18 PM
    Moderator
  • Hi Jay,

    Could you please provide the following information

    a. Does your custom interface have a proxy/stub

    b. Does the object that implements the custom interface aggregate an FTM?

    -Radhika

     

    Wednesday, November 30, 2011 7:23 PM
  • Hi,

    >> a. Does your custom interface have a proxy/stub

    No.

    >> b. Does the object that implements the custom interface aggregate an FTM?

    Sorry, what is FTM?

     

    Thursday, December 1, 2011 6:24 AM
  • Since your effect is activated inside MTA and you talk to it from JS(which is ASTA), the custom interface needs to be marshalled between COM components which means you would need a proxy and stub for your custom interface.

    An FTM (free threaded marshaller) allows for inproc cross apartment calls without marshalling

    Some information on this is available here

    http://msdn.microsoft.com/en-us/library/ms694500(v=vs.85).aspx

    http://support.microsoft.com/kb/256217

    In WINRT this is really simplified by the use of FTMBase Class. http://msdn.microsoft.com/en-us/library/br230421(v=VS.110).aspx

    All you have to do is derive from this class.

    As an example, you could have the below in your header file.

    class yourClass: public Microsoft::WRL::RuntimeClass< ISomeinterface, Microsoft::WRL::FTMBase>

    {

    }

     

     

     

    • Marked as answer by Jay Su Friday, December 2, 2011 4:03 AM
    Thursday, December 1, 2011 8:56 PM
  • Hi Radhika,

        By deriving from FtmBase, it works for the 1st case (Inserting the effect instance at the property set for JS APP to access it).

        However, the 2nd case (registering for MapChanged event in MFT) still failed. I still got an E_NOINTERFACE error at IObservableMap::add_MapChanged call.

        Anyway, I got a working method to config my MFT.

        Thank you very much.

     

     

     

     

    Friday, December 2, 2011 4:03 AM
  • Hi Jay,

    Thanks for trying the suggestion and I am glad you have a method that works.

    The IObservableMap::add_MapChanged call failure seems to be unrelated to your code at this point and we will need to investigate it further.

    Could you please help us by providing the following information

    1. What were the template params for IObservableMap

    2. The IObservableMap::add_MapChanged call succeeded when you inserted your effect into video tag. Is this correct?

    Thanks for your help

    -Radhika

    Friday, December 2, 2011 7:31 PM
  • >> 1. What were the template params for IObservableMap

     My MFT derives from:
     
            public Collections::MapChangedEventHandler<HSTRING, IInspectable*>
     
     and implement the following codes for add_MapChanged:
     
        { // Add MapChanged event handler
            ComPtr<Collections::IObservableMap<HSTRING, IInspectable *>> observableMap;
            HRESULT hr = propertySet.As(&observableMap);

            if ( SUCCEEDED ( hr ))
                hr = observableMap->add_MapChanged ( this, &m_mapChangedToken );
        }  
       
    >> 2. The IObservableMap::add_MapChanged call succeeded when you inserted your effect into video tag. Is this correct?

     Yes, it works if my effect is added by HTML5 video msInsertVideoEffect method.

    Monday, December 5, 2011 3:18 AM
  • Hi Jay,

    Can you show me how you use MediaCapture.AddEffectAsync method to add effect to MediaCapture?

    Thanks a lot!

    Friday, December 23, 2011 7:31 AM
  • Hi Jay Su,

    It seems to me that you successfuly implemented some MFT of your own, based on MSDN examples.

    I'm struggling to do the same but I'm experiencing some difficulties.

    Could you please provide me an example that actually works for WinRT? It would be REALLY helpful.

    Thanks,

    JP

     

    Friday, January 13, 2012 5:19 PM