import gobject
gobject.threads_init()
import pygst
pygst.require('0.10')
import gst
import sys

#FIXME: create a test-case for this

def _buf(pad, buffer):
    print "BUFFER PROBE"
    return True

def _state(bin, s):
    print "set state to", s
    bin.set_state(s)

port = 1000
pipe = "tcpclientsrc port=%d ! fakesink name=f" % (port)
print pipe
bin = gst.parse_launch(pipe)
f = bin.get_by_name('f')
f.get_pad('sink').add_buffer_probe(_buf)
bin.set_state(gst.STATE_PLAYING)
gobject.timeout_add(3000, _state, bin, gst.STATE_PAUSED)
gobject.timeout_add(6000, _state, bin, gst.STATE_PLAYING)


m = gobject.MainLoop()
m.run()
