[gst-devel] gst_clock_id_wait_async equivalent in Python

Edward Hervey bilboed at gmail.com
Wed May 6 07:51:14 CEST 2009


Hi,

  The gst.ClockId objects are not wrapped properly yet in gst-python.

  There is a patch that needs deeper reviewing here :
http://bugzilla.gnome.org/show_bug.cgi?id=380495

    Edward

On Tue, 2009-05-05 at 15:58 -0700, EmbeddedMicro wrote:
> I need an equivalent to gst_clock_id_wait_async() for python. I need to
> reproduce these lines from
> gst-plugins-good/tests/examples/spectrum/demo-audiotest.c
> 
> gst_clock_id_wait_async (clock_id, delayed_spectrum_update, (gpointer)
> spect);
> gst_clock_id_unref (clock_id);
> 
> Here is what I have 
> import rb
> > import gst
> > import serial
> > 
> > class LEDcube(rb.Plugin):
> > 
> > 	def activate(self, shell):
> > 		self.max = -60
> > 		self.spectrum = gst.element_factory_make("spectrum")
> > 		self.spectrum.set_property('bands',70)
> > 		self.spectrum.set_property('interval',10000000)
> > 		self.spectrum.set_property('threshold',-50)
> > 
> > 		player = shell.get_player().props.player
> > 		player.add_filter(self.spectrum)
> > 
> > 		bus = player.props.bus
> > 
> > 		if bus is None:
> > 			self.bus_id = player.connect('notify::bus', self.bus_notify)
> > 		else:
> > 			self.bus_id = player.props.bus.connect('message', self.on_message)
> > 
> > 		self.ser = serial.Serial('/dev/ttyS0', 115200, timeout=1)
> > 
> > 	def deactivate(self, shell):
> > 		player = shell.get_player().props.player
> > 
> > 		player.remove_filter(self.spectrum)
> > 		player.props.bus.disconnect(self.bus_id)
> > 		self.bus_id = 0
> > 
> > 	def bus_notify(self, obj, pspec):
> > 		obj.disconnect(self.bus_id)
> > 		self.bus_id = obj.props.bus.connect('message', self.on_message)
> > 
> > 	def on_message(self, bus, message):
> > 		clock = self.spectrum.get_clock()
> > 		if message.src == self.spectrum and
> > message.structure.has_key('magnitude') and clock:
> > 			magnitudes = message.structure['magnitude']
> > 			time = message.structure['running-time'] +
> > message.structure['duration']
> > 			
> > 			clock_id = clock.new_single_shot_id(time +
> > self.spectrum.get_base_time())
> > 
> > 			clock_id.wait_async() #NEED SOMETHING LIKE THIS
> > 			clock_id.unref()
> > 
> > 			self.ser.write("\x35")
> > 			for i in range(0, 27):
> > 				mag = (50 + int(round(magnitudes[i]))) * 1.4
> > 
> > 				red = (mag * mag / 25) + 1
> > 				green = ((50 - mag) * mag / 25) + 1
> > 
> > 				if red > 51:
> > 					red = 51
> > 				if green > 51:
> > 					green = 51
> > 
> > 				self.ser.write(chr(int(round(red))))
> > 				self.ser.write(chr(int(round(green))))
> 
> Thanks,
> Justin





More information about the gstreamer-devel mailing list