/// <summary> /// Validates a media type for this transform. /// </summary> /// <param name="pmt">The media type to validate.</param> /// <returns>S_Ok or MF_E_INVALIDTYPE.</returns> /// <remarks>Since both input and output types must be /// the same, they both call this routine.</remarks> private HResult OnCheckMediaType(IMFMediaType pmt) { HResult hr = HResult.S_OK; hr = CheckMediaType(pmt, MFMediaType.Video, m_MediaSubtypes); if (Succeeded(hr)) { int interlace; // Video must be progressive frames. m_MightBeInterlaced = false; MFError throwonhr = pmt.GetUINT32(MFAttributesClsid.MF_MT_INTERLACE_MODE, out interlace); MFVideoInterlaceMode im = (MFVideoInterlaceMode)interlace; // Mostly we only accept Progressive. if (im != MFVideoInterlaceMode.Progressive) { // If the type MIGHT be interlaced, we'll accept it. if (im != MFVideoInterlaceMode.MixedInterlaceOrProgressive) { hr = HResult.MF_E_INVALIDTYPE; } else { // But we will check to see if any samples actually // are interlaced, and reject them. m_MightBeInterlaced = true; } } } return(hr); }
// Retrieves a description of how the frames are interlaced. public void GetInterlaceMode(out MFVideoInterlaceMode pmode) { int i; HResult hr = GetMediaType().GetUINT32(MFAttributesClsid.MF_MT_INTERLACE_MODE, out i); MFError.ThrowExceptionForHR(hr); pmode = (MFVideoInterlaceMode)i; }
public static extern void MFCreateVideoMediaTypeFromVideoInfoHeader( VideoInfoHeader pVideoInfoHeader, int cbVideoInfoHeader, int dwPixelAspectRatioX, int dwPixelAspectRatioY, MFVideoInterlaceMode InterlaceMode, long VideoFlags, [In, MarshalAs(UnmanagedType.LPStruct)] Guid pSubtype, out IMFVideoMediaType ppIVideoMediaType );
public static extern void MFCreateVideoMediaTypeFromBitMapInfoHeader( [In, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(BMMarshaler))] BitmapInfoHeader pbmihBitMapInfoHeader, int dwPixelAspectRatioX, int dwPixelAspectRatioY, MFVideoInterlaceMode InterlaceMode, long VideoFlags, long qwFramesPerSecondNumerator, long qwFramesPerSecondDenominator, int dwMaxBitRate, out IMFVideoMediaType ppIVideoMediaType );
/// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= /// <summary> /// Validates a media type for this transform. Since both input and output types must be /// the same, they both call this routine. /// </summary> /// <param name="pmt">The media type to validate.</param> /// <returns>S_Ok or MF_E_INVALIDTYPE.</returns> /// <history> /// 01 Nov 18 Cynic - Ported over /// </history> private HResult OnCheckMediaType(IMFMediaType pmt) { int interlace; HResult hr = HResult.S_OK; // see if the media type is one of our list of acceptable subtypes hr = TantaWMFUtils.CheckMediaType(pmt, MFMediaType.Video, m_MediaSubtypes); if (hr != HResult.S_OK) { throw new Exception("OnCheckMediaType call to TantaWMFUtils.CheckMediaType failed. Err=" + hr.ToString()); } // Video must be progressive frames. Set this now m_MightBeInterlaced = false; // get the interlace mode hr = pmt.GetUINT32(MFAttributesClsid.MF_MT_INTERLACE_MODE, out interlace); if (hr != HResult.S_OK) { throw new Exception("OnCheckMediaType call to getting the interlace mode failed. Err=" + hr.ToString()); } // set it now MFVideoInterlaceMode im = (MFVideoInterlaceMode)interlace; // Mostly we only accept Progressive. if (im == MFVideoInterlaceMode.Progressive) { return(HResult.S_OK); } // If the type MIGHT be interlaced, we'll accept it. if (im == MFVideoInterlaceMode.MixedInterlaceOrProgressive) { // But we will check to see if any samples actually // are interlaced, and reject them. m_MightBeInterlaced = true; return(HResult.S_OK); } // not a valid option return(HResult.MF_E_INVALIDTYPE); }
/// <summary> /// Validates a media type for this transform. /// </summary> /// <param name="pmt">The media type to validate.</param> /// <returns>S_Ok or MF_E_INVALIDTYPE.</returns> /// <remarks>Since both input and output types must be /// the same, they both call this routine.</remarks> private HResult OnCheckMediaType(IMFMediaType pmt, Guid[] gType) { HResult hr = HResult.S_OK; hr = CheckMediaType(pmt, MFMediaType.Video, gType); if (Succeeded(hr)) { MFError throwonhr; int interlace; // Video must be progressive frames. throwonhr = pmt.GetUINT32(MFAttributesClsid.MF_MT_INTERLACE_MODE, out interlace); MFVideoInterlaceMode im = (MFVideoInterlaceMode)interlace; if (im == MFVideoInterlaceMode.Progressive) { m_MightBeInterlaced = false; } else { if (im == MFVideoInterlaceMode.MixedInterlaceOrProgressive) { m_MightBeInterlaced = true; } else { hr = HResult.MF_E_INVALIDTYPE; } } } // In theory we should check to ensure sizes etc are the same as // input, but I'm just going to assume. return(hr); }
// Sets a description of how the frames are interlaced. public void SetInterlaceMode(MFVideoInterlaceMode mode) { int hr = GetMediaType().SetUINT32(MFAttributesClsid.MF_MT_INTERLACE_MODE, (int)mode); MFError.ThrowExceptionForHR(hr); }
// Retrieves a description of how the frames are interlaced. public void GetInterlaceMode(out MFVideoInterlaceMode pmode) { int i; int hr = GetMediaType().GetUINT32(MFAttributesClsid.MF_MT_INTERLACE_MODE, out i); MFError.ThrowExceptionForHR(hr); pmode = (MFVideoInterlaceMode)i; }
// Sets a description of how the frames are interlaced. public void SetInterlaceMode(MFVideoInterlaceMode mode) { HResult hr = GetMediaType().SetUINT32(MFAttributesClsid.MF_MT_INTERLACE_MODE, (int)mode); MFError.ThrowExceptionForHR(hr); }