javaaudiostreaminggstreamer

GStreamer dynamically change the filesrc location of a pipeline- No sound


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.


Solution

  • 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.