locked
How to add EVR stream sink while I am using an activation object? RRS feed

  • Question

  • Hi,
    I am trying to use EVR mixer on my Media Foundation project.

    I have got the EVR "activation object" on my own, and rendered the reference stream corrently.

    I now want to mix a second stream to the EVR, but I found some problem.


    The MSDN reference page for EVR (http://msdn.microsoft.com/en-us/library/aa965265%28VS.85%29.aspx) says :

    The EVR media sink initially has one stream sink, which corresponds to the reference stream. To add new stream sinks, call IMFMediaSink::AddStreamSink.


    But, the problem is, I am using a "activation object" on the topology. How could I get "IMFMediaSink" object?
    My code listed below :

    -----
        ....
        MFCreateVideoRendererActivate(hVideoWindow, &pActivate);    // get EVR (activation object)
        ....
        MFCreateTopologyNode(MF_TOPOLOGY_OUTPUT_NODE, &pNode);    // get a sink node for EVR
        pNode->SetObject(pActivate);
        pNode->SetUINT32(MF_TOPONODE_STREAMID, dwId);
        pNode->SetUINT32(MF_TOPONODE_NOSHUTDOWN_ON_REMOVE, TRUE);
        pTopology->AddNode(pNode);                    // add sink node to my topology
        ....
    -----

    Even though I can activate the activation object, it is not the same one my topology internally uses, right?

    So, how could I add a stream sink by using an activation object?

    Thanks in advance.
    Tuesday, October 13, 2009 1:57 AM

Answers

  • If you want to get an IMFMediaSink interface from your Activate Object you called IMFActivate::ActivateObject(). You'll have something like:

    IMFMediaSink* evrMediaSink = NULL;
    IMFActivate* pActivate;

    //Init pActivate blah blah blah

    pActivate->ActivateObject(IMFMediaSink,(void**)&evrMediaSink);

    then release the activate object.

    Once you have your IMFMediaSink interface, use this as the Topology Node Object instead of the Activate you had before. One benefit of not using the Activate is that you can now use the TopoLoader on a partially created Topology which will solve any decoders/encoders you need.

    With regards to EVR mixing though, if you're doing Z-order video mixing, you should look into using a Hardware EVR mixer. Haven't done it myself but there is documentation I've read on the subject there. The base stream is always your highest Z-order(if you consider the negative Z-axis coming out of the screen). Any other streams you create are technically sub-streams which can appear in any Z-order you want but always on top of the base stream.
    • Marked as answer by optimaluu Wednesday, October 14, 2009 12:07 AM
    Tuesday, October 13, 2009 8:59 AM

All replies

  • If you want to get an IMFMediaSink interface from your Activate Object you called IMFActivate::ActivateObject(). You'll have something like:

    IMFMediaSink* evrMediaSink = NULL;
    IMFActivate* pActivate;

    //Init pActivate blah blah blah

    pActivate->ActivateObject(IMFMediaSink,(void**)&evrMediaSink);

    then release the activate object.

    Once you have your IMFMediaSink interface, use this as the Topology Node Object instead of the Activate you had before. One benefit of not using the Activate is that you can now use the TopoLoader on a partially created Topology which will solve any decoders/encoders you need.

    With regards to EVR mixing though, if you're doing Z-order video mixing, you should look into using a Hardware EVR mixer. Haven't done it myself but there is documentation I've read on the subject there. The base stream is always your highest Z-order(if you consider the negative Z-axis coming out of the screen). Any other streams you create are technically sub-streams which can appear in any Z-order you want but always on top of the base stream.
    • Marked as answer by optimaluu Wednesday, October 14, 2009 12:07 AM
    Tuesday, October 13, 2009 8:59 AM
  • I know I can use IMFActivate::ActivateObject() to activate an activate object.

    But what if I am using EVR inside of PMP? Because PMP only takes activation object, not IMFMediaSink interface.

    I think there might be a way to add stream sinks by using an activate object, otherwise, you can not do mixing stuff in PMP. (Is this right?)

    (Although, I am not using PMP right now, just asking. :P)

    Thanks.
    Tuesday, October 13, 2009 9:16 AM
  • I'm not familiar with PMP or what it is. The problem with Activate Objects though is you have to consider them as a Half-Way-House, because in terms of finalising the interface of the object, it's unusable by the pipeline until it is activated(either by you or functionality implemented by a particular node). This is why you can't add streams to it.
    Tuesday, October 13, 2009 10:26 AM