本文整理汇总了C#中IPin.QueryPinInfo方法的典型用法代码示例。如果您正苦于以下问题:C# IPin.QueryPinInfo方法的具体用法?C# IPin.QueryPinInfo怎么用?C# IPin.QueryPinInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPin
的用法示例。
在下文中一共展示了IPin.QueryPinInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetName
/// <summary> Retrieve the friendly name of a connectorType. </summary>
private string GetName(IPin pin)
{
string str = "Unknown pin";
PinInfo pinInfo = new PinInfo();
// Direction matches, so add pin name to listbox
int errorCode = pin.QueryPinInfo(out pinInfo);
if (errorCode == 0)
{
str = pinInfo.name ?? "";
}
else
{
Marshal.ThrowExceptionForHR(errorCode);
}
// The pininfo structure contains a reference to an IBaseFilter,
// so you must release its reference to prevent resource a leak.
if (pinInfo.filter != null)
{
Marshal.ReleaseComObject(pinInfo.filter);
}
pinInfo.filter = null;
return str;
}
示例2: FixFlippedVideo
public static void FixFlippedVideo(IAMVideoControl videoControl, IPin pPin)
{
VideoControlFlags pCapsFlags;
int hr = videoControl.GetCaps(pPin, out pCapsFlags);
DsError.ThrowExceptionForHR(hr);
if ((pCapsFlags & VideoControlFlags.FlipVertical) > 0)
{
hr = videoControl.GetMode(pPin, out pCapsFlags);
DsError.ThrowExceptionForHR(hr);
hr = videoControl.SetMode(pPin, pCapsFlags & ~VideoControlFlags.FlipVertical);
DsError.ThrowExceptionForHR(hr);
PinInfo pinInfo;
hr = pPin.QueryPinInfo(out pinInfo);
DsError.ThrowExceptionForHR(hr);
Trace.WriteLine("Fixing 'FlipVertical' video for pin " + pinInfo.name);
}
if ((pCapsFlags & VideoControlFlags.FlipHorizontal) > 0)
{
hr = videoControl.GetMode(pPin, out pCapsFlags);
DsError.ThrowExceptionForHR(hr);
hr = videoControl.SetMode(pPin, pCapsFlags | VideoControlFlags.FlipHorizontal);
DsError.ThrowExceptionForHR(hr);
PinInfo pinInfo;
hr = pPin.QueryPinInfo(out pinInfo);
DsError.ThrowExceptionForHR(hr);
Trace.WriteLine("Fixing 'FlipHorizontal' video for pin " + pinInfo.name);
}
}
示例3: getName
/// <summary> Retrieve the friendly name of a connectorType. </summary>
private string getName(IPin pin)
{
string s = "Unknown pin";
PinInfo pinInfo = new PinInfo();
// Direction matches, so add pin name to listbox
int hr = pin.QueryPinInfo(out pinInfo);
Marshal.ThrowExceptionForHR(hr);
s = pinInfo.name + "";
// The pininfo structure contains a reference to an IBaseFilter,
// so you must release its reference to prevent resource a leak.
if (pinInfo.filter != null)
Marshal.ReleaseComObject(pinInfo.filter);
pinInfo.filter = null;
return (s);
}
示例4: getName
private string getName(IPin pin)
{
string str = "Unknown pin";
PinInfo pInfo = new PinInfo();
int errorCode = pin.QueryPinInfo(out pInfo);
if (errorCode == 0)
{
str = pInfo.name ?? "";
}
else
{
Marshal.ThrowExceptionForHR(errorCode);
}
if (pInfo.filter != null)
{
Marshal.ReleaseComObject(pInfo.filter);
}
pInfo.filter = null;
return str;
}
示例5: PrintInfoAndReturnPin
private static IPin PrintInfoAndReturnPin(IBaseFilter filter, IPin pin, PinDirection direction, Guid mediaType, Guid pinCategory, string debugInfo)
{
if (Settings.Default.VideoGraphDebugMode)
{
FilterInfo fInfo;
int hr = filter.QueryFilterInfo(out fInfo);
DsError.ThrowExceptionForHR(hr);
string vendorInfo = null;
hr = filter.QueryVendorInfo(out vendorInfo);
if ((uint)hr != 0x80004001) /* Not Implemented*/
DsError.ThrowExceptionForHR(hr);
string mediaTypeStr = "N/A";
if (mediaType == MediaType.AnalogVideo)
mediaTypeStr = "AnalogVideo";
else if (mediaType == MediaType.Video)
mediaTypeStr = "Video";
else if (mediaType == MediaType.Null)
mediaTypeStr = "Null";
string categoryStr = "N/A";
if (pinCategory == PinCategory.Capture)
categoryStr = "Capture";
else if (pinCategory == PinCategory.Preview)
categoryStr = "Preview";
else if (pinCategory == PinCategory.AnalogVideoIn)
categoryStr = "AnalogVideoIn";
else if (pinCategory == PinCategory.CC)
categoryStr = "CC";
PinInfo pinInfo;
hr = pin.QueryPinInfo(out pinInfo);
DsError.ThrowExceptionForHR(hr);
Trace.WriteLine(string.Format("Using {0} pin '{1}' of media type '{2}' and category '{3}' {4} ({5}::{6})",
direction == PinDirection.Input ? "input" : "output",
pinInfo.name,
mediaTypeStr,
categoryStr,
debugInfo,
vendorInfo, fInfo.achName));
}
return pin;
}
示例6: TryConnect
public static bool TryConnect(IGraphBuilder graphBuilder, string filtername, IPin outputPin, bool TryNewFilters)
{
int hr;
Log.Info("----------------TryConnect-------------");
PinInfo outputInfo;
outputPin.QueryPinInfo(out outputInfo);
DsUtils.FreePinInfo(outputInfo);
//ListMediaTypes(outputPin);
ArrayList currentfilters = GetFilters(graphBuilder);
foreach (IBaseFilter filter in currentfilters)
{
if (TryConnect(graphBuilder, filtername, outputPin, filter))
{
ReleaseFilters(currentfilters);
return true;
}
}
ReleaseFilters(currentfilters);
//not found, try new filter from registry
if (TryNewFilters)
{
Log.Info("No preloaded filter could be connected. Trying to load new one from registry");
IEnumMediaTypes enumTypes;
hr = outputPin.EnumMediaTypes(out enumTypes);
if (hr != 0)
{
Log.Debug("Failed: {0:x}", hr);
return false;
}
Log.Debug("Got enum");
ArrayList major = new ArrayList();
ArrayList sub = new ArrayList();
Log.Debug("Getting corresponding filters");
for (;;)
{
AMMediaType[] mediaTypes = new AMMediaType[1];
int typesFetched;
hr = enumTypes.Next(1, mediaTypes, out typesFetched);
if (hr != 0 || typesFetched == 0)
{
break;
}
major.Add(mediaTypes[0].majorType);
sub.Add(mediaTypes[0].subType);
}
ReleaseComObject(enumTypes);
Log.Debug("Found {0} media types", major.Count);
Guid[] majorTypes = (Guid[])major.ToArray(typeof (Guid));
Guid[] subTypes = (Guid[])sub.ToArray(typeof (Guid));
Log.Debug("Loading filters");
ArrayList filters = FilterHelper.GetFilters(majorTypes, subTypes, (Merit)0x00400000);
Log.Debug("Loaded {0} filters", filters.Count);
foreach (string name in filters)
{
if (!CheckFilterIsLoaded(graphBuilder, name))
{
Log.Debug("Loading filter: {0}", name);
IBaseFilter f = AddFilterToGraph(graphBuilder, name);
if (f != null)
{
if (TryConnect(graphBuilder, filtername, outputPin, f))
{
ReleaseComObject(f);
return true;
}
else
{
graphBuilder.RemoveFilter(f);
ReleaseComObject(f);
}
}
}
else
{
Log.Debug("Ignoring filter {0}. Already in graph.", name);
}
}
}
Log.Debug("TryConnect failed.");
return outputInfo.name.StartsWith("~");
}
示例7: GetPinName
/// <summary>
/// Gets the pin name.
/// </summary>
/// <param name="pin">The pin.</param>
/// <returns>PinName</returns>
public static string GetPinName(IPin pin)
{
if (pin == null)
return "";
PinInfo pinInfo;
int hr = pin.QueryPinInfo(out pinInfo);
if (hr == 0)
{
if (pinInfo.filter != null)
Release.ComObject(pinInfo.filter);
}
return String.Format(pinInfo.name);
}
示例8: RebuildMediaType
protected void RebuildMediaType(IPin pPin)
{
if (pPin != null)
{
//Detection if the Video Stream is VC-1 on output pin of the splitter
IEnumMediaTypes enumMediaTypesAudioVideo;
int hr = pPin.EnumMediaTypes(out enumMediaTypesAudioVideo);
AMMediaType[] mediaTypes = new AMMediaType[1];
int typesFetched;
PinInfo pinInfo;
pPin.QueryPinInfo(out pinInfo);
while (0 == enumMediaTypesAudioVideo.Next(1, mediaTypes, out typesFetched))
{
if (typesFetched == 0)
break;
if (mediaTypes[0].majorType == MediaType.Video && !pinInfo.name.ToLowerInvariant().Contains("sub"))
{
if (mediaTypes[0].subType == MediaSubType.VC1)
{
Log.Info("VideoPlayer9: found VC-1 video out pin");
vc1Codec = true;
}
if (mediaTypes[0].subType == MediaSubType.H264 || mediaTypes[0].subType == MediaSubType.AVC1)
{
Log.Info("VideoPlayer9: found H264 video out pin");
h264Codec = true;
}
if (mediaTypes[0].subType == MediaSubType.XVID || mediaTypes[0].subType == MediaSubType.xvid ||
mediaTypes[0].subType == MediaSubType.dx50 || mediaTypes[0].subType == MediaSubType.DX50 ||
mediaTypes[0].subType == MediaSubType.divx || mediaTypes[0].subType == MediaSubType.DIVX)
{
Log.Info("VideoPlayer9: found XVID video out pin");
xvidCodec = true;
}
MediatypeVideo = true;
}
else if (mediaTypes[0].majorType == MediaType.Audio)
{
//Detection if the Audio Stream is AAC on output pin of the splitter
if (mediaTypes[0].subType == MediaSubType.LATMAAC || mediaTypes[0].subType == MediaSubType.AAC)
{
Log.Info("VideoPlayer9: found AAC Audio out pin");
aacCodec = true;
}
if (mediaTypes[0].subType == MediaSubType.LATMAACLAF)
{
Log.Info("VideoPlayer9: found AAC LAVF Audio out pin");
aacCodecLav = true;
}
MediatypeAudio = true;
}
else if (mediaTypes[0].majorType == MediaType.Subtitle)
{
MediatypeSubtitle = true;
}
}
DirectShowUtil.ReleaseComObject(enumMediaTypesAudioVideo);
enumMediaTypesAudioVideo = null;
}
}
示例9: logMediaTypes
private void logMediaTypes(IPin pin)
{
IEnumMediaTypes mediaTypes = null;
AMMediaType[] mediaType = new AMMediaType[1];
AMMediaType connectedMediaType = new AMMediaType();
reply = pin.ConnectionMediaType(connectedMediaType);
reply = pin.EnumMediaTypes(out mediaTypes);
if (reply != 0)
{
LogMessage("Media types cannot be determined at this time (not connected yet?)");
return;
}
while (mediaTypes.Next(mediaType.Length, mediaType, IntPtr.Zero) == 0)
{
foreach (AMMediaType currentMediaType in mediaType)
{
PinInfo pinInfo;
reply = pin.QueryPinInfo(out pinInfo);
DsError.ThrowExceptionForHR(reply);
string majorType = TranslateMediaMajorType(currentMediaType.majorType);
string subType = TranslateMediaSubType(currentMediaType.subType);
string connectedComment;
if (currentMediaType.majorType == connectedMediaType.majorType && currentMediaType.subType == connectedMediaType.subType)
connectedComment = "** Connected **";
else
connectedComment = string.Empty;
LogMessage("Media type: " +
majorType + " ; " +
subType + " " +
currentMediaType.fixedSizeSamples + " " +
currentMediaType.sampleSize + " " +
connectedComment);
}
}
}
示例10: 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;
}
示例11: QueryConnect
/// <summary>
/// QueryConnect checks if two Pins can be connected.
/// </summary>
/// <param name="pin">Pin 1</param>
/// <param name="other">Pin 2</param>
/// <returns>True if they accept connection</returns>
static bool QueryConnect(IPin pin, IPin other)
{
var pin1 = new DSPin(pin);
var pinOther = new DSPin(other);
foreach (var mediaType in pin1.MediaTypes)
{
if (pinOther.IsAccepted(mediaType))
return true;
}
PinInfo info;
PinInfo infoOther;
pin.QueryPinInfo(out info);
other.QueryPinInfo(out infoOther);
ServiceRegistration.Get<ILogger>().Info("Pins {0} and {1} do not accept each other. Tested {2} media types", info.name, infoOther.name, pin1.MediaTypes.Count);
FilterGraphTools.FreePinInfo(info);
FilterGraphTools.FreePinInfo(infoOther);
return false;
}
示例12: QueryConnect
/// <summary>
/// QueryConnect checks if two Pins can be connected.
/// </summary>
/// <param name="pin">Pin 1</param>
/// <param name="other">Pin 2</param>
/// <returns>True if they accept connection</returns>
static bool QueryConnect(IPin pin, IPin other)
{
IEnumMediaTypes enumTypes;
int hr = pin.EnumMediaTypes(out enumTypes);
if (hr != 0 || enumTypes == null)
return false;
int count = 0;
IntPtr ptrFetched = Marshal.AllocCoTaskMem(4);
try
{
for (; ; )
{
AMMediaType[] types = new AMMediaType[1];
hr = enumTypes.Next(1, types, ptrFetched);
if (hr != 0 || Marshal.ReadInt32(ptrFetched) == 0)
break;
count++;
try
{
if (other.QueryAccept(types[0]) == 0)
return true;
}
finally
{
FilterGraphTools.FreeAMMediaType(types[0]);
}
}
PinInfo info;
PinInfo infoOther;
pin.QueryPinInfo(out info);
other.QueryPinInfo(out infoOther);
ServiceRegistration.Get<ILogger>().Info("Pins {0} and {1} do not accept each other. Tested {2} media types", info.name, infoOther.name, count);
FilterGraphTools.FreePinInfo(info);
FilterGraphTools.FreePinInfo(infoOther);
return false;
}
finally
{
Marshal.FreeCoTaskMem(ptrFetched);
}
}
示例13: Connect
public int Connect(IPin pReceivePin, AMMediaType pmt)
{
Monitor.Enter(this);
int hr = S_OK;
pin = null;
pintype = null;
allocator = null;
string id = "Unnamed pin";
pReceivePin.QueryId(out id);
PinInfo pi = new PinInfo();
hr = pReceivePin.QueryPinInfo(out pi);
if (hr == S_OK)
{
FilterInfo fi = new FilterInfo();
hr = pi.filter.QueryFilterInfo(out fi);
if (hr == S_OK)
{
id += (" (" + fi.achName);
}
Guid guid;
hr = pi.filter.GetClassID(out guid);
if (hr == S_OK)
{
id += (", " + guid.ToString());
}
id += ")";
}
try
{
AMMediaType amt = null;
if (pmt != null)
{
amt = pmt;
}
else
#if false
{
IEnumMediaTypes ie;
hr = pReceivePin.EnumMediaTypes(out ie);
int fetched;
int alloc = Marshal.SizeOf(typeof(AMMediaType));
IntPtr mtypePtr = Marshal.AllocCoTaskMem(alloc);
while (ie.Next(1, mtypePtr, out fetched) == S_OK)
{
amt = new AMMediaType();
Marshal.PtrToStructure(mtypePtr, amt);
hr = pReceivePin.QueryAccept(amt);
if (hr == S_OK)
{
break;
}
DsUtils.FreeAMMediaType(amt);
amt = null;
}
if (fetched == 0)
{
amt = null;
}
Marshal.FreeCoTaskMem(mtypePtr);
}
if (amt == null)
#endif
{
amt = mediatype;
}
hr = pReceivePin.QueryAccept(amt);
if (hr == S_FALSE)
{
log.InfoFormat("No media type for pin '{0}'", id);
Monitor.Exit(this);
return VFW_E_NO_ACCEPTABLE_TYPES;
}
hr = pReceivePin.ReceiveConnection(this, amt);
if (hr == VFW_E_TYPE_NOT_ACCEPTED)
{
log.InfoFormat("No connection to pin '{0}'", id);
Monitor.Exit(this);
return VFW_E_NO_ACCEPTABLE_TYPES;
}
DsError.ThrowExceptionForHR(hr);
pin = pReceivePin;
pintype = amt;
}
catch (Exception e)
{
LogUtil.ExceptionLog.ErrorFormat("Caught exception in connect ({0}): {1}{2}", id, e.Message, e.StackTrace);
pin = null;
pintype = null;
allocator = null;
Monitor.Exit(this);
return VFW_E_NO_TRANSPORT;
}
Monitor.Exit(this);
log.InfoFormat("Connected to pin '{0}'", id);
return S_OK;
}
示例14: 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;
}
示例15: 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;
}