Use gst_element_get_request_pad() instead of doing it complicated by first getting...
authorSebastian Dröge <sebastian@centricular.com>
Wed, 16 Aug 2017 18:33:17 +0000 (21:33 +0300)
committerSebastian Dröge <sebastian@centricular.com>
Wed, 16 Aug 2017 18:34:15 +0000 (21:34 +0300)
Also use the correct pad template name for tee in the docs so that it
actually works.

examples/tutorials/basic-tutorial-7.c
examples/tutorials/basic-tutorial-8.c
markdown/tutorials/basic/multithreading-and-pad-availability.md
markdown/tutorials/basic/short-cutting-the-pipeline.md

index 6edb3c1..79bd4b7 100644 (file)
@@ -5,7 +5,6 @@ int main(int argc, char *argv[]) {
   GstElement *video_queue, *visual, *video_convert, *video_sink;
   GstBus *bus;
   GstMessage *msg;
-  GstPadTemplate *tee_src_pad_template;
   GstPad *tee_audio_pad, *tee_video_pad;
   GstPad *queue_audio_pad, *queue_video_pad;
 
@@ -49,11 +48,10 @@ int main(int argc, char *argv[]) {
   }
 
   /* Manually link the Tee, which has "Request" pads */
-  tee_src_pad_template = gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (tee), "src_%u");
-  tee_audio_pad = gst_element_request_pad (tee, tee_src_pad_template, NULL, NULL);
+  tee_audio_pad = gst_element_get_request_pad (tee, "src_%u");
   g_print ("Obtained request pad %s for audio branch.\n", gst_pad_get_name (tee_audio_pad));
   queue_audio_pad = gst_element_get_static_pad (audio_queue, "sink");
-  tee_video_pad = gst_element_request_pad (tee, tee_src_pad_template, NULL, NULL);
+  tee_video_pad = gst_element_get_request_pad (tee, "src_%u");
   g_print ("Obtained request pad %s for video branch.\n", gst_pad_get_name (tee_video_pad));
   queue_video_pad = gst_element_get_static_pad (video_queue, "sink");
   if (gst_pad_link (tee_audio_pad, queue_audio_pad) != GST_PAD_LINK_OK ||
index 1ab3bf6..f7649c2 100644 (file)
@@ -118,7 +118,6 @@ static void error_cb (GstBus *bus, GstMessage *msg, CustomData *data) {
 
 int main(int argc, char *argv[]) {
   CustomData data;
-  GstPadTemplate *tee_src_pad_template;
   GstPad *tee_audio_pad, *tee_video_pad, *tee_app_pad;
   GstPad *queue_audio_pad, *queue_video_pad, *queue_app_pad;
   GstAudioInfo info;
@@ -187,14 +186,13 @@ int main(int argc, char *argv[]) {
   }
 
   /* Manually link the Tee, which has "Request" pads */
-  tee_src_pad_template = gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (data.tee), "src_%u");
-  tee_audio_pad = gst_element_request_pad (data.tee, tee_src_pad_template, NULL, NULL);
+  tee_audio_pad = gst_element_get_request_pad (data.tee, "src_%u");
   g_print ("Obtained request pad %s for audio branch.\n", gst_pad_get_name (tee_audio_pad));
   queue_audio_pad = gst_element_get_static_pad (data.audio_queue, "sink");
-  tee_video_pad = gst_element_request_pad (data.tee, tee_src_pad_template, NULL, NULL);
+  tee_video_pad = gst_element_get_request_pad (data.tee, "src_%u");
   g_print ("Obtained request pad %s for video branch.\n", gst_pad_get_name (tee_video_pad));
   queue_video_pad = gst_element_get_static_pad (data.video_queue, "sink");
-  tee_app_pad = gst_element_request_pad (data.tee, tee_src_pad_template, NULL, NULL);
+  tee_app_pad = gst_element_get_request_pad (data.tee, "src_%u");
   g_print ("Obtained request pad %s for app branch.\n", gst_pad_get_name (tee_app_pad));
   queue_app_pad = gst_element_get_static_pad (data.app_queue, "sink");
   if (gst_pad_link (tee_audio_pad, queue_audio_pad) != GST_PAD_LINK_OK ||
index 3b53541..5f5232b 100644 (file)
@@ -92,7 +92,6 @@ int main(int argc, char *argv[]) {
   GstElement *video_queue, *visual, *video_convert, *video_sink;
   GstBus *bus;
   GstMessage *msg;
-  GstPadTemplate *tee_src_pad_template;
   GstPad *tee_audio_pad, *tee_video_pad;
   GstPad *queue_audio_pad, *queue_video_pad;
 
@@ -136,11 +135,10 @@ int main(int argc, char *argv[]) {
   }
 
   /* Manually link the Tee, which has "Request" pads */
-  tee_src_pad_template = gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (tee), "src_%d");
-  tee_audio_pad = gst_element_request_pad (tee, tee_src_pad_template, NULL, NULL);
+  tee_audio_pad = gst_element_get_request_pad (tee, "src_%u");
   g_print ("Obtained request pad %s for audio branch.\n", gst_pad_get_name (tee_audio_pad));
   queue_audio_pad = gst_element_get_static_pad (audio_queue, "sink");
-  tee_video_pad = gst_element_request_pad (tee, tee_src_pad_template, NULL, NULL);
+  tee_video_pad = gst_element_get_request_pad (tee, "src_%u");
   g_print ("Obtained request pad %s for video branch.\n", gst_pad_get_name (tee_video_pad));
   queue_video_pad = gst_element_get_static_pad (video_queue, "sink");
   if (gst_pad_link (tee_audio_pad, queue_audio_pad) != GST_PAD_LINK_OK ||
@@ -257,11 +255,10 @@ comment says).
 
 ``` c
 /* Manually link the Tee, which has "Request" pads */
-tee_src_pad_template = gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (tee), "src_%d");
-tee_audio_pad = gst_element_request_pad (tee, tee_src_pad_template, NULL, NULL);
+tee_audio_pad = gst_element_get_request_pad (tee, "src_%u");
 g_print ("Obtained request pad %s for audio branch.\n", gst_pad_get_name (tee_audio_pad));
 queue_audio_pad = gst_element_get_static_pad (audio_queue, "sink");
-tee_video_pad = gst_element_request_pad (tee, tee_src_pad_template, NULL, NULL);
+tee_video_pad = gst_element_get_request_pad (tee, "src_%u");
 g_print ("Obtained request pad %s for video branch.\n", gst_pad_get_name (tee_video_pad));
 queue_video_pad = gst_element_get_static_pad (video_queue, "sink");
 if (gst_pad_link (tee_audio_pad, queue_audio_pad) != GST_PAD_LINK_OK ||
@@ -276,15 +273,12 @@ gst_object_unref (queue_video_pad);
 
 To link Request Pads, they need to be obtained by “requesting” them to
 the element. An element might be able to produce different kinds of
-Request Pads, so, when requesting them, the desired Pad Template must be
-provided. Pad templates are obtained with
-`gst_element_class_get_pad_template()` and are identified by their name.
+Request Pads, so, when requesting them, the desired Pad Template name must be
+provided.
 In the documentation for the `tee` element we see that it has two pad
-templates named “sink” (for its sink Pads) and “src_%d” (for the Request
-Pads).
-
-Once we have the Pad template, we request two Pads from the tee (for the
-audio and video branches) with `gst_element_request_pad()`.
+templates named “sink” (for its sink Pads) and “src_%u” (for the Request
+Pads). We request two Pads from the tee (for the
+audio and video branches) with `gst_element_get_request_pad()`.
 
 We then obtain the Pads from the downstream elements to which these
 Request Pads need to be linked. These are normal Always Pads, so we
@@ -320,7 +314,7 @@ it still needs to be unreferenced (freed) with `gst_object_unref()`.
     `queue` elements.
 
   - What is a Request Pad and how to link elements with request pads,
-    with `gst_element_class_get_pad_template()`, `gst_element_request_pad()`, `gst_pad_link()` and
+    with `gst_element_get_request_pad()`, `gst_pad_link()` and
      `gst_element_release_request_pad()`.
 
   - How to have the same stream available in different branches by using
index c40fbb2..3779598 100644 (file)
@@ -210,7 +210,6 @@ static void error_cb (GstBus *bus, GstMessage *msg, CustomData *data) {
 
 int main(int argc, char *argv[]) {
   CustomData data;
-  GstPadTemplate *tee_src_pad_template;
   GstPad *tee_audio_pad, *tee_video_pad, *tee_app_pad;
   GstPad *queue_audio_pad, *queue_video_pad, *queue_app_pad;
   GstAudioInfo info;
@@ -280,14 +279,13 @@ int main(int argc, char *argv[]) {
   }
 
   /* Manually link the Tee, which has "Request" pads */
-  tee_src_pad_template = gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (data.tee), "src_%d");
-  tee_audio_pad = gst_element_request_pad (data.tee, tee_src_pad_template, NULL, NULL);
+  tee_audio_pad = gst_element_get_request_pad (data.tee, "src_%u");
   g_print ("Obtained request pad %s for audio branch.\n", gst_pad_get_name (tee_audio_pad));
   queue_audio_pad = gst_element_get_static_pad (data.audio_queue, "sink");
-  tee_video_pad = gst_element_request_pad (data.tee, tee_src_pad_template, NULL, NULL);
+  tee_video_pad = gst_element_get_request_pad (data.tee, "src_%u");
   g_print ("Obtained request pad %s for video branch.\n", gst_pad_get_name (tee_video_pad));
   queue_video_pad = gst_element_get_static_pad (data.video_queue, "sink");
-  tee_app_pad = gst_element_request_pad (data.tee, tee_src_pad_template, NULL, NULL);
+  tee_app_pad = gst_element_get_request_pad (data.tee, "src_%u");
   g_print ("Obtained request pad %s for app branch.\n", gst_pad_get_name (tee_app_pad));
   queue_app_pad = gst_element_get_static_pad (data.app_queue, "sink");
   if (gst_pad_link (tee_audio_pad, queue_audio_pad) != GST_PAD_LINK_OK ||