Gstreamer-element-queue/queue2/multiqueue

GStreamer的queue插件功能及代码分析 阅读详情

相关连接:https://blog.youkuaiyun.com/knowledgebao/article/details/84621238


queue/queue2/multiqueue

queue:

queue只有一个src pad和一个sink pad,会在src pad上创建一个线程,减少src和sink的关联。queue有三个限制参数buffers、bytes、time(单位纳秒ns)。有最大阀值和最小阀值供6个参数。最大默认值:200 buffers、10MB、one second,最小默认值都是0.

当三个限制参数某一个达到最大值的时候,会阻塞上游的链路传输(可以通过设置属性 “leaky” property 来处理阻塞情况,分为上游丢弃或下游丢弃或不丢弃阻塞)。“overrun” signal会被发送,当数据达到最高阀值的时候,“underrun” signal 会被发送,当数据达到最低阀值的时候。

 “current-level-buffers” property可以获取当前buffers的个数。notify::current-level-buffers signal 可以监听buffers的变动。bytes和time也有类似的属性和信号。

queue2:

和queue的区别如下:

  1. 默认值不同:最大值:100 buffers, 2MB,  two seconds,最小值默认都是0.
  2. 增加了temp-template属性比如:/tmp/gstreamer-XXXXXX,设置此属性后,数据会被保存到文件中,具体文件名可以通过属性temp-location获取。
  3. 一些属性发生了变化,比如:只有“overrun” 信号,增加循环buf,增加GST_MESSAGE_BUFFERING消息等

multiqueue:

和queue的区别如下:

  1. src pad和sink pad由1个变成了多个。When requesting a given sinkpad with gst_element_request_pad(), the associated srcpad for that stream will be created. 如果stream超过一个,对应的queue也会增长,保证不会饿死。
  2. 当src pad没有下游连接的时候,sink pad的内容也会发给src pad。sink pad和src pad总是成对出现,创建sink pad的时候回同步创建src pad。当src pad和下游处于unlink的时候,buffers和envet由sink pad发送给src pad的时候必须按照先后顺序发送。针对这样情况有一个属性“sync-by-running-time”,当此属性设置为true时,非link的stream也会参考link的stream的runing time来同步。
  3. 默认值不同:最大值:5 buffers, 10MB,  two second ,最小值默认都是0.
  4. The “underrun” signal is emitted when all of the queues are empty. The “overrun” signal is emitted when one of the queues is filled. 
  5. 当有多个src pad的时候,对应多个线程,类似于多个queue,其中max-size-buffers等也有多份,只不过都相同而已。

 

queue:内存单队列

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── GstObject
            ╰── GstElement
                ╰── GstQueue

Properties

guintcurrent-level-buffersRead当前队列中buffers大小
guintcurrent-level-bytesRead当前队列中bytes大小
guint64current-level-timeRead当前队列中包含数据time大小,单位ns
gbooleanflush-on-eosRead / Write是否支持eos events处理。
GstQueueLeakyleakyRead / Writequeue满时的处理策略。阻塞,扔新数据,扔旧数据
guintmax-size-buffersRead / Writequeue中允许的最大buffers
guintmax-size-bytesRead / Writequeue中允许的最大bytes
guint64max-size-timeRead / Writequeue中允许的最大time,单位ns
guintmin-threshold-buffersRead / Writequeue中允许发送的最小buffers
guintmin-threshold-bytesRead / Writequeue中允许发送的最小bytes
guint64min-threshold-timeRead / Writequeue中允许发送的最小time
gbooleansilentRead / Write是否支持发送信号,默认为FALSE

Signals

voidoverrunRun Firstqueue满时发送的信号,silent必须为TRUE(下同)
voidpushingRun Firstqueue由空闲变为有数据时发送的信号。
voidrunningRun First当queue阻塞且由满变为有空闲的时候发送。或pushing满足的时候也发送。
voidunderrunRun Firstqueue三个限制条件都低于给定值时发送的信号

Types and Values

structGstQueueOpaque GstQueue structure.透明结构体,无需了解
enumGstQueueLeaky

GST_QUEUE_NO_LEAK阻塞

GST_QUEUE_LEAK_UPSTREAM丢新数据

GST_QUEUE_LEAK_DOWNSTREAM丢旧数据


Description

Data is queued until one of the limits specified by the “max-size-buffers”, “max-size-bytes” and/or “max-size-time”properties has been reached. Any attempt to push more buffers into the queue will block the pushing thread until more space becomes available.

The queue will create a new thread on the source pad to decouple the processing on sink and source pad.

You can query how many buffers are queued by reading the “current-level-buffers” property. You can track changes by connecting to the notify::current-level-buffers signal (which like all signals will be emitted from the streaming thread). The same applies to the “current-level-time” and “current-level-bytes” properties.

The default queue size limits are 200 buffers, 10MB of data, or one second worth of data, whichever is reached first.

As said earlier, the queue blocks by default when one of the specified maximums (bytes, time, buffers) has been reached. You can set the “leaky” property to specify that instead of blocking it should leak (drop) new or old buffers.

The “underrun” signal is emitted when the queue has less data than the specified minimum thresholds require (by default: when the queue is empty). The “overrun” signal is emitted when the queue is filled up. Both signals are emitted from the context of the streaming thread.

Synopsis

Element Information

plugin

coreelements

author

Erik Walthinsen <omega@cse.ogi.edu>

class

Generic

Element Pads

name

sink

direction

sink

presence

always

details

ANY

name

src

direction

source

presence

always

details

ANY

queue2:文件单队列

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── GstObject
            ╰── GstElement
                ╰── GstQueue2

Properties

guintcurrent-level-buffersRead参考queue
guintcurrent-level-bytesRead参考queue
guint64current-level-timeRead参考queue
ginthigh-percentRead / Write废弃,Deprecated: use high-watermark instead
gintlow-percentRead / Write废弃,Deprecated: use low-watermark instead
guintmax-size-buffersRead / Write参考queue
guintmax-size-bytesRead / Write参考queue
guint64max-size-timeRead / Write参考queue
guint64ring-buffer-max-sizeRead / Write循环buf的最大个数,为0不用循环buf
gchar *temp-locationRead文件名,系统根据temp-template生成
gbooleantemp-removeRead / Write使用完成后,清除临时文件
gchar *temp-templateRead / Write设置生成文件模板,类似:/tmp/gstreamer-XXXXXX
gbooleanuse-bufferingRead / Write是否发送 GST_MESSAGE_BUFFERING消息。
gbooleanuse-rate-estimateRead / WriteEstimate the bitrate of the stream to calculate time level.
gint64avg-in-rateReadThe average input data rate.
gbooleanuse-tags-bitrateRead / WriteUse a bitrate from upstream tags to estimate buffer duration if not provided.
gdoublehigh-watermarkRead / Write触发GST_MESSAGE_BUFFERING消息的上限[0~1],默认0.99
gdoublelow-watermarkRead / Write触发GST_MESSAGE_BUFFERING消息的下限[0~1],默认0.01

Signals

voidoverrunRun First参考queue

Types and Values

structGstQueue2Opaque GstQueue2 structure.透明结构体,无需了解


Description

Data is queued until one of the limits specified by the “max-size-buffers”, “max-size-bytes” and/or “max-size-time”properties has been reached. Any attempt to push more buffers into the queue will block the pushing thread until more space becomes available.

The queue will create a new thread on the source pad to decouple the processing on sink and source pad.

You can query how many buffers are queued by reading the “current-level-buffers” property.

The default queue size limits are 100 buffers, 2MB of data, or two seconds worth of data, whichever is reached first.

If you set temp-template to a value such as /tmp/gstreamer-XXXXXX, the element will allocate a random free filename and buffer data in the file. By using this, it will buffer the entire stream data on the file independently of the queue size limits, they will only be used for buffering statistics.

The temp-location property will be used to notify the application of the allocated filename.

Synopsis

Element Information

plugin

coreelements

author

Erik Walthinsen <omega@cse.ogi.edu>, Wim Taymans <wim.taymans@gmail.com>

class

Generic

Element Pads

name

sink

direction

sink

presence

always

details

ANY

name

src

direction

source

presence

always

details

ANY

multiqueue:内存多队列

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── GstObject
            ╰── GstElement
                ╰── GstMultiQueue

Properties

guintextra-size-buffersRead / Write暂时未实现
guintextra-size-bytesRead / Write暂时未实现
guint64extra-size-timeRead / Write暂时未实现
ginthigh-percentRead / Write类似high-watermark,取值范围[0,100],queue2此值以放弃
gintlow-percentRead / Write类似low-watermark,取值范围[0,100],queue2此值以放弃
guintmax-size-buffersRead / Write参考queue
guintmax-size-bytesRead / Write参考queue
guint64max-size-timeRead / Write参考queue
gbooleansync-by-running-timeRead / Write设置为true时,非link的stream也会参考link的stream的runing time来同步
gbooleanuse-bufferingRead / Write参考queue2
guint64unlinked-cache-timeRead / WriteExtra buffering in time for unlinked streams (if 'sync-by-running-time').Default value: 250000000
gbooleanuse-interleaveRead / WriteAdjust time limits based on input interleave.是否使用interleave.multiqueue: New "use-interleave" property which allows the size of the queues to be optimized based on the input streams interleave. This should only be used with input streams which are properly timestamped. It will be used in the future decodebin3 element.
gdoublehigh-watermarkRead / Write参考queue2
gdoublelow-watermarkRead / Write参考queue2
guint64min-interleave-timeRead / WriteMinimum extra buffering for deinterleaving (size of the queues) when use-interleave=true.

Signals

voidoverrunRun First参考queue,任意一个满都触发
voidunderrunRun First参考queue,所有都不足才触发

Types and Values

structGstMultiQueueOpaque GstMultiQueue structure.透明结构体,无需了解


Description

Multiqueue is similar to a normal GstQueue with the following additional features:

1) Multiple streamhandling

  • The element handles queueing data on more than one stream at once. To achieve such a feature it has request sink pads (sinku) and 'sometimes' src pads (srcu). When requesting a given sinkpad with gst_element_request_pad(), the associated srcpad for that stream will be created. Example: requesting sink1 will generate src1.

2) Non-starvation on multiple stream

  • If more than one stream is used with the element, the streams' queues will be dynamically grown (up to a limit), in order to ensure that no stream is risking data starvation. This guarantees that at any given time there are at least N bytes queued and available for each individual stream. If an EOS event comes through a srcpad, the associated queue will be considered as 'not-empty' in the queue-size-growing algorithm.

3) Non-linked srcpads graceful handling

  • In order to better support dynamic switching between streams, the multiqueue (unlike the current GStreamer queue) continues to push buffers on non-linked pads rather than shutting down. In addition, to prevent a non-linked stream from very quickly consuming all available buffers and thus 'racing ahead' of the other streams, the element must ensure that buffers and inlined events for a non-linked stream are pushed in the same order as they were received, relative to the other streams controlled by the element. This means that a buffer cannot be pushed to a non-linked pad any sooner than buffers in any other stream which were received before it.

Data is queued until one of the limits specified by the “max-size-buffers”, “max-size-bytes” and/or “max-size-time”properties has been reached. Any attempt to push more buffers into the queue will block the pushing thread until more space becomes available. “extra-size-buffers”,

“extra-size-bytes” and “extra-size-time” are currently unused.

The default queue size limits are 5 buffers, 10MB of data, or two second worth of data, whichever is reached first. Note that the number of buffers will dynamically grow depending on the fill level of other queues.

The “underrun” signal is emitted when all of the queues are empty. The “overrun” signal is emitted when one of the queues is filled. Both signals are emitted from the context of the streaming thread.

When using “sync-by-running-time” the unlinked streams will be throttled by the highest running-time of linked streams. This allows further relinking of those unlinked streams without them being in the future (i.e. to achieve gapless playback). When dealing with streams which have got different consumption requirements downstream (ex: video decoders which will consume more buffer (in time) than audio decoders), it is recommended to group streams of the same type by using the pad "group-id" property. This will further throttle streams in time within that group.

Synopsis

Element Information

plugin

coreelements

author

Edward Hervey <edward@fluendo.com>

class

Generic

Element Pads

name

sink_%u

direction

sink

presence

request

details

ANY

name

src_%u

direction

source

presence

sometimes

details

ANY

 

参考资料:

  1. queue
  2. queue2
  3. multiqueue
  4. 源码

有任何问题,请联系:knowledgebao@163.com

QT 音视频开发 基于gstreamer框架 环境: apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0 阅读详情

相关推荐

GStreamer基础教程7:多线程和Pad的有效性

目标 GStreamer会自动处理多线程这部分,但在有些情况下,你需要手动对线程做解耦。本教程会教你怎样才能做到这一点,另外也展示了Pad的有效性。主要内容包括: 如何针对部分的pipeline建立一个新的线程 什么是Pad的有效性 如何复制流 介绍 多线程 GStreamer是一个支持多线程的框架。这就说明,如果有必要它会在内部自动创建/销毁线程。比如:在应用线程中把流解出来。而且,...

ZONGXP的博客 1436

Gstreamer- 多线程(Threads)

多线程 GStreamer 本质上是多线程的,并且是完全线程安全的。大多数线程内部对应用程序是隐藏的,这应该使应用程序开发更容易。但是,在某些情况下,应用程序可能希望影响其中的某些部分。 GStreamer 允许应用程序在pipeline的某些部分强制使用多个线程。请参阅何时要强制使用线程?。 GStreamer 还可以在创建线程时通知您,以便您可以配置要使用的线程优先级或线程池等内容。请参阅在 GStreamer 中配置线程。 GStreamer 中的调度 GStreamer pipeline中的每个el

zk5950886的博客 2658

GStreamer基础教程14:常用的element

目标 本教程给出了一系列开发中常用的element。它们包括大杂烩般的eleemnt(比如playbin2)以及一些调试时很有用的element。 简单来说,下面用gst-launch这个工具给出一个个具体例子(命令行),你可以用-v参数可以看到Pad得Caps是如何协商的。 Bins 这些是Bin element,它们在内部包含其他的element,已经组成了内部的pipeline,但在...

ZONGXP的博客 1868

DeepStream/Gstreamer queue实现预缓存功能

DeepStream/Gstreamer queue实现预缓存功能

qq_41632852的博客 2651

gstreamer开发之--- 常用element

一、bin,这些bin在内部包含了element,但是在外部还是把它看做一个element。 1、playbin:它会处理播放器从source经过解复用、解码到显示的过程,同时它也非常灵活,有很多的设置项。 2、uridecodebin:从一个uri获取数据,然后解码成原始数据。 二、文件输入和输出 1、filesrc:读取一个本地文件然后用caps输出媒体数据 2、filesink:这个element把所有收到的媒体数据存成文件,用location来指定文件名 gst-launch-1.0 audiote

技术联盟 748

Ubuntu 上 1Panel 的安装与高效运维实践

本文详细介绍了在Ubuntu系统上安装和高效运维1Panel面板的完整实践指南。内容涵盖了一键安装、Docker容器可视化部署、计划任务自动化以及网站数据库管理等核心功能,并提供了安全加固、资源监控与数据备份等进阶技巧,旨在帮助用户快速搭建并管理一个强大易用的服务器环境。

weixin_29210759的博客 143

Gstreamer-element-tee

相关连接:https://blog.youkuaiyun.com/knowledgebao/article/details/84621238 Properties GstPad * alloc-pad Read / Write 已弃用DEPRECATED gboolean has-chain Read / Write / Construct If the ele...

knowledgebao的博客 2617

别再手动折腾了!PICO Unity SDK 一键配置开发环境保姆级教程(含PDC串流调试)

本文详细介绍了PICO Unity SDK的一键配置功能,帮助开发者快速搭建VR开发环境。通过自动化配置流程,大幅减少手动设置时间,提升开发效率。文章还涵盖了PDC串流调试技巧和常见问题解决方案,是PICO VR开发的实用指南。

weixin_30335575的博客 450

GStreamer基础教程14——常用的element

本教程给出了一系列开发中常用的element。

sakulafly的专栏 2万+

uniapp 实现RFID识别的实战指南

本文提供了在uniapp中实现RFID识别的完整实战指南。核心在于通过Android系统广播机制,利用uni-app的plus对象调用原生接口,完成与RFID手持设备的“软硬件握手”。文章详细介绍了从环境准备、设备选型、核心代码实现到避坑优化的全流程,帮助开发者快速构建高效的RFID盘点或管理应用。

weixin_29161719的博客 404

SoIC、CoWoS、InFO一次讲透:从2D/2.5D/3D看懂先进封装

先进封装是后摩尔时代提升芯片性能的关键路径,但面对SoIC、CoWoS、InFO这些名词,很多人容易混淆。理解它们,需从最基本的2D、2.5D、3D封装概念入手:2D是传统平房,2.5D通过硅中介层实现高密度互连,3D则让芯片直接堆叠。CoWoS作为2.5D中介层封装,已成为AI芯片与HBM高带宽存储集成的行业标准;SoIC通过铜-铜混合键合实现真正的3D堆叠,为逻辑与缓存提供极致带宽;InFO以扇出型封装兼顾成本与集成度,广泛用于移动SoC。在系统级封装(SiP)和CPO共封装光学等前沿趋势中,这些技术往

weixin_42388898的博客 310

GStreamer基础教程14——惯用的element

GStreamer基础教程14——常用的element 目标       本教程给出了一系列开发中常用的element。它们包括大杂烩般的eleemnt(比如playbin2)以及一些调试时很有用的element。       简单来说,下面用gst-launch这个工具给出一个个具体例子(命令行),你可以用-v参数可以看到Pad得Caps是如何协商的。 Bin

如丧 1193

Chromatix_AEC—深入解析曝光表配置与传感器参数计算

本文深入解析高通Chromatix AEC模块中的曝光表配置与传感器参数计算,详细介绍了自动曝光控制(AEC)的核心概念、首行曝光时间计算、行时间与曝光模式对比、帧率计算逻辑以及曝光表高级配置技巧。通过实战案例展示如何优化传感器参数联调,帮助开发者掌握Chromatix工具在摄像头系统中的关键应用。

266

【GStreamer开发】GStreamer基础教程14——常用的element

目标       本教程给出了一系列开发中常用的element。它们包括大杂烩般的eleemnt(比如playbin2)以及一些调试时很有用的element。       简单来说,下面用gst-launch这个工具给出一个个具体例子(命令行),你可以用-v参数可以看到Pad得Caps是如何协商的。 Bins       这些是Bin element,它们在内部包含其他的eleme

ZhangPY的专栏 1268

openCv +3.4.0 车牌定位(C++版本)

#include <iostream> #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc.hpp> #include "opencv2/shape.hpp" using namespace ...

Bamboo265925的博客 2337

解决开着代理情况下pip或魔搭下载失败

最近由于经常配环境导致,老是要来回切clash关掉代理,非常的不方便如下面的,魔搭模型下载失败如下面的,pip换源后下载失败。

风吹落叶的博客 2949

gstreamer基础教程14-Handy elements

索引:https://blog.youkuaiyun.com/knowledgebao/article/details/84621238 Goal 这篇教程主要是介绍gstreamer提供的各种element工具,从复杂的playbin到简单的帮助调试element,非常有必要学会这些工具。为了方便我们使用gst-launch-1.0来演示这些工具。如果你想看pad谈判过程,可以使用-v参数查看。 Th...

knowledgebao的博客 899

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

GstQueue2 知识文档

queue2是queue的"重量级"升级版,同属 coreelements 插件。名字里的 “2” 不代表它取代queue——两者定位不同,长期共存。相比queuequeue2能力说明Buffering 消息按低/高水位线向应用发送(带百分比),驱动播放器"缓冲中…"进度条与自动暂停/恢复本地缓存(temp-file / ring-buffer)可把数据落到磁盘临时文件或内存环形缓冲,缓冲容量远超内存 FIFO,支持 download buffering 与 timeshiftPull 模式 / 随机读。

我的博客 215

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

playbin3源码分析

playbin3基于decodebin3,通过GstStreamCollection机制实现流的精准控制。其核心流程包括:通过stream-collection消息收集所有可用流(音频、视频、字幕),并以唯一ID标识;应用通过发送GST_EVENT_SELECT_STREAMS事件选择目标流,实现多轨道灵活切换。init函数创建uridecodebin3与playsink元件,通过pad-added等信号动态链接上游源。decodebin3采用multiqueue作为核心组件,支持原子化切换,复用解码器,确

我的博客 232

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

GStreamer 简明教程(六):利用 Tee 复制流数据,巧用 Queue 实现多线程

本章基于官方教程进行说明和补充。本章内容并不复杂,引入了两个新的 Element:Tee 和 Queue。Tee 用于复制数据, Queue 创建线程让 Pipeline 的一部分在另外线程中运行。由于官方教程在本人机器上总是无法运行,我对它做了一些修改,具体代码在。

记录学习的过程 2382
上一篇: Gstreamer-GstEvent
下一篇: Gstreamer-element-tee
knowledgebao
博客等级 码龄15年 401粉丝 198原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值