本文整理汇总了C#中IPin.ConnectionMediaType方法的典型用法代码示例。如果您正苦于以下问题:C# IPin.ConnectionMediaType方法的具体用法?C# IPin.ConnectionMediaType怎么用?C# IPin.ConnectionMediaType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPin
的用法示例。
在下文中一共展示了IPin.ConnectionMediaType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
}
示例2: ChangePinFormat
private void ChangePinFormat(IPin pin, int samplesPerSec, bool forceMono)
{
AMMediaType outputMediaType = new AMMediaType();
pin.ConnectionMediaType(outputMediaType);
var formatEx = Marshal.PtrToStructure(outputMediaType.formatPtr, typeof(WaveFormatEx)) as WaveFormatEx;
if (samplesPerSec != 0 && samplesPerSec < formatEx.nSamplesPerSec)
formatEx.nSamplesPerSec = samplesPerSec;
if (forceMono)
formatEx.nChannels = 1;
formatEx.nBlockAlign = (short)(formatEx.nChannels * 2); // * 2 for 16 bit
formatEx.nAvgBytesPerSec = formatEx.nSamplesPerSec * formatEx.nBlockAlign;
Marshal.StructureToPtr(formatEx, outputMediaType.formatPtr, true);
IAMStreamConfig streamConfig = (IAMStreamConfig)pin;
streamConfig.SetFormat(outputMediaType);
}