How to investigate gst_element_link_many() funcion's error?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to investigate gst_element_link_many() funcion's error?

박민호
  I don't know how to fix link confirmation error.   Thank you for any reply in advance.

1.  Following commands is working well.
$gst-launch-1.0 -v rtspsrc location=rtsp://admin:1q2w3e4r@192.168.0.18/TANK/media.smp !  rtpmp4vdepay ! decodebin ! autovideosink

2. I modified the sample code as followings but It doesn't work. The error was is 118,119 line number.

** (ex1:30254): WARNING **: Linking part (B) Fail...

  1 //Display RTSP streaming of video
  2  //(c) 2011 enthusiasticgeek
  3  // This code is distributed in the hope that it will be useful,
  4  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  5  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
  6 
  7 #include <string.h>
  8 #include <math.h>
  9 #include <gst/gst.h>
 10 #include <glib.h>
 11 
 12 static gboolean bus_call (GstBus *bus,GstMessage *msg, gpointer data){
 13   GMainLoop *loop = (GMainLoop *) data;
 14 
 15   switch (GST_MESSAGE_TYPE (msg)) {
 16 
 17     case GST_MESSAGE_EOS:
 18       g_printerr ("Stream Ends\n");
 19       g_main_loop_quit (loop);
 20       break;
 21 
 22     case GST_MESSAGE_ERROR: {
 23       gchar  *debug;
 24       GError *error;
 25 
 26       gst_message_parse_error (msg, &error, &debug);
 27       g_free (debug);
 28 
 29       g_printerr ("Error: %s\n", error->message);
 30       g_error_free (error);
 31 
 32       g_main_loop_quit (loop);
 33       break;
 34     }
 35     default:
 36       break;
 37   }
 38 
 39   return TRUE;
 40 }
 41 
 42 static void on_pad_added (GstElement *element, GstPad *pad, gpointer data){
 43 
 44   GstPad *sinkpad;
 45   GstElement *decoder = (GstElement *) data;
 46 
 47   /* We can now link this pad with the rtsp-decoder sink pad */
 48   g_print ("Dynamic pad created, linking source/demuxer\n");
 49 
 50   sinkpad = gst_element_get_static_pad (decoder, "sink");
 51 
 52   gst_pad_link (pad, sinkpad);
 53 
 54   gst_object_unref (sinkpad);
 55 }
 56 
 57 int main (int argc, char *argv[])
 58 {
 59   GMainLoop *loop;
 60   GstBus *bus;
 61   GstElement *source;
 62   GstElement *decoder;
 63   GstElement *sink;
 64   GstElement *pipeline;
 65   GstElement *demux;
 66   GstElement *colorspace;
 67 
 68   /* Initializing GStreamer */
 69   gst_init (&argc, &argv);
 70   loop = g_main_loop_new (NULL, FALSE);
 71 
 72  //gst-launch-0.10 rtspsrc location=rtsp://<ip> ! decodebin ! ffmpegcolorspace ! autovideosink
 73  //gst-launch -v rtspsrc location="rtsp://<ip> ! rtpmp4vdepay ! mpeg4videoparse ! ffdec_mpeg4 ! ffmpe    gcolorspace! autovideosink
 74  //gst-launch -v rtspsrc location="rtsp://<ip> ! rtpmp4vdepay ! ffdec_mpeg4 ! ffmpegcolorspace! autov    ideosink
 75 
 76   /* Create Pipe's Elements */
 77   pipeline = gst_pipeline_new ("video player");
 78   g_assert (pipeline);
 79   source   = gst_element_factory_make ("rtspsrc", "Source");
 80   g_assert (source);
 81 
 82   demux = gst_element_factory_make ("rtpmp4vdepay", "Depay");
 83   g_assert (demux);
 84   decoder = gst_element_factory_make ("decodebin", "Decoder");
 85   g_assert (decoder);
 86 
 87   sink     = gst_element_factory_make ("autovideosink", "Output");
 88   g_assert (sink);
 89 
 90   /*Make sure: Every elements was created ok*/
 91   if (!pipeline || !source || !demux || !decoder || !sink) {
 92     g_printerr ("One of the elements wasn't create... Exiting\n");
 93     return -1;
 94   }
 95 
 96   if (!pipeline || !source ) {
 97     g_printerr ("One of the elements wasn't create... Exiting\n");
 98     return -1;
 99   }
100 
101   g_printerr(" \nPipeline is Part(A) ->(dynamic/runtime link)  Part(B)[ Part(B-1) -> Part(B-2) -> Par    t(B-3) ]\n\n");
102   g_printerr(" [source](dynamic)->(dynamic)[demux]->[decoder]->[colorspace]->[videosink] \n\n");
103 
104   /* Set video Source */
105   g_printerr(" argv[1]=%s \n", argv[1]);
106   g_object_set (G_OBJECT (source), "location", argv[1], NULL);
107 
108 
109   /* Putting a Message handler */
110   bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
111   gst_bus_add_watch (bus, bus_call, loop);
112   gst_object_unref (bus);
113 
114   /* Add Elements to the Bin */
115   gst_bin_add_many (GST_BIN (pipeline), demux, decoder, sink, NULL);
116 
117   /* Link confirmation */
118   if (gst_element_link_many (  demux, decoder,  sink, NULL)!=TRUE){
119       g_warning ("Linking part (B) Fail...");
120   }
121 
122 
123 
124   g_printerr("\nNote that the source will be linked to the demuxer(depayload) dynamically.\n\
125      The reason is that rtspsrc may contain various elements (for example\n\
126      audio and video). The source pad(s) will be created at run time,\n\
127      by the rtspsrc when it detects the amount and nature of elements.\n\
128      Therefore we connect a callback function which will be executed\n\
129      when the \"pad-added\" is emitted.\n");
130 
131   /* Dynamic Pad Creation */
132   if(! g_signal_connect (source, "pad-added", G_CALLBACK (on_pad_added),demux))
133   {
134     g_warning ("Linking part (A) with part (B) Fail... g_sinal_connect");
135 
136   }
137   /* Run the pipeline */
138   g_print ("Playing: %s\n", argv[1]);
139   gst_element_set_state (pipeline, GST_STATE_PLAYING);
140   g_main_loop_run (loop);
141 
142   /* Ending Playback */
143   g_print ("End of the Streaming... ending the playback\n");
144   gst_element_set_state (pipeline, GST_STATE_NULL);
145 
146   /* Eliminating Pipeline */
147   g_print ("Eliminating Pipeline\n");
148   gst_object_unref (GST_OBJECT (pipeline));
149 
150   return 0;
151 }
        -Its over-


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to investigate gst_element_link_many() funcion's error?

Sebastian Dröge-3
On Mon, 2017-06-12 at 13:44 +0900, Fred wrote:

>   I don't know how to fix link confirmation error.   Thank you for
> any reply in advance.
>
> 1.  Following commands is working well.
> $gst-launch-1.0 -v rtspsrc
> location=rtsp://admin:1q2w3e4r@192.168.0.18/TANK/media.smp !
>  rtpmp4vdepay ! decodebin ! autovideosink
>
> 2. I modified the sample code as followings but It doesn't work. The
> error was is 118,119 line number.
> [...]
> 118   if (gst_element_link_many (  demux, decoder,  sink,
> NULL)!=TRUE){
decodebin ("decoder") is adding source pads when the contained streams
are known. You have to connect to its "pad-added" signal and from there
get notified when pads (and which) are added, and continue linking from
there.

Check the manual chapter about dynamic pads for details.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (981 bytes) Download Attachment