Yuan Yijun (bbbush) wrote,
Yuan Yijun
bbbush

GstAdapter

GStreamer-0.8 有 GstByteStream
GStreamer-0.10 变成了 GstAdapter

GstByteStream 的用法

In the above example, you'll notice how bytestream handles buffering of data for you. The result is that you can handle the same data multiple times. Event handling in bytestream is currently sort of wacky, but it works quite well. The one big disadvantage of bytestream is that it requires the element to be loop-based. Long-term, we hope to have a chain-based usable version of bytestream, too.


GstAdapter 文档提到:

This class is for elements that receive buffers in an undesired size. While for example raw video contains one image per buffer, the same is not true for a lot of other formats, especially those that come directly from a file. So if you have undefined buffer sizes and require a specific size, this object is for you.

An adapter is created with gst_adapter_new(). It can be freed again with g_object_unref().

The theory of operation is like this: All buffers received are put into the adapter using gst_adapter_push() and the data is then read back in chunks of the desired size using gst_adapter_peek(). After the data is processed, it is freed using gst_adapter_flush().

For example, a sink pad's chain function that needs to pass data to a library in 512-byte chunks could be implemented like this:


觉得 Gstreamer 的文档写得真不错,连我都能看懂 :D 并且,重构也是出神入化的。


update:
为什么后面的文档都统统看不懂了捏
Tags: linux, 转载
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments