<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="margin: 0px; "><font face="Arial">Hi all,</font></div><div style="margin: 0px; "><font face="Arial"><br></font></div><div style="margin: 0px; "><font face="Arial">I've managed to find some code online that nicely demonstrates the use of osxvideosink and</font></div><div style="margin: 0px; "><font face="Arial">gstreamer integration into a standard Cocoa Application project, using interface builder and </font></div><div style="margin: 0px; "><font face="Arial">normal Xcode tools:</font></div><div style="margin: 0px; "><font face="Arial"><br></font></div><div style="margin: 0px; "><a href="http://blog.angrymango.com/post/2012/01/04/Playing-a-video-using-gstreamer-on-OSX.aspx#comment">http://blog.angrymango.com/post/2012/01/04/Playing-a-video-using-gstreamer-on-OSX.aspx#comment</a></div><div style="margin: 0px; "><font face="Arial"><br></font></div><div style="margin: 0px; "><span style="font-family: Arial; ">This is (eventually) using the osxvideosink and </span><font face="Arial">therefore can </font><span style="font-family: Arial; ">be used directly with the </span><font face="Arial">streamer </font></div><div style="margin: 0px; "><span style="font-family: Arial; ">installation packages that were developed for the mac. </span><span style="font-family: Arial; ">CPU usage on 720p video using this </span><font face="Arial">play bin </font></div><div style="margin: 0px; "><span style="font-family: Arial; ">amounts to 80-100% or so, whereas the movie player gets up to 7-10% or so, probably using </span></div><div style="margin: 0px; "><font face="Arial">video acceleration of some kind (or the play bin uses some unnecessary conversions).</font></div><div style="margin: 0px; "><font face="Arial"><br></font></div><div style="margin: 0px; "><font face="Arial">I modified the code to use an existing 'frame' (dummy area) where the video is going to be embedded.</font></div><div style="margin: 0px; "><font face="Arial">It does not resize properly and there are some other issues probably, but it' s a good start.</font></div><div style="margin: 0px; "><br></div><div style="margin: 0px; ">I think this example is great to show others how to develop players that use osxvideosink and which can integrate</div><div style="margin: 0px; ">gstreamer in applications built with interface builder, without jumping through 20 hoops to get there.</div><div style="margin: 0px; "><br></div><div style="margin: 0px; ">Please let me know your concerns and what needs to happen before this can be integrated somewhere in the</div><div style="margin: 0px; ">gstreamer example code.</div><div style="margin: 0px; "><br></div><div style="margin: 0px; ">Rgds,</div><div style="margin: 0px; "><br></div><div style="margin: 0px; ">Gerard</div><div style="margin: 0px; "><br></div><div style="margin: 0px; "><font face="Arial"><br></font></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(0, 132, 0); "><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(0, 132, 0); ">-----------</div><div style="margin: 0px; font-size: 11px; color: rgb(0, 132, 0); "><font face="Courier"><br></font></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="font-size: 11px;"><font face="Courier">//</font></span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="font-size: 11px;"><font face="Courier">// AppDelegate.m</font></span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="font-size: 11px;"><font face="Courier">//</font></span></div><div style="margin: 0px; min-height: 13px; "><span style="font-size: 11px;"><font face="Courier"><br></font></span></div><div style="margin: 0px; color: rgb(209, 47, 27); "><span style="font-size: 11px;"><font face="Courier"><span style="color: #78492a">#import </span>"AppDelegate.h"</font></span></div><div style="margin: 0px; color: rgb(209, 47, 27); "><span style="font-size: 11px;"><font face="Courier"><span style="color: #78492a">#include </span><gst/gst.h></font></span></div><div style="margin: 0px; color: rgb(209, 47, 27); "><span style="font-size: 11px;"><font face="Courier"><span style="color: #78492a">#include </span><gst/interfaces/xoverlay.h></font></span></div><div style="margin: 0px; color: rgb(209, 47, 27); "><span style="font-size: 11px;"><font face="Courier"><span style="color: #78492a">#import </span>"MainWindow.h"</font></span></div><div style="margin: 0px; min-height: 13px; "><span style="font-size: 11px;"><font face="Courier"><br></font></span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="font-size: 11px;"><font face="Courier">/* ============================================================= */</font></span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="font-size: 11px;"><font face="Courier">/* */</font></span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="font-size: 11px;"><font face="Courier">/* gstreamer callbacks */</font></span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="font-size: 11px;"><font face="Courier">/* */</font></span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="font-size: 11px;"><font face="Courier">/* ============================================================= */</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"><span style="color: #bb2ca2">typedef</span> <span style="color: #bb2ca2">struct</span> context_t {</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #bb2ca2">void</span> *appDelegate;</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #bb2ca2">void</span> *viewingArea;</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier">} context_t;</font></span></div><div style="margin: 0px; min-height: 13px; "><span style="font-size: 11px;"><font face="Courier"><br></font></span></div><div style="margin: 0px; color: rgb(112, 61, 170); "><span style="font-size: 11px;"><font face="Courier"><span style="color: #bb2ca2">static</span><span style="color: #000000"> </span>GMainLoop<span style="color: #000000"> *loop;</span></font></span></div><div style="margin: 0px; min-height: 13px; "><span style="font-size: 11px;"><font face="Courier"><br></font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"><span style="color: #bb2ca2">static</span> <span style="color: #703daa">gboolean</span> bus_call(<span style="color: #703daa">GstBus</span> *bus, <span style="color: #703daa">GstMessage</span> *msg, <span style="color: #bb2ca2">void</span> *user_data)</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier">{</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #4f8187">context_t</span> *context;</font></span></div><p style="margin: 0px; min-height: 13px; "><span style="font-size: 11px;"><font face="Courier"> <br class="webkit-block-placeholder"></font></span></p><div style="margin: 0px; color: rgb(120, 73, 42); "><span style="font-size: 11px;"><font face="Courier"><span style="color: #000000"> </span><span style="color: #bb2ca2">switch</span><span style="color: #000000"> (</span>GST_MESSAGE_TYPE<span style="color: #000000">(msg)) {</span></font></span></div><div style="margin: 0px; color: rgb(61, 29, 129); "><span style="font-size: 11px;"><font face="Courier"><span style="color: #000000"> </span><span style="color: #bb2ca2">case</span><span style="color: #000000"> </span>GST_MESSAGE_EOS<span style="color: #000000">: {</span></font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #78492a">g_message</span>(<span style="color: #d12f1b">"End-of-stream"</span>);</font></span></div><div style="margin: 0px; color: rgb(61, 29, 129); "><span style="font-size: 11px;"><font face="Courier"><span style="color: #000000"> </span>g_main_loop_quit<span style="color: #000000">(</span><span style="color: #4f8187">loop</span><span style="color: #000000">);</span></font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #bb2ca2">break</span>;</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> }</font></span></div><div style="margin: 0px; color: rgb(61, 29, 129); "><span style="font-size: 11px;"><font face="Courier"><span style="color: #000000"> </span><span style="color: #bb2ca2">case</span><span style="color: #000000"> </span>GST_MESSAGE_ERROR<span style="color: #000000">: {</span></font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #703daa">GError</span> *err;</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #3d1d81">gst_message_parse_error</span>(msg, &err, <span style="color: #bb2ca2">NULL</span>);</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #78492a">g_error</span>(<span style="color: #d12f1b">"%s"</span>, err-><span style="color: #703daa">message</span>);</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #3d1d81">g_error_free</span>(err);</font></span></div><p style="margin: 0px; min-height: 13px; "><span style="font-size: 11px;"><font face="Courier"> <br class="webkit-block-placeholder"></font></span></p><div style="margin: 0px; color: rgb(61, 29, 129); "><span style="font-size: 11px;"><font face="Courier"><span style="color: #000000"> </span>g_main_loop_quit<span style="color: #000000">(</span><span style="color: #4f8187">loop</span><span style="color: #000000">);</span></font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #bb2ca2">break</span>;</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> }</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #bb2ca2">default</span>:</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> context = (<span style="color: #4f8187">context_t</span> *)user_data;</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #bb2ca2">if</span> (<span style="color: #3d1d81">gst_structure_has_name</span>(msg-><span style="color: #703daa">structure</span>, <span style="color: #d12f1b">"have-ns-view"</span>)) {</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #703daa">NSView</span>* myView = (<span style="color: #bb2ca2">__bridge</span> <span style="color: #703daa">NSView</span>*)<span style="color: #3d1d81">g_value_get_pointer</span>(<span style="color: #3d1d81">gst_structure_get_value</span>(msg-><span style="color: #703daa">structure</span>, <span style="color: #d12f1b">"nsview"</span>));</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #4f8187">AppDelegate</span>* del = (<span style="color: #bb2ca2">__bridge</span> <span style="color: #4f8187">AppDelegate</span>*)context-><span style="color: #4f8187">appDelegate</span>;</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #703daa">NSRect</span> viewFrame = [(<span style="color: #bb2ca2">__bridge</span> <span style="color: #703daa">NSView</span>*)context-><span style="color: #4f8187">viewingArea</span> <span style="color: #3d1d81">frame</span>];</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> [[del.<span style="color: #4f8187">window</span> <span style="color: #3d1d81">contentView</span>] <span style="color: #3d1d81">addSubview</span>:myView];</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> [myView <span style="color: #3d1d81">setFrame</span>: viewFrame];</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> [myView <span style="color: #3d1d81">setNeedsDisplay</span>:<span style="color: #bb2ca2">YES</span>];</font></span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="font-size: 11px;"><font face="Courier"><span style="color: #000000"> </span>//[del.window setContentView: myWindow];</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> }</font></span></div><p style="margin: 0px; min-height: 13px; "><span style="font-size: 11px;"><font face="Courier"> <br class="webkit-block-placeholder"></font></span></p><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #bb2ca2">break</span>;</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> }</font></span></div><p style="margin: 0px; min-height: 13px; "><span style="font-size: 11px;"><font face="Courier"> <br class="webkit-block-placeholder"></font></span></p><div style="margin: 0px; color: rgb(187, 44, 162); "><span style="font-size: 11px;"><font face="Courier"><span style="color: #000000"> </span>return<span style="color: #000000"> </span>true<span style="color: #000000">;</span></font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier">}</font></span></div><div style="margin: 0px; min-height: 13px; "><span style="font-size: 11px;"><font face="Courier"><br></font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"><span style="color: #bb2ca2">static</span> <span style="color: #bb2ca2">void</span> gst_finish(<span style="color: #703daa">GstElement</span>* object, <span style="color: #703daa">gpointer</span> user_data)</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier">{</font></span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="font-size: 11px;"><font face="Courier"><span style="color: #000000"> </span>//set uri to the next clip</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier">}</font></span></div><div style="margin: 0px; min-height: 13px; "><span style="font-size: 11px;"><font face="Courier"><br></font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"><span style="color: #bb2ca2">static</span> <span style="color: #bb2ca2">void</span> play_uri(<span style="color: #bb2ca2">const</span> <span style="color: #bb2ca2">char</span> *uri, <span style="color: #bb2ca2">void</span> *user_data)</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier">{</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #703daa">GstElement</span> *pipeline;</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #703daa">GstBus</span> *bus;</font></span></div><p style="margin: 0px; min-height: 13px; "><span style="font-size: 11px;"><font face="Courier"> <br class="webkit-block-placeholder"></font></span></p><div style="margin: 0px; color: rgb(61, 29, 129); "><span style="font-size: 11px;"><font face="Courier"><span style="color: #000000"> </span><span style="color: #4f8187">loop</span><span style="color: #000000"> = </span>g_main_loop_new<span style="color: #000000">(</span><span style="color: #bb2ca2">NULL</span><span style="color: #000000">, </span><span style="color: #bb2ca2">FALSE</span><span style="color: #000000">);</span></font></span></div><div style="margin: 0px; color: rgb(61, 29, 129); "><span style="font-size: 11px;"><font face="Courier"><span style="color: #000000"> pipeline = </span>gst_element_factory_make<span style="color: #000000">(</span><span style="color: #d12f1b">"playbin2"</span><span style="color: #000000">, </span><span style="color: #d12f1b">"player"</span><span style="color: #000000">);</span></font></span></div><p style="margin: 0px; min-height: 13px; "><span style="font-size: 11px;"><font face="Courier"> <br class="webkit-block-placeholder"></font></span></p><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #bb2ca2">if</span> (uri)</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #3d1d81">g_object_set</span>(<span style="color: #78492a">G_OBJECT</span>(pipeline), <span style="color: #d12f1b">"uri"</span>, uri, <span style="color: #bb2ca2">NULL</span>);</font></span></div><p style="margin: 0px; min-height: 13px; "><span style="font-size: 11px;"><font face="Courier"> <br class="webkit-block-placeholder"></font></span></p><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> bus = <span style="color: #3d1d81">gst_pipeline_get_bus</span>(<span style="color: #78492a">GST_PIPELINE</span>(pipeline));</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #3d1d81">gst_bus_add_watch</span>(bus, <span style="color: #31595d">bus_call</span>, user_data);</font></span></div><div style="margin: 0px; color: rgb(61, 29, 129); "><span style="font-size: 11px;"><font face="Courier"><span style="color: #000000"> </span>gst_object_unref<span style="color: #000000">(bus);</span></font></span></div><p style="margin: 0px; min-height: 13px; "><span style="font-size: 11px;"><font face="Courier"> <br class="webkit-block-placeholder"></font></span></p><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #78492a">g_signal_connect</span>(pipeline, <span style="color: #d12f1b">"about-to-finish"</span>, <span style="color: #78492a">G_CALLBACK</span>(<span style="color: #31595d">gst_finish</span>), user_data);</font></span></div><p style="margin: 0px; min-height: 13px; "><span style="font-size: 11px;"><font face="Courier"> <br class="webkit-block-placeholder"></font></span></p><div style="margin: 0px; color: rgb(61, 29, 129); "><span style="font-size: 11px;"><font face="Courier"><span style="color: #000000"> </span>gst_element_set_state<span style="color: #000000">(</span><span style="color: #78492a">GST_ELEMENT</span><span style="color: #000000">(pipeline), </span>GST_STATE_PLAYING<span style="color: #000000">);</span></font></span></div><p style="margin: 0px; min-height: 13px; "><span style="font-size: 11px;"><font face="Courier"> <br class="webkit-block-placeholder"></font></span></p><div style="margin: 0px; color: rgb(61, 29, 129); "><span style="font-size: 11px;"><font face="Courier"><span style="color: #000000"> </span>g_main_loop_run<span style="color: #000000">(</span><span style="color: #4f8187">loop</span><span style="color: #000000">);</span></font></span></div><p style="margin: 0px; min-height: 13px; "><span style="font-size: 11px;"><font face="Courier"> <br class="webkit-block-placeholder"></font></span></p><div style="margin: 0px; color: rgb(61, 29, 129); "><span style="font-size: 11px;"><font face="Courier"><span style="color: #000000"> </span>gst_element_set_state<span style="color: #000000">(</span><span style="color: #78492a">GST_ELEMENT</span><span style="color: #000000">(pipeline), </span>GST_STATE_NULL<span style="color: #000000">);</span></font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #3d1d81">gst_object_unref</span>(<span style="color: #78492a">GST_OBJECT</span>(pipeline));</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier">}</font></span></div><div style="margin: 0px; min-height: 13px; "><span style="font-size: 11px;"><font face="Courier"><br></font></span></div><div style="margin: 0px; color: rgb(187, 44, 162); "><span style="font-size: 11px;"><font face="Courier">@implementation<span style="color: #000000"> AppDelegate</span></font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"><span style="color: rgb(187, 44, 162); ">@synthesize</span> videoView = _videoView;</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"><span style="color: #bb2ca2">@synthesize</span> window = _window;</font></span></div><div style="margin: 0px; min-height: 13px; "><span style="font-size: 11px;"><font face="Courier"><br></font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier">-(<span style="color: #bb2ca2">void</span>)g_init:(<span style="color: #bb2ca2">id</span>)param</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier">{</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #3d1d81">gst_init</span>(<span style="color: #bb2ca2">NULL</span>, <span style="color: #bb2ca2">NULL</span>);</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #4f8187">context_t</span> *context = <span style="color: #3d1d81">malloc</span>(<span style="color: #bb2ca2">sizeof</span>(<span style="color: #4f8187">context_t</span>));</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> context-><span style="color: #4f8187">appDelegate</span> = (<span style="color: #bb2ca2">__bridge</span> <span style="color: #bb2ca2">void</span>*)<span style="color: #bb2ca2">self</span>;</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> context-><span style="color: #4f8187">viewingArea</span> = (<span style="color: #bb2ca2">__bridge</span> <span style="color: #bb2ca2">void</span>*)<span style="color: #4f8187">_videoView</span>;</font></span></div><div style="margin: 0px; color: rgb(209, 47, 27); "><span style="font-size: 11px;"><font face="Courier"><span style="color: #000000"> </span><span style="color: #31595d">play_uri</span><span style="color: #000000">(</span>"<a href="file:///Users/Shared/movies/holiday.mp4">file:///Users/Shared/movies/holiday.mp4</a>"<span style="color: #000000">, context);</span></font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier">}</font></span></div><div style="margin: 0px; min-height: 13px; "><span style="font-size: 11px;"><font face="Courier"><br></font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier">- (<span style="color: #bb2ca2">void</span>)applicationDidFinishLaunching:(<span style="color: #703daa">NSNotification</span> *)aNotification</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier">{</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> <span style="color: #703daa">NSThread</span> *g_thread = [[<span style="color: #703daa">NSThread</span> <span style="color: #3d1d81">alloc</span>] <span style="color: #3d1d81">initWithTarget</span>:<span style="color: #bb2ca2">self</span> <span style="color: #3d1d81">selector</span>:<span style="color: #bb2ca2">@selector</span>(g_init:) <span style="color: #3d1d81">object</span>:<span style="color: #bb2ca2">nil</span>];</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier"> [g_thread <span style="color: #3d1d81">start</span>];</font></span></div><div style="margin: 0px; "><span style="font-size: 11px;"><font face="Courier">}</font></span></div><div style="margin: 0px; min-height: 13px; "><span style="font-size: 11px;"><font face="Courier"><br></font></span></div><div style="margin: 0px; color: rgb(187, 44, 162); "><span style="font-size: 11px; "><font face="Courier">@end</font></span></div></body></html>