Reputation: 4650
I am using GStreamer in my application in Vala to play .mp4 video. I am trying to make pipeline from tutorial: filesrc -> decodebin -> pulsesink, but my application always crashes. Here is my code:
this.pipeline = new Pipeline ("mypipeline");
this.src = ElementFactory.make ("filesrc", "video");
src.set("location", downloadFileName);
this.decode = ElementFactory.make ("decodebin", "decode");
this.sink = ElementFactory.make ("autoaudiosink", "sink");
this.pipeline.add_many (this.src, this.decode, this.sink);
if (this.src == null)
error("Gstreamer element init error 1");
if (this.decode == null)
error("Gstreamer element init error 2");
if (this.sink == null)
error("Gstreamer element init error 3");
if (!this.src.link (this.decode))
error("GStreamer linking problems.");
if (!this.decode.link (this.sink))
error("GStreamer linking problems 2.");
this.pipeline.set_state (State.PLAYING);
And my application always crashes with "GStreamer linking problems 2."
gst-launch-1.0 filesrc location=<filename> ! decodebin ! pulsesink
works normal, so I think it's Vala-related problem ( is my actual filename, of course).
Can you tell me what I'm doing wrong?
Upvotes: 0
Views: 368
Reputation: 827
You should put a videoconvert between decodebin and the sink, also make sure you called gst_init (I guess you did but can't hurt to check).
Edit: the actual problem here is that decodebin exposes its source pad once it has constructed its internal element chains internally, which happens in the transition from READY to PAUSED. That means you will need to connect to its "pad-added" signal, and do the connection in the callback you provide. I'm sure googling "gstreamer pad-added" will yield interesting information.
Upvotes: 1