Skip to content

Instantly share code, notes, and snippets.

@yashi
Created December 28, 2016 07:51
Show Gist options
  • Save yashi/3df4aa74f30ceb11d490967aa6bacd7c to your computer and use it in GitHub Desktop.
Save yashi/3df4aa74f30ceb11d490967aa6bacd7c to your computer and use it in GitHub Desktop.
GstAdapter example 3
#include <stdio.h>
#include <gst/base/gstadapter.h>
int main(int argc, char *argv[])
{
GstAdapter *a;
GstBuffer *b;
char *buf;
char const * p;
GstMapInfo i;
gst_init(&argc, &argv);
a = gst_adapter_new();
buf = g_malloc0(10);
sprintf(buf, "abc");
b = gst_buffer_new_wrapped(buf, 10);
gst_adapter_push(a, b);
g_print("size: %" G_GSIZE_FORMAT "\n", gst_adapter_available(a));
p = gst_adapter_map(a, 4);
g_print("%s\n", p);
gst_adapter_unmap(a);
g_print("size: %" G_GSIZE_FORMAT "\n", gst_adapter_available(a));
b = gst_adapter_take_buffer(a, 4);
gst_buffer_map(b, &i, GST_MAP_READ);
g_print("%s\n", i.data);
gst_buffer_unmap(b, &i);
g_print("size: %" G_GSIZE_FORMAT "\n", gst_adapter_available(a));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment