簡體   English   中英

如何獲取 FlutterWindow 的 GLFW 窗口 ID

[英]How to get GLFW window Id of FlutterWindow

我正在嘗試使用桌面版 Flutter 構建視頻播放器。 有一個適用於 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();

感謝有人可以就如何獲取可與 glimagesink 一起使用的 GLFW 窗口句柄提供一些提示。

您無法通過該 API 獲取對任何 GLFW 對象的引用。 這是設計使然,因為正如您引用的評論所說,您不能在同一進程中擁有多個 GLFW 副本。 GLFW 靜態鏈接到 Linux Flutter 嵌入中,因此您不能在 runner 或插件中使用 GLFW。

應該使用紋理 API 來實現視頻播放器,該 API 將在此 PR 中為 GLFW 添加。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM