basic-tutorial-3: Use gst_pad_get_current_caps() instead of gst_pad_query_caps()
authorSebastian Dröge <sebastian@centricular.com>
Thu, 14 Sep 2017 10:38:22 +0000 (13:38 +0300)
committerSebastian Dröge <sebastian@centricular.com>
Thu, 14 Sep 2017 10:39:05 +0000 (13:39 +0300)
We're interested in the currently negotiated caps, not all the caps the
pad can potentially output. Also update the text accordingly.

examples/tutorials/basic-tutorial-3.c
markdown/tutorials/basic/dynamic-pipelines.md

index a892224..10aacda 100644 (file)
@@ -123,7 +123,7 @@ static void pad_added_handler (GstElement *src, GstPad *new_pad, CustomData *dat
   }
 
   /* Check the new pad's type */
-  new_pad_caps = gst_pad_query_caps (new_pad, NULL);
+  new_pad_caps = gst_pad_get_current_caps (new_pad);
   new_pad_struct = gst_caps_get_structure (new_pad_caps, 0);
   new_pad_type = gst_structure_get_name (new_pad_struct);
   if (!g_str_has_prefix (new_pad_type, "audio/x-raw")) {
index f2f94aa..b3ef9e0 100644 (file)
@@ -211,7 +211,7 @@ static void pad_added_handler (GstElement *src, GstPad *new_pad, CustomData *dat
   }
 
   /* Check the new pad's type */
-  new_pad_caps = gst_pad_query_caps (new_pad, NULL);
+  new_pad_caps = gst_pad_get_current_caps (new_pad);
   new_pad_struct = gst_caps_get_structure (new_pad_caps, 0);
   new_pad_type = gst_structure_get_name (new_pad_struct);
   if (!g_str_has_prefix (new_pad_type, "audio/x-raw")) {
@@ -390,7 +390,7 @@ trying to link to a new pad once we are already linked.
 
 ``` c
 /* Check the new pad's type */
-new_pad_caps = gst_pad_query_caps (new_pad, NULL);
+new_pad_caps = gst_pad_get_current_caps (new_pad, NULL);
 new_pad_struct = gst_caps_get_structure (new_pad_caps, 0);
 new_pad_type = gst_structure_get_name (new_pad_struct);
 if (!g_str_has_prefix (new_pad_type, "audio/x-raw")) {
@@ -405,10 +405,14 @@ previously created a piece of pipeline which deals with audio (an
 `audioconvert` linked with an `autoaudiosink`), and we will not be able
 to link it to a pad producing video, for example.
 
-`gst_pad_query_caps()` retrieves the *capabilities* of the pad (this is,
-the kind of data it supports), wrapped in a `GstCaps` structure. A pad
-can offer many capabilities, and hence `GstCaps` can contain many
-`GstStructure`, each representing a different capability.
+`gst_pad_get_current_caps()` retrieves the current *capabilities* of the pad
+(that is, the kind of data it currently outputs), wrapped in a `GstCaps`
+structure. All possible caps a pad can support can be queried with
+`gst_pad_query_caps()`. A pad can offer many capabilities, and hence `GstCaps`
+can contain many `GstStructure`, each representing a different capability. The
+current caps on a pad will always have a single `GstStructure` and represent a
+single media format, or if there are no current caps yet `NULL` will be
+returned.
 
 Since, in this case, we know that the pad we want only had one
 capability (audio), we retrieve the first `GstStructure` with