private void ConfigurePusher(IGenericSampleConfig2 ips, ImageHandler ih) { int hr; ih.SetMediaType(ips); // Specify the callback routine to call with each sample hr = ips.SetBitmapCB(ih); DsError.ThrowExceptionForHR(hr); }
/// <summary> /// This method calls the GSSF and specifies the media type to use. This /// overridable method builds a generic AMMediaType based on the arguments /// passed to the constructor. /// </summary> /// <param name="psc">Interface pointer to the GSSF</param> public override void SetMediaType(IGenericSampleConfig2 psc) { VideoInfoHeader2 vih2 = new VideoInfoHeader2(); vih2.BmiHeader = new BitmapInfoHeader(); vih2.SrcRect = new DsRect(0, 0, m_Width, m_Height); vih2.TargetRect = new DsRect(0, 0, m_Width, m_Height); // Build a BitmapInfo struct using the parms from the file vih2.BmiHeader.Size = Marshal.SizeOf(typeof(BitmapInfoHeader)); vih2.BmiHeader.Width = m_Width; vih2.BmiHeader.Height = m_Height; vih2.BmiHeader.Planes = 1; vih2.BmiHeader.BitCount = m_bpp; vih2.BmiHeader.Compression = (int)m_SubType; vih2.BmiHeader.ImageSize = ((vih2.BmiHeader.BitCount * vih2.BmiHeader.Width) / 8) * vih2.BmiHeader.Height; vih2.BmiHeader.XPelsPerMeter = 0; vih2.BmiHeader.YPelsPerMeter = 0; vih2.BmiHeader.ClrUsed = 0; vih2.BmiHeader.ClrImportant = 0; vih2.BmiHeader.Height *= -1; // The bitmap is a top-down DIB vih2.BitRate = (int)(vih2.BmiHeader.ImageSize * 8 * m_Fps); vih2.BitErrorRate = 0; vih2.AvgTimePerFrame = UNIT / m_Fps; vih2.InterlaceFlags = 0; vih2.CopyProtectFlags = 0; vih2.PictAspectRatioX = 4; vih2.PictAspectRatioY = 3; vih2.ControlFlags = 0; vih2.Reserved2 = 0; // Free any previous media type if (m_pmt != null) { DsUtils.FreeAMMediaType(m_pmt); } m_pmt = new AMMediaType(); m_pmt.majorType = MediaType.Video; m_pmt.fixedSizeSamples = true; m_pmt.temporalCompression = false; m_pmt.formatType = FormatType.VideoInfo2; m_pmt.sampleSize = vih2.BmiHeader.ImageSize; int iStride; if ((int)m_SubType == 3) // 3 == BI_BITFIELDS { Debug.Assert(vih2.BmiHeader.BitCount == 32); // 16bit uses a slightly different format m_pmt.subType = MediaSubType.ARGB32; // Can't use the compression type to compute the subtype m_pmt.formatSize = Marshal.SizeOf(vih2) + (3 * (m_bpp / 8)); // Make room for the bitfields m_pmt.formatPtr = Marshal.AllocCoTaskMem(m_pmt.formatSize); if (m_bpp != 16) { vih2.BmiHeader.Size += 3 * sizeof(int); // One byte per color Marshal.WriteInt32(m_pmt.formatPtr, 0xff); // Red Marshal.WriteInt32(m_pmt.formatPtr, 4, 0xff00); // Green Marshal.WriteInt32(m_pmt.formatPtr, 8, 0xff0000); // Blue } else { // Todo - 555, 565 } iStride = (m_Width * m_bpp) / 8; } else { // Calculate the stride from the compression type MFExtern.MFGetStrideForBitmapInfoHeader(vih2.BmiHeader.Compression, vih2.BmiHeader.Width, out iStride); m_pmt.subType = (Guid)m_SubType; m_pmt.formatSize = Marshal.SizeOf(vih2); m_pmt.formatPtr = Marshal.AllocCoTaskMem(m_pmt.formatSize); } m_pmt.sampleSize = iStride * m_Height; Marshal.StructureToPtr(vih2, m_pmt.formatPtr, false); int hr = psc.SetPinMediaType(m_pmt); DsError.ThrowExceptionForHR(hr); }
/// <summary> /// Calls the GSSF to specify the media type. Must be called before pins try to connect. /// </summary> /// <param name="psc">Pointer to the GSSF</param> public abstract void SetMediaType(IGenericSampleConfig2 psc);
/// <summary> /// Calls the GSSF to specify the media type. Must be called before pins try to connect. /// </summary> /// <param name="psc">Pointer to the GSSF</param> abstract public void SetMediaType(IGenericSampleConfig2 psc);