PythonGStreamer:使用固定参数访问回调函数中的类成员

2024-10-03 15:34:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个回调,它是由GStreamer Python绑定提供的,它接受固定数量的参数。下面是API:add_probe 我从类函数内部调用这个函数。以下是比苏多代码:

class Example:
   def __init__(self):
        thread = threading.Thread(target=self.run)
        thread.start()

   def run(self):
        #if external event
        self.idsrcpad = identity.get_static_pad("src")  #get source pad 
        self.idsrcpad.add_probe(Gst.PadProbeType.IDLE,self.modify_pipeline)


   def modify_pipeline(pad,info,self):
        #access self.idsrcpad
        self.idsrcpad.unlink(...)

访问self.idsrcpad,会出现一个错误,说明idsrcpad不是self的成员。你知道吗

下面的question解决了一个类似的问题,但是问题中的回调函数没有固定数量的参数。在我的例子中,回调函数的参数是固定的。下面是对add_probe函数更详细的描述。你知道吗

有人能告诉我我做错了什么吗。你知道吗


Tags: 函数runselfadd参数get数量pipeline