0

I trying to display video in GTK# using Gstreamer via P/Invoke(on Ubuntu). I tried to use many code samples but nothing is working. Here is one of them: GTK# code:

 [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 code:

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);
}

After executing play_file function my GTK# app just closes. How can I correctly use play_file in GTK# and what I need to execute from play_file function in C to display video in GTK# application?

konstantin_doncov
  • 2,725
  • 4
  • 40
  • 100

1 Answers1

1

I found solution. I linked my shared library with libgstvideo-1.0.so using this: target_link_libraries(${PROJECT_NAME} gstvideo-1.0). Full description of the solution available here.

konstantin_doncov
  • 2,725
  • 4
  • 40
  • 100