IMediaControl.Run () - successful display of the camera, black

Using Directshow.NET and C #, I developed an application that shows a camera preview. Everything has been working fine since 1 year, but suddenly a customer complaint about a black camera view.

After some digging, I find out that the anti-virus program blocks the use of the camera in my application . After adding my application to the exclusion list, this anti-virus program makes the application work as before.

In the program, I correctly selected the exception for HRESULT, as shown below:

try
{
    //FilterGraph creation
    //CaptureGraphBuilder2 creation
    //AddSourceFilterForMoniker()
    //SampleGrabber configuration
    //VMR9 configuration

    hr = mediaControl.Run();
    DsError.ThrowExceptionForHR(hr);
}
catch(Exception ex)
{
    //logging part
}

, , . , : , , ? , .

+4
3

. , , , esp. IP- , , , , . , , . , .

, , . :

  • ,
  • , , .
  • (, IQualProp::get_FramesDrawn "... , " )

, , , .

+2

MediaElementBase.NewAllocatorFrame, , .

0

DirectShow , GraphEdit "" . , , , .

/ , Graphedit.

///
/// \fn AddGraphToRot(IUnknown *pUnkGraph, DWORD *pdwRegister)
/// 
HRESULT CCapture::AddGraphToRot(IUnknown *pUnkGraph, DWORD *pdwRegister)
{
    IMoniker * pMoniker;
    IRunningObjectTable *pROT;
    WCHAR wsz[128];
    HRESULT hr;
    ULONG ret = 0;

    if (FAILED(GetRunningObjectTable(0, &pROT)))
        return E_FAIL;

    wsprintfW(wsz, L"FilterGraph %08x pid %08x", (DWORD_PTR)pUnkGraph,
        GetCurrentProcessId());

    hr = CreateItemMoniker(L"!", wsz, &pMoniker);
    if (SUCCEEDED(hr)) {
        hr = pROT->Register(0, pUnkGraph, pMoniker, pdwRegister);
        ret = pMoniker->Release();
    }   
    pROT->Release();
    return hr;
}

GraphEdit Microsoft Windows (SDK) (http://go.microsoft.com/fwlink/p/?linkid=62332).

0

Source: https://habr.com/ru/post/1684759/


All Articles