locked
How to expose an ITransform interface from an runtimeclass object (WRL)

    Question

  •     there is some hint in other discussion that to write an video effect object such as grayscaletransform.dll need to make the transform object into a WinRT object (derives from IInspectable) with some additional code of activation factory.

    (refer to this thread: http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/9621e528-2eab-4685-8223-dd04a872ffc3)

        so I convert grayscale samples of windows SDK 7.1 to an runtime class via WRL.

        it works as I can activate this object, but I cannot query IMFTransform from this object, nor can I expose IMFTransform interface.

        does anybody have experience here? so can give me some suggestion?

     

        My test code is like this:

            CGrayscale^ myscale = ref new NSGrayscale::CGrayscale();

            IGrayscale^ pScale = dynamic_cast<IGrayscale^> ( myscale );

            IMFTransform* pTrans = NULL; // dynamic_cast<IMFTransform*> ( myscale );

            pScale->QueryInterface(IID_IMFTransform, (void**)&pTrans);

            MEDIA::ThrowIfFailed(m_spEngineEx->InsertVideoEffect(pTrans, enable));

     

        My implement is like this:

            //class CGrayscale : public Microsoft::WRL::RuntimeClass< IGrayscale, IMFTransform >

            class CGrayscale :public IMFTransform, public Microsoft::WRL::RuntimeClass< IGrayscale >

           {

                InspectableClass(RuntimeClass_NSGrayscale_CGrayscale, TrustLevel::BaseTrust);

                public: CGrayscale();

                // IMFTransform ...

            };

            namespace NSGrayscale

            {

                ActivatableClass(CGrayscale)

            }

     

        My idl file is like this:

            namespace NSGrayscale {

                // Forward declarations

                runtimeclass CGrayscale;

                // Interface definitions {21DC3586-E64E-490D-B582-5E5E13177F35}

               [version(1.0), uuid(21DC3586-E64E-490D-B582-5E5E13177F35)]

                interface IGrayscale : IInspectable {

                        // HRESULT GetObject( [in] REFIID riid, [out] IUnknown* ppvObj );

                }

                [version(1.0), activatable(1.0)]

                 runtimeclass CGrayscale {

                        [default] interface IGrayscale;

                        // interface IMFTransform;

                 }

            }

     

         I have tried below two solution:

         trial 1) expose IMFTransform interface like this

              runtimeclass CGrayscale {

                    [default] interface IGrayscale;

                    interface IMFTransform;

             }

        it report error that: " error MIDL2587: Runtime classes cannot implement non windows runtime interfaces. : IMFTransform ... "

        trial 2) try to get transform object from runtime class object like this:

               interface IGrayscale : IInspectable {

                     HRESULT GetObject( [in] REFIID riid, [out] IUnknown* ppvObj );

               }

         it report error that "error MIDL4004: The type of a parameter is not a valid Windows Runtime type. "

         I know IID is ok, so error should comes out with IUnknown.

     

        is there anybody know something here, and give me some suggestion?

        I don't know how to continue now.....

        thanks.

     

     


    ---------------------------------------------- JohnYe from SHANGHAI. email: yechzh@126.com

    • Edited by JohnYe Thursday, December 01, 2011 3:45 AM
    Thursday, December 01, 2011 3:36 AM

Answers

  • Hello John,

    As you have found in order to have your custom MFT packaged and loaded from within your Metro application, you are going to need to add an interface or two to get things to work correctly. Unfortunately as of the “Build” developer preview release we don’t have a good bit of sample code to show you how to make your MFT callable from the Win RT environment.

    I know that Stan promised a sample when he spoke at “Build” (http://channel9.msdn.com/events/BUILD/BUILD2011/PLAT-783T). I’ve been working with Stan and others to make sure we get a good sample published as soon as we can. Once we have a clean sample that is up to date I will make sure to announce it on my blog (http://blogs.msdn.com/mediasdkstuff/). I’m not sure when we will get this published but I’m working to get it out as soon as possible.

    Thanks for your patience,

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


    Saturday, December 17, 2011 1:06 AM
    Moderator

All replies

  • Hello John,

    As you have found in order to have your custom MFT packaged and loaded from within your Metro application, you are going to need to add an interface or two to get things to work correctly. Unfortunately as of the “Build” developer preview release we don’t have a good bit of sample code to show you how to make your MFT callable from the Win RT environment.

    I know that Stan promised a sample when he spoke at “Build” (http://channel9.msdn.com/events/BUILD/BUILD2011/PLAT-783T). I’ve been working with Stan and others to make sure we get a good sample published as soon as we can. Once we have a clean sample that is up to date I will make sure to announce it on my blog (http://blogs.msdn.com/mediasdkstuff/). I’m not sure when we will get this published but I’m working to get it out as soon as possible.

    Thanks for your patience,

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


    Saturday, December 17, 2011 1:06 AM
    Moderator
  • thanks.

     


    ---------------------------------------------- JohnYe from SHANGHAI. email: yechzh@126.com
    Sunday, December 18, 2011 6:51 AM