Full dublex rtp stream

tommi roth roth.tommi at gmail.com
Wed Dec 5 04:39:25 PST 2012


Hi All,

I 'm struggling with full dublex rtp problem.

When I launch two separate pipeline (in same host) like below everything
works just fine ( I can hear both sounds wave 5 and wave 1 and with
wireshark I can see that rtp packets flows nicely in both directions):

Client A
------------
gst-launch-0.10 -v gstrtpbin name=rtpbin udpsrc
caps="application/x-rtp,media=(string)audio,clock-rate=(int)16000,encoding-name=(string)SPEEX"
port=5000 ! rtpbin.recv_rtp_sink_0 audiotestsrc wave=5 ! audioconvert !
audioresample ! audio/x-raw-int,rate=16000 ! queue leaky=1 ! speexenc
bitrate=16000 ! rtpspeexpay ! rtpbin.send_rtp_sink_0 rtpbin.send_rtp_src_0
! udpsink port=5002 sync=false async=false rtpbin. ! rtpspeexdepay ! queue
leaky=1 ! speexdec ! audioconvert ! audioresample ! autoaudiosink


Client B
------------
gst-launch-0.10 -v gstrtpbin name=rtpbin udpsrc
caps="application/x-rtp,media=(string)audio,clock-rate=(int)16000,encoding-name=(string)SPEEX"
port=5002 ! rtpbin.recv_rtp_sink_0 audiotestsrc wave=1 ! audioconvert !
audioresample ! audio/x-raw-int,rate=16000 ! queue leaky=1 ! speexenc
bitrate=16000 ! rtpspeexpay ! rtpbin.send_rtp_sink_0 rtpbin.send_rtp_src_0
! udpsink port=5000 sync=false async=false rtpbin. ! rtpspeexdepay ! queue
leaky=1 ! speexdec ! audioconvert ! audioresample ! autoaudiosink


But some reason version coded with Python doesn't work so well. I can hear
only audio sent by one client not both.

Any idea what could be wrong in this Python code? Why both sounds cannot be
heard?

client-b code is exactly same except port numbers and in 'def go()' line
'print autoaudiosink.set_locked_state(gst.STATE_PLAYING)' is not commented
out (i don't know why it have to be like this?).


#!/usr/bin/env python
# -=- encoding: utf-8 -=-

import gobject, pygst
pygst.require("0.10")
import gst
import gobject
import sys
import os
import readline

# To the laptop that will catch everything
REMOTE_HOST = 'localhost'

caps =
'application/x-rtp,media=(string)audio,clock-rate=(int)16000,encoding-name=(string)SPEEX'

mainloop = gobject.MainLoop()
pipeline = gst.Pipeline('client-a')
bus = pipeline.get_bus()

# incoming audio stream elements
rtpspeexdepay = gst.element_factory_make('rtpspeexdepay')
speexdec = gst.element_factory_make('speexdec')
audioconvert1 = gst.element_factory_make('audioconvert')
audioconvert2 = gst.element_factory_make('audioconvert')
audioresample = gst.element_factory_make('audioresample')
autoaudiosink = gst.element_factory_make('autoaudiosink')
queue1 = gst.element_factory_make('queue')
#queue1.set_property('leaky', 1)

# outgoing audio stream elements
audiotestsrc = gst.element_factory_make('audiotestsrc')
audiotestsrc.set_property('wave', 5)
audioconvert = gst.element_factory_make('audioconvert')
audioresample = gst.element_factory_make('audioresample')
speexenc = gst.element_factory_make('speexenc')
speexenc.set_property('bitrate', 16000)
rtpspeexpay = gst.element_factory_make('rtpspeexpay')
queue2 = gst.element_factory_make('queue')
#queue2.set_property('leaky', 1)

# incoming rtp
udpsrc_rtpin = gst.element_factory_make('udpsrc', "udpsrc1")
udpsrc_rtpin.set_property('port', 5000)
udpsrc_caps = gst.caps_from_string(caps)
udpsrc_rtpin.set_property('caps', udpsrc_caps)

# outgoing rtp
udpsink_rtpout = gst.element_factory_make("udpsink", "udpsink0")
udpsink_rtpout.set_property('host', REMOTE_HOST)
udpsink_rtpout.set_property('port', 5002)
udpsink_rtpout.set_property('sync', 'false')
udpsink_rtpout.set_property('async', 'false')

# incoming and outgoing rtcp
#udpsink_rtcpout = gst.element_factory_make("udpsink", "udpsink1")
#udpsink_rtcpout.set_property('host', REMOTE_HOST)
#udpsink_rtcpout.set_property('port', 5003)
#udpsink_rtcpout.set_property('sync', 'false')
#udpsink_rtcpout.set_property('async', 'false')
#udpsrc_rtcpin = gst.element_factory_make("udpsrc", "udpsrc0")
#udpsrc_rtcpin.set_property('port', 5007)

rtpbin = gst.element_factory_make('gstrtpbin', 'gstrtpbin')

# Add elements
pipeline.add(rtpbin, udpsrc_rtpin, rtpspeexdepay, speexdec, audioconvert1,
queue1, autoaudiosink, audiotestsrc, audioconvert2, audioresample, queue2,
speexenc, rtpspeexpay, udpsink_rtpout)

# Link them
udpsrc_rtpin.link_pads('src', rtpbin, 'recv_rtp_sink_0')

def rtpbin_pad_added(obj, pad):
    print "PAD ADDED"
    print "  obj              = ", obj
    print "  pad              = ", pad
    print "  pad capabilities = ", str(pad.get_property('caps'))
    rtpbin.link(rtpspeexdepay)

rtpspeexdepay.link(queue1)
queue1.link(speexdec)
speexdec.link(audioconvert1)
audioconvert1.link(autoaudiosink)

audiotestsrc.link(audioconvert2)
audioconvert2.link(audioresample)
audio_caps = gst.Caps("audio/x-raw-int,rate=16000")
audioresample.link_filtered(queue2, audio_caps)
queue2.link(speexenc)
speexenc.link(rtpspeexpay)

rtpspeexpay.link_pads('src', rtpbin, 'send_rtp_sink_0')
rtpbin.link_pads('send_rtp_src_0', udpsink_rtpout, 'sink')

rtpbin.connect('pad-added', rtpbin_pad_added)

def go():
    #print "Setting locked state for autovideosink and udpsink"
    #print udpsink_rtcpout.set_locked_state(gst.STATE_PLAYING)
    #print autoaudiosink.set_locked_state(gst.STATE_PLAYING)
    print "Setting pipeline to PLAYING"
    print pipeline.set_state(gst.STATE_PLAYING)
    print "Waiting pipeline to settle"
    print pipeline.get_state()
    #print "Final caps writte to", WRITE_AUDIO_CAPS
    #open(WRITE_AUDIO_CAPS,
'w').write(str(udpsink_rtpout.get_pad('sink').get_property('caps')))
    print "audio stream caps = ",
str(udpsink_rtpout.get_pad('sink').get_property('caps'))
    mainloop.run()

go()


Thanks in advance!

Thanks & Regards,
Tommi Roth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20121205/e3dd9172/attachment.html>


More information about the gstreamer-devel mailing list