【发布时间】:2019-12-07 06:22:17
【问题描述】:
我正在尝试使用 Flutter for Desktop 构建视频播放器。有一个适用于 iOS 和 Android 的 video_player 插件,但不适用于桌面。因此,暂时考虑尝试使用 gstreamer 在 C++ 代码中进行解码和硬件渲染作为 Flutter 的后端。想法是将flutter窗口的Window Id传递给gstreamer的glimagesink插件来渲染视频。
我使用来自https://github.com/google/flutter-desktop-embedding 的最新代码作为我实验的基础。下面提到的点是参考这个 repo 的。
在flutter-desktop-embedding/example/linux/main.cc文件中,创建了FlutterWindowController对象,如下所示。
flutter::FlutterWindowController flutter_controller(icu_data_path);
这在内部调用
FlutterDesktopInit();
将鼠标指针悬停在上述方法上时,VS代码显示如下
bool FlutterDesktopInit()
Sets up the library's graphic context. Must be called before any other
methods.
Note: Internally, this library uses GLFW, which does not support multiple
copies within the same process. Internally this calls glfwInit, which will
fail if you have called glfwInit elsewhere in the process.
很明显 FlutterDesktopInit() 使用 GLFW 创建窗口。检查我是否可以获得窗口句柄。但是,没有运气。我只能得到 FlutterWindow 对象,如下所示。
flutter::FlutterWindow *win = flutter_controller.window();
如果有人能提供一些关于如何获取 GLFW 窗口句柄的提示,可以与 glimagesink 一起使用。
【问题讨论】:
标签: flutter