rtpbin how to add and play items
Samuel Mathieson
samuel at mathieson.net
Sun Jul 15 22:35:19 UTC 2018
Hello,
I am trying to link a depayer and a decoder to an rtpbin when a pad is
added (new stream).
It does not seem to work, no errors, just does not play.
The prototype pipeline is:
gst-launch-1.0 -v audiomixer name=mix ! audioconvert ! alsasink rtpbin
name=bin udpsrc address=ipHere port=portHere
caps="application/x-rtp,media=audio,clock-rate=8000" ! bin.recv_rtp_sink_0
bin. ! rtppcmudepay ! mulawdec ! mix.
This works without issue, however after one stream it no longer works. I
can keep adding "bin. ! rtppcmudepay ! mulawdec ! mix." a thousand times,
but the real solution is for the elements to be created and destroyed as
needed.
I have not gotten round to handling the destroyed part at all yet. Do I
need to? Or will gstreamer delete elements as they are no longer used?
Any help would be appreciated.
Thanks.
Here is the relevant code:
def request_decoder(self, element, pad):
depay = Gst.ElementFactory.make("rtppcmudepay")
decode = Gst.ElementFactory.make("mulawdec")
self.pipeline.add(depay, decode)
pad.link(depay.get_static_pad("sink"))
depay.link(decode)
decode.link(self.mixpad)
def startAudio(self):
logger.info("setting up audio reception @
{}:{}".format(multicast, port))
pipestring = "audiomixer name=mix ! audioconvert ! alsasink
rtpbin name=bin udpsrc name=src ! bin.recv_rtp_sink_0"
logger.info("PipeLine: "+pipestring)
self.pipeline = Gst.parse_launch(pipestring)
self.srcpad = self.pipeline.get_by_name('src')
self.binpad = self.pipeline.get_by_name('bin')
self.mixpad = self.pipeline.get_by_name('mix')
self.srcpad.props.address = multicast
self.srcpad.props.port = port
self.srcpad.props.caps =
Gst.Caps.from_string('application/x-rtp,media=audio,clock-rate=8000')
self.binpad.connect('pad_added', self.request_decoder)
ret = self.pipeline.set_state(Gst.State.PLAYING)
if ret == Gst.StateChangeReturn.FAILURE:
raise Exception("Unable to start udp source!")
logger.info("ready to receive audio")
bus = self.pipeline.get_bus()
bus.add_signal_watch()
terminate = False
while True:
try:
msg = bus.timed_pop_filtered(
0.5 * Gst.SECOND,
Gst.MessageType.ERROR | Gst.MessageType.EOS)
if msg:
terminate = True
except KeyboardInterrupt:
terminate = True
if terminate:
break
self.pipeline.set_state(Gst.State.NULL)
--
Este correo electrónico y cualquier archivo transmitido adjunto son
confidenciales y destinados exclusivamente para el uso de la persona o
entidad a quien se dirigen. Si usted ha recibido este mensaje por error por
favor notifique al administrador del sistema.
*Aviso de Privacidad*: La
empresa Mathieson Electrónica en Comunicación S.A. De C.V. con domicilio
ubicado en, Geranios #76, Jardines de San Mateo, Naucalpan, Estado de
Mexico, C.P. 53240. utilizara sus datos personales recabados con los
siguientes fines: Fines laborales. para mayor información sobre el
tratamiento de sus datos personales usted puede ingresar a la siguiente
página web: http://privacy.mathiesonelco.com/
<http://privacy.mathiesonelco.com>
Mathieson Electronica en Comunicación
S.A. de C.V.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20180715/19087a38/attachment-0001.html>
More information about the gstreamer-devel
mailing list