title: Concatenating files in Python Gstreamer
body: <p>I want to stream files from one computer to another using <code>pygst</code>. I wrote the following code:</p>
  
  <pre><code>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 &gt;&gt; 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 &lt; 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 &gt;&gt; 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]))
  </code></pre>
  
  <p>But it plays only the first file and then stops. As you can see, on EOS I stopped the pipeline and changed the src but it gave me nothing.  </p>
  
  <p>How can get the code to  "concatenate" the second file? </p>