Example #1
0
        protected void ClearDesiredSampleTime(IMFSample pSample)
        {
            if (pSample == null)
            {
                throw new COMException("ClearDesiredSampleTime", E_Pointer);
            }

            IMFDesiredSample pDesired = null;
            object pUnkSwapChain = null;

            // We store some custom attributes on the sample, so we need to cache them
            // and reset them.
            //
            // This works around the fact that IMFDesiredSample::Clear() removes all of the
            // attributes from the sample.

            int counter;
            int hr;

            hr = pSample.GetUINT32(MFSamplePresenter_SampleCounter, out counter);
            MFError.ThrowExceptionForHR(hr);

            try
            {
                Guid IID_IUnknown = new Guid("00000000-0000-0000-C000-000000000046");
                hr = pSample.GetUnknown(MFSamplePresenter_SampleSwapChain, IID_IUnknown, out pUnkSwapChain);
                MFError.ThrowExceptionForHR(hr);
            }
            catch { }

            pDesired = (IMFDesiredSample)pSample;

            pDesired.Clear();

            hr = pSample.SetUINT32(MFSamplePresenter_SampleCounter, counter);
            MFError.ThrowExceptionForHR(hr);

            if (pUnkSwapChain != null)
            {
                hr = pSample.SetUnknown(MFSamplePresenter_SampleSwapChain, pUnkSwapChain);
                MFError.ThrowExceptionForHR(hr);
            }

            SafeRelease(pUnkSwapChain);
            //SafeRelease(pDesired);
        }