本文整理汇总了C#中IPin.ReceiveConnection方法的典型用法代码示例。如果您正苦于以下问题:C# IPin.ReceiveConnection方法的具体用法?C# IPin.ReceiveConnection怎么用?C# IPin.ReceiveConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPin
的用法示例。
在下文中一共展示了IPin.ReceiveConnection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: while
int IPin.Connect(IPin pReceivePin, AMMediaType pmt)
{
IEnumMediaTypes emt;
if (connectedPin != null)
return DsResults.E_AlreadyConnected;
if (pReceivePin == null)
return E_POINTER;
if (pReceivePin.EnumMediaTypes(out emt) == S_OK)
{
var mediaTypes = new AMMediaType[1];
while (emt.Next(1, mediaTypes, IntPtr.Zero) == S_OK)
if (mediaTypes[0].majorType == MediaType.Stream && pReceivePin.ReceiveConnection(this, mediaTypes[0]) == S_OK)
{
emt = null;
connectedPin = pReceivePin;
return S_OK;
}
emt = null;
}
if (pmt != null && pmt.majorType != MediaType.Null && pmt.majorType != MediaType.Stream)
return DsResults.E_TypeNotAccepted;
if (pReceivePin.ReceiveConnection(this, mediaType) == S_OK)
{
connectedPin = pReceivePin;
return S_OK;
}
return DsResults.E_NoAcceptableTypes;
}
示例2: 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;
}