Created
December 10, 2015 13:59
-
-
Save yashi/c47c443c6b17bc6a4aba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <gst/gst.h> | |
#include <string.h> | |
int main(int argc, char *argv[]) | |
{ | |
GstBuffer *buf; | |
GstMemory *mem; | |
GstMapInfo info; | |
gsize size; | |
gsize maxsize; | |
gst_init(&argc, &argv); | |
buf = gst_buffer_new(); | |
size = gst_buffer_get_sizes(buf, NULL, &maxsize); | |
g_print("buf:\n"); | |
g_print(" size: %" G_GSIZE_FORMAT "\n", size); | |
g_print(" maxsize: %" G_GSIZE_FORMAT "\n", maxsize); | |
g_print(" nr: %u\n", gst_buffer_n_memory(buf)); | |
mem = gst_allocator_alloc(NULL, 3, NULL); | |
size = gst_memory_get_sizes(mem, NULL, &maxsize); | |
g_print("mem 1:\n"); | |
g_print(" size: %" G_GSIZE_FORMAT "\n", size); | |
g_print(" maxsize: %" G_GSIZE_FORMAT "\n", maxsize); | |
gst_memory_map(mem, &info, GST_MAP_WRITE); | |
memcpy(info.data, "abc", 3); | |
gst_memory_unmap(mem, &info); | |
gst_buffer_insert_memory(buf, -1, mem); | |
size = gst_buffer_get_sizes(buf, NULL, &maxsize); | |
g_print("buf:\n"); | |
g_print(" size: %" G_GSIZE_FORMAT "\n", size); | |
g_print(" maxsize: %" G_GSIZE_FORMAT "\n", maxsize); | |
g_print(" nr: %u\n", gst_buffer_n_memory(buf)); | |
mem = gst_allocator_alloc(NULL, 6, NULL); | |
size = gst_memory_get_sizes(mem, NULL, &maxsize); | |
g_print("mem 2:\n"); | |
g_print(" size: %" G_GSIZE_FORMAT "\n", size); | |
g_print(" maxsize: %" G_GSIZE_FORMAT "\n", maxsize); | |
gst_memory_map(mem, &info, GST_MAP_WRITE); | |
memcpy(info.data, "12345", 6); | |
gst_memory_unmap(mem, &info); | |
gst_buffer_insert_memory(buf, -1, mem); | |
size = gst_buffer_get_sizes(buf, NULL, &maxsize); | |
g_print("buf:\n"); | |
g_print(" size: %" G_GSIZE_FORMAT "\n", size); | |
g_print(" maxsize: %" G_GSIZE_FORMAT "\n", maxsize); | |
g_print(" nr: %u\n", gst_buffer_n_memory(buf)); | |
gst_buffer_map(buf, &info, GST_MAP_READ); | |
g_print("%s\n", info.data); | |
gst_buffer_unmap(buf, &info); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment