您的位置:首页 > 其它

[gstreamer] [002] porting from 0.10 to 1.0 knew how

2016-05-10 13:45 761 查看
前言:gstreamer 的 1.0 porting guide 里面有提到一下改变,但是,并不是覆盖了全面,本文结合porting 的实际写成,涉及整个porting 真正要用的的一下接口。

gstreamer 0.1 to 1.0 的主要接口改动包括如下方面:

1 Gstbuffer的变化

2 Gstreamer 的 一些插件的接口变化,gst-plugins-base Elements

3 glib 的相关改动

1 *GstBuffer 的变化,这部分,在接口更改说明文档里面有比较详细的说明:

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.

【hsy案】 CAPS 现在不能从buffer里面拿到了,所以,类似, GstStructure* meta = gst_caps_get_structure(GST_BUFFER_CAPS(buffer), 0);的接口要改下。


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.


HSY案:

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


* GstQuery 是一个重要的改动

    Boxed types derived from GstMiniObject.

    The GstStructure is removed from the public API, use the getters to get
    a handle to a GstStructure.

    gst_query_new_application() -> gst_query_new_custom()

    gst_query_parse_formats_length() -> gst_query_parse_n_formats()
    gst_query_parse_formats_nth() -> gst_query_parse_nth_format()

    Some query utility functions no longer use an inout parameter for the 
    destination/query format:

【hsy案】这里是指有一些指针传递来取回的接口被改掉了,改成直接值传递的方式,以前inout的模式取消了,只有in的模式。
      - gst_pad_query_position()
      - gst_pad_query_duration()
      - gst_pad_query_convert()
      - gst_pad_query_peer_position()
      - gst_pad_query_peer_duration()
      - gst_pad_query_peer_convert()
      - gst_element_query_position()
      - gst_element_query_duration()
      - gst_element_query_convert()
    gst_element_get_query_types() and gst_pad_get_query_types() with associated functions were removed.


* GstTagList

    is now an opaque mini object instead of being typedefed to a GstStructure.

    While it was previously okay (and in some cases required because of

    missing taglist API) to cast a GstTagList to a GstStructure or use

    gst_structure_* API on taglists, you can no longer do that. Doing so will

    cause crashes.

    Also, tag lists are refcounted now, and can therefore not be freely

    modified any longer. Make sure to call

      taglist = gst_tag_list_make_writable (taglist);

    before adding, removing or changing tags in the taglist.

    gst_tag_list_new() has been renamed to gst_tag_list_new_empty().

    gst_tag_list_new_full*() have been renamed to gst_tag_list_new*().

    gst_tag_list_free() has been replaced by gst_tag_list_unref().

    GST_TAG_IMAGE, GST_TAG_PREVIEW_IMAGE, GST_TAG_ATTACHMENT: many tags that

    used to be of type GstBuffer are now of type GstSample (which is basically

    a struct containing a buffer alongside caps and some other info).

    gst_tag_list_get_buffer() => gst_tag_list_get_sample()

    gst_is_tag_list() => GST_IS_TAG_LIST ()

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);
...

2 Gstreamer 的 一些插件的接口变化

2.1 gst-plugins-base Elements

GstBuffer 被Gstsample取代了

appsrc and GstBuffer

Basic: 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 aqueuefrom 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.

appsink

buffer

[b]--01 0.1 接口函数和buffer有关的不能用了[/b]
GstBuffer* buffer = gst_app_sink_pull_buffer(sink);

[b]--02 1.0的写法如下[/b]

GstBuffer *gst_sample_get_buffer ()
接口从sample里面获取buffer的值。

  GstSample *sample;

  sample = gst_app_sink_pull_sample (appsink);

  buf = gst_sample_get_buffer (sample);

Caps

1.0 版本的使用

GstCaps *           gst_app_sink_get_caps               ([code]GstAppSink *appsink
);[/code]
0.1 版本的使用

GST_BUFFER_CAPS(buf)

  
ref:

1  Porting 0.10 applications to 1.0
https://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/chapter-porting-1.0.html
2 GStreamer 0.10 to 1.0 porting guide
https://cgit.freedesktop.org/gstreamer/gstreamer/plain/docs/random/porting-to-1.0.txt
3  GStreamer Application Development Manual (1.4.5)
https://gstreamer.freedesktop.org/data/doc/gstreamer/1.4/manual/html/index.html
4  GStreamer Base Plugins 0.10 Library Reference Manual : appsink
https://www.freedesktop.org/software/gstreamer-sdk/data/docs/2012.5/gst-plugins-base-libs-0.10/gst-plugins-base-libs-appsink.html
GStreamer Base Plugins 1.0 Library Reference Manual :appsink
https://developer.gnome.org/gst-plugins-libs/stable/gst-plugins-base-libs-appsink.html
5 gst-plugins-base Elements
https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-plugins/html/
6 The sample code for gstreamer
https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstSample.html
7 library reference : elements and plugins GStreamer Core Plugins 1.0 Plugins Reference Manual
https://developer.gnome.org/gst-plugins-libs/stable/index.html
8 sample for gst_buffer_map 
https://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/section-allocation-buffer.html
gst_buffer_map 
https://developer.gnome.org/gstreamer/stable/gstreamer-GstBuffer.html#gst-buffer-map
10 glib

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

版权所有:转贴请指明出处!谢谢!

正在制作中,马上还会更新。。。

微信: NewTechLife 

Made by huang.makin@gmail.com

QQ:28044280
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: