Simple RTSP Pipeline Works with gst-launch But Not with API
Michael Gruner
michael.gruner at ridgerun.com
Fri Jun 17 02:34:18 UTC 2016
Hi Zheng
Whenever possible, I use gst_parse_launch <https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstParse.html#gst-parse-launch> to avoid these types of complications. This is what gst-launch uses underneath, so if it works on one it should work on the other.
Specifically in your example:
int startPipeline(const char *vs_location) {
GstElement *pipeline;
GstBus *bus;
guint bus_watch_id;
gchar *pipe_desc;
GError *error = NULL;
gst_init(NULL, NULL);
pipe_desc = g_strdup_printf("rtspsrc port-range=5000-5100 location=%s latency=0 ! decodebin ! videoconvert ! video/x-raw,width=640,height=480,format=YUY2 ! autovideosink”, vs_location);
pipeline = gst_parse_launch (pipe_desc, &error);
//Handle errors here
g_free (pipe_desc);
bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
bus_watch_id = gst_bus_add_watch(bus, bus_callback, NULL);
gst_object_unref(bus);
gst_element_set_state(pipeline, GST_STATE_PLAYING);
loop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(loop);
// Clean up.
gst_element_set_state(pipeline, GST_STATE_NULL);
gst_object_unref(pipeline);
g_source_remove(bus_watch_id);
g_main_loop_unref(loop);
return 0;
}
—
Michael Gruner <michael.gruner at ridgerun.com <mailto:michael.gruner at ridgerun.com>>
Embedded Linux and GStreamer solutions
RidgeRun Engineering
Contact Us - http://www.ridgerun.com/#!contact/c3vn <http://www.ridgerun.com/#!contact/c3vn>
> On Jun 16, 2016, at 19:45, Zheng <superxingzheng at gmail.com> wrote:
>
> *Thang you in advance!*
>
> *This is the working gst-launch-1.0 pipeline.*
>
> gst-launch-1.0 rtspsrc port-range=5000-5100
> location=rtsp://192.168.1.10:8555/right latency=0 ! decodebin ! videoconvert
> ! video/x-raw,width=640,height=480,format=YUY2 ! autovideosink
>
> *The following is the NOT working C function.*
>
> int startPipeline(const char *vs_location) {
> GstElement *pipeline;
> GstBus *bus;
> guint bus_watch_id;
>
> gst_init(NULL, NULL);
> pipeline = gst_pipeline_new("my_pipeline");
> bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
> bus_watch_id = gst_bus_add_watch(bus, bus_callback, NULL);
> gst_object_unref(bus);
>
> GstElement *source, *dec_bin, *v_conv, *sink;
> source = gst_element_factory_make("rtspsrc", "source");
> dec_bin = gst_element_factory_make("decodebin", "dec_bin");
> v_conv = gst_element_factory_make("videoconvert", "v_con");
> sink = gst_element_factory_make("autovideosink", "sink");
> gst_bin_add_many(GST_BIN(pipeline), source, dec_bin, v_conv, sink, NULL);
>
> // Set element properties.
> g_object_set(G_OBJECT(source), "port-range", "5000-5100", NULL);
> g_object_set(G_OBJECT(source), "location", vs_location, NULL);
> g_object_set(G_OBJECT(source), "latency", 0, NULL);
>
> gst_element_link_many(source, dec_bin, v_conv, NULL);
>
> GstCaps *caps;
> caps = gst_caps_new_simple(
> "video/x-raw",
> "width", G_TYPE_INT, 640,
> "height", G_TYPE_INT, 480,
> "format", G_TYPE_STRING, "YUY2",
> NULL);
> gst_element_link_filtered(v_conv, sink, caps);
> gst_caps_unref(caps);
>
> gst_element_set_state(pipeline, GST_STATE_PLAYING);
>
> loop = g_main_loop_new(NULL, FALSE);
> g_main_loop_run(loop);
>
> // Clean up.
> gst_element_set_state(pipeline, GST_STATE_NULL);
> gst_object_unref(pipeline);
> g_source_remove(bus_watch_id);
> g_main_loop_unref(loop);
>
> return 0;
> }
>
> *Then the Errors are here.*
>
> 0:00:00.442295071 16407 0x7f007c01e940 FIXME default
> gstutils.c:3825:gst_pad_create_stream_id_internal:<fakesrc0:src> Creating
> random stream-id, consider implementing a deterministic way of creating a
> stream-id
> 0:00:00.455584401 16407 0x7f006c0025e0 FIXME rtpjitterbuffer
> gstrtpjitterbuffer.c:1395:gst_jitter_buffer_sink_parse_caps:<rtpjitterbuffer0>
> Unsupported timestamp reference clock
> 0:00:00.455616947 16407 0x7f006c0025e0 FIXME rtpjitterbuffer
> gstrtpjitterbuffer.c:1403:gst_jitter_buffer_sink_parse_caps:<rtpjitterbuffer0>
> Unsupported media clock
> 0:00:00.457236636 16407 0x7f006c0025e0 WARN basesrc
> gstbasesrc.c:2947:gst_base_src_loop:<udpsrc0> error: Internal data flow
> error.
> 0:00:00.457268553 16407 0x7f006c0025e0 WARN basesrc
> gstbasesrc.c:2947:gst_base_src_loop:<udpsrc0> error: streaming task paused,
> reason not-linked (-1)
> Error: Internal data flow error.
> Debug: gstbasesrc.c(2947): gst_base_src_loop ():
> /GstPipeline:my_pipeline/GstRTSPSrc:source/GstUDPSrc:udpsrc0:
> streaming task paused, reason not-linked (-1)
> 0:00:00.458046376 16407 0x10af5e0 WARN rtspsrc
> gstrtspsrc.c:5520:gst_rtspsrc_try_send:<source> receive interrupted
> 0:00:00.458083322 16407 0x10af5e0 WARN rtspsrc
> gstrtspsrc.c:7546:gst_rtspsrc_pause:<source> PAUSE interrupted
>
>
>
>
>
> --
> View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Simple-RTSP-Pipeline-Works-with-gst-launch-But-Not-with-API-tp4678108.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20160616/d23ae58b/attachment.html>
More information about the gstreamer-devel
mailing list