diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2017-09-14 13:38:22 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2017-09-14 13:39:05 +0300 |
commit | 020bf14d03f01e48836d8c13e186e488755d5527 (patch) | |
tree | a68809eecd40bf757d35da7467755604532a8525 | |
parent | dbf7d255dc3dab9f8d6e50bffbe2e228f9b64d6a (diff) |
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.
-rw-r--r-- | examples/tutorials/basic-tutorial-3.c | 2 | ||||
-rw-r--r-- | 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 a892224..10aacda 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 f2f94aa..b3ef9e0 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 |