Skip to content

Instantly share code, notes, and snippets.

@tetkuz
Created May 23, 2016 10:52
Show Gist options
  • Save tetkuz/4b6c051ff7ecb6415479ec46b6bbbcae to your computer and use it in GitHub Desktop.
Save tetkuz/4b6c051ff7ecb6415479ec46b6bbbcae to your computer and use it in GitHub Desktop.
gst_buffer and gstring
/* gcc -Wall -Wextra main.c `pkg-config --libs --cflags gstreamer-1.0` */
#include <gst/gst.h>
int main(int argc, char *argv[])
{
GstBuffer *buf;
GstMapInfo info;
GString *tmp;
gst_init (&argc, &argv);
buf = gst_buffer_new ();
tmp = g_string_new ("Hello");
/* gst_buffer_append_memory()
* https://developer.gnome.org/gstreamer/stable/gstreamer-GstBuffer.html#gst-buffer-append-memory
* gst_memory_new_wrapped()
* https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstAllocator.html#gst-memory-new-wrapped
*/
gst_buffer_append_memory (buf,
gst_memory_new_wrapped (GST_MEMORY_FLAG_NO_SHARE,
tmp->str, tmp->allocated_len, 0, tmp->len, NULL, NULL));
/* gst_buffer_map()
* https://developer.gnome.org/gstreamer/stable/gstreamer-GstBuffer.html#gst-buffer-map
*/
gst_buffer_map (buf, &info, GST_MAP_READ);
g_print ("%s\n", info.data);
gst_buffer_unmap (buf, &info);
gst_buffer_unref (buf);
g_string_free (tmp, TRUE);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment