3

I am currently on working on my university project which involves GStreamer audio streaming. I have successfully managed to get streaming working between client/server and TCP.

My next task is to dynamically change the audio stream on user input. I tried the following:

    pp.setState(State.PAUSED);

    pp.setState(State.READY);

    pp.unlink(src);

    source = ElementFactory.make("filesrc", "src");

    pp.link(source);

    source.set("location", fpath);

    pp.setState(State.PLAYING);

fpath is the audio file location. When a user input is received, the state is set to PAUSE, the source is unlinked and a new source is added. The state is set to PLAYING.

I used GST_DEBUG on client side and there are no errors, buffers are sent to the client but no sound.

Any suggestions would be appreciated.

m f
  • 33
  • 1
  • 3

2 Answers2

2

You don't need to unlink and add a new source. Just go straight to READY (no need to go to PAUSED and then to READY, this will happen implicitly), set a new location and go back to playing.

ensonic
  • 3,304
  • 20
  • 31
  • Thanks for your prompt response. I have tried the above, and now the client just hangs, and no buffers are sent. – m f May 02 '12 at 09:06
  • I added a bus to monitor the errors and I get the following errors: WARNING **: Changing the `location' property on filesrc when a file is open is not supported and the bus error: Error occurred: Could not open resource for reading. BaseSink: [serversink] – m f May 02 '12 at 12:58
  • The error indicates that filesrc is still not in READY. Could you update the above code to reflect the changes. – ensonic May 03 '12 at 07:40
  • Thanks for your help, I've got it working. It's just like you said READY, change source and then PLAYING. What I was trying to do is, change the source without tearing down the gstreamer connection between the client and the server, whilst changing the source. But I realised that is not possible. So currently, when a stream is playing, it is set to READY, the source is set and set then to playing. The client then connects to the server on the same port and it works. pp.setState(State.READY); src.set("location", fpath); pp.setState(State.PLAYING); – m f May 06 '12 at 12:57
  • @mf what do you mean the client connects again to the server? Another question: do you use version 1.0 or 0.1 of GStreamer ? – Danis Fischer May 03 '15 at 02:48
1

you need to syncStateWithParent();.

I am using it for different purpose but this can be extended to your application on property change Gstreamer: Pausing/resuming video in RTP streams

Community
  • 1
  • 1
enthusiasticgeek
  • 2,640
  • 46
  • 53