在Python Gstreamer中连接文件

在Python Gstreamer中连接文件,python,streaming,gstreamer,audio-streaming,python-gstreamer,Python,Streaming,Gstreamer,Audio Streaming,Python Gstreamer,我想使用pygst将文件从一台计算机传输到另一台计算机。我编写了以下代码: import gobject import pygst pygst.require("0.10") import gst import sys class CustomData: is_live = False pipeline = None loop = None src = None def cb_message(bus, msg, data): def error():

我想使用pygst将文件从一台计算机传输到另一台计算机。我编写了以下代码:

import gobject
import pygst
pygst.require("0.10")
import gst
import sys

class CustomData:
    is_live = False
    pipeline = None
    loop = None
    src = None

def cb_message(bus, msg, data):
    def error():
        print >> sys.stderr, ("Error: {0}".format(err.message))
        data.pipeline.set_state(gst.STATE_READY)
        data.loop.quit()
    def eos():
        data.pipeline.set_state(gst.STATE_READY)
        data.src.set_property("location", "/home/user/con1.wav")
        data.pipeline.set_state(gst.STATE_PLAYING)
    def buffering():
        percent = 0

        if (data.is_live):
            return
        percent = msg.parse_buffering()
        sys.stdout.write("\rBuffering ({0}%)".format(percent))
        sys.stdout.flush()

        if (percent < 0):
            data.pipeline.set_state(gst.STATE_PAUSED)
        else:
            data.pipeline.set_state(gst.STATE_PLAYING)
    def clock_lost():
        #Get a new clock
        data.pipeline.set_state(gst.STATE_PAUSED)
        data.pipeline.set_state(gst.STATE_PLAYING)
    def default():
        pass

    handlers = dict({gst.MESSAGE_ERROR: error, 
                     gst.MESSAGE_EOS: eos,
                     gst.MESSAGE_BUFFERING: buffering,
                     gst.MESSAGE_CLOCK_LOST: clock_lost
                     })
    if (handlers.has_key(msg.type)):
        handlers[msg.type]()

def send_file(port):
    data = CustomData()
    pipeline = gst.Pipeline("client")
    bus = pipeline.get_bus()
    src = gst.element_factory_make("filesrc","curr_src")
    src.set_property("location", "/home/user/con2.wav")
    pipeline.add(src)

    client = gst.element_factory_make("tcpclientsink", "client")
    pipeline.add(client)
    client.set_property("host", "192.168.1.100")
    client.set_property("port", port)
    src.link(client)
    ret = pipeline.set_state(gst.STATE_PLAYING)
    if (ret == gst.STATE_CHANGE_FAILURE):
        print >> sys.stderr, ("Unable to set pipeline to the playing     state")
        exit(-1)
    # enter into a mainloo
    loop = gobject.MainLoop()
    data.loop = loop
    data.pipeline = pipeline
    data.src = src

    bus.enable_sync_message_emission()
    bus.add_signal_watch()
    bus.connect("message", cb_message, data)
    data.loop.run()
    #loop.run()

if __name__ == '__main__':
    send_file(int(sys.argv[1]))
但它只播放第一个文件,然后停止。正如您所见,在EOS上,我停止了管道并更改了src,但它什么也没有给我

如何让代码连接第二个文件