GStreamer 正确接入 Qt:事件循环、线程与视频显示
专栏:GStreamer C++ 从零到工程实战· 第 16 篇 / 共 17 篇
明确 Qt 与 GStreamer 集成的四个独立问题:Bus 消息、事件循环、跨线程 GUI 更新和视频显示,并给出可选架构与退出顺序。
附录 A:接入 Qt 时,真正需要解决的四件事
主教程没有把 Qt 作为前置条件。
当你已经掌握 GStreamer 后,接入 Qt 只新增四类问题:
Qt Event Loop 与 GLib MainContext Bus Message 到 Qt queued signal streaming thread 与 GUI thread 视频窗口嵌入或 appsink 转图像一、Bus Watch 不是 MainContext 的替代品
错误理解:
调用 gst_bus_add_watch() → 不运行 GLib Main Loop 也会自动回调正确模型:
gst_bus_add_watch → 把 Source 附加到 GMainContext → 必须有线程运行/迭代这个 Context → callback 才会执行常见方案:
A. 独立线程运行 GMainLoop Bus callback → Qt queued signal