【问题标题】:Gstreamer : 'src' element task going to PAUSE state when one of the elements in pipeline is added dynamicallyGstreamer:当动态添加管道中的元素之一时,“src”元素任务进入暂停状态
【发布时间】:2018-09-24 17:12:13
【问题描述】:

我有以下管道:

v4l2src -> queue -> h264parse -> avdec_h264 -> identity ->
imagefreeze(added/removed dynamically) -> glupload -> glcolorconvert ->
gltransformation -> glimagesink
  1. 我在元素identitysrcpad 上添加了一个探针。
  2. 根据用户输入,我动态添加或删除元素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
  1. 插入imagefreeze 没问题,它工作正常。我可以通过imagefreeze 观察到我想要的结果
  2. 但是,在添加元素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.
    

谁能解释一下,为什么一旦将新元素添加到管道中,管道的源元素就会进入暂停状态。

以及来自实际代码的 sn-ps:

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

函数check_and_link(srcpad,sinkpad)check_and_unlink(srcpad,sinkpad) 仅检查srcsink 焊盘,然后相应地链接和取消链接。

【问题讨论】:

    标签: gstreamer v4l2 python-gstreamer


    【解决方案1】:

    当动态添加图像冻结时,接收器发送EOS 事件。这使得管道进入PAUSED 状态。但是,sink 为什么会收到EOS 事件仍不清楚,需要进一步调查。更多观察信息请见here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-10
      • 2012-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-27
      相关资源
      最近更新 更多