سؤال

I'm using DirectShow for video rendering in NPAPI plugin. I've written a source filter that pushes YUY2 samples upstream, I was trying to use VMR9 in windowless mode to render video into plugin's HWND. Anyway, the frame actually are getting delivered, but no output is shown in plugin window. I'm sure about frame delivery because if I use VMR9 in windowed mode I can actually see the video.

This piece of code is intended for graph building and rendering.

// init VMR9 filter
IBaseFilter *pVmr = NULL;
HRESULT hr = CoCreateInstance(CLSID_VideoMixingRenderer9, 0,
    CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pVmr);

hr = _base->AddFilter(pVmr, L"VMR9");
pVmr->Release();

// set VMR9 windowless
IVMRFilterConfig9* pConfig;
hr = pVmr->QueryInterface(IID_IVMRFilterConfig9, (void**)&pConfig);

if (SUCCEEDED(hr))
{
    pConfig->SetRenderingMode(VMRMode_Windowless);
    pConfig->SetNumberOfStreams(1);
    pConfig->Release();

}

// set VMR9 clipping window
IVMRWindowlessControl9* pWc = NULL;
hr = pVmr->QueryInterface(IID_IVMRWindowlessControl9, (void**)&pWc);
if (SUCCEEDED(hr))
{
    hr = pWc->SetVideoClippingWindow((_outputWindow));

    RECT r;
    GetWindowRect(_outputWindow, &r);
    pWc->SetVideoPosition(NULL, &r);

    pWc->Release();

}

// init source filter
IBaseFilter *pSource = new NetReceiverFilter();
hr = _base->AddFilter(pSource, L"Net Receiver");

_capture->RenderStream(0, 0, pSource, 0, pVmr);


long evCode;
_control->Run();
_event->WaitForCompletion(10000, &evCode);

where:

  • _outputWindow is HWND of plugin
  • _base is IGraphBuilder *
  • _build is ICaptureGraphBuilder2 *
  • _control is IMediaControl *
  • _event is IMediaEvent *
هل كانت مفيدة؟

المحلول

IVMRWindowlessControl9::SetVideoPosition takes client (relative) coordinates, whereas GetWindowRect gets you screen (absolute) coordinates, you need to work this out, e.g. using GetclientRect instead, or using additional ScreenToClient call.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top