码迷,mamicode.com
首页 > 其他好文 > 详细

[gstreamer] porting from 0.10 to 1.0 knew how

时间:2016-05-12 17:21:07      阅读:429      评论:0      收藏:0      [点我收藏+]

标签:

The changes:

* GstBuffer 基础

HSY案:0.10的版本中,Gstbuffer是一个多层结构的数据,包括数据指针,buff大小等。新版本就是一个boxed 结构,

    A GstBuffer is now a simple boxed type this means that subclassing is not possible anymore. 

    To add data to the buffer you would now use gst_buffer_insert_memory() with a GstMemory object containing the data. Multiple memory blocks can added to a GstBuffer that can then be retrieved with gst_buffer_peek_memory().

    GST_BUFFER_DATA(), GST_BUFFER_MALLOCDATA(), GST_BUFFER_FREE_FUNC() and
    GST_BUFFER_SIZE() are gone, along with the fields in GstBuffer.

    The most common way to access all the data in a buffer is by using
    gst_buffer_map() and gst_buffer_unmap(). These calls require you to specify
    the access mode required to the data and will automatically merge and return
    a writable copy of the data.

    GST_BUFFER_SIZE() can be replaced with gst_buffer_get_size() but if also
    access to the data is required, gst_buffer_map() can return both the size
    and data in one go.

    The buffer must be writable (gst_buffer_is_writable()) in order to modify
    the fields, metadata or buffer memory. gst_buffer_make_writable() will not
    automatically make a writable copy of the memory but will instead increase
    the refcount of the memory. The _map() and _peek_memory() methods will
    automatically create writable copies when needed.
    
    gst_buffer_make_metadata_writable() is gone, you can replace this safely
    with gst_buffer_make_writable().
    
    gst_buffer_copy_metadata() is gone, use gst_buffer_copy_into() instead and
    mind use GST_BUFFER_COPY_METADATA instead of the former GST_BUFFER_COPY_ALL.

    gst_buffer_create_sub() is gone and can be safely replaced with
    gst_buffer_copy_region(). 

    Changing the size of the buffer data can be done with gst_buffer_resize(),
    which will also update the metadata fields correctly. gst_buffer_set_size()
    is #defined to a special case of gst_buffer_resize() with a 0 offset.

    gst_buffer_try_new_and_alloc() is replaced with gst_buffer_new_and_alloc(),
    which now returns NULL when memory allocation fails.

    GST_BUFFER_CAPS() is gone, caps are not set on buffers anymore but are set
    on the pads where the buffer is pushed on. Likewise GST_BUFFER_COPY_CAPS is
    not needed anymore. gst_buffer_get/set_caps() are gone too.

    GST_BUFFER_TIMESTAMP is gone, use GST_BUFFER_PTS or GST_BUFFER_DTS instead.
    Likewise GST_BUFFER_TIMESTAMP_IS_VALID() was changed to
    GST_BUFFER_PTS_IS_VALID and GST_BUFFER_DTS_IS_VALID

    gst_buffer_join() was renamed to gst_buffer_append() and the memory is not
    directly merged but appended.

    gst_buffer_merge() was removed, it is the same as gst_buffer_join() but
    without taking ownership of the arguments. Caller code should ref themselves
    when needed. Note that the extra refs might force slower paths in
    gst_buffer_join().

    gst_buffer_is_span() and gst_buffer_span() are removed, use
    gst_buffer_merge() and gst_buffer_resize() for the same effect. Merging and
    spanning is delayed until the buffer is mapped and in some cases no merging
    of memory is needed at all when the element can deal with individual memory
    chunks.


Sample to create a memory block via 1.0 edition
1
2
3
4
5
6
7
8
9
GstBuffer *buffer;
GstMemory *memory;
gint size, width, height, bpp;
...
size = width * height * bpp;
buffer = gst_buffer_new ();
memory = gst_allocator_alloc (NULL, size, NULL);
gst_buffer_insert_memory (buffer, -1, memory);
...


appsrc and GstBuffer


The appsrc element can be used by applications to insert data into a GStreamer pipeline. Unlike most GStreamer elements, appsrc provides external API functions.

The main way of handing data to the appsrc element is by calling the gst_app_src_push_buffer() method or by emitting the push-buffer action signal. This will put the buffer onto a queue from which appsrc will read from in its streaming thread. It is important to note that data transport will not happen from the thread that performed the push-buffer call.




ref:

https://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/chapter-porting-1.0.html

2

https://cgit.freedesktop.org/gstreamer/gstreamer/plain/docs/random/porting-to-1.0.txt

3

https://gstreamer.freedesktop.org/data/doc/gstreamer/1.4/manual/html/index.html

4

https://gstreamer.freedesktop.org/data/doc/gstreamer/1.4/manual/html/index.html

5

http://docs.gstreamer.com/pages/viewpage.action?pageId=327735


[gstreamer] porting from 0.10 to 1.0 knew how

标签:

原文地址:http://blog.csdn.net/yellow_hill/article/details/51362506

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!