#!/usr/bin/python

import gst, time, sys

p = gst.parse_launch("videotestsrc is-live=1 name=src ! video/x-raw-yuv,width=320,height=240 ! ffmpegcolorspace name=f1 ! ffmpegcolorspace name=f2 ! xvimagesink");
f1 = p.get_by_name("f1")
f2 = p.get_by_name("f2")
src = p.get_by_name("src")
p.set_state(gst.STATE_PLAYING)
time.sleep(2)
# After this is it start doing too many caps nego after each alloc call


print "Blocking"
pad = src.get_static_pad("src")
pad.set_blocked (True)
print "Blocked"
f1_pad = f1.get_static_pad("src")
f2_pad = f2.get_static_pad("sink")
f1_pad.unlink(f2_pad)
edgetv = gst.element_factory_make("edgetv")
p.add(edgetv)
e_src = edgetv.get_static_pad("src")
e_sink = edgetv.get_static_pad("sink")
f1_pad.link(e_sink)
e_src.link(f2_pad)
edgetv.set_state(gst.STATE_PLAYING)
print "Unblocking"
pad.set_blocked (False)
print "Unblocked"

time.sleep(10) 
p.set_state(gst.STATE_NULL)

