m f
m f

Reputation: 33

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.

Upvotes: 3

Views: 7058

Answers (2)

enthusiasticgeek
enthusiasticgeek

Reputation: 2736

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

Upvotes: 1

ensonic
ensonic

Reputation: 3440

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.

Upvotes: 2

Related Questions