<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Plain Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.5pt;
        font-family:Consolas;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.PlainTextChar
        {mso-style-name:"Plain Text Char";
        mso-style-priority:99;
        mso-style-link:"Plain Text";
        font-family:Consolas;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal>Hi everybody,<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>I am writing an application where the user should be able to
draw (with the mouse) a rectangle on a playing video window (for now it is an
ximagesink).<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>I try the following but I see nothing drawing on the screen&#8230;<o:p></o:p></p>

<p class=MsoNormal>### CONFIGURE PIPELINE TO CATCH SYNC MESSAGES<o:p></o:p></p>

<p class=MsoPlainText style='margin-left:.5in'>bus = self.Pipeline.get_bus()<o:p></o:p></p>

<p class=MsoPlainText style='margin-left:.5in'>bus.add_signal_watch()<o:p></o:p></p>

<p class=MsoPlainText style='margin-left:.5in'>bus.enable_sync_message_emission()<o:p></o:p></p>

<p class=MsoPlainText style='margin-left:.5in'>bus.connect('message',
self.on_message)<o:p></o:p></p>

<p class=MsoPlainText style='margin-left:.5in'>bus.connect('sync-message::element',
self.on_sync_message)<o:p></o:p></p>

<p class=MsoNormal style='text-indent:.5in'><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='text-indent:.5in'><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='text-indent:.5in'>#############<o:p></o:p></p>

<p class=MsoNormal style='text-indent:.5in'>## Tell ximagesink to draw into the
draw area that I give it, not in it&#8217;s own &#8230;<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp; def on_sync_message(self, bus,
message):<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp; &nbsp; if message.structure is None:<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp; &nbsp; message_name =
message.structure.get_name()<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp; &nbsp; if message_name ==
&quot;prepare-xwindow-id&quot;:<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; imagesink
= message.src<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; imagesink.set_property(&quot;force-aspect-ratio&quot;,
True)<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; imagesink.set_xwindow_id(self.DrawingArea.window.xid)<o:p></o:p></p>

<p class=MsoNormal style='text-indent:.5in'><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='text-indent:.5in'>#############<o:p></o:p></p>

<p class=MsoNormal style='text-indent:.5in'>## Now, on the expose event of the
drawing area, paint the rectangle according to user input (mouse)<o:p></o:p></p>

<p class=MsoNormal style='text-indent:.5in'>#############<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp; def
on_DrawingAreaCamera_expose_event(self,widget,event):<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #if
self.area_selection_now is True:<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; context =
widget.window.cairo_create()<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
#widget.window.draw(context)<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
context.rectangle(self.area_selection)<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
context.set_source_rgb(1,0,0)<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
context.stroke()<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>What is the right way to interact with ximagesink, so I can
also draw things on it&#8217;s drawable??<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Regards<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</body>

</html>