Hi I have a gstreamer pipeline set up like so:
//Create pipeline m_pPipeline = GST_PIPELINE(gst_pipeline_new("livemjpg-player")); // Create source elements GstElement *source = gst_element_factory_make("rtspsrc", "source"); g_object_set(source, "location", rtspUrl.c_str(), NULL ); // Create decode element GstElement *decode = gst_element_factory_make("decodebin2", "decode"); // Create jpeg encoder element GstElement *encoder = gst_element_factory_make("jpegenc", "jpegenc"); // Create sink format element GstElement *sink = gst_element_factory_make("fdsink", "sink"); // Add elements to the pipeline gst_bin_add_many( GST_BIN(m_pPipeline), source, decode, encoder, sink, NULL); // Link all elements except source and decoder // The rtspsrc and decoder will automatically determine the appropriate pad // at run time and then they will link accordingly gst_element_link_many(encoder, sink, NULL)); g_signal_connect(source, "pad-added", G_CALLBACK(on_rtsppad_added), decode ); g_signal_connect(decode, "new-decoded-pad", G_CALLBACK (on_pad_added), encoder ); When the soruce pad is detected the on_rtsppad_added function is called: static void on_rtsppad_added(GstElement *element, GstPad *pad, gpointer data) { GstElement *linkElement = (GstElement *) data; GstPad *sinkpad = gst_element_get_static_pad (linkElement, "sink"); if ( GST_PAD_IS_LINKED( sinkpad ) ) { gst_pad_unlink (pad, sinkpad)) } GstPadLinkReturn linkreturn = gst_pad_link (pad, sinkpad); gst_object_unref(GST_OBJECT (sinkpad)); } then the on_pad_added function is called: static void on_pad_added(GstElement *element, GstPad *pad, gboolean last, gpointer data) { GstElement *linkElement = (GstElement *) data; GstPad *sinkpad = gst_element_get_static_pad (linkElement, "sink"); if ( GST_PAD_IS_LINKED( sinkpad ) ) { g_object_unref(sinkpad); return; } // Link pads (decoder --> <link Element>) gst_pad_link (pad, sinkpad); gst_object_unref(GST_OBJECT (sinkpad)); } The source is a video stream from an rtsp server. Everything works fine until the video stream changes from e.g. MJPEG to MP4. The video stops diaplaying on my output and the following happens in my debug window: 1. After a few seconds the function on_rtsppad_added is called because it detects a new input stream. 2. I check to see if the pad is already linked: if ( GST_PAD_IS_LINKED( sinkpad ) ) { gst_pad_unlink (pad, sinkpad)) } and it tells me that it IS linked. So I try to unlink it but the return code from gst_pad_unlink (pad, sinkpad)) is GST_PAD_LINK_WAS_LINKED. **Note** The unlinking code is code I have added in to try and get round the problem of the video stopping. Normally after on_rtsppad_added is called, on_pad_added gets called but what i see is that on_pad_added does not get called at all when the stream type changes. Questions: 1. Why is it telling me that the pad is linked? Is this not a new pad that should not be linked to anything> 2. Why will it not let me unlink the pad so that I can re-link it and then hopefuly on_pad_added will get called and all will be ok. Thanks experts. |
Free forum by Nabble | Edit this page |