I have been doing a little bit of research around this issue:<div><br></div><div>Turns out that Qt is still using the older Carbon windowing framework, which means that the ID I am getting from Qt is actually a HIViewRef.</div>
<div><br></div><div>The &quot;have-ns-view&quot; message contains a value called &quot;nsview&quot;, which can be cast to a &quot;NSView*&quot;, which is a Cocoa based view (the system used by almost all OSX apps).</div><div>
<br></div><div>According to Apple&#39;s dev docs, there are a handful of Carbon functions, which allow one to attach a Cocoa view to a special wrapper, which makes it look like a Carbon view. I have tried this using the following code:</div>
<div><br></div><div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">WindowHandle&nbsp;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color: #5c2699">CocoaHelper</span>::AttachCocoaViewFromMessage(<span style="color: #5c2699">GstMessage</span>* <span style="color: #3f6e74">message</span>, <span style="color: #aa0d91">const</span> WindowHandle&amp; handle)</p>

<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">{</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">&nbsp; &nbsp; WindowHandle outputHandle;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px">&nbsp;&nbsp; &nbsp;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400"><span style="color: #000000">&nbsp; &nbsp; </span>// Extract the cocoa view from the message:</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">&nbsp; &nbsp; <span style="color: #5c2699">NSView</span>* cocoaView = (<span style="color: #5c2699">NSView</span>*)<span style="color: #2e0d6e">g_value_get_pointer</span>(</p>

<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #2e0d6e"><span style="color: #000000">&nbsp; &nbsp; &nbsp; &nbsp; </span>gst_structure_get_value<span style="color: #000000">(</span><span style="color: #3f6e74">message</span><span style="color: #000000">-&gt;</span><span style="color: #5c2699">structure</span><span style="color: #000000">, </span><span style="color: #c41a16">&quot;nsview&quot;</span><span style="color: #000000">));</span></p>

<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px">&nbsp;&nbsp; &nbsp;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">&nbsp; &nbsp; <span style="color: #aa0d91">if</span> (cocoaView == <span style="color: #1c00cf">0</span>)</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">&nbsp; &nbsp; {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #c41a16"><span style="color: #000000">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #643820">MEDIA_LOG_ERROR</span><span style="color: #000000">(</span>&quot;Message does not contain a value with name \&quot;nsview\&quot;&quot;<span style="color: #000000">);</span></p>

<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #aa0d91">return</span> outputHandle;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">&nbsp; &nbsp; }</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px">&nbsp;&nbsp; &nbsp;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400"><span style="color: #000000">&nbsp; &nbsp; </span>// Create Cocoa wrapper view:</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">&nbsp; &nbsp; <span style="color: #5c2699">HIViewRef</span> cocoaWrapperView;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">&nbsp; &nbsp; <span style="color: #5c2699">OSStatus</span> retVal;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">&nbsp; &nbsp; retVal = HICocoaViewCreate(cocoaView, <span style="color: #1c00cf">0</span>, &amp;cocoaWrapperView);</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px">&nbsp;&nbsp; &nbsp;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">&nbsp; &nbsp; [cocoaView release];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px">&nbsp;&nbsp; &nbsp;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">&nbsp; &nbsp; <span style="color: #aa0d91">if</span> (retVal != <span style="color: #1c00cf">0</span>)</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">&nbsp; &nbsp; {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #c41a16"><span style="color: #000000">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #643820">MEDIA_LOG_ERROR</span><span style="color: #000000">(</span>&quot;Unable to create Cocoa wrapper view, return value: &quot;<span style="color: #000000">, retVal);</span></p>

<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #aa0d91">return</span> outputHandle;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">&nbsp; &nbsp; }</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400"><span style="color: #000000">&nbsp; &nbsp; </span>// Attach view to incoming Carbon view:</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400"><span style="color: #000000">&nbsp; &nbsp; </span>// From Qt sources &quot;qwidget_mac.cpp&quot; confirms that a WId can be</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400"><span style="color: #000000">&nbsp; &nbsp; </span>// safely converted to a HIViewRef on the mac. (see qt_mac_hiview_for line 254)</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">&nbsp; &nbsp; <span style="color: #5c2699">HIViewRef</span> renderView = (<span style="color: #5c2699">HIViewRef</span>)handle.<span style="color: #2e0d6e">GetHandle</span>();</p>

<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">&nbsp; &nbsp; <span style="color: #aa0d91">if</span> ((retVal = <span style="color: #2e0d6e">HIViewAddSubview</span>(renderView, cocoaWrapperView)) != <span style="color: #1c00cf">0</span>)</p>

<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">&nbsp; &nbsp; {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #c41a16"><span style="color: #000000">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #643820">MEDIA_LOG_ERROR</span><span style="color: #000000">(</span>&quot;Unable to attach Cocoa wrapper view to render view. &quot;</p>

<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c41a16">&quot; return value: &quot;</span>, retVal);</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #aa0d91">return</span> outputHandle;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">&nbsp; &nbsp; }</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px">&nbsp;&nbsp; &nbsp;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">&nbsp; &nbsp; outputHandle = <span style="color: #2e0d6e">WindowHandle</span>((<span style="color: #5c2699">HandleType</span>)cocoaWrapperView);</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px">&nbsp;&nbsp; &nbsp;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #c41a16"><span style="color: #000000">&nbsp; &nbsp; </span><span style="color: #643820">MEDIA_LOG_INFO</span><span style="color: #000000">(</span>&quot;Successfully attached Cocoa view &quot;<span style="color: #000000">, </span><span style="color: #aa0d91">static_cast</span><span style="color: #000000">&lt;</span><span style="color: #aa0d91">void</span><span style="color: #000000">*&gt;(cocoaView),</span></p>

<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #c41a16"><span style="color: #000000">&nbsp; &nbsp; &nbsp; &nbsp; </span>&quot; to Carbon view with handle &quot;<span style="color: #000000">, handle,</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #c41a16"><span style="color: #000000">&nbsp; &nbsp; &nbsp; &nbsp; </span>&quot;. Handle of view wrapper view is &quot;<span style="color: #000000">, outputHandle);</span></p>

<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">&nbsp; &nbsp; <span style="color: #aa0d91">return</span> outputHandle;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p><div><span class="Apple-style-span" style="font-family: Monaco; font-size: 10px;"><br></span></div></div><div>The WindowHandle object is just a simple wrapper around the window ID I am getting from Qt (GetHandle() returns the same value as QWidget::winid()).<br>
</div><div><br></div><div>I am also calling NSApplicationLoad() during startup to ensure I can use Cocoa in my Carbon based app.</div><div><br></div><div>When I run my app, I don&#39;t see any video, instead I get a lot of the following messages in my debugger:</div>
<div><br></div><div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier"><span class="Apple-style-span" style="font-weight: bold;"></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier"><b>2008-06-27 11:05:38.106 com.neokast.stream.player.ui.view_TESTCASES[92020:a80b] invalid drawable</b></p>

<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier"><b>2008-06-27 11:05:38.147 com.neokast.stream.player.ui.view_TESTCASES[92020:a80b] *** _NSAutoreleaseNoPool(): Object 0x1af9cb10 of class NSSurface autoreleased with no pool in place - just leaking</b></p>

<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier"><b>Stack: (0x90c9e12f 0x90baaec2 0x92cdef8b 0x92daa15c 0x190b3bca 0x190b2af7 0x31791f2 0x317acf0 0x317b351 0x317b970 0x31f5d86 0x31f657a 0x31890e3 0x31f5d86 0x31f657a 0x18f13fff 0x3212309 0x32f97ec 0x32f76de 0x94ef3c55 0x94ef3b12)</b></p>

<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier"><b>2008-06-27 11:05:38.147 com.neokast.stream.player.ui.view_TESTCASES[92020:a80b] *** _NSAutoreleaseNoPool(): Object 0x1afc2dd0 of class NSCFString autoreleased with no pool in place - just leaking</b></p>

<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier"><b>Stack: (0x90c9e12f 0x90baaec2 0x92ddbc92 0x92daa15c 0x190b3bca 0x190b2af7 0x31791f2 0x317acf0 0x317b351 0x317b970 0x31f5d86 0x31f657a 0x31890e3 0x31f5d86 0x31f657a 0x18f13fff 0x3212309 0x32f97ec 0x32f76de 0x94ef3c55 0x94ef3b12)</b></p>
<div><br></div><p></p></div><div><br></div><div><br></div><div>I am less concerned about the apparent leakage (I have been experimenting with the NSAutoReleasePool to fix those), I think the main problem is the &quot;invalid drawable&quot; message. I would guess that the frequency of those messages roughly corresponds to the framerate.</div>
<div><br></div><div><br></div><div>I would greatly appreciate any input from more experienced Mac developers. I understand that my situation is further complicated by the fact that I am using Carbon. I will keep digging and post the solution when I find it. It would be great is someone could then take this code and use it for a proper implementation of the GstXOverlay interface for the OSX video sink.</div>
<div><br></div><div>Thanks,</div><div><br></div><div>Andreas</div><div><br></div><div><br><br><div class="gmail_quote">On Thu, Jun 26, 2008 at 9:41 AM, Andreas Schuler &lt;<a href="mailto:andreas@neokast.com">andreas@neokast.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Thanks for your detailed response. I have taken a closer look at the source code for osxvideosink and found that it supports an &quot;embed&quot; property (which is FALSE by default).<br>
<br>I can tell that when TRUE it will emit a message called &quot;have-ns-view&quot;, where it passes a GstGLView object to the callback. This object is an NSView (part of the Apple Cocoa framework). I have learned that I am supposed to attach that to a NSWindow.<br>

<br>Unfortunately I am pretty new to programming on the Mac. Thus far I have been using OS abstraction libraries such as Qt to avoid dealing with different windowing systems. Qt gives me back a window handle, which turns out to be integer but I have no idea how to retrieve a NSWindow object from that.<br>

<br>So if anyone has done this before on the Mac (with or without Qt) I would greatly appreciate your input.<br><br>Thanks,<br><font color="#888888"><br>Andreas</font><div><div></div><div class="Wj3C7c"><br><br><div class="gmail_quote">
On Wed, Jun 25, 2008 at 5:26 PM, Michael Smith &lt;<a href="mailto:msmith@xiph.org" target="_blank">msmith@xiph.org</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<div>On Wed, Jun 25, 2008 at 3:16 PM, Andreas Schuler &lt;<a href="mailto:andreas@neokast.com" target="_blank">andreas@neokast.com</a>&gt; wrote:<br>
&gt; Hi all,<br>
&gt;<br>
&gt; I am trying to get an application to run on a Max OSX <a href="http://10.5.2." target="_blank">10.5.2.</a> I have<br>
&gt; downloaded and built the latest tar balls and everything seems to be running<br>
&gt; fine when I use gst-launch.<br>
&gt;<br>
&gt; &gt;From within my app, which also runs on Windows, I am doing the following to<br>
&gt; set the id of the window I want the video to be rendered on:<br>
&gt;<br>
&gt; - get_bus_set_sync_handler to setup my callback<br>
&gt; - The callback function looks as follows:<br>
<br>
</div>That looks good for Win32 and linux. On linux the &#39;window handle&#39; will<br>
need to be the XID for the window, but that&#39;s just a matter of<br>
different platform-specific types, not a big problem.<br>
<br>
On OSX, you&#39;re presumably using osxvideosink (well, you say you&#39;re<br>
using autovideosink, but that&#39;ll be selecting osxvideosink<br>
internally).<br>
<br>
osxvideosink doesn&#39;t implement GstXOverlay, so you can&#39;t do this with<br>
it. Because of this it won&#39;t ever even emit the prepare-xwindow-id<br>
signal, which is what you&#39;re seeing.<br>
<br>
osxvideosink has some other interface to set this up, but I don&#39;t know<br>
the details of how it works. You may find looking at the output of<br>
&quot;gst-inspect-0.10 osxvideosink&quot; to be helpful - it&#39;ll tell you what<br>
signals exist, etc.<br>
<br>
If possible, it would be best to make osxvideosink implement the<br>
GstXOverlay interface - that would let people use more common code<br>
across different platforms. Looking into whether that&#39;s possible is on<br>
my TODO list, but pretty far down right now - I probably won&#39;t get to<br>
it for a month or two. If you manage to do that sooner, that&#39;d be<br>
great - patches would be very welcome.<br>
<br>
Mike</blockquote></div></div></div></blockquote></div></div>