Skip to content

Inspecting GStreamer Pad Capabilities

How to query and reason about pad capabilities while building or debugging a pipeline.

This English edition preserves the original commands, configuration fragments, and diagrams so the steps can be reproduced directly.

Reference diagram 1

Reference diagram 2

Commands and configuration

gst-inspect-1.0 <GstElement>
// 确保连接正确的 pad
ret = gst_element_link(videoconvert, gamma);
if (!ret) {
    GST_ERROR_OBJECT(vsb, "Failed to link videoconvert to gamma");
}
#include <gst/gst.h>

GstPad *src_pad_vc, *sink_pad_gamma;
GstCaps *caps_vc, *caps_gamma;

// 获取 videoconvert 的输出 pad(src)
src_pad_vc = gst_element_get_static_pad(videoconvert, "src");
if (!src_pad_vc) {
    GST_ERROR("Failed to get src pad from videoconvert");
    return;
}

// 获取 gamma 的输入 pad(sink)
sink_pad_gamma = gst_element_get_static_pad(gamma, "sink");
if (!sink_pad_gamma) {
    GST_ERROR("Failed to get sink pad from gamma");
    gst_object_unref(src_pad_vc);
    return;
}

// 查询 caps
caps_vc = gst_pad_query_caps(src_pad_vc, NULL);  // 不过滤,获取所有可能的格式
caps_gamma = gst_pad_query_caps(sink_pad_gamma, NULL);  // 不过滤,获取所有可能的格式

// 打印 capabilities 信息
GST_INFO("videoconvert src pad capabilities: %s", gst_caps_to_string(caps_vc));
GST_INFO("gamma sink pad capabilities: %s", gst_caps_to_string(caps_gamma));

// 确保 capabilities 能够兼容,如果需要的话可以对这些 caps 进行进一步处理
// 比如,如果发现不匹配,可以使用 gst_element_link_filtered 来强制链接

// 清理
gst_caps_unref(caps_vc);
gst_caps_unref(caps_gamma);
gst_object_unref(src_pad_vc);
gst_object_unref(sink_pad_gamma);

Notes

Use these examples as a starting point and adjust versions, device names, codecs, and network addresses for the target platform.