From 020bf14d03f01e48836d8c13e186e488755d5527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 14 Sep 2017 13:38:22 +0300 Subject: [PATCH] basic-tutorial-3: Use gst_pad_get_current_caps() instead of gst_pad_query_caps() 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 | 2 +- markdown/tutorials/basic/dynamic-pipelines.md | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/examples/tutorials/basic-tutorial-3.c b/examples/tutorials/basic-tutorial-3.c index a892224e96..10aacda053 100644 --- a/examples/tutorials/basic-tutorial-3.c +++ b/examples/tutorials/basic-tutorial-3.c @@ -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")) { diff --git a/markdown/tutorials/basic/dynamic-pipelines.md b/markdown/tutorials/basic/dynamic-pipelines.md index f2f94aa070..b3ef9e0877 100644 --- a/markdown/tutorials/basic/dynamic-pipelines.md +++ b/markdown/tutorials/basic/dynamic-pipelines.md @@ -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