GstAppSink简介
Description
Appsink is a sink plugin that supports many different methods for making the application get a handle on the GStreamer data in a pipeline. Unlike most GStreamer elements, Appsink provides external API functions.appsink can be used by linking to the gstappsink.h header file to access the methods or by using the appsink action signals and properties.
AppsInk是一个槽插件,它提供了多种供应用程序处理GStreamer管道数据流的方法。不同于大多数的GStreamer元件。Appsink提供额外的API函数。添加gstappsink.h头文件后获取appsink的方法(函数)或者使用appsink的响应信号和属性。
The normal way of retrieving samples from appsink is by using the gst_app_sink_pull_sample()
and gst_app_sink_pull_preroll()
methods. These methods block until a sample becomes available in the sink or when the sink is shut down or reaches EOS.There are also timed variants of these methods, gst_app_sink_try_pull_sample()
and gst_app_sink_try_pull_preroll()
, which accept a timeout parameter to limit the amount of time to wait.
常用的从appsink获取采样数据的方法是使用gst_app_sink_pull_sample函数和gst_app_sink_pull_preroll函数。这两个函数都是阻塞的,直到在槽中可获取到一个采样数据或者当槽被关闭或者结束信号到来。这两个方法也都有时间上的变体函数,gst_app_sink_try_pull_sample函数和gst_app_sink_pull_preroll函数,这两个函数接受一个超时参数来限制函数等待时间。
Appsink will internally use a queue to collect buffers from the streaming thread. If the application is not pulling samples fast enough, this queue will consume a lot of memory over time. The "max-buffers" property can be used to limit the queue size. The "drop" property controls whether the streaming thread blocks or if older buffers are dropped when the maximum queue size is reached. Note that blocking the streaming thread can negatively affect real-time performance and should be avoided.
Appsink将在内部使用一个队列来收集从流线程中获取的缓存。如果应用程序没有足够快的拉取(pull)采样数据,随着时间消逝,这个队列将消耗大量的内存。Appsink的max-buffers属性可以用来限制内部队列的大小。AppSink的drop属性控制当流线程阻塞、缓存到达了队列最大个数之后是否掉先前的缓存数据。注意,阻塞流线程将对实时性能有负面影响,应当避免。
If a blocking behaviour is not desirable, setting the "emit-signals" property to TRUE
will make appsink emit the "new-sample" and "new-preroll" signals when a sample can be pulled without blocking.The "caps" property on appsink can be used to control the formats that appsink can receive. This property can contain non-fixed caps, the format of the pulled samples can be obtained by getting the sample caps.
如果阻塞式行为不可取,那么设置Appsink的emit-signals属性为TRUE,让appsink在采样数据可以被非阻塞式拉取的时候发送“new-sample”信号和“new-preroll”信号。Appsink的caps属性可以用来控制appsink能够接收的缓存数据格式。该数据可以包含不固定的caps,拉取采样数据的格式可以通过获取采样caps获知。
If one of the pull-preroll or pull-sample methods return NULL
, the appsink is stopped or in the EOS state. You can check for the EOS state with the "eos" property or with the gst_app_sink_is_eos()
method.The eos signal can also be used to be informed when the EOS state is reached to avoid polling.
如果pull-preroll方法或者pull-sample方法返回NULL,那么appsink被停止了或者处于EOS(结束)状态。可以通过Appsink的eos属性或者gst_app_sink_is_eos函数来检查Appsink是否处于EOS状态。eos信号也可以用来通知应用程序避免拉取数据,当Appsink到达了EOS状态。