如何在 Python 中获取 GstBuffer 标志

How to get GstBuffer flags in Python

在 GStreamer C API 中,我们可以使用 GST_BUFFER_FLAG_IS_SET 宏来检查 GstBuffer 标志。这似乎在 Python 绑定中不可用。如何在 Python 中访问这些标志?

我正在使用 Python GObject Introspection 库。 GStreamer 版本为 1.8.3.

https://lazka.github.io/pgi-docs/Gst-1.0/classes/Buffer.html#Gst.Buffer.has_flags

 has_flags(flags)
    Parameters: flags (Gst.BufferFlags)
    Return type:    bool

一个例子:

import gi

gi.require_version('Gst', '1.0')

from gi.repository import Gst

Gst.init(None)

buf = Gst.Buffer.new()
res = buf.has_flags(Gst.BufferFlags.LAST)

print(res)
$ python3 gst.py 
False

!正如评论中所指出的,这个符号是在 GStreamer 1.10 中引入的!