本文整理汇总了C#中IBaseFilter类的典型用法代码示例。如果您正苦于以下问题:C# IBaseFilter类的具体用法?C# IBaseFilter怎么用?C# IBaseFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IBaseFilter类属于命名空间,在下文中一共展示了IBaseFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConnectFilter
private static bool ConnectFilter(IFilterGraph2 graphBuilder, IBaseFilter networkFilter, IBaseFilter tunerFilter)
{
IPin pinOut = DsFindPin.ByDirection(networkFilter, PinDirection.Output, 0);
IPin pinIn = DsFindPin.ByDirection(tunerFilter, PinDirection.Input, 0);
int hr = graphBuilder.Connect(pinOut, pinIn);
return (hr == 0);
}
示例2: Hauppauge
//Initializes the Hauppauge interfaces
/// <summary>
/// Constructor: Require the Hauppauge capture filter, and the deviceid for the card to be passed in
/// </summary>
public Hauppauge(IBaseFilter filter, string tuner)
{
try
{
//Don't create the class if we don't have any filter;
if (filter == null)
{
return;
}
//Load Library
hauppaugelib = LoadLibrary("hauppauge.dll");
//Get Proc addresses, and set the delegates for each function
IntPtr procaddr = GetProcAddress(hauppaugelib, "Init");
_Init = (Init)Marshal.GetDelegateForFunctionPointer(procaddr, typeof (Init));
procaddr = GetProcAddress(hauppaugelib, "DeInit");
_DeInit = (DeInit)Marshal.GetDelegateForFunctionPointer(procaddr, typeof (DeInit));
procaddr = GetProcAddress(hauppaugelib, "IsHauppauge");
_IsHauppauge = (IsHauppauge)Marshal.GetDelegateForFunctionPointer(procaddr, typeof (IsHauppauge));
procaddr = GetProcAddress(hauppaugelib, "SetVidBitRate");
_SetVidBitRate = (SetVidBitRate)Marshal.GetDelegateForFunctionPointer(procaddr, typeof (SetVidBitRate));
procaddr = GetProcAddress(hauppaugelib, "GetVidBitRate");
_GetVidBitRate = (GetVidBitRate)Marshal.GetDelegateForFunctionPointer(procaddr, typeof (GetVidBitRate));
procaddr = GetProcAddress(hauppaugelib, "SetAudBitRate");
_SetAudBitRate = (SetAudBitRate)Marshal.GetDelegateForFunctionPointer(procaddr, typeof (SetAudBitRate));
procaddr = GetProcAddress(hauppaugelib, "GetAudBitRate");
_GetAudBitRate = (GetAudBitRate)Marshal.GetDelegateForFunctionPointer(procaddr, typeof (GetAudBitRate));
procaddr = GetProcAddress(hauppaugelib, "SetStreamType");
_SetStreamType = (SetStreamType)Marshal.GetDelegateForFunctionPointer(procaddr, typeof (SetStreamType));
procaddr = GetProcAddress(hauppaugelib, "GetStreamType");
_GetStreamType = (GetStreamType)Marshal.GetDelegateForFunctionPointer(procaddr, typeof (GetStreamType));
procaddr = GetProcAddress(hauppaugelib, "SetDNRFilter");
_SetDNRFilter = (SetDNRFilter)Marshal.GetDelegateForFunctionPointer(procaddr, typeof (SetDNRFilter));
//Hack
//The following is strangely necessary when using delegates instead of P/Invoke - linked to MP using utf-8
//Hack
byte[] encodedstring = Encoding.UTF32.GetBytes(tuner);
string card = Encoding.Unicode.GetString(encodedstring);
hr = new HResult(_Init(filter, card));
Log.Log.WriteFile("Hauppauge Quality Control Initializing " + hr.ToDXString());
}
catch (Exception ex)
{
Log.Log.WriteFile("Hauppauge Init failed " + ex.Message);
}
}
示例3: Create
public void Create(ref string strAVIin, ref string strAVIout, ref string strDevice, ref string strPinOut, ref IBaseFilter pRen)
{
var hr = 0;
_class.Debug.Log("");
_class.Debug.Log("Creating AVI renderer");
var pAviDecompressor = (IBaseFilter) new AVIDec();
hr = _class.Graph.CaptureGraph.AddFilter(pAviDecompressor, "AVI Decompressor");
_class.Debug.Log("-> " + DsError.GetErrorText(hr));
_class.GraphPin.ListPin(pAviDecompressor);
strAVIin = _class.GraphPin.AssumePinIn("XForm");
strAVIout = _class.GraphPin.AssumePinOut("XForm");
_class.Debug.Log("");
_class.Debug.Log("*** Connect " + strDevice + " (" + strPinOut + ") to AVI Decompressor (" + strAVIin + ")");
hr = _class.Graph.CaptureGraph.ConnectDirect(_class.GraphPin.GetPin(pRen, strPinOut), _class.GraphPin.GetPin(pAviDecompressor, strAVIin), null);
if (hr == 0)
{
_class.Debug.Log("[OK] Connected " + strDevice + " to AVI Decompressor");
pRen = pAviDecompressor;
strDevice = "AVI Decompressor";
strPinOut = strAVIout;
}
else
{
_class.Debug.Log("[FAIL] Can't connected " + strDevice + " to AVI Decompressor. May interrupt operation");
}
}
示例4: BuildGraph
private void BuildGraph(string fileName)
{
int hr = 0;
try
{
graphBuilder = (IFilterGraph2)new FilterGraph();
mediaControl = (IMediaControl)graphBuilder;
mediaSeeking = (IMediaSeeking)graphBuilder;
mediaPosition = (IMediaPosition)graphBuilder;
vmr9 = (IBaseFilter)new VideoMixingRenderer9();
ConfigureVMR9InWindowlessMode();
hr = graphBuilder.AddFilter(vmr9, "Video Mixing Renderer 9");
DsError.ThrowExceptionForHR(hr);
hr = graphBuilder.RenderFile(fileName, null);
DsError.ThrowExceptionForHR(hr);
}
catch (Exception e)
{
CloseInterfaces();
MessageBox.Show("An error occured during the graph building : \r\n\r\n" + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例5: PinInfo
/// <summary>
/// Erzeugt eine neue Beschreibung.
/// </summary>
/// <param name="direction">Die Übertragunsrichtung des Endpunktes.</param>
/// <param name="name">Der eindeutige Name des Endpunktes.</param>
/// <param name="filter">Der Filter, zu dem dieser Endpunkt gehört.</param>
public PinInfo( PinDirection direction, string name, IBaseFilter filter )
{
// Remember all
Filter = Marshal.GetComInterfaceForObject( filter, typeof( IBaseFilter ) );
Direction = direction;
Name = name;
}
示例6: ViXSATSC
/// <summary>
/// Initializes a new instance of the <see cref="ViXSATSC"/> class.
/// </summary>
/// <param name="tunerFilter">The tuner filter.</param>
public ViXSATSC(IBaseFilter tunerFilter)
{
IPin pin = DsFindPin.ByName(tunerFilter, "MPEG2 Transport");
if (pin != null)
{
_propertySet = tunerFilter as IKsPropertySet;
if (_propertySet != null)
{
KSPropertySupport supported;
_propertySet.QuerySupported(guidViXSTunerExtention, (int)BdaDigitalModulator.MODULATION_TYPE, out supported);
if ((supported & KSPropertySupport.Set) != 0)
{
Log.Log.Debug("ViXS ATSC: DVB-S card found!");
_tempValue = Marshal.AllocCoTaskMem(1024);
_isViXSATSC = true;
}
else
{
Log.Log.Debug("ViXS ATSC: card NOT found!");
_isViXSATSC = false;
}
}
}
else
Log.Log.Info("ViXS ATSC: could not find MPEG2 Transport pin!");
}
示例7: GetPin
/// <summary>
/// Get filter's pin.
/// </summary>
///
/// <param name="filter">Filter to get pin of.</param>
/// <param name="dir">Pin's direction.</param>
/// <param name="num">Pin's number.</param>
///
/// <returns>Returns filter's pin.</returns>
///
public static IPin GetPin( IBaseFilter filter, PinDirection dir, int num )
{
IPin[] pin = new IPin[1];
IEnumPins pinsEnum = null;
// enum filter pins
if ( 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;
}
示例8: Run
public static void Run()
{
var fg = FilterGraph.Create();
var mc = (IMediaControl)fg;
var me = (IMediaEvent)fg;
fg.RenderFile("c:\\test.mp3", IntPtr.Zero);
IEnumFilters ief;
var filters = new IBaseFilter[8];
fg.EnumFilters(out ief);
int fetched;
ief.Next(8, filters, out fetched);
for (int i = 0; i < fetched; i++)
{
var ibf = filters[i];
FilterInfo fi;
ibf.QueryFilterInfo(out fi);
string vendorInfo = "";
try
{
ibf.QueryVendorInfo(out vendorInfo);
}
catch (Exception)
{
}
Console.WriteLine(fi.Name + " " + vendorInfo);
}
Console.ReadLine();
}
示例9: GenericATSC
/// <summary>
/// Initializes a new instance of the <see cref="GenericATSC"/> class.
/// </summary>
/// <param name="tunerFilter">The tuner filter.</param>
public GenericATSC(IBaseFilter tunerFilter)
{
IPin pin = DsFindPin.ByName(tunerFilter, "MPEG2 Transport");
if (pin != null)
{
_propertySet = pin as IKsPropertySet;
if (_propertySet != null)
{
KSPropertySupport supported;
_propertySet.QuerySupported(guidBdaDigitalDemodulator, (int)BdaDigitalModulator.MODULATION_TYPE, out supported);
if ((supported & KSPropertySupport.Set) != 0)
{
Log.Log.Debug("GenericATSC: QAM capable card found!");
_isGenericATSC = true;
_tempValue = Marshal.AllocCoTaskMem(1024);
_tempInstance = Marshal.AllocCoTaskMem(1024);
}
else
{
Log.Log.Debug("GenericATSC: QAM card NOT found!");
_isGenericATSC = false;
}
}
}
else
Log.Log.Info("GenericATSC: tuner pin not found!");
}
示例10: TBSDVBS2Handler
internal TBSDVBS2Handler(IBaseFilter tunerFilter, Tuner tuner)
{
if (!tuner.Name.ToUpperInvariant().Contains("TBS"))
return;
IPin pin = DsFindPin.ByDirection(tunerFilter, PinDirection.Input, 0);
if (pin != null)
{
propertySet = pin as IKsPropertySet;
if (propertySet != null)
{
KSPropertySupport supported;
reply = propertySet.QuerySupported(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_NBC_PARAMS, out supported);
if (reply == 0)
{
dvbs2Capable = (supported & KSPropertySupport.Get) == KSPropertySupport.Get || (supported & KSPropertySupport.Set) == KSPropertySupport.Set;
if (dvbs2Capable)
{
useSet = (supported & KSPropertySupport.Set) == KSPropertySupport.Set;
useGet = !useSet;
}
}
}
}
}
示例11: Hauppauge
/// <summary>
/// Initializes a new instance of the <see cref="Hauppauge"/> class.
/// </summary>
/// <param name="tunerFilter">The tuner filter.</param>
public Hauppauge(IBaseFilter tunerFilter)
{
IPin pin = DsFindPin.ByDirection(tunerFilter, PinDirection.Input, 0);
if (pin != null)
{
_propertySet = pin as IKsPropertySet;
if (_propertySet != null)
{
KSPropertySupport supported;
_propertySet.QuerySupported(BdaTunerExtentionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_DISEQC,
out supported);
if ((supported & KSPropertySupport.Set) != 0)
{
Log.Log.Debug("Hauppauge: DVB-S card found!");
_isHauppauge = true;
_ptrDiseqc = Marshal.AllocCoTaskMem(1024);
_tempValue = Marshal.AllocCoTaskMem(1024);
_tempInstance = Marshal.AllocCoTaskMem(1024);
}
else
{
Log.Log.Debug("Hauppauge: DVB-S card NOT found!");
_isHauppauge = false;
Dispose();
}
}
}
else
Log.Log.Info("Hauppauge: tuner pin not found!");
}
示例12: ConnectFilter
public static int ConnectFilter(IGraphBuilder graph, IBaseFilter up, IBaseFilter down)
{
IPin pinSrc = null;
int i = 0;
while ( (pinSrc = DsFindPin.ByDirection(up, PinDirection.Output, i++) ) != null )
{
IPin pinDest = null;
int j = 0;
while((pinDest = DsFindPin.ByDirection(down, PinDirection.Input, j++)) != null)
{
try
{
ConnectFilters(graph, pinSrc, pinDest, true);
}
catch(Exception e)
{
Marshal.FinalReleaseComObject(pinDest);
continue;
}
//�ɹ�
Marshal.FinalReleaseComObject(pinSrc);
Marshal.FinalReleaseComObject(pinDest);
return 0;
}
Marshal.FinalReleaseComObject(pinSrc);
}
return -1;
}
示例13: TwinhanDVBS2Handler
public TwinhanDVBS2Handler(IBaseFilter filter)
{
captureFilter = filter;
if (filter != null)
dvbs2Capable = checkTwinhanInterface();
}
示例14: SetupAudio
protected virtual void SetupAudio()
{
int hr;
IEnumFilters enumFilters;
hr = _graph.EnumFilters(out enumFilters);
DsError.ThrowExceptionForHR(hr);
IBaseFilter[] filters = new IBaseFilter[1];
IntPtr fetched = new IntPtr();
while (enumFilters.Next(1, filters, fetched) == 0)
{
IBaseFilter filter = filters[0] as IBaseFilter;
IPin unconnectedPin = DsFindPin.ByConnectionStatus((IBaseFilter)filter, PinConnectedStatus.Unconnected, 0);
if (unconnectedPin != null)
{
PinDirection direction;
hr = unconnectedPin.QueryDirection(out direction);
DsError.ThrowExceptionForHR(hr);
if (direction == PinDirection.Output)
{
hr = _graph.Render(unconnectedPin);
DsError.ThrowExceptionForHR(hr);
SetupSampleGrabber();
}
}
}
}
示例15: createSmartTee
public void createSmartTee(ref string strPreviewIn, ref string strPreviewOut, ref string strDevice, ref string strPinOut, ref IBaseFilter pRen)
{
int hr = 0;
_class.Debug.Log("");
_class.Debug.Log("Creating SmartTee Preview Filter");
IBaseFilter pSmartTee2 = (IBaseFilter)new DirectShowLib.SmartTee();
hr = _class.Graph.CaptureGraph.AddFilter(pSmartTee2, "Smart Tee");
_class.Debug.Log(DsError.GetErrorText(hr));
_class.Debug.Log("");
_class.GraphPin.ListPin(pSmartTee2);
strPreviewIn = _class.GraphPin.AssumePinIn("Input");
strPreviewOut = _class.GraphPin.AssumePinOut("Preview");
_class.Debug.Log("");
_class.Debug.Log("*** Connect " + strDevice + " (" + strPinOut + ") to SmartTee Preview Filter (" + strPreviewIn + ")");
hr = _class.Graph.CaptureGraph.ConnectDirect(_class.GraphPin.GetPin(pRen, strPinOut), _class.GraphPin.GetPin(pSmartTee2, strPreviewIn), null);
if (hr == 0)
{
_class.Debug.Log("[OK] Connected " + strDevice + " to SmartTee Preview Filter");
strDevice = "SmartTee Preview Filter";
pRen = pSmartTee2;
strPinOut = strPreviewOut;
}
else
{
_class.Debug.Log("[NG] cant Connect " + strDevice + " to Preview Filter. Attempting to continue without preview");
_class.Debug.Log("-> " + DsError.GetErrorText(hr));
}
}