【问题标题】:How to get GLFW window Id of FlutterWindow如何获取 FlutterWindow 的 GLFW 窗口 ID
【发布时间】: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


    【解决方案1】:

    您无法通过该 API 获取对任何 GLFW 对象的引用。这是设计使然,因为正如您引用的评论所说,您不能在同一进程中拥有多个 GLFW 副本。 GLFW 静态链接到 Linux Flutter 嵌入中,因此您不能在运行程序或插件中使用 GLFW。

    应该使用纹理 API 来实现视频播放器,该 API 将在 this PR 中为 GLFW 添加。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-03-16
      • 2020-10-14
      • 2020-08-12
      • 2023-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多