Esempio n. 1
0
        public override int DecideBufferSize(ref IMemAllocatorImpl pAlloc, ref AllocatorProperties prop)
        {
            Console.WriteLine("DecideBufferSize");

            if (!Output.IsConnected) return VFW_E_NOT_CONNECTED;
            if (Output.CurrentMediaType.majorType != MediaType.Video) return VFW_E_INVALIDMEDIATYPE;
            AllocatorProperties _actual = new AllocatorProperties();
            BitmapInfoHeader _bmi = (BitmapInfoHeader)Output.CurrentMediaType;
            if (_bmi == null) return VFW_E_INVALIDMEDIATYPE;
            prop.cbBuffer = _bmi.GetBitmapSize();
            if (prop.cbBuffer < _bmi.ImageSize)
            {
                prop.cbBuffer = _bmi.ImageSize;
            }
            prop.cBuffers = 1;
            int hr = pAlloc.SetProperties(prop, _actual);
            return hr;
        }
Esempio n. 2
0
 public override int DecideBufferSize(ref IMemAllocatorImpl pAlloc, ref AllocatorProperties pProperties)
 {
     if (!IsConnected) return VFW_E_NOT_CONNECTED;
     AllocatorProperties _actual = new AllocatorProperties();
     HRESULT hr = (HRESULT)GetAllocatorProperties(_actual);
     if (SUCCEEDED(hr) && _actual.cBuffers <= pProperties.cBuffers && _actual.cbBuffer <= pProperties.cbBuffer && _actual.cbAlign == pProperties.cbAlign)
     {
         AllocatorProperties Actual = new AllocatorProperties();
         hr = (HRESULT)pAlloc.SetProperties(pProperties, Actual);
         if (SUCCEEDED(hr))
         {
             pProperties.cbAlign  = Actual.cbAlign;
             pProperties.cbBuffer = Actual.cbBuffer;
             pProperties.cbPrefix = Actual.cbPrefix;
             pProperties.cBuffers = Actual.cBuffers;
         }
     }
     return (m_Filter as VirtualCamFilter).DecideBufferSize(ref pAlloc, ref pProperties);
 }
 public override int DecideBufferSize(ref IMemAllocatorImpl pAlloc, ref AllocatorProperties pProperties)
 {
     if (!IsConnected) return VFW_E_NOT_CONNECTED;
     var actual = new AllocatorProperties();
     var hr = (HRESULT)GetAllocatorProperties(actual);
     if (SUCCEEDED(hr) && actual.cBuffers <= pProperties.cBuffers && actual.cbBuffer <= pProperties.cbBuffer && actual.cbAlign == pProperties.cbAlign)
     {
         actual = new AllocatorProperties();
         hr = (HRESULT)pAlloc.SetProperties(pProperties, actual);
         if (SUCCEEDED(hr))
         {
             pProperties.cbAlign = actual.cbAlign;
             pProperties.cbBuffer = actual.cbBuffer;
             pProperties.cbPrefix = actual.cbPrefix;
             pProperties.cBuffers = actual.cBuffers;
         }
     }
     return CamFilter.DecideBufferSize(ref pAlloc, ref pProperties);
 }
Esempio n. 4
0
        public int DecideBufferSize(ref IMemAllocatorImpl pAlloc, ref AllocatorProperties prop)
        {
            AllocatorProperties _actual = new AllocatorProperties();

            BitmapInfoHeader _bmi = (BitmapInfoHeader)Pins[0].CurrentMediaType;
            prop.cbBuffer = _bmi.GetBitmapSize();

            if (prop.cbBuffer < _bmi.ImageSize)
            {
                prop.cbBuffer = _bmi.ImageSize;
            }
            if (prop.cbBuffer < m_bmi.bmiHeader.ImageSize)
            {
                prop.cbBuffer = m_bmi.bmiHeader.ImageSize;
            }

            prop.cBuffers = 1;
            prop.cbAlign = 1;
            prop.cbPrefix = 0;
            int hr = pAlloc.SetProperties(prop, _actual);
            return hr;
        }