在 Gstreamer 0.10 中创建空实例

Create Null Instance in Gstreamer 0.10

成功安装了ossbuild GStreamer,享受Gstreamer for C#。

步骤总结如下:

  1. 下载GStreamer-WinBuilds-GPL-x86-Beta04-0.10.7.msiGStreamer-WinBuilds-SDK-GPL-x86-Beta04 -0.10.7.msi 来自 https://code.google.com/p/ossbuild/downloads/list(或者您可以下载支持较少插件的 LGPL 许可证对)
  2. 然后安装前者然后安装后者。
  3. 然后您可以找到 gstreamer-sharp .NET 参考文件,gstreamer-sharp.dll 位于此处:

    C:\Program Files (x86)\OSSBuild\GStreamer\version_variable\sdk\bindings\dotnet\gstreamer-sharp.dll

  4. 另一个胶水文件,gstreamersharpglue-0.10.dll,需要添加到项目中并将其设置为“始终复制”或“如果较新则复制”使 gstreamer-sharp 在 Windows.

  5. 中工作

但是当我尝试 运行 示例代码(使用 Gst;)时,出现异常。

var pipeline = new Gst.Pipeline();
//always have null instance here
var elementA = Gst.ElementFactory.Make("videotestsrc");
//exceptions happens
elementA["pattern"] = 18; 
//must have
Gst.Application.Init();
var pipeline = new Gst.Pipeline();
//if don't have Gst.Application.Init(), it will always have null instance here
var elementA = Gst.ElementFactory.Make("videotestsrc");
//if no exceptions happens here then everything should be fine
elementA["pattern"] = 18; 

如果 Gst.Application.Init(); 触发找不到 python26.dll 的错误,通过安装 python 2.6 解决并在项目中添加 python26.dll。

记得用Gst.Application.Init();初始化,解决空实例花了我2天时间。最后,由于 GStreamer 及其绑定是为 x86 体系结构编译的,因此强制为 x86 构建 .NET 程序集。