Gstreamer:动态添加管道中的一个元素时,“src”元素任务将进入暂停状态

Gstreamer:动态添加管道中的一个元素时,“src”元素任务将进入暂停状态,gstreamer,v4l2,python-gstreamer,Gstreamer,V4l2,Python Gstreamer,我有以下管道: v4l2src -> queue -> h264parse -> avdec_h264 -> identity -> imagefreeze(added/removed dynamically) -> glupload -> glcolorconvert -> gltransformation -> glimagesink 我在元素标识srcpad上添加了一个探针。 根据用户输入,我动态添加或删除元素imagefreeze

我有以下管道:

v4l2src -> queue -> h264parse -> avdec_h264 -> identity ->
imagefreeze(added/removed dynamically) -> glupload -> glcolorconvert ->
gltransformation -> glimagesink
我在元素标识srcpad上添加了一个探针。 根据用户输入,我动态添加或删除元素imagefreeze 以下是伪代码:

#show live video on rendering window till no user input
#if user_input == 1:
  insert_imagefreeze  #analogous to image being displayed on rendering window
#if user_input == 2:
  delete_imagefreeze  #resume back showing live video as before
插入imagefreeze没有问题,它工作正常。我可以通过图像冻结观察到我想要的结果 但是,添加元素imagefreeze后,元素v4l2src任务将进入暂停状态。以下是信息日志:

0:03:39.608226968 [333m29510[00m      0x1561c00 [36mINFO   [00m [00m             v4l2src gstv4l2src.c:949:gst_v4l2src_create:<source>[00m sync to 0:03:39.066664476 out ts 0:03:39.375180156
0:03:39.608449406 [333m29510[00m      0x1561c00 [36mINFO   [00m [00m             basesrc gstbasesrc.c:2965:gst_base_src_loop:<source>[00m pausing after gst_pad_push() = eos
0:03:39.608561724 [333m29510[00m      0x1561c00 [36mINFO   [00m [00m                task gsttask.c:316:gst_task_func:<source:src>[00m Task going to paused.
函数check_和_linksrcpad,sinkpad和check_和_unlinksrcpad,sinkpad只检查src和sink pad,然后相应地链接和取消链接

动态添加imagefreeze时,接收器发送EOS事件。这会使管道进入暂停状态。然而,接收器接收EOS事件的原因仍不清楚,需要进一步调查。提供了更多关于观察结果的信息

def add_delete(self):
   if ui_input_cnt = 1  #updated based on user input
        self.idsrcpad = self.identity.get_static_pad("src")
        self.in_idle_probe = False
        self.probeID = self.idsrcpad.add_probe(Gst.PadProbeType.IDLE,self.lengthen_pipeline)

   if ui_input_cnt = 2        
        self.probeID2 = self.idsrcpad.add_probe(Gst.PadProbeType.IDLE,self.shorten_pipeline)

def lengthen_pipeline(self,pad,info):
    print("entered callback")
    global pipeline

    #restrict only 1 call to this callback 
    if self.in_idle_probe == True:
        print("callback for now restricted to one call per thread")
        return Gst.PadProbeReturn.OK

    if  self.in_idle_probe == False:
        self.in_idle_probe == True

    #create image freze element
    self.ifreeze = Gst.ElementFactory.make("imagefreeze","ifreeze")
    # increment reference
    self.ifreeze.ref()
    #add imagefreze to pipeline
    pipeline.add(self.ifreeze)
    #sync image freeze state to main pipeline
    self.ifreeze.sync_state_with_parent()

    #unlink identity and upload

    #1.get sink pad of upload and srcpad of identity
    sinkpad = self.upload.get_static_pad("sink")
    srcpad = self.identity.get_static_pad("src")
    print("unlinking identit srcpad - uplaod sinkpad")
    if self.check_and_unlink(srcpad,sinkpad):
        #2.get sink pad of imagefreeze
        sinkpad = self.ifreeze.get_static_pad("sink")

        #3. link identity src pad to image freeze sinkpad
        print("linking identity srcpad - ifreeze sinkpad")
        self.check_and_link(srcpad,sinkpad)

        #4. link imagefreeze src pad to upload sink pad
        #get image freeze srcpad and sinkpad of upload
        srcpad = self.ifreeze.get_static_pad("src")
        sinkpad = self.upload.get_static_pad("sink")
        print("linking ifreeze srcpad - upload sinkpad")
        if self.check_and_link(srcpad,sinkpad):
            return Gst.PadProbeReturn.REMOVE
    else:
        print("ERORR : unlinking")
    return -1