gpt4 book ai didi

c - 来自 GTK 的 gst_video_overlay_set_window_handle#

转载 作者:行者123 更新时间:2023-11-30 17:06:45 35 4
gpt4 key购买 nike

我尝试通过 P/Invoke(在 Ubuntu 上)使用 Gstreamer 在 GTK# 中显示视频。我尝试使用许多代码示例,但没有任何效果。这是其中之一:GTK#代码:

 [DllImport("libgstTestDLL.so", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public extern static int play_file (StringBuilder path, IntPtr win);
...
play_file (new StringBuilder ().Append ("file:///home/user/Downloads/test.mp4"), screen.GdkWindow.Handle);

C 代码:

void play_file(char* path, void* hwnd_ptr){
GdkWindow* gdkWin = (GdkWindow*)hwnd_ptr;
pipeline = gst_element_factory_make("playbin", "player");
g_object_set (G_OBJECT (pipeline), "uri", path, NULL);
gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(pipeline), GDK_WINDOW_XID(gdkWin));
gst_element_set_state(pipeline, GST_STATE_PLAYING);
}

执行 play_file 函数后,我的 GTK# 应用程序将关闭。如何在 GTK# 中正确使用 play_file 以及需要从 C 中的 play_file 函数执行什么才能在 GTK# 应用程序中显示视频?

最佳答案

我找到了解决方案。我使用以下命令将我的共享库与 libgstvideo-1.0.so 链接起来:target_link_libraries(${PROJECT_NAME} gstvideo-1.0)。可用解决方案的完整描述 here .

关于c - 来自 GTK 的 gst_video_overlay_set_window_handle#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34468468/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com