element link error in gstreamer pipeline

Mayank Agarwal mayank77fromindia at gmail.com
Tue Sep 9 03:58:58 PDT 2014


Hi,

I have written the following code to realize the pipeline which is playing fine:

 gst-launch souphttpsrc location=
http://video.webmfiles.org/big-buck-bunny_trailer.webm ! matroskademux
! vp8dec ! ffmpegcolorspace ! ximagesink



#include <gst/gst.h>
#include <glib.h>



int main(int argc,char *argv[])
{

GMainLoop *loop;
GstElement *htpsrc,*demuxer,*decoder,*ffmpeg,*sink;
GstElement *pipeline;
GstBus *bus;
guint bus_watch_id;
GstMessage *msg;
GstStateChangeReturn ret;

gst_init(&argc,&argv);

htpsrc = gst_element_factory_make("souphttpsrc","htonesrc");

demuxer = gst_element_factory_make("matroskademux","demux");

decoder = gst_element_factory_make("vp8dec","vp8decoder");

ffmpeg = gst_element_factory_make("ffmpegcolorspace","ffmpeg");

sink =  gst_element_factory_make("ximagesink","sink");

if(!htpsrc)
{
g_print("source element could not be created\n");
return;
}

if(!demuxer)
{
g_print("demuxer element could not be created\n");
return;
}

if(!decoder)
{
g_print("decoder element could not be created\n");
return;
}


if(!ffmpeg)
{
g_print("ffmpeg element could not be created\n");
return;
}


if(!sink)
{
g_print("sink element could not be created\n");
return;
}

g_print("before creating pipeline \n");
pipeline = gst_pipeline_new("basic_player");
if(!pipeline)
{
g_printf("Pipeline could not be created");
return;
}


g_object_set (G_OBJECT (htpsrc), "location", argv[1], NULL);


gst_bin_add_many(GST_BIN (pipeline),htpsrc,demuxer,decoder,ffmpeg,sink,NULL);

if(gst_element_link_many(htpsrc,demuxer,decoder,ffmpeg,sink,NULL)!=TRUE)
{
g_printerr("Elements could not be linked");
gst_object_unref(pipeline);
return -1;
}

ret = gst_element_set_state(pipeline,GST_STATE_PLAYING);

if(ret!= GST_STATE_CHANGE_SUCCESS)
{
g_print("could not set pipeline to playing");
gst_object_unref(pipeline);
return -1;
}



  bus = gst_element_get_bus (pipeline);
  msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
GST_MESSAGE_ERROR | GST_MESSAGE_EOS);

  /* Parse message */
  if (msg != NULL) {
    GError *err;
    gchar *debug_info;

    switch (GST_MESSAGE_TYPE (msg)) {
      case GST_MESSAGE_ERROR:
        gst_message_parse_error (msg, &err, &debug_info);
        g_printerr ("Error received from element %s: %s\n",
GST_OBJECT_NAME (msg->src), err->message);
        g_printerr ("Debugging information: %s\n", debug_info ?
debug_info : "none");
        g_clear_error (&err);
        g_free (debug_info);
        break;
      case GST_MESSAGE_EOS:
        g_print ("End-Of-Stream reached.\n");
        break;
      default:
         g_printerr ("Unexpected message received.\n");
        break;
    }
    gst_message_unref (msg);
  }

  /* Free resources */
  gst_object_unref (bus);
  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_object_unref (pipeline);
  return 0;

}


when i am running the executable i am getting error in:
gst_element_link_many.
how can i debug this error,whats the issue.
also please point me to the url from where i can install all plugins
for gstreamer-1.0


Regards,
Mayank


More information about the gstreamer-devel mailing list