本文整理汇总了C#中IPin.Disconnect方法的典型用法代码示例。如果您正苦于以下问题:C# IPin.Disconnect方法的具体用法?C# IPin.Disconnect怎么用?C# IPin.Disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPin
的用法示例。
在下文中一共展示了IPin.Disconnect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DisconnectPin
public static bool DisconnectPin(IGraphBuilder graphBuilder, IPin pin)
{
IPin other;
int hr = pin.ConnectedTo(out other);
bool allDisconnected = true;
PinInfo info;
pin.QueryPinInfo(out info);
DsUtils.FreePinInfo(info);
if (hr == 0 && other != null)
{
other.QueryPinInfo(out info);
if (!DisconnectAllPins(graphBuilder, info.filter))
{
allDisconnected = false;
}
hr = pin.Disconnect();
if (hr != 0)
{
allDisconnected = false;
}
hr = other.Disconnect();
if (hr != 0)
{
allDisconnected = false;
}
DsUtils.FreePinInfo(info);
Marshal.ReleaseComObject(other);
}
else
{
}
return allDisconnected;
}
示例2: DisconnectPin
public static bool DisconnectPin(IGraphBuilder graphBuilder, IPin pin)
{
IPin other;
int hr = pin.ConnectedTo(out other);
bool allDisconnected = true;
PinInfo info;
pin.QueryPinInfo(out info);
DsUtils.FreePinInfo(info);
Log.Info("Disconnecting pin {0}", info.name);
if (hr == 0 && other != null)
{
other.QueryPinInfo(out info);
if (!DisconnectAllPins(graphBuilder, info.filter))
{
allDisconnected = false;
}
hr = pin.Disconnect();
if (hr != 0)
{
allDisconnected = false;
Log.Error("Error disconnecting: {0:x}", hr);
}
hr = other.Disconnect();
if (hr != 0)
{
allDisconnected = false;
Log.Error("Error disconnecting other: {0:x}", hr);
}
DsUtils.FreePinInfo(info);
ReleaseComObject(other);
}
else
{
Log.Info(" Not connected");
}
return allDisconnected;
}
示例3: TryConnect
private static bool TryConnect(IGraphBuilder graphBuilder, string filtername, IPin outputPin, IBaseFilter to)
{
bool ret = false;
int hr;
FilterInfo info;
PinInfo outputInfo;
to.QueryFilterInfo(out info);
ReleaseComObject(info.pGraph);
outputPin.QueryPinInfo(out outputInfo);
DsUtils.FreePinInfo(outputInfo);
if (info.achName.Equals(filtername))
{
return false; //do not connect to self
}
Log.Debug("Testing filter: {0}", info.achName);
IEnumPins enumPins;
IPin[] pins = new IPin[1];
to.EnumPins(out enumPins);
do
{
int pinsFetched;
hr = enumPins.Next(1, pins, out pinsFetched);
if (hr != 0 || pinsFetched == 0)
{
break;
}
PinDirection direction;
pins[0].QueryDirection(out direction);
if (direction == PinDirection.Input && !HasConnection(pins[0])) // && TestMediaTypes(outputPin, pins[0]))
{
PinInfo pinInfo;
pins[0].QueryPinInfo(out pinInfo);
DsUtils.FreePinInfo(pinInfo);
Log.Debug("Testing compatibility to {0}",
pinInfo.name);
//ListMediaTypes(pins[0]);
//hr = outputPin.Connect(pins[0], null);
hr = graphBuilder.ConnectDirect(outputPin, pins[0], null);
if (hr == 0)
{
Log.Debug("Connection succeeded");
if (RenderOutputPins(graphBuilder, to))
{
Log.Info("Successfully rendered pin {0}:{1} to {2}:{3}.",
filtername, outputInfo.name, info.achName, pinInfo.name);
ret = true;
ReleaseComObject(pins[0]);
break;
}
else
{
Log.Debug("Rendering got stuck. Trying next filter, and disconnecting {0}!", outputInfo.name);
outputPin.Disconnect();
pins[0].Disconnect();
}
}
else
{
Log.Debug("Could not connect, filters are not compatible: {0:x}", hr);
}
}
ReleaseComObject(pins[0]);
} while (true);
ReleaseComObject(enumPins);
if (!ret)
{
Log.Debug("Dead end. Could not successfully connect pin {0} to filter {1}!", outputInfo.name, info.achName);
}
return ret;
}
示例4: DisconnectPin
/// <summary>
/// Disconnects a single Pin.
/// </summary>
/// <param name="graphBuilder">IGraphBuilder</param>
/// <param name="pin">Pin to disconnect</param>
/// <returns>True if successful</returns>
bool DisconnectPin(IGraphBuilder graphBuilder, IPin pin)
{
IntPtr other_ptr;
int hr = pin.ConnectedTo(out other_ptr);
bool allDisconnected = true;
if (hr == 0 && other_ptr != IntPtr.Zero)
{
IPin other = Marshal.GetObjectForIUnknown(other_ptr) as IPin;
PinInfo info;
pin.QueryPinInfo(out info);
ServiceRegistration.Get<ILogger>().Info("Disconnecting pin {0}", info.name);
FilterGraphTools.FreePinInfo(info);
other.QueryPinInfo(out info);
if (!DisconnectAllPins(graphBuilder, info.filter))
allDisconnected = false;
FilterGraphTools.FreePinInfo(info);
hr = pin.Disconnect();
if (hr != 0)
{
allDisconnected = false;
ServiceRegistration.Get<ILogger>().Error("Error disconnecting: {0:x}", hr);
}
hr = other.Disconnect();
if (hr != 0)
{
allDisconnected = false;
ServiceRegistration.Get<ILogger>().Error("Error disconnecting other: {0:x}", hr);
}
Marshal.ReleaseComObject(other);
}
else
{
ServiceRegistration.Get<ILogger>().Info(" Not connected");
}
return allDisconnected;
}