当前位置: 首页>>代码示例>>C#>>正文


C# IGraphBuilder.IsNull方法代码示例

本文整理汇总了C#中IGraphBuilder.IsNull方法的典型用法代码示例。如果您正苦于以下问题:C# IGraphBuilder.IsNull方法的具体用法?C# IGraphBuilder.IsNull怎么用?C# IGraphBuilder.IsNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IGraphBuilder的用法示例。


在下文中一共展示了IGraphBuilder.IsNull方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddFilterFromClsid

		public static IBaseFilter AddFilterFromClsid(IGraphBuilder graphBuilder, Guid clsid, string name)
		{
			int hr = 0;
			IBaseFilter filter = null;

			if (graphBuilder.IsNull())
				throw new ArgumentNullException("graphBuilder");

			try
			{
				Type type = Type.GetTypeFromCLSID(clsid);
				filter = (IBaseFilter)Activator.CreateInstance(type);

				hr = graphBuilder.AddFilter(filter, name);
				DsError.ThrowExceptionForHR(hr);
			}
			catch
			{
				if (filter.NotNull())
				{
					Marshal.ReleaseComObject(filter);
					filter = null;
				}
			}

			return filter;
		}
开发者ID:davinx,项目名称:Imint.Media.DirectShow,代码行数:27,代码来源:FilterGraphTools.cs

示例2: ConnectFilters

		public static void ConnectFilters(IGraphBuilder graphBuilder, IPin sourcePin, IPin destPin, bool useIntelligentConnect)
		{
			int hr = 0;

			if (graphBuilder.IsNull())
				throw new ArgumentNullException("graphBuilder");

			if (sourcePin.IsNull())
				throw new ArgumentNullException("sourcePin");

			if (destPin.IsNull())
				throw new ArgumentNullException("destPin");

			if (useIntelligentConnect)
			{
				hr = graphBuilder.Connect(sourcePin, destPin);
				DsError.ThrowExceptionForHR(hr);
			}
			else
			{
				hr = graphBuilder.ConnectDirect(sourcePin, destPin, null);
				DsError.ThrowExceptionForHR(hr);
			}
		}
开发者ID:davinx,项目名称:Imint.Media.DirectShow,代码行数:24,代码来源:FilterGraphTools.cs

示例3: SaveGraphFile

		public static void SaveGraphFile(IGraphBuilder graphBuilder, string fileName)
		{
			int hr = 0;
			IStorage storage = null;
#if USING_NET11
			UCOMIStream stream = null;
#else
			IStream stream = null;
#endif

			if (graphBuilder.IsNull())
				throw new ArgumentNullException("graphBuilder");

			try
			{
				hr = NativeMethods.StgCreateDocfile(
					fileName,
					STGM.Create | STGM.Transacted | STGM.ReadWrite | STGM.ShareExclusive,
					0,
					out storage
					);

				Marshal.ThrowExceptionForHR(hr);

				hr = storage.CreateStream(
					@"ActiveMovieGraph",
					STGM.Write | STGM.Create | STGM.ShareExclusive,
					0,
					0,
					out stream
					);

				Marshal.ThrowExceptionForHR(hr);

				hr = (graphBuilder as IPersistStream).Save(stream, true);
				Marshal.ThrowExceptionForHR(hr);

				hr = storage.Commit(STGC.Default);
				Marshal.ThrowExceptionForHR(hr);
			}
			finally
			{
				if (stream.NotNull())
					Marshal.ReleaseComObject(stream);
				if (storage.NotNull())
					Marshal.ReleaseComObject(storage);
			}
		}
开发者ID:davinx,项目名称:Imint.Media.DirectShow,代码行数:48,代码来源:FilterGraphTools.cs

示例4: LoadGraphFile

		public static void LoadGraphFile(IGraphBuilder graphBuilder, string fileName)
		{
			int hr = 0;
			IStorage storage = null;
#if USING_NET11
			UCOMIStream stream = null;
#else
			IStream stream = null;
#endif

			if (graphBuilder.IsNull())
				throw new ArgumentNullException("graphBuilder");

			try
			{
				if (NativeMethods.StgIsStorageFile(fileName) != 0)
					throw new ArgumentException();

				hr = NativeMethods.StgOpenStorage(
					fileName,
					null,
					STGM.Transacted | STGM.Read | STGM.ShareDenyWrite,
					IntPtr.Zero,
					0,
					out storage
					);

				Marshal.ThrowExceptionForHR(hr);

				hr = storage.OpenStream(
					@"ActiveMovieGraph",
					IntPtr.Zero,
					STGM.Read | STGM.ShareExclusive,
					0,
					out stream
					);

				Marshal.ThrowExceptionForHR(hr);

				hr = (graphBuilder as IPersistStream).Load(stream);
				Marshal.ThrowExceptionForHR(hr);
			}
			finally
			{
				if (stream.NotNull())
					Marshal.ReleaseComObject(stream);
				if (storage.NotNull())
					Marshal.ReleaseComObject(storage);
			}
		}
开发者ID:davinx,项目名称:Imint.Media.DirectShow,代码行数:50,代码来源:FilterGraphTools.cs

示例5: DisconnectAllPins

		public static void DisconnectAllPins(IGraphBuilder graphBuilder)
		{
			int hr = 0;
			IEnumFilters enumFilters;

			if (graphBuilder.IsNull())
				throw new ArgumentNullException("graphBuilder");

			hr = graphBuilder.EnumFilters(out enumFilters);
			DsError.ThrowExceptionForHR(hr);

			try
			{
				IBaseFilter[] filters = new IBaseFilter[1];

				while (enumFilters.Next(filters.Length, filters, IntPtr.Zero) == 0)
				{
					try
					{
						DisconnectPins(filters[0]);
					}
					catch { }
					Marshal.ReleaseComObject(filters[0]);
				}
			}
			finally
			{
				Marshal.ReleaseComObject(enumFilters);
			}
		}
开发者ID:davinx,项目名称:Imint.Media.DirectShow,代码行数:30,代码来源:FilterGraphTools.cs

示例6: RemoveAllFilters

		public static void RemoveAllFilters(IGraphBuilder graphBuilder)
		{
			int hr = 0;
			IEnumFilters enumFilters;
			ArrayList filtersArray = new ArrayList();

			if (graphBuilder.IsNull())
				throw new ArgumentNullException("graphBuilder");

			hr = graphBuilder.EnumFilters(out enumFilters);
			DsError.ThrowExceptionForHR(hr);

			try
			{
				IBaseFilter[] filters = new IBaseFilter[1];

				while (enumFilters.Next(filters.Length, filters, IntPtr.Zero) == 0)
				{
					filtersArray.Add(filters[0]);
				}
			}
			finally
			{
				Marshal.ReleaseComObject(enumFilters);
			}

			foreach (IBaseFilter filter in filtersArray)
			{
				hr = graphBuilder.RemoveFilter(filter);
				Marshal.ReleaseComObject(filter);
			}
		}
开发者ID:davinx,项目名称:Imint.Media.DirectShow,代码行数:32,代码来源:FilterGraphTools.cs

示例7: RenderPin

		public static bool RenderPin(IGraphBuilder graphBuilder, IBaseFilter source, string pinName)
		{
			int hr = 0;

			if (graphBuilder.IsNull())
				throw new ArgumentNullException("graphBuilder");

			if (source.IsNull())
				throw new ArgumentNullException("source");

			IPin pin = DsFindPin.ByName(source, pinName);

			if (pin.NotNull())
			{
				hr = graphBuilder.Render(pin);
				Marshal.ReleaseComObject(pin);

				return (hr >= 0);
			}

			return false;
		}
开发者ID:davinx,项目名称:Imint.Media.DirectShow,代码行数:22,代码来源:FilterGraphTools.cs

示例8: FindFilterByClsid

		public static IBaseFilter FindFilterByClsid(IGraphBuilder graphBuilder, Guid filterClsid)
		{
			int hr = 0;
			IBaseFilter filter = null;
			IEnumFilters enumFilters = null;

			if (graphBuilder.IsNull())
				throw new ArgumentNullException("graphBuilder");

			hr = graphBuilder.EnumFilters(out enumFilters);
			if (hr == 0)
			{
				IBaseFilter[] filters = new IBaseFilter[1];

				while (enumFilters.Next(filters.Length, filters, IntPtr.Zero) == 0)
				{
					Guid clsid;

					hr = filters[0].GetClassID(out clsid);

					if ((hr == 0) && (clsid == filterClsid))
					{
						filter = filters[0];
						break;
					}

					Marshal.ReleaseComObject(filters[0]);
				}
				Marshal.ReleaseComObject(enumFilters);
			}

			return filter;
		}
开发者ID:davinx,项目名称:Imint.Media.DirectShow,代码行数:33,代码来源:FilterGraphTools.cs

示例9: FindFilterByName

		public static IBaseFilter FindFilterByName(IGraphBuilder graphBuilder, string filterName)
		{
			int hr = 0;
			IBaseFilter filter = null;
			IEnumFilters enumFilters = null;

			if (graphBuilder.IsNull())
				throw new ArgumentNullException("graphBuilder");

			hr = graphBuilder.EnumFilters(out enumFilters);
			if (hr == 0)
			{
				IBaseFilter[] filters = new IBaseFilter[1];

				while (enumFilters.Next(filters.Length, filters, IntPtr.Zero) == 0)
				{
					FilterInfo filterInfo;

					hr = filters[0].QueryFilterInfo(out filterInfo);
					if (hr == 0)
					{
						if (filterInfo.pGraph.NotNull())
							Marshal.ReleaseComObject(filterInfo.pGraph);

						if (filterInfo.achName.Equals(filterName))
						{
							filter = filters[0];
							break;
						}
					}

					Marshal.ReleaseComObject(filters[0]);
				}
				Marshal.ReleaseComObject(enumFilters);
			}

			return filter;
		}
开发者ID:davinx,项目名称:Imint.Media.DirectShow,代码行数:38,代码来源:FilterGraphTools.cs

示例10: AddFilterByDevicePath

		public static IBaseFilter AddFilterByDevicePath(IGraphBuilder graphBuilder, string devicePath, string name)
		{
			int hr = 0;
			IBaseFilter filter = null;
#if USING_NET11
			UCOMIBindCtx bindCtx = null;
			UCOMIMoniker moniker = null;
#else
			IBindCtx bindCtx = null;
			IMoniker moniker = null;
#endif
			int eaten;

			if (graphBuilder.IsNull())
				throw new ArgumentNullException("graphBuilder");

			try
			{
				hr = NativeMethods.CreateBindCtx(0, out bindCtx);
				Marshal.ThrowExceptionForHR(hr);

				hr = NativeMethods.MkParseDisplayName(bindCtx, devicePath, out eaten, out moniker);
				Marshal.ThrowExceptionForHR(hr);

				hr = (graphBuilder as IFilterGraph2).AddSourceFilterForMoniker(moniker, bindCtx, name, out filter);
				DsError.ThrowExceptionForHR(hr);
			}
			catch
			{
				// An error occur. Just returning null...
			}
			finally
			{
				if (bindCtx.NotNull()) Marshal.ReleaseComObject(bindCtx);
				if (moniker.NotNull()) Marshal.ReleaseComObject(moniker);
			}

			return filter;
		}
开发者ID:davinx,项目名称:Imint.Media.DirectShow,代码行数:39,代码来源:FilterGraphTools.cs

示例11: AddFilterByName

		/// <summary>
		/// Add a filter to a DirectShow Graph using its name
		/// </summary>
		/// <param name="graphBuilder">the IGraphBuilder interface of the graph</param>
		/// <param name="deviceCategory">the filter category (see DirectShowLib.FilterCategory)</param>
		/// <param name="friendlyName">the filter name (case-sensitive)</param>
		/// <returns>an instance of the filter if the method successfully created it, null if not</returns>
		/// <example>This sample shows how to programmatically add a NVIDIA Video decoder filter to a graph
		/// <code>
		/// filter = FilterGraphTools.AddFilterByName(graphBuilder, FilterCategory.LegacyAmFilterCategory, "NVIDIA Video Decoder");
		/// </code>
		/// </example>
		/// <exception cref="System.ArgumentNullException">Thrown if graphBuilder is null</exception>
		/// <exception cref="System.Runtime.InteropServices.COMException">Thrown if errors occur when the filter is add to the graph</exception>

		public static IBaseFilter AddFilterByName(IGraphBuilder graphBuilder, Guid deviceCategory, string friendlyName)
		{
			int hr = 0;
			IBaseFilter filter = null;

			if (graphBuilder.IsNull())
				throw new ArgumentNullException("graphBuilder");

			DsDevice[] devices = DsDevice.GetDevicesOfCat(deviceCategory);

			for (int i = 0; i < devices.Length; i++)
			{
				if (!devices[i].Name.Equals(friendlyName))
					continue;

				hr = (graphBuilder as IFilterGraph2).AddSourceFilterForMoniker(devices[i].Mon, null, friendlyName, out filter);
				DsError.ThrowExceptionForHR(hr);

				break;
			}

			return filter;
		}
开发者ID:davinx,项目名称:Imint.Media.DirectShow,代码行数:38,代码来源:FilterGraphTools.cs


注:本文中的IGraphBuilder.IsNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。