本文整理汇总了C#中IPin类的典型用法代码示例。如果您正苦于以下问题:C# IPin类的具体用法?C# IPin怎么用?C# IPin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IPin类属于命名空间,在下文中一共展示了IPin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPinCategory
/// <summary>
/// Returns the PinCategory of the specified pin. Usually a member of PinCategory. Not all pins have a category.
/// </summary>
/// <param name="pPin"></param>
/// <returns>Guid indicating pin category or Guid.Empty on no category. Usually a member of PinCategory</returns>
public static Guid GetPinCategory(IPin pPin)
{
Guid guidRet = Guid.Empty;
// Memory to hold the returned guid
int iSize = Marshal.SizeOf(typeof(Guid));
IntPtr ipOut = Marshal.AllocCoTaskMem(iSize);
try
{
int hr;
int cbBytes;
Guid g = PropSetID.Pin;
// Get an IKsPropertySet from the pin
IKsPropertySet pKs = pPin as IKsPropertySet;
if (pKs != null)
{
// Query for the Category
hr = pKs.Get(g, (int)AMPropertyPin.Category, IntPtr.Zero, 0, ipOut, iSize, out cbBytes);
DsError.ThrowExceptionForHR(hr);
// Marshal it to the return variable
guidRet = (Guid)Marshal.PtrToStructure(ipOut, typeof(Guid));
}
}
finally
{
Marshal.FreeCoTaskMem(ipOut);
ipOut = IntPtr.Zero;
}
return guidRet;
}
示例2: GetPin
public static IPin GetPin(this IBaseFilter filter, PinDirection dir, int num)
{
IPin[] pin = new IPin[1];
IEnumPins pinsEnum = null;
if (filter.EnumPins(out pinsEnum) == 0)
{
PinDirection pinDir;
int n;
while (pinsEnum.Next(1, pin, out n) == 0)
{
pin[0].QueryDirection(out pinDir);
if (pinDir == dir)
{
if (num == 0) return pin[0];
num--;
}
Marshal.ReleaseComObject(pin[0]);
pin[0] = null;
}
}
return null;
}
示例3: interface
internal IPin Pin; // audio mixer interface (COM object)
// -------------------- Constructors/Destructors ----------------------
/// <summary> Constructor. This class cannot be created directly. </summary>
internal AudioSource( IPin pin )
{
if ( (pin as IAMAudioInputMixer) == null )
throw new NotSupportedException( "The input pin does not support the IAMAudioInputMixer interface" );
this.Pin = pin;
this.name = getName( pin );
}
示例4: GetMediaTypes
/// <summary>
/// Gets iSC's available _AMMediaTypes, without freeing pbFormat
/// Caller should call MediaType.Free(_AMMediaType[]) when done
/// </summary>
public static _AMMediaType[] GetMediaTypes(IPin pin)
{
IEnumMediaTypes iEnum;
pin.EnumMediaTypes(out iEnum);
ArrayList alMTs = new ArrayList();
IntPtr[] ptrs = new IntPtr[1];
uint fetched;
iEnum.Next(1, ptrs, out fetched);
while(fetched == 1)
{
_AMMediaType mt = (_AMMediaType)Marshal.PtrToStructure(ptrs[0], typeof(_AMMediaType));
alMTs.Add(mt);
Marshal.FreeCoTaskMem(ptrs[0]);
ptrs[0] = IntPtr.Zero;
iEnum.Next(1, ptrs, out fetched);
}
_AMMediaType[] mts = new _AMMediaType[alMTs.Count];
alMTs.CopyTo(mts);
return mts;
}
示例5: GetPinCategory
public static Guid GetPinCategory(IPin pPin)
{
var guidRet = Guid.Empty;
var iSize = Marshal.SizeOf(typeof(Guid));
var ipOut = Marshal.AllocCoTaskMem(iSize);
try
{
var g = PropSetID.Pin;
var pKs = pPin as IKsPropertySet;
if (pKs != null)
{
int cbBytes;
var hr = pKs.Get(g, (int)AMPropertyPin.Category, IntPtr.Zero, 0, ipOut, iSize, out cbBytes);
DsError.ThrowExceptionForHR(hr);
guidRet = (Guid)Marshal.PtrToStructure(ipOut, typeof(Guid));
}
}
finally
{
Marshal.FreeCoTaskMem(ipOut);
}
return guidRet;
}
示例6: GetPin
// Get pin of the filter
public IPin GetPin(PinDirection dir, int num)
{
IPin[] pin = new IPin[1];
IEnumPins pinsEnum = null;
// enum filter pins
if (m_Filter.EnumPins(out pinsEnum) == 0)
{
PinDirection pinDir;
int n;
// get next pin
while (pinsEnum.Next(1, pin, out n) == 0)
{
// query pin`s direction
pin[0].QueryDirection(out pinDir);
if (pinDir == dir)
{
if (num == 0)
return pin[0];
num--;
}
Marshal.ReleaseComObject(pin[0]);
pin[0] = null;
}
}
return null;
}
示例7: GetMinimumFreq
public AmMediaType GetMinimumFreq(IPin OutputPin)
{
AmMediaType[] types = OutputPin.GetAllMediaTypes();
IAMStreamConfig cfg = (IAMStreamConfig)OutputPin;
AmMediaType currentType = cfg.GetFormat();
WaveFormatEx currentWave = currentType.GetStruct<WaveFormatEx>();
ShowMsg(String.Format(
"CurrentOut: bps:{0} bit; ch:{1}, freq:{2} Hz",
currentWave.wBitsPerSample, currentWave.nChannels, currentWave.nSamplesPerSec
));
AmMediaType minimum = currentType;
foreach (AmMediaType type in types)
{
WaveFormatEx wave = type.GetStruct<WaveFormatEx>();
ShowMsg(String.Format(
"bps:{0} bit; ch:{1}, freq:{2} Hz",
wave.wBitsPerSample, wave.nChannels, wave.nSamplesPerSec
));
if (wave.wFormatTag == currentWave.wFormatTag &&
wave.nChannels == currentWave.nChannels &&
wave.wBitsPerSample == currentWave.wBitsPerSample &&
wave.nSamplesPerSec < currentWave.nSamplesPerSec)
{
minimum = type;
currentWave = minimum.GetStruct<WaveFormatEx>();
}
}
ShowMsg(String.Format(
"Selected: bps:{0} bit; ch:{1}, freq:{2} Hz",
currentWave.wBitsPerSample, currentWave.nChannels, currentWave.nSamplesPerSec
));
return minimum;
}
示例8: CrossbarHelper
public CrossbarHelper(IPin startingVideoInputPin)
{
foreach (PhysicalConnectorType type in Enum.GetValues(typeof(PhysicalConnectorType)))
this.pinNameByPhysicalConnectorType[type] = StringFromPinType(type);
int hr = BuildRoutingList(startingVideoInputPin, new Routing(), 0 /* Depth */);
}
示例9: CreateAudioCompressor
public static IBaseFilter CreateAudioCompressor(DisposalCleanup dc, IGraphBuilder graph, IPin outPin,
AudioFormat settings)
{
if (dc == null) throw new ArgumentNullException("dc");
if (graph == null) throw new ArgumentNullException("graph");
if (outPin == null) throw new ArgumentNullException("outPin");
if (settings == null) throw new ArgumentNullException("settings");
int hr = 0;
using (AudioCompressor compressor = AudioCompressorFactory.Create(settings))
{
IBaseFilter compressorFilter = compressor.Filter;
dc.Add(compressorFilter);
hr = graph.AddFilter(compressorFilter, settings.AudioCompressor);
DsError.ThrowExceptionForHR(hr);
FilterGraphTools.ConnectFilters(graph, outPin, compressorFilter, true);
// set the media type on the output pin of the compressor
if (compressor.MediaType != null)
{
FilterGraphTools.SetFilterFormat(compressor.MediaType, compressorFilter);
}
return compressorFilter;
}
}
示例10: ConnectedTo
public int ConnectedTo(out IPin pin)
{
// temporal
pin = null;
//throw new NotImplementedException();
return 0;
}
示例11: 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;
}
示例12: AudioSource
internal AudioSource(IPin pin)
{
if (!(pin is IAMAudioInputMixer))
{
throw new NotSupportedException("The input pin does not support the IAMAudioInputMixer interface");
}
this.Pin = pin;
base.name = this.GetName(pin);
}
示例13: GetValue
public object GetValue(IPin pin)
{
if (Dispatcher == null)
{
return pin.GetValue();
}
return Dispatcher.Invoke(() => pin.GetValue());
}
示例14: VideoOutPinConfiguration
public VideoOutPinConfiguration( IBaseFilter filter, IPin pin, int format_id, VideoInfoHeader header )
{
this.filter = filter;
this.pin = pin;
this.width = header.BmiHeader.Width;
this.height = header.BmiHeader.Height;
this.fps = 10000000 / header.AvgTimePerFrame;
this.format_id = format_id;
}
示例15: FindPin
public static IPin FindPin(IBaseFilter filter, PinDirection direction, Guid mediaType, Guid pinCategory, string preferredName)
{
if (Guid.Empty != pinCategory)
{
int idx = 0;
do
{
IPin pinByCategory = DsFindPin.ByCategory(filter, pinCategory, idx);
if (pinByCategory != null)
{
if (IsMatchingPin(pinByCategory, direction, mediaType))
return PrintInfoAndReturnPin(filter, pinByCategory, direction, mediaType, pinCategory, "found by category");
Marshal.ReleaseComObject(pinByCategory);
}
else
break;
idx++;
}
while (true);
}
if (!string.IsNullOrEmpty(preferredName))
{
IPin pinByName = DsFindPin.ByName(filter, preferredName);
if (pinByName != null && IsMatchingPin(pinByName, direction, mediaType))
return PrintInfoAndReturnPin(filter, pinByName, direction, mediaType, pinCategory, "found by name");
Marshal.ReleaseComObject(pinByName);
}
IEnumPins pinsEnum;
IPin[] pins = new IPin[1];
int hr = filter.EnumPins(out pinsEnum);
DsError.ThrowExceptionForHR(hr);
while (pinsEnum.Next(1, pins, IntPtr.Zero) == 0)
{
IPin pin = pins[0];
if (pin != null)
{
if (IsMatchingPin(pin, direction, mediaType))
return PrintInfoAndReturnPin(filter, pin, direction, mediaType, pinCategory, "found by direction and media type");
Marshal.ReleaseComObject(pin);
}
}
return null;
}