Using GstVideoOverlay on Mac

Andy Robinson andy at seventhstring.com
Sun Jan 10 08:42:13 PST 2016


On 08/01/16 13:37, Sebastian Dröge wrote:
> On Mi, 2016-01-06 at 17:33 +0000, Andy Robinson wrote:
>> Mac OS 10.10
>> GStreamer 1.6.1
>> Xcode 6.4
>>
>> Hello, can anyone point me to any sample code (C/C++) showing how to
>> display video on the Mac, in a window owned by the application
>> (rather  than GStreamer creating a window for the video)?
>>
>> I have written code (using wxWidgets as it happens) which works fine
>> on  Linux/GTK and on Windows.
>>
>> I have a top-level window containing a child control in which I want
>> the video to appear. I get a handle like this:
>>
>> #ifdef __WXMAC__
>>      NSView *nsv = GetPeer()->GetWXWidget();
>>      m_video_window_handle = (gulong)nsv;
>> #endif
>>
>> The wxWidgets people assure me that this will obtain a NSView* on
>> Mac.
>>
>> Then in the bus_sync_callback I do:
>>      GstVideoOverlay *overlay =
>> GST_VIDEO_OVERLAY(GST_MESSAGE_SRC(msg));
>>      gst_video_overlay_set_window_handle(overlay,
>> m_video_window_handle);
>>
>> As I say, this works on Windows & Linux. But on Mac the place where
>> the video should be, is blank.
>
> This seems all correct, assuming the NSView can accept a child view
> that contains the actual video.
>
> Can you try without wxWidgets in a plain OSX application if you have
> the same problem?
>
> Also which video sink is actually used here?

Thanks for this - I'm still wrestling with it. I was using autovideosink 
but your question prompted me to use gst-inspect to see what else is 
available and I found osxvideosink. This doesn't work too well - it 
displays a green screen or a freeze frame of the first frame of the 
video, and the pipeline doesn't want to go into a PAUSE state, but, the 
green screen rectangle is in the right place in my parent window, which 
encourages me to think that the NSView* I am giving to 
gst_video_overlay_set_window_handle is indeed the right thing.

You mentioned that addSubview is used so I also added a diagnostic to 
report how many subviews my NSView has, and it said 1 as we would expect.

So I switched back to autovideosink and the diagnostic now reports 0 
subviews. So the video subview is somehow not being added to the NSView 
I provide. From inside the program, autovideosink seems to be working 
perfectly - I can set the video playing and query its current position, 
which advances just as it should. But nothing is displayed.

I agree that writing a plain OSX application would be good. I've only 
ever programmed the Mac using wxWidgets so it would be very helpful for 
me if there were any simple example programs using GStreamer on Mac for 
me to use as a starting point. Are there any such samples? I think I've 
seem samples mentioned in the GStreamer docs, but I've not found the 
samples themselves.

Regards,
Andy Robinson, Seventh String Software, www.seventhstring.com



More information about the gstreamer-devel mailing list