Пример #1
0
        protected void IsMediaTypeSupported(IMFMediaType pMediaType)
        {
            VideoTypeBuilder pProposed = null;

            bool bCompressed = false;
            MFVideoInterlaceMode InterlaceMode = MFVideoInterlaceMode.Unknown;
            MFVideoArea VideoCropArea;
            int width = 0, height = 0;

            try
            {
                // Helper object for reading the proposed type.
                pProposed = new VideoTypeBuilder(pMediaType);

                // Reject compressed media types.
                pProposed.IsCompressedFormat(out bCompressed);
                if (bCompressed)
                {
                    throw new COMException("Compressed formats not supported", MFError.MF_E_INVALIDMEDIATYPE);
                }

                // Validate the format.
                int i;
                pProposed.GetFourCC(out i);

                // The D3DPresentEngine checks whether the format can be used as
                // the back-buffer format for the swap chains.
                m_pD3DPresentEngine.CheckFormat(i);

                // Reject interlaced formats.
                pProposed.GetInterlaceMode(out InterlaceMode);
                if (InterlaceMode != MFVideoInterlaceMode.Progressive)
                {
                    throw new COMException("Interlaced formats not supported", MFError.MF_E_INVALIDMEDIATYPE);
                }

                pProposed.GetFrameDimensions(out width, out height);

                // Validate the various apertures (cropping regions) against the frame size.
                // Any of these apertures may be unspecified in the media type, in which case
                // we ignore it. We just want to reject invalid apertures.

                try
                {
                    pProposed.GetPanScanAperture(out VideoCropArea);
                    ValidateVideoArea(VideoCropArea, width, height);
                }
                catch { }

                try
                {
                    pProposed.GetGeometricAperture(out VideoCropArea);
                    ValidateVideoArea(VideoCropArea, width, height);
                }
                catch { }

                try
                {
                    pProposed.GetMinDisplayAperture(out VideoCropArea);
                    ValidateVideoArea(VideoCropArea, width, height);
                }
                catch { }

            }
            finally
            {
                pProposed.Dispose();
                //SafeRelease(pMediaType);
            }
        }