Search code examples
c++windows-7ms-media-foundation

How to control camera capture display in MediaFoundation?


I wonder which MediaFoundation API can I use to control the brightness, contrast, hue and saturation etc? I find IMFVideoProcessor::SetProcAmpValues can modify these attributes, but these attributes are modified in graphics card; I want to modify these by capture device or by MediaFoundation interface within AVStream. thank you!


Solution

  • that will be the same as in DirectShow : acquire a IMFMediaSource for your video capture device and then query the IAMVideoProcAmp interface :

     IMFMediaSource * pSource = NULL;
     ...
     IAMVideoProcAmp *pProcAmp = NULL;
     hr = pSource->QueryInterface(IID_PPV_ARGS(&pProcAmp));
     if (SUCCEEDED(hr))
     {
        long lMin, lMax, lStep, lDefault, lCaps;
        hr = pProcAmp->GetRange(
                          VideoProcAmp_Brightness, 
                          &lMin, 
                          &lMax, 
                          &lStep, 
                          &lDefault, 
                          &lCaps
        );
    
        if (SUCCEEDED(hr))
        {
           hr = pProcAmp->Set(
                           VideoProcAmp_Brightness, 
                           lMax, 
                           VideoProcAmp_Flags_Manual
           );
        }
     }