示例#1
0
        public int RequestAllocator(IntPtr pPreferred, AllocatorProperties pProps, out IntPtr ppActual)
        {
            ppActual = IntPtr.Zero;
            if (m_pUnknown == IntPtr.Zero) return E_NOINTERFACE;

            RequestAllocatorProc _Proc = GetProcDelegate<RequestAllocatorProc>(3);

            if (_Proc == null) return E_UNEXPECTED;

            return (HRESULT)_Proc(
                        m_pUnknown,
                        pPreferred, pProps, out ppActual
                        );
        }
示例#2
0
        public int SetProperties(AllocatorProperties pRequest, AllocatorProperties pActual)
        {
            if (m_pUnknown == IntPtr.Zero) return E_NOINTERFACE;

            SetPropertiesProc _Proc = GetProcDelegate<SetPropertiesProc>(3);

            if (_Proc == null) return E_UNEXPECTED;

            return (HRESULT)_Proc(
                        m_pUnknown,
                        pRequest, pActual
                        );
        }
示例#3
0
        public int GetProperties(AllocatorProperties pProps)
        {
            if (m_pUnknown == IntPtr.Zero) return E_NOINTERFACE;

            GetPropertiesProc _Proc = GetProcDelegate<GetPropertiesProc>(4);

            if (_Proc == null) return E_UNEXPECTED;

            return (HRESULT)_Proc(
                        m_pUnknown,
                        pProps
                        );
        }
 /// <summary>
 /// Requests an allocator during the pin connection.
 /// </summary>
 /// <param name="pPreferred">Pointer to the <see cref="IMemAllocator"/> interface on the input pin's preferred allocator, or NULL.</param>
 /// <param name="pProps">An <see cref="AllocatorProperties"/> structure, allocated by the caller. The caller should fill in any allocator properties that the input pin requires, and set the remaining members to zero.</param>
 /// <param name="ppActual">Pointer that receives an <see cref="IMemAllocator"/>.</param>
 /// <returns></returns>
 public int RequestAllocator(IntPtr pPreferred, AllocatorProperties pProps, out IntPtr ppActual)
 {
   lock (m_Lock)
   {
     // We are not working with Allocators, set the outgoing pointer to 0
     ppActual = IntPtr.Zero;
     return S_OK;
   }
 }
示例#5
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;
        }
 public int SuggestAllocatorProperties(AllocatorProperties pprop)
 {
     if (IsConnected) return VFW_E_ALREADY_CONNECTED;
     var hr = (HRESULT)CamFilter.SuggestAllocatorProperties(pprop);
     if (FAILED(hr))
     {
         _properties = null;
         return hr;
     }
     if (_properties == null)
     {
         _properties = new AllocatorProperties();
         CamFilter.GetAllocatorProperties(_properties);
     }
     if (pprop.cbBuffer != -1) _properties.cbBuffer = pprop.cbBuffer;
     if (pprop.cbAlign != -1) _properties.cbAlign = pprop.cbAlign;
     if (pprop.cbPrefix != -1) _properties.cbPrefix = pprop.cbPrefix;
     if (pprop.cBuffers != -1) _properties.cBuffers = pprop.cBuffers;
     return NOERROR;
 }
 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);
 }
示例#8
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 int GetAllocatorProperties(AllocatorProperties pprop)
 {
     if (pprop == null) return E_POINTER;
     if (_properties != null)
     {
         pprop.cbAlign = _properties.cbAlign;
         pprop.cbBuffer = _properties.cbBuffer;
         pprop.cbPrefix = _properties.cbPrefix;
         pprop.cBuffers = _properties.cBuffers;
         return NOERROR;
     }
     if (IsConnected)
     {
         var hr = (HRESULT)Allocator.GetProperties(pprop);
         if (SUCCEEDED(hr) && pprop.cBuffers > 0 && pprop.cbBuffer > 0) return hr;
     }
     return CamFilter.GetAllocatorProperties(pprop);
 }
示例#10
0
 public int SuggestAllocatorProperties(AllocatorProperties pprop)
 {
     AllocatorProperties _properties = new AllocatorProperties();
     HRESULT hr = (HRESULT)GetAllocatorProperties(_properties);
     if (FAILED(hr)) return hr;
     if (pprop.cbBuffer != -1)
     {
         if (pprop.cbBuffer < _properties.cbBuffer) return E_FAIL;
     }
     if (pprop.cbAlign != -1 && pprop.cbAlign != _properties.cbAlign) return E_FAIL;
     if (pprop.cbPrefix != -1 && pprop.cbPrefix != _properties.cbPrefix) return E_FAIL;
     if (pprop.cBuffers != -1 && pprop.cBuffers < 1) return E_FAIL;
     return NOERROR;
 }
示例#11
0
        public int GetAllocatorProperties(AllocatorProperties pprop)
        {
            AMMediaType mt = Pins[0].CurrentMediaType;
            if (mt.majorType == MediaType.Video)
            {
                int lSize = mt.sampleSize;
                BitmapInfoHeader _bmi = mt;
                if (_bmi != null)
                {
                    if (lSize < _bmi.GetBitmapSize())
                    {
                        lSize = _bmi.GetBitmapSize();
                    }
                    if (lSize < _bmi.ImageSize)
                    {
                        lSize = _bmi.ImageSize;
                    }
                }
                pprop.cbBuffer = lSize;
                pprop.cBuffers = 1;
                pprop.cbAlign = 1;
                pprop.cbPrefix = 0;

            }
            return NOERROR;
        }
示例#12
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;
        }
示例#13
0
 public int SuggestAllocatorProperties(AllocatorProperties pprop)
 {
     if (IsConnected) return VFW_E_ALREADY_CONNECTED;
     HRESULT hr = (HRESULT)(m_Filter as VirtualCamFilter).SuggestAllocatorProperties(pprop);
     if (FAILED(hr))
     {
         m_pProperties = null;
         return hr;
     }
     if (m_pProperties == null)
     {
         m_pProperties = new AllocatorProperties();
         (m_Filter as VirtualCamFilter).GetAllocatorProperties(m_pProperties);
     }
     if (pprop.cbBuffer != -1) m_pProperties.cbBuffer = pprop.cbBuffer;
     if (pprop.cbAlign != -1) m_pProperties.cbAlign = pprop.cbAlign;
     if (pprop.cbPrefix != -1) m_pProperties.cbPrefix = pprop.cbPrefix;
     if (pprop.cBuffers != -1) m_pProperties.cBuffers = pprop.cBuffers;
     return NOERROR;
 }
        public int GetAllocatorProperties(AllocatorProperties pprop)
        {
            var mt = Pins[0].CurrentMediaType;
            if (mt.majorType != MediaType.Video) return NOERROR;

            var lSize = mt.sampleSize;
            BitmapInfoHeader bmi = mt;
            if (lSize < bmi.GetBitmapSize())
            {
                lSize = bmi.GetBitmapSize();
            }
            if (lSize < bmi.ImageSize)
            {
                lSize = bmi.ImageSize;
            }
            pprop.cbBuffer = lSize;
            pprop.cBuffers = 1;
            pprop.cbAlign = 1;
            pprop.cbPrefix = 0;
            return NOERROR;
        }