0

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

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>,
         }
     }
}

感谢你们

4

1 回答 1

0

您正在寻找的功能是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做的。见代码

于 2017-12-14T01:24:19.317 回答