Python-gst -> 列出元素的所有属性

Python-gst -> List All Properties of an Element

是否可以获取元素具有的所有元素属性? 我可以列出元素但我不知道(也是在阅读文档之后) 我如何访问这些属性。

from gi.repository import Gst
Gst.init()
reg = Gst.Registry.get()

for x in reg.get_plugin_list():
     print x.get_name(), x.get_version()

目标是将属性和元素信息转换为 json 格式,例如:

{
    "name": <plugin-name>,
    "version": <plugin-version>
    "properties": {
        "<property-key>": {
            "desc": <propertie-desc>,
            "value": <propertie-value>,
            "data-type": <propertie-type>,
         }
     }
}

谢谢大家

您要查找的函数是 g_object_class_list_properties(),它将为您提供每个元素支持的属性列表。例如

import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst, GObject
Gst.init([])
e = Gst.ElementFactory.make("identity", None)
e.list_properties()
[<GParamString 'name'>, <GParamObject 'parent'>, <GParamBoolean 'qos'>, <GParamUInt 'sleep-time'>, <GParamInt 'error-after'>, <GParamFloat 'drop-probability'>, <GParamFlags 'drop-buffer-flags'>, <GParamInt 'datarate'>, <GParamBoolean 'silent'>, <GParamBoolean 'single-segment'>, <GParamString 'last-message'>, <GParamBoolean 'dump'>, <GParamBoolean 'sync'>, <GParamInt64 'ts-offset'>, <GParamBoolean 'check-imperfect-timestamp'>, <GParamBoolean 'check-imperfect-offset'>, <GParamBoolean 'signal-handoffs'>]

这也是gst-inspect-1.0所做的。参见 the code