Phil's blog

Apr 2014
Mo Tu We Th Fr Sa Su
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

Python, sockets, GStreamer and the Garbage collector

Long time no blog, eh? Anyway I was today hooking up Telepathy Stream Tubes with GStreamer so that I could stream video over local-xmpp, go figure why... :)

Everything was fine:

  • on one side, offer a stream tube in a multi-user room and setup a pipeline like this one:

    videotestsrc ! gdppay ! multifdsink
  • on client side, join the room and accept the tube, hooked into the following pipeline with a socket:

    fdsrc ! gdpdepay ! xvimagesink
  • when server is notified of new client, add its socket fd in multifdsink and start playback

But it wasn't working, multifdsink was removing the fd by itself from the list and client wasn't receiving data. I spent some time this afternoon trying to figure out why and thought I might share the solution, if it can serve to anyone using multifdsink in Python. Because I wasn't keeping references of the client socket instances in my code, they were garbage-collected by Python, so the fd was becoming invalid, hence the rejection by multifdsink.

Keeping a list of the socket instances and cleaning it up when the sink emits the client-removed signal does the trick and I got my video streaming over local-xmpp working. Those Tubes are so much fun, thanks Collabora & Telepathy folks for this nice stuff!

by Philippe Normand on Sat May 23 22:56:20 2009 (Viewed: 489837 / 2 comments )
  |   RSS  |   RSS2  |   Atom  |   Source  |   Edit

#.   wiflye81 on Sun May 24 22:05:03 2009

It's great and seem simple at the same time, can we have a little sample ?

#.   phil on Sun May 24 22:40:03 2009

You'll need Coherence trunk too:

Unfortunately this strategy doesn't work on Jabber because the Telepathy Gabble manager handles stream tubes as in-bound connections. So I started looking at how I could use Farsight Stream Engine to achieve video streaming over Jabber ;)

Comments not allowed anymore on this post