protected HRESULT GetSwapChainPresentParameters(IMFMediaType pType, out PresentParameters pPP)
        {
            pPP = null;

            HRESULT hr;
            int width = 0, height = 0;
            UInt32 d3dFormat = 0;

            Guid _subtype;
            hr = (HRESULT)pType.GetGUID(MFAttributesClsid.MF_MT_SUBTYPE, out _subtype);
            hr.Assert();
            if (hr.Succeeded)
            {
                hr = MFHelper.MFGetAttribute2UINT32asUINT64(pType, MFAttributesClsid.MF_MT_FRAME_SIZE, out width, out height);
                hr.Assert();

                if (hr.Succeeded)
                {
                    FOURCC _fourcc = new FOURCC(_subtype);
                    d3dFormat = _fourcc;
                    pPP = new PresentParameters();
                    pPP.BackBufferWidth = width;
                    pPP.BackBufferHeight = height;
                    pPP.Windowed = true;
                    pPP.SwapEffect = SwapEffect.Copy;
                    pPP.BackBufferFormat = (Format)d3dFormat;
                    pPP.DeviceWindowHandle = m_VideoControl != null ? m_VideoControl.Handle : m_Device.CreationParameters.Window;
                    pPP.PresentFlags = PresentFlags.Video;
                    pPP.PresentationInterval = PresentInterval.Default;

                    if (m_Device.CreationParameters.DeviceType != DeviceType.Hardware)
                    {
                        pPP.PresentFlags = pPP.PresentFlags | PresentFlags.LockableBackBuffer;
                    }
                }
            }
            return hr;
        }
Exemple #2
0
 public ScriptNativeFunctionAttribute(char a, char b, char c, char d)
     : this(FOURCC.Make(a, b, c, d))
 {
 }