Using GstVideoOverlay on Mac

classic Classic list List threaded Threaded
28 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: Using GstVideoOverlay on Mac

Sebastian Dröge-3
On Mo, 2016-03-07 at 11:54 -0800, doon wrote:

> Ok, I built gst-plugins-base and checked that. So I added
> «/usr/local/Cellar/gtk+/2.24.29/include/gtk-2.0/» path to «Header
> Search
> Paths»(I installed gtk via homebrew) and added #include
> <gdk/gdkquartz.h> in
> my .h. After that I got many errors in «NSObjCRuntime.h», «NSZone.h»,
> and
> «NSObject.h» like:
> «/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform
> /Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Foundation.
> framework/Headers/NSObjCRuntime.h:437:19:
> Unknown type name 'NSString'»
> I think it’s because gdkquartz uses some Objective-C headers. So is
> it
> right? How can I solve these errors?
> By the way, if I add #include <gdk/gdk.h> instead of
> gdkquartz.h, then I get
> «’gdkconfig.h' file not found».
Why don't you just check how one of the applications I linked is built?
https://cgit.freedesktop.org/gstreamer/gst-plugins-base/tree/tests/examples/playback/Makefile.am

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (968 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Using GstVideoOverlay on Mac

doon
Sebastian Dröge-3 wrote
On Mo, 2016-03-07 at 11:54 -0800, doon wrote:
> Ok, I built gst-plugins-base and checked that. So I added
> «/usr/local/Cellar/gtk+/2.24.29/include/gtk-2.0/» path to «Header
> Search
> Paths»(I installed gtk via homebrew) and added #include
> <gdk/gdkquartz.h> in
> my .h. After that I got many errors in «NSObjCRuntime.h», «NSZone.h»,
> and
> «NSObject.h» like:
> «/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform
> /Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Foundation.
> framework/Headers/NSObjCRuntime.h:437:19:
> Unknown type name 'NSString'»
> I think it’s because gdkquartz uses some Objective-C headers. So is
> it
> right? How can I solve these errors?
> By the way, if I add #include <gdk/gdk.h> instead of
> gdkquartz.h, then I get
> «’gdkconfig.h' file not found».

Why don't you just check how one of the applications I linked is built?
https://cgit.freedesktop.org/gstreamer/gst-plugins-base/tree/tests/examples/playback/Makefile.am

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


signature.asc (968 bytes) <http://gstreamer-devel.966125.n4.nabble.com/attachment/4676230/0/signature.asc>
Sorry, some things is not obvious for me.
So, I added «-x objective-c++» in «Other C++ Flags» and «/usr/local/Cellar/gtk+/2.24.29/lib/gtk-2.0/include» in «Header Search Paths».
Now I try to compile:  
guintptr window_handle = (guintptr)gdk_quartz_window_get_nsview(gdkWin);

but get:
Undefined symbols for architecture x86_64:
  "_gdk_quartz_window_get_nsview", referenced from:
      GstAPI::play_file(char*, void*) in gstLib.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

How can I solve this?
Reply | Threaded
Open this post in threaded view
|

Re: Using GstVideoOverlay on Mac

Sebastian Dröge-3
On Di, 2016-03-08 at 17:35 -0800, doon wrote:

> Sorry, some things is not obvious for me. 
> So, I added «-x objective-c++» in «Other C++ Flags» and
> «/usr/local/Cellar/gtk+/2.24.29/lib/gtk-2.0/include» in «Header
> Search
> Paths».
> Now I try to compile:  
> guintptr window_handle =
> (guintptr)gdk_quartz_window_get_nsview(gdkWin);
>
> but get: 
> Undefined symbols for architecture x86_64:
>   "_gdk_quartz_window_get_nsview", referenced from:
>       GstAPI::play_file(char*, void*) in gstLib.o
> ld: symbol(s) not found for architecture x86_64
> clang: error: linker command failed with exit code 1 (use -v to see
> invocation)
>
> How can I solve this?
Link against the gdk-quartz-2.0 library.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (968 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Using GstVideoOverlay on Mac

doon
Sebastian Dröge-3 wrote
On Di, 2016-03-08 at 17:35 -0800, doon wrote:
> Sorry, some things is not obvious for me. 
> So, I added «-x objective-c++» in «Other C++ Flags» and
> «/usr/local/Cellar/gtk+/2.24.29/lib/gtk-2.0/include» in «Header
> Search
> Paths».
> Now I try to compile:  
> guintptr window_handle =
> (guintptr)gdk_quartz_window_get_nsview(gdkWin);
>
> but get: 
> Undefined symbols for architecture x86_64:
>   "_gdk_quartz_window_get_nsview", referenced from:
>       GstAPI::play_file(char*, void*) in gstLib.o
> ld: symbol(s) not found for architecture x86_64
> clang: error: linker command failed with exit code 1 (use -v to see
> invocation)
>
> How can I solve this?

Link against the gdk-quartz-2.0 library.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


signature.asc (968 bytes) <http://gstreamer-devel.966125.n4.nabble.com/attachment/4676255/0/signature.asc>
Ok, thanks! I got it! Now I linked this .dylib with libgdk-quartz-2.0.0.dylib. But when I try to use this library with my GTK# project I get this exception:

Stack overflow in unmanaged: IP: 0x10fbf6a29, fault addr: 0x7fff53024fa8
Stack overflow in unmanaged: IP: 0x10fbf6a29, fault addr: 0x7fff53022fa8
Stack overflow in unmanaged: IP: 0x10fbf6a29, fault addr: 0x7fff53021fa8
Stack overflow in unmanaged: IP: 0x10fbf6a29, fault addr: 0x7fff53020fa8
Stack overflow in unmanaged: IP: 0x10fbf6a29, fault addr: 0x7fff5301ffa8
Stack overflow in unmanaged: IP: 0x10fbf6a29, fault addr: 0x7fff5301efa8
Stack overflow in unmanaged: IP: 0x10fbf6a29, fault addr: 0x7fff5301dfa8
Stack overflow: IP: 0x10fbf6a29, fault addr: 0x7fff5301bfa8
Stacktrace:
  at <unknown> <0xffffffff>
  at Gtk.Application.Run () [0x00001] in /private/tmp/source-mono-mac-4.2.0-branch-64/bockbuild-mono-4.2.0-branch/profiles/mono-mac-xamarin/build-root/gtk-sharp-2.12.21/gtk/Application.cs:135
  <...>
  at GTKSharpDLLTest.MainClass.Main (string[]) [0x00012] in /Users/user/Documents/XamarinStudioProjects/GTKSharpDLLTest/GTKSharpDLLTest/Program.cs:13
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00051, 0x0030a>

It's interesting that I get that exception only when I trying to move my cursor over the video rendering area in the GTK# app.
_________________________________________________
GTK# code:
[DllImport("libgstLibrary.dylib", EntryPoint="play_file", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public extern static void play_file (StringBuilder path, IntPtr win);

play_file (new StringBuilder ().Append ("file:///Users/user/Downloads/test.mp4"), drawingarea1.GdkWindow.Handle);
_________________________________________________
libgstLibrary.dylib .h:

#include <gst/gst.h>
#include <gst/video/videooverlay.h>
#include <gdk/gdkquartz.h>
#define DLL_PUBLIC __attribute__ ((visibility ("default")))


namespace GstAPI
{
    extern "C" DLL_PUBLIC void play_file(char* path, void* hwnd_ptr);
}

_________________________________________________
libgstLibrary.dylib .cpp:
#include "gstLibrary.h"

namespace GstAPI{
    GstElement *pipeline;

    void play_file(char* path, void* hwnd_ptr){
        gst_init(NULL, NULL);

        GdkWindow* gdkWin = (GdkWindow*)hwnd_ptr;
        pipeline = gst_element_factory_make("playbin", "player");
        g_object_set (G_OBJECT (pipeline), "uri", path, NULL);
       
        gst_element_set_state(pipeline, GST_STATE_NULL);
       
        guintptr window_handle = (guintptr)gdk_quartz_window_get_nsview(gdkWin);
        gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(pipeline), window_handle);

        gst_element_set_state(pipeline, GST_STATE_PLAYING);

    }
}
_________________________________________________
Can it be due to I use Hackintosh without any video kext?
Maybe you can suggest some solutions to this problem?
Many thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Using GstVideoOverlay on Mac

Sebastian Dröge-3
On Mi, 2016-03-09 at 16:35 -0800, doon wrote:
> Ok, thanks! I got it! Now I linked this .dylib with
> libgdk-quartz-2.0.0.dylib. But when I try to use this library with my
> GTK#
> project I get this exception:
>
> Stack overflow in unmanaged: IP: 0x10fbf6a29, fault addr:
> 0x7fff53024fa8

This suggests that somewhere in native code you have something like an
infinite recursion. Run in a debugger to find the problem.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (968 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Using GstVideoOverlay on Mac

doon
Sebastian Dröge-3 wrote
On Mi, 2016-03-09 at 16:35 -0800, doon wrote:
> Ok, thanks! I got it! Now I linked this .dylib with
> libgdk-quartz-2.0.0.dylib. But when I try to use this library with my
> GTK#
> project I get this exception:
>
> Stack overflow in unmanaged: IP: 0x10fbf6a29, fault addr:
> 0x7fff53024fa8

This suggests that somewhere in native code you have something like an
infinite recursion. Run in a debugger to find the problem.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


signature.asc (968 bytes) <http://gstreamer-devel.966125.n4.nabble.com/attachment/4676267/0/signature.asc>
Ok, thanks I will try to debug it. And one more question: I give the "drawingarea1.GdkWindow.Handle" to the native Gstreamer code, but video plays in the full window and over the other widgets. Why?
Reply | Threaded
Open this post in threaded view
|

Re: Using GstVideoOverlay on Mac

Sebastian Dröge-3
On Do, 2016-03-10 at 18:04 -0800, doon wrote:
> Ok, thanks I will try to debug it. And one more question: I give the
> "drawingarea1.GdkWindow.Handle" to the native Gstreamer code, but
> video plays in the full window and over the other widgets. Why?

Does the drawing area have it's own native window or does it share with
the other widgets? In GTK+2 it is necessary to call
  gdk_window_ensure_native()
on the GdkWindow before getting the handle. Otherwise it might share
the native window with other widgets.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (968 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Using GstVideoOverlay on Mac

doon
Sebastian Dröge-3 wrote
On Do, 2016-03-10 at 18:04 -0800, doon wrote:
> Ok, thanks I will try to debug it. And one more question: I give the
> "drawingarea1.GdkWindow.Handle" to the native Gstreamer code, but
> video plays in the full window and over the other widgets. Why?

Does the drawing area have it's own native window or does it share with
the other widgets? In GTK+2 it is necessary to call
  gdk_window_ensure_native()
on the GdkWindow before getting the handle. Otherwise it might share
the native window with other widgets.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


signature.asc (968 bytes) <http://gstreamer-devel.966125.n4.nabble.com/attachment/4676281/0/signature.asc>

1. I debugged my app with gdb and got this output after trying to move my cursor over the rendering area:
[New Thread 0x2623 of process 524]
[New Thread 0x2703 of process 524]
[New Thread 0x2803 of process 524]
[New Thread 0x2903 of process 524]

Program received signal SIGSEGV, Segmentation fault.
0x00000001060eea29 in find_nsview_at_pos ()
   from /Library/Frameworks/Mono.framework/Versions/4.2.1/lib/libgdk-quartz-2.0.0.dylib

In the my library I just set window handle and change pipeline state to playing, without creating another threads, almost same code works on other operating systems. If I create new thread and run main loop in that thread, than I get same result.
But when I run main loop in the main function than all everything goes fine. But I think this is not a good solution for application logic, so I still need to fix this bug. Maybe it’s due to my Hackintosh OS?

2. About full window playback(instead of playback in drawingarea widget): when I call gdk_window_ensure_native(drawingarea1.GdkWindow.Handle) function in GTK# app(before Gstreamer calling) I get:

Gdk-CRITICAL **: gdk_window_ensure_native: assertion 'GDK_IS_WINDOW (window)' failed

How can I fix it?
12