2012-07-06 08:22:22 +00:00
|
|
|
/* GStreamer
|
|
|
|
*
|
|
|
|
* unit test for state changes on all elements
|
|
|
|
*
|
|
|
|
* Copyright (C) <2012> Matthew Waters <ystreet00@gmail.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-08 11:53:56 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2012-07-06 08:22:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gst/check/gstcheck.h>
|
|
|
|
|
2015-12-14 07:15:42 +00:00
|
|
|
#include <gst/gl/gl.h>
|
2012-07-06 08:22:22 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
static GstGLDisplay *display;
|
2013-08-22 05:55:35 +00:00
|
|
|
static GstGLContext *context;
|
2012-07-06 08:22:22 +00:00
|
|
|
|
2014-03-16 14:06:37 +00:00
|
|
|
static void
|
2012-07-06 08:22:22 +00:00
|
|
|
setup (void)
|
|
|
|
{
|
|
|
|
display = gst_gl_display_new ();
|
2013-08-22 05:55:35 +00:00
|
|
|
context = gst_gl_context_new (display);
|
|
|
|
gst_gl_context_create (context, 0, NULL);
|
2015-12-14 02:43:59 +00:00
|
|
|
gst_gl_memory_init_once ();
|
2012-07-06 08:22:22 +00:00
|
|
|
}
|
|
|
|
|
2014-03-16 14:06:37 +00:00
|
|
|
static void
|
2012-07-06 08:22:22 +00:00
|
|
|
teardown (void)
|
|
|
|
{
|
2013-06-13 04:36:41 +00:00
|
|
|
gst_object_unref (display);
|
2013-08-22 05:55:35 +00:00
|
|
|
gst_object_unref (context);
|
2012-07-06 08:22:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_START_TEST (test_basic)
|
|
|
|
{
|
|
|
|
GstMemory *mem, *mem2;
|
|
|
|
GstGLMemory *gl_mem, *gl_mem2;
|
|
|
|
GstAllocator *gl_allocator;
|
2015-12-16 07:41:06 +00:00
|
|
|
GstGLBaseMemoryAllocator *base_mem_alloc;
|
2014-08-01 00:01:18 +00:00
|
|
|
gint i, j;
|
|
|
|
static GstVideoFormat formats[] = {
|
|
|
|
GST_VIDEO_FORMAT_RGBA, GST_VIDEO_FORMAT_RGB,
|
|
|
|
GST_VIDEO_FORMAT_YUY2, GST_VIDEO_FORMAT_I420
|
2012-07-06 08:22:22 +00:00
|
|
|
};
|
|
|
|
|
2015-12-16 07:41:06 +00:00
|
|
|
gl_allocator = gst_allocator_find (GST_GL_MEMORY_ALLOCATOR_NAME);
|
2014-08-01 00:01:18 +00:00
|
|
|
fail_if (gl_allocator == NULL);
|
2015-12-16 07:41:06 +00:00
|
|
|
base_mem_alloc = GST_GL_BASE_MEMORY_ALLOCATOR (gl_allocator);
|
2014-08-01 00:01:18 +00:00
|
|
|
|
|
|
|
/* test allocator creation */
|
2014-09-29 15:45:20 +00:00
|
|
|
ASSERT_WARNING (mem = gst_allocator_alloc (gl_allocator, 0, NULL));
|
2014-08-01 00:01:18 +00:00
|
|
|
|
2012-07-06 08:22:22 +00:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (formats); i++) {
|
2014-08-01 00:01:18 +00:00
|
|
|
GstVideoInfo v_info;
|
|
|
|
gsize width = 320, height = 240;
|
|
|
|
|
|
|
|
gst_video_info_set_format (&v_info, formats[i], width, height);
|
|
|
|
|
|
|
|
for (j = 0; j < GST_VIDEO_INFO_N_PLANES (&v_info); j++) {
|
2015-12-16 07:41:06 +00:00
|
|
|
GstGLVideoAllocationParams *params;
|
|
|
|
|
|
|
|
params = gst_gl_video_allocation_params_new (context, NULL, &v_info, j,
|
|
|
|
NULL, GST_GL_TEXTURE_TARGET_2D);
|
|
|
|
|
|
|
|
mem = (GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc,
|
|
|
|
(GstGLAllocationParams *) params);
|
2014-08-01 00:01:18 +00:00
|
|
|
fail_if (mem == NULL);
|
|
|
|
gl_mem = (GstGLMemory *) mem;
|
|
|
|
|
|
|
|
/* test init params */
|
|
|
|
fail_if (gst_video_info_is_equal (&v_info, &gl_mem->info) == FALSE);
|
2015-06-10 06:36:15 +00:00
|
|
|
fail_if (gl_mem->mem.context != context);
|
2014-08-01 00:01:18 +00:00
|
|
|
fail_if (gl_mem->tex_id == 0);
|
|
|
|
|
|
|
|
/* copy the memory */
|
|
|
|
mem2 = gst_memory_copy (mem, 0, -1);
|
|
|
|
fail_if (mem2 == NULL);
|
|
|
|
gl_mem2 = (GstGLMemory *) mem2;
|
|
|
|
|
|
|
|
/* test params */
|
|
|
|
fail_if (gst_video_info_is_equal (&gl_mem2->info,
|
|
|
|
&gl_mem->info) == FALSE);
|
2015-06-10 06:36:15 +00:00
|
|
|
fail_if (gl_mem->mem.context != gl_mem2->mem.context);
|
2014-08-01 00:01:18 +00:00
|
|
|
|
|
|
|
if (gst_gl_context_get_error ())
|
|
|
|
printf ("%s\n", gst_gl_context_get_error ());
|
|
|
|
fail_if (gst_gl_context_get_error () != NULL);
|
|
|
|
|
2015-12-16 07:41:06 +00:00
|
|
|
gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
|
2014-08-01 00:01:18 +00:00
|
|
|
gst_memory_unref (mem);
|
|
|
|
gst_memory_unref (mem2);
|
|
|
|
}
|
2012-07-06 08:22:22 +00:00
|
|
|
}
|
2014-08-01 00:01:18 +00:00
|
|
|
|
|
|
|
gst_object_unref (gl_allocator);
|
2012-07-06 08:22:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2014-09-29 15:45:20 +00:00
|
|
|
/* one red rgba pixel */
|
|
|
|
static gchar rgba_pixel[] = {
|
|
|
|
0xff, 0x00, 0x00, 0xff,
|
|
|
|
};
|
|
|
|
|
2015-12-16 07:41:06 +00:00
|
|
|
static void
|
|
|
|
test_transfer_allocator (const gchar * allocator_name)
|
2014-09-29 15:45:20 +00:00
|
|
|
{
|
|
|
|
GstAllocator *gl_allocator;
|
2015-12-16 07:41:06 +00:00
|
|
|
GstGLBaseMemoryAllocator *base_mem_alloc;
|
2014-09-29 15:45:20 +00:00
|
|
|
GstVideoInfo v_info;
|
|
|
|
GstMemory *mem, *mem2, *mem3;
|
|
|
|
GstMapInfo map_info;
|
2015-12-16 07:41:06 +00:00
|
|
|
GstGLVideoAllocationParams *params;
|
2014-09-29 15:45:20 +00:00
|
|
|
|
2015-12-16 07:41:06 +00:00
|
|
|
gl_allocator = gst_allocator_find (allocator_name);
|
2014-09-29 15:45:20 +00:00
|
|
|
fail_if (gl_allocator == NULL);
|
2015-12-16 07:41:06 +00:00
|
|
|
base_mem_alloc = GST_GL_BASE_MEMORY_ALLOCATOR (gl_allocator);
|
2014-09-29 15:45:20 +00:00
|
|
|
|
|
|
|
gst_video_info_set_format (&v_info, GST_VIDEO_FORMAT_RGBA, 1, 1);
|
|
|
|
|
2015-12-16 07:41:06 +00:00
|
|
|
params = gst_gl_video_allocation_params_new (context, NULL, &v_info, 0,
|
|
|
|
NULL, GST_GL_TEXTURE_TARGET_2D);
|
|
|
|
|
2014-09-29 15:45:20 +00:00
|
|
|
/* texture creation */
|
2015-12-16 07:41:06 +00:00
|
|
|
mem = (GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc,
|
|
|
|
(GstGLAllocationParams *) params);
|
|
|
|
gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
|
2015-06-10 06:36:15 +00:00
|
|
|
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD));
|
2015-06-10 06:36:15 +00:00
|
|
|
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD));
|
2014-09-29 15:45:20 +00:00
|
|
|
|
|
|
|
/* test wrapping raw data */
|
2015-12-16 07:41:06 +00:00
|
|
|
params = gst_gl_video_allocation_params_new_wrapped_data (context, NULL,
|
|
|
|
&v_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D, rgba_pixel, NULL, NULL);
|
2014-09-29 15:45:20 +00:00
|
|
|
mem2 =
|
2015-12-16 07:41:06 +00:00
|
|
|
(GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc,
|
|
|
|
(GstGLAllocationParams *) params);
|
|
|
|
gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
|
2014-09-29 15:45:20 +00:00
|
|
|
fail_if (mem == NULL);
|
|
|
|
|
2015-06-10 06:36:15 +00:00
|
|
|
fail_unless (GST_MEMORY_FLAG_IS_SET (mem2,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD));
|
2015-06-10 06:36:15 +00:00
|
|
|
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD));
|
2014-09-29 15:45:20 +00:00
|
|
|
|
|
|
|
/* wrapped texture creation */
|
2015-12-16 07:41:06 +00:00
|
|
|
params = gst_gl_video_allocation_params_new_wrapped_texture (context, NULL,
|
|
|
|
&v_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D, ((GstGLMemory *) mem)->tex_id,
|
2015-10-28 13:44:26 +00:00
|
|
|
NULL, NULL);
|
2015-12-16 07:41:06 +00:00
|
|
|
mem3 =
|
|
|
|
(GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc,
|
|
|
|
(GstGLAllocationParams *) params);
|
|
|
|
gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
|
2015-06-10 06:36:15 +00:00
|
|
|
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem3,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD));
|
2015-06-10 06:36:15 +00:00
|
|
|
fail_unless (GST_MEMORY_FLAG_IS_SET (mem3,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD));
|
2014-09-29 15:45:20 +00:00
|
|
|
|
|
|
|
/* check data/flags are correct */
|
|
|
|
fail_unless (gst_memory_map (mem2, &map_info, GST_MAP_READ));
|
|
|
|
|
2015-06-10 06:36:15 +00:00
|
|
|
fail_unless (GST_MEMORY_FLAG_IS_SET (mem2,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD));
|
2015-06-10 06:36:15 +00:00
|
|
|
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD));
|
2014-09-29 15:45:20 +00:00
|
|
|
|
2015-12-30 01:06:17 +00:00
|
|
|
fail_unless (memcmp (map_info.data, rgba_pixel,
|
|
|
|
G_N_ELEMENTS (rgba_pixel)) == 0,
|
|
|
|
"0x%02x%02x%02x%02x != 0x%02x%02x%02x%02x", map_info.data[0],
|
|
|
|
map_info.data[1], map_info.data[2], map_info.data[3],
|
|
|
|
(guint8) rgba_pixel[0], (guint8) rgba_pixel[1], (guint8) rgba_pixel[2],
|
|
|
|
(guint8) rgba_pixel[3]);
|
2014-09-29 15:45:20 +00:00
|
|
|
|
|
|
|
gst_memory_unmap (mem2, &map_info);
|
|
|
|
|
2015-06-10 06:36:15 +00:00
|
|
|
fail_unless (GST_MEMORY_FLAG_IS_SET (mem2,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD));
|
2015-06-10 06:36:15 +00:00
|
|
|
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD));
|
2014-09-29 15:45:20 +00:00
|
|
|
|
|
|
|
fail_unless (gst_memory_map (mem2, &map_info, GST_MAP_READ | GST_MAP_GL));
|
|
|
|
|
2015-06-10 06:36:15 +00:00
|
|
|
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD));
|
2015-06-10 06:36:15 +00:00
|
|
|
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD));
|
2014-09-29 15:45:20 +00:00
|
|
|
|
|
|
|
/* test texture copy */
|
2015-12-14 02:43:59 +00:00
|
|
|
fail_unless (gst_gl_memory_copy_into ((GstGLMemory *) mem2,
|
2015-10-30 04:00:23 +00:00
|
|
|
((GstGLMemory *) mem)->tex_id, GST_GL_TEXTURE_TARGET_2D,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_VIDEO_GL_TEXTURE_TYPE_RGBA, 1, 1));
|
|
|
|
GST_MINI_OBJECT_FLAG_SET (mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD);
|
2014-09-29 15:45:20 +00:00
|
|
|
|
2015-06-10 06:36:15 +00:00
|
|
|
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD));
|
2015-06-10 06:36:15 +00:00
|
|
|
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD));
|
2015-06-10 06:36:15 +00:00
|
|
|
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD));
|
2015-06-10 06:36:15 +00:00
|
|
|
fail_unless (GST_MEMORY_FLAG_IS_SET (mem,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD));
|
2014-09-29 15:45:20 +00:00
|
|
|
|
|
|
|
gst_memory_unmap (mem2, &map_info);
|
|
|
|
|
|
|
|
/* test download of copied texture */
|
|
|
|
fail_unless (gst_memory_map (mem, &map_info, GST_MAP_READ));
|
|
|
|
|
2015-12-30 01:06:17 +00:00
|
|
|
fail_unless (memcmp (map_info.data, rgba_pixel,
|
|
|
|
G_N_ELEMENTS (rgba_pixel)) == 0,
|
|
|
|
"0x%02x%02x%02x%02x != 0x%02x%02x%02x%02x", (guint8) map_info.data[0],
|
|
|
|
(guint8) map_info.data[1], (guint8) map_info.data[2],
|
|
|
|
(guint8) map_info.data[3], (guint8) rgba_pixel[0], (guint8) rgba_pixel[1],
|
|
|
|
(guint8) rgba_pixel[2], (guint8) rgba_pixel[3]);
|
2014-09-29 15:45:20 +00:00
|
|
|
|
|
|
|
gst_memory_unmap (mem, &map_info);
|
|
|
|
|
|
|
|
/* test download of wrapped copied texture */
|
|
|
|
fail_unless (gst_memory_map (mem3, &map_info, GST_MAP_READ));
|
|
|
|
|
2015-06-10 06:36:15 +00:00
|
|
|
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD));
|
2015-06-10 06:36:15 +00:00
|
|
|
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD));
|
2014-09-29 15:45:20 +00:00
|
|
|
|
2015-12-30 01:06:17 +00:00
|
|
|
fail_unless (memcmp (map_info.data, rgba_pixel,
|
|
|
|
G_N_ELEMENTS (rgba_pixel)) == 0,
|
|
|
|
"0x%02x%02x%02x%02x != 0x%02x%02x%02x%02x", (guint8) map_info.data[0],
|
|
|
|
(guint8) map_info.data[1], (guint8) map_info.data[2],
|
|
|
|
(guint8) map_info.data[3], (guint8) rgba_pixel[0], (guint8) rgba_pixel[1],
|
|
|
|
(guint8) rgba_pixel[2], (guint8) rgba_pixel[3]);
|
2014-09-29 15:45:20 +00:00
|
|
|
|
|
|
|
gst_memory_unmap (mem3, &map_info);
|
|
|
|
|
|
|
|
/* test upload flag */
|
|
|
|
fail_unless (gst_memory_map (mem3, &map_info, GST_MAP_WRITE));
|
|
|
|
gst_memory_unmap (mem3, &map_info);
|
|
|
|
|
2015-06-10 06:36:15 +00:00
|
|
|
fail_unless (GST_MEMORY_FLAG_IS_SET (mem3,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD));
|
2015-06-10 06:36:15 +00:00
|
|
|
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem3,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD));
|
2014-09-29 15:45:20 +00:00
|
|
|
|
|
|
|
/* test download flag */
|
|
|
|
fail_unless (gst_memory_map (mem3, &map_info, GST_MAP_WRITE | GST_MAP_GL));
|
|
|
|
gst_memory_unmap (mem3, &map_info);
|
|
|
|
|
2015-06-10 06:36:15 +00:00
|
|
|
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem3,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD));
|
2015-06-10 06:36:15 +00:00
|
|
|
fail_unless (GST_MEMORY_FLAG_IS_SET (mem3,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD));
|
2014-09-29 15:45:20 +00:00
|
|
|
|
|
|
|
if (gst_gl_context_get_error ())
|
|
|
|
printf ("%s\n", gst_gl_context_get_error ());
|
|
|
|
fail_if (gst_gl_context_get_error () != NULL);
|
|
|
|
|
|
|
|
gst_memory_unref (mem);
|
|
|
|
gst_memory_unref (mem2);
|
|
|
|
gst_memory_unref (mem3);
|
|
|
|
gst_object_unref (gl_allocator);
|
|
|
|
}
|
|
|
|
|
2015-12-16 07:41:06 +00:00
|
|
|
|
|
|
|
GST_START_TEST (test_transfer)
|
|
|
|
{
|
|
|
|
test_transfer_allocator (GST_GL_MEMORY_ALLOCATOR_NAME);
|
|
|
|
test_transfer_allocator (GST_GL_MEMORY_PBO_ALLOCATOR_NAME);
|
|
|
|
}
|
|
|
|
|
2014-09-29 15:45:20 +00:00
|
|
|
GST_END_TEST;
|
2012-07-06 08:22:22 +00:00
|
|
|
|
2015-06-11 08:26:50 +00:00
|
|
|
GST_START_TEST (test_separate_transfer)
|
|
|
|
{
|
2015-12-16 07:41:06 +00:00
|
|
|
GstGLBaseMemoryAllocator *base_mem_alloc;
|
|
|
|
GstGLVideoAllocationParams *params;
|
2015-06-11 08:26:50 +00:00
|
|
|
GstAllocator *gl_allocator;
|
|
|
|
GstVideoInfo v_info;
|
|
|
|
GstMemory *mem;
|
|
|
|
GstMapInfo info;
|
|
|
|
|
2015-12-14 02:43:59 +00:00
|
|
|
gl_allocator = gst_allocator_find (GST_GL_MEMORY_PBO_ALLOCATOR_NAME);
|
2015-06-11 08:26:50 +00:00
|
|
|
fail_if (gl_allocator == NULL);
|
2015-12-16 07:41:06 +00:00
|
|
|
base_mem_alloc = GST_GL_BASE_MEMORY_ALLOCATOR (gl_allocator);
|
2015-06-11 08:26:50 +00:00
|
|
|
|
|
|
|
gst_video_info_set_format (&v_info, GST_VIDEO_FORMAT_RGBA, 1, 1);
|
|
|
|
|
2015-12-16 07:41:06 +00:00
|
|
|
params = gst_gl_video_allocation_params_new_wrapped_data (context, NULL,
|
|
|
|
&v_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D, rgba_pixel, NULL, NULL);
|
2015-06-11 08:26:50 +00:00
|
|
|
mem =
|
2015-12-16 07:41:06 +00:00
|
|
|
(GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc,
|
|
|
|
(GstGLAllocationParams *) params);
|
|
|
|
gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
|
2015-06-11 08:26:50 +00:00
|
|
|
fail_if (mem == NULL);
|
|
|
|
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD));
|
2015-06-11 08:26:50 +00:00
|
|
|
|
2015-12-14 02:43:59 +00:00
|
|
|
gst_gl_memory_pbo_upload_transfer ((GstGLMemoryPBO *) mem);
|
2015-06-11 08:26:50 +00:00
|
|
|
|
|
|
|
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem,
|
2015-12-14 02:43:59 +00:00
|
|
|
GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD));
|
2015-06-11 08:26:50 +00:00
|
|
|
|
|
|
|
fail_unless (gst_memory_map (mem, &info, GST_MAP_READ));
|
|
|
|
|
2015-12-30 01:06:17 +00:00
|
|
|
fail_unless (memcmp (info.data, rgba_pixel, G_N_ELEMENTS (rgba_pixel)) == 0,
|
|
|
|
"0x%02x%02x%02x%02x != 0x%02x%02x%02x%02x", (guint8) info.data[0],
|
|
|
|
(guint8) info.data[1], (guint8) info.data[2],
|
|
|
|
(guint8) info.data[3], (guint8) rgba_pixel[0], (guint8) rgba_pixel[1],
|
|
|
|
(guint8) rgba_pixel[2], (guint8) rgba_pixel[3]);
|
2015-06-11 08:26:50 +00:00
|
|
|
|
|
|
|
gst_memory_unmap (mem, &info);
|
|
|
|
|
|
|
|
/* FIXME: add download transfer */
|
|
|
|
|
|
|
|
if (gst_gl_context_get_error ())
|
|
|
|
printf ("%s\n", gst_gl_context_get_error ());
|
|
|
|
fail_if (gst_gl_context_get_error () != NULL);
|
|
|
|
|
|
|
|
gst_memory_unref (mem);
|
|
|
|
gst_object_unref (gl_allocator);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2014-03-16 14:06:37 +00:00
|
|
|
static Suite *
|
2012-07-06 08:22:22 +00:00
|
|
|
gst_gl_memory_suite (void)
|
|
|
|
{
|
|
|
|
Suite *s = suite_create ("GstGLMemory");
|
|
|
|
TCase *tc_chain = tcase_create ("general");
|
|
|
|
|
|
|
|
suite_add_tcase (s, tc_chain);
|
|
|
|
tcase_add_checked_fixture (tc_chain, setup, teardown);
|
|
|
|
tcase_add_test (tc_chain, test_basic);
|
2014-09-29 15:45:20 +00:00
|
|
|
tcase_add_test (tc_chain, test_transfer);
|
2015-06-11 08:26:50 +00:00
|
|
|
tcase_add_test (tc_chain, test_separate_transfer);
|
2012-07-06 08:22:22 +00:00
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_CHECK_MAIN (gst_gl_memory);
|