创建 GStreamer XUL 元素?
我想为基于 XULRunner 的视频编辑应用程序创建一个名为“video”的自定义 XUL 元素。在 XPCOM 文档中解释了如何从 Javascript 访问组件,但我似乎找不到任何有关如何声明新 XUL 元素的文档。我在哪里可以找到这个?有人能指出我正确的方向吗?
澄清
我希望能够将 GStreamer 管道连接到 XUL 小部件。这需要从我的应用程序的 C++ 部分完成。本质上,它归结为调用:
gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(mOverlay), (gulong)windowId);
所以我需要实现的是一种从 XUL 小部件访问 windowId(Windows 上的 HWND)的方法。这样的最低要求(访问 XUL 组件的窗口 id)真的需要我创建 NPAPI 插件吗?创建 NPAPI 插件似乎有些令人畏惧(但由于这个项目,这可能是可行的)。我想避免过度杀伤,所以如果 XPCOM 组件就足够了,那就太好了。
解决了!
我在 XPCOM 插件中找到了一种方法。我发现可以获得顶级 XUL 窗口的本机句柄。这需要一些技巧,因为您需要包含一些私有 XUL 标头才能破解打开 XUL 元素并获取窗口句柄。但是一旦有了它,您就可以创建一个子窗口。
下一个挑战是让子窗口服从XUL 的布局管理器。由于此窗口不作为 XUL 元素存在,因此它根本不会受到布局管理器的影响。解决方法是创建一个 XUL 元素,用作覆盖本机窗口的占位符。对于此元素,您需要为“调整大小”事件注册回调。在事件处理程序中,您可以使自定义窗口的大小和位置与 XUL 元素相同。
我使用 XBL 定义名为“video”的元素类型。它包含一个 XUL 标签作为唯一的子元素。该元素在我的 XPCOM 插件中用于上述布局。
这个解决方案效果很好。
这要归功于 Songbird 团队的迈克尔·史密斯 (Michael Smith)。他回答了我关于 GStreamer 邮件的问题< /a> 列表。如果您有兴趣,可以查看此代码。
I would like to create a custom XUL element named 'video' for a video editing application based on XULRunner. In the XPCOM documentation it is explained how to access your component from Javascript, but I can't seem to find any documentation on how to declare a new XUL element. Where can I find this? Can anyone point me in the right direction?
Clarification
I want to be able to connect a GStreamer pipeline to a XUL widget. This needs to be done from the C++ part of my application. In essence it boils down to the call:
gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(mOverlay), (gulong)windowId);
So what I need to achieve is a way to access a windowId (HWND on Windows) from a XUL widget. Does such a minimal requirement (accessing the window id for a XUL component) truly require me to create NPAPI plugin? Creating an NPAPI plugin seems somewhat daunting (but probably doable thanks to this project). I would like to avoid overkill, so if a XPCOM component would suffice then that would be great.
Solved!
I found a way to do it in an XPCOM plugin. I discovered that it's possible to obtain the native handle of the top-level XUL window. This requires some hackery because you need to inluclude some of the private XUL headers in order to crack open de XUL element and obtain the window handle. But once you have it, you can create a child window.
The next challenge is to make the child window obey the layout manager of XUL. Since this window does not exists as a XUL element it won't be affected by the layout manager at all. The workaround is to create a XUL element that will serve as a placeholder to overlay the native window on. For this element you then need to register a callback for the "resize" event. In the event handler you can make the size and position of your custom window to be the same as the XUL element.
I use XBL to define an element type with the name "video". It contains a XUL label as only sub-element. This element is used in my XPCOM plugin as for the layouting described above.
This solution works pretty well.
Credit goes to Michael Smith of the Songbird team. He answered my question on the GStreamer mailing list. If you are interested you can look at this code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法使用 XPCOM 实现新的 XUL 元素。您的选择是:
You can't implement a new XUL element using XPCOM. Your options are:
我认为,最简单的方法是创建一个新的 XPCom (C++) Canvas 上下文(“网络摄像头”),并通过 Thebes API 在此上下文中注入框架。为了拥有更“美丽”的东西,我建议将所有内容嵌入到 XBL 中。
This easiest way, I think, is to create a new XPCom (C++) Canvas context ("webcam") and via the Thebes API inject the frame in this context. And to have something more "beautiful", I would suggest to embed everything in a XBL.