如何获取FlutterWindow的GLFW窗口ID

时间:2019-12-07 06:22:17

标签: flutter

我正在尝试使用Flutter for Desktop构建视频播放器。有一个video_player插件可用于iOS和Android,但不适用于桌面。因此,暂时考虑尝试使用gstreamer进行解码和C ++代码中的硬件渲染作为抖动的后端。想法是将颤动窗口的窗口ID传递给gstreamer的glimagesink插件以渲染视频。

我正在使用https://github.com/google/flutter-desktop-embedding中的最新代码作为我的实验基础。下面提到的要点是与此仓库有关的。

在文件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一起使用。

1 个答案:

答案 0 :(得分:0)

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

视频播放器的安装应使用纹理API,该API将在this PR中为GLFW添加。