/// <summary> /// Free the nested structures and release any /// COM objects within an AMMediaType struct. /// </summary> public static void FreeAMMediaType(CoreStreaming.AMMediaType mediaType) { if (mediaType.formatSize != 0) Marshal.FreeCoTaskMem(mediaType.formatPtr); if (mediaType.unkPtr != IntPtr.Zero) Marshal.Release(mediaType.unkPtr); mediaType.formatSize = 0; mediaType.formatPtr = IntPtr.Zero; mediaType.unkPtr = IntPtr.Zero; }
public int SampleCB(double SampleTime, CoreStreaming.IMediaSample pSample) { return 0; }
/// <summary> /// Removes all filters downstream from a filter from the graph. /// This is called only by DerenderGraph() to remove everything /// from the graph except the devices and compressors. The parameter /// "removeFirstFilter" is used to keep a compressor (that should /// be immediately downstream of the device) if one is begin used. /// </summary> protected void RemoveDownstream(CoreStreaming.IBaseFilter filter, bool removeFirstFilter) { // Get a pin enumerator off the filter CoreStreaming.IEnumPins pinEnum; int hr = filter.EnumPins(out pinEnum); pinEnum.Reset(); if ((hr == 0) && (pinEnum != null)) { // Loop through each pin var pins = new CoreStreaming.IPin[1]; int f; do { // Get the next pin hr = pinEnum.Next(1, pins, out f); if ((hr == 0) && (pins[0] != null)) { // Get the pin it is connected to CoreStreaming.IPin pinTo = null; pins[0].ConnectedTo(out pinTo); if (pinTo != null) { // Is this an input pin? var info = new CoreStreaming.PinInfo(); hr = pinTo.QueryPinInfo(out info); if ((hr == 0) && (info.dir == (CoreStreaming.PinDirection.Input))) { // Recurse down this branch RemoveDownstream(info.filter, true); // Disconnect GraphBuilder.Disconnect(pinTo); GraphBuilder.Disconnect(pins[0]); // Remove this filter // but don't remove the video or audio compressors if (info.filter != VideoCompressorFilter) GraphBuilder.RemoveFilter(info.filter); } Marshal.ReleaseComObject(info.filter); Marshal.ReleaseComObject(pinTo); } Marshal.ReleaseComObject(pins[0]); } } while (hr == 0); Marshal.ReleaseComObject(pinEnum); pinEnum = null; } }