Fundamentals of Audio and Video Programming for Games (Pro-Developer)

Once the compositor has been implemented, attaching it to the VMR is easy. Just call IVMRFilterConfig9::SetImageCompositor with a pointer to the compositor s IVMRImageCompositor9 interface.

// Create a new instance of the compositor. m_pMixer = new CMixer(); // CMixer inherits IVMRImageCompositor9. if (!m_pMixer) { return E_OUTOFMEMORY; } // Increment the reference count. m_pMixer->AddRef(); // Query the VMR for the IVMRFilterConfig9 interface. CComQIPtr<IVMRFilterConfig9> pConfig(m_pWC); // Assign the custom compositor. pConfig->SetImageCompositor(pMix);

One minor point to keep in mind is that the VMR does not automatically load the compositor when you call SetImageCompositor. Instead, it merely stores a copy of the IVMRImageCompositor9 pointer. It will load the compositor if it switches to mixing mode, but not if it remains in pass-through mode. So if video starts playing but the VMR never calls any methods on your compositor, check to make sure that your application calls IVMRFilterConfig9::SetNumberOfStreams to activate mixing mode.

Категории