diff options
author | Tim-Philipp Müller <tim@centricular.com> | 2017-12-11 12:59:09 +0000 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2017-12-19 12:02:31 +0000 |
commit | 769a21d0bb310906b880c07da0e1e2376e11c187 (patch) | |
tree | 02b93bbe659389c940abd69b3a214cfa05f6c501 /tests | |
parent | 43631c63ea76c524f96488dbdf4f4e20fa764626 (diff) |
gl: remove GStreamer OpenGL integration library and move to -base
https://bugzilla.gnome.org/show_bug.cgi?id=754094
Diffstat (limited to 'tests')
113 files changed, 2 insertions, 13238 deletions
diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index f3961ed19..3fae4e574 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -204,23 +204,6 @@ else check_ipcpipeline= endif -if USE_GL -check_gl=libs/gstglcontext \ - libs/gstglmemory \ - libs/gstglupload \ - libs/gstglcolorconvert \ - libs/gstglmatrix \ - libs/gstglquery \ - libs/gstglsl \ - libs/gstglslstage \ - libs/gstglshader \ - libs/gstglheaders \ - elements/glimagesink \ - pipelines/simple-launch-lines -else -check_gl= -endif - VALGRIND_TO_FIX = \ elements/mpeg2enc \ elements/mplex \ @@ -297,7 +280,6 @@ check_PROGRAMS = \ $(check_zbar) \ $(check_orc) \ libs/insertbin \ - $(check_gl) \ $(check_hlsdemux_m3u8) \ $(check_hlsdemux) \ $(check_srtp) \ @@ -554,119 +536,6 @@ orc/audiomixer.c: $(top_srcdir)/gst/audiomixer/gstaudiomixerorc.orc $(MKDIR_P) orc $(ORCC) --test -o $@ $< -libs_gstglcontext_LDADD = \ - $(top_builddir)/gst-libs/gst/gl/libgstgl-@GST_API_VERSION@.la \ - $(GST_PLUGINS_BASE_LIBS) $(GST_VIDEO_LIBS) $(GST_BASE_LIBS) \ - $(GST_LIBS) $(LDADD) - -libs_gstglcontext_CFLAGS = \ - $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \ - -DGST_USE_UNSTABLE_API \ - $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GL_CFLAGS) $(AM_CFLAGS) - -libs_gstglmemory_LDADD = \ - $(top_builddir)/gst-libs/gst/gl/libgstgl-@GST_API_VERSION@.la \ - $(GST_PLUGINS_BASE_LIBS) $(GST_VIDEO_LIBS) $(GST_BASE_LIBS) \ - $(GST_LIBS) $(LDADD) - -libs_gstglmemory_CFLAGS = \ - $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \ - -DGST_USE_UNSTABLE_API \ - $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GL_CFLAGS) $(AM_CFLAGS) - -libs_gstglupload_CFLAGS = \ - $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \ - -DGST_USE_UNSTABLE_API \ - $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GL_CFLAGS) $(AM_CFLAGS) - -libs_gstglupload_LDADD = \ - $(top_builddir)/gst-libs/gst/gl/libgstgl-@GST_API_VERSION@.la \ - $(GST_PLUGINS_BASE_LIBS) $(GST_VIDEO_LIBS) $(GST_BASE_LIBS) \ - $(GST_LIBS) $(LDADD) - -libs_gstglcolorconvert_CFLAGS = \ - $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \ - -DGST_USE_UNSTABLE_API \ - $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GL_CFLAGS) $(AM_CFLAGS) - -libs_gstglcolorconvert_LDADD = \ - $(top_builddir)/gst-libs/gst/gl/libgstgl-@GST_API_VERSION@.la \ - $(GST_PLUGINS_BASE_LIBS) $(GST_VIDEO_LIBS) $(GST_BASE_LIBS) \ - $(GST_LIBS) $(LDADD) - -libs_gstglmatrix_CFLAGS = \ - $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \ - -DGST_USE_UNSTABLE_API \ - $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(AM_CFLAGS) - -libs_gstglmatrix_LDADD = \ - $(top_builddir)/gst-libs/gst/gl/libgstgl-@GST_API_VERSION@.la \ - $(GST_PLUGINS_BASE_LIBS) $(GST_VIDEO_LIBS) $(GST_BASE_LIBS) \ - $(GST_LIBS) $(LDADD) - -libs_gstglquery_LDADD = \ - $(top_builddir)/gst-libs/gst/gl/libgstgl-@GST_API_VERSION@.la \ - $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS) $(LDADD) - -libs_gstglquery_CFLAGS = \ - $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \ - -DGST_USE_UNSTABLE_API \ - $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GL_CFLAGS) $(AM_CFLAGS) - -libs_gstglsl_LDADD = \ - $(top_builddir)/gst-libs/gst/gl/libgstgl-@GST_API_VERSION@.la \ - $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS) $(LDADD) - -libs_gstglsl_CFLAGS = \ - $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \ - -DGST_USE_UNSTABLE_API \ - $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GL_CFLAGS) $(AM_CFLAGS) - -libs_gstglslstage_LDADD = \ - $(top_builddir)/gst-libs/gst/gl/libgstgl-@GST_API_VERSION@.la \ - $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS) $(LDADD) - -libs_gstglslstage_CFLAGS = \ - $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \ - -DGST_USE_UNSTABLE_API \ - $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GL_CFLAGS) $(AM_CFLAGS) - -libs_gstglshader_LDADD = \ - $(top_builddir)/gst-libs/gst/gl/libgstgl-@GST_API_VERSION@.la \ - $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS) $(LDADD) - -libs_gstglshader_CFLAGS = \ - $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \ - -DGST_USE_UNSTABLE_API \ - $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GL_CFLAGS) $(AM_CFLAGS) - -libs_gstglheaders_LDADD = \ - $(top_builddir)/gst-libs/gst/gl/libgstgl-@GST_API_VERSION@.la \ - $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS) $(LDADD) - -libs_gstglheaders_CFLAGS = \ - $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \ - -DGST_USE_UNSTABLE_API \ - $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GL_CFLAGS) $(AM_CFLAGS) - -elements_glimagesink_CFLAGS = \ - $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \ - -DGST_USE_UNSTABLE_API \ - $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(AM_CFLAGS) - -elements_glimagesink_LDADD = \ - $(top_builddir)/gst-libs/gst/gl/libgstgl-@GST_API_VERSION@.la \ - $(GST_PLUGINS_BASE_LIBS) $(GST_VIDEO_LIBS) $(GST_BASE_LIBS) \ - $(GST_LIBS) $(LDADD) - -pipelines_simple_launch_lines_CFLAGS = \ - $(GST_PLUGINS_BAD_CFLAGS) \ - -DGST_USE_UNSTABLE_API \ - $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(AM_CFLAGS) - -pipelines_simple_launch_lines_LDADD = \ - $(GST_BASE_LIBS) $(GST_LIBS) $(LDADD) - elements_compositor_LDADD = \ $(GST_PLUGINS_BASE_LIBS) $(GST_VIDEO_LIBS) $(GST_BASE_LIBS) $(LDADD) elements_compositor_CFLAGS = \ diff --git a/tests/check/elements/glimagesink.c b/tests/check/elements/glimagesink.c deleted file mode 100644 index c536ecd65..000000000 --- a/tests/check/elements/glimagesink.c +++ /dev/null @@ -1,283 +0,0 @@ -/* GStreamer - * - * Unit tests for glimagesink - * - * Copyright (C) 2014 Julien Isorce <j.isorce@samsung.com> - * Copyright (C) 2016 Matthew Waters <matthew@centricular.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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gst/gst.h> -#include <gst/video/video.h> -#include <gst/check/gstcheck.h> - -static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("RGBA")) - ); - -static GstElement *sinkelement = NULL; -static GstPad *srcpad = NULL; - -#define PAD_FUNC(name, type, param, check) \ - static gpointer do_##name##_func (type * param) { \ - fail_unless (gst_pad_##name (srcpad, param) == check); \ - return NULL; \ -} - -/* *INDENT-OFF* */ -PAD_FUNC (peer_query, GstQuery, query, TRUE) -PAD_FUNC (push, GstBuffer, buf, GST_FLOW_OK) -/* *INDENT-ON* */ - -/* On OSX it's required to have a main loop running in the - * main thread while using the display connection. - * So the call that use this display connection needs to be - * done in another thread. - * On other platforms a direct call can be done. */ -#ifdef __APPLE__ -static GMainLoop *loop; -static GThread *thread; -static GMutex lock; -static GCond cond; - -static gboolean -_unlock_mutex (gpointer * unused) -{ - g_cond_broadcast (&cond); - g_mutex_unlock (&lock); - - return G_SOURCE_REMOVE; -} - -static gpointer -_thread_main (gpointer * unused) -{ - g_mutex_lock (&lock); - g_idle_add ((GSourceFunc) _unlock_mutex, NULL); - - g_main_loop_run (loop); - - g_main_loop_unref (loop); - loop = NULL; - - return NULL; -} - -static void -_start_thread (void) -{ - loop = g_main_loop_new (NULL, FALSE); - g_mutex_init (&lock); - g_cond_init (&cond); - - thread = g_thread_new ("GLOSXTestThread", (GThreadFunc) _thread_main, NULL); - - g_mutex_lock (&lock); - while (!loop) { - g_cond_wait (&cond, &lock); - } - g_mutex_unlock (&lock); -} - -static void -_stop_thread (void) -{ - g_main_loop_quit (loop); - g_thread_join (thread); - - g_mutex_clear (&lock); - g_cond_clear (&cond); -} -#endif - -static void -setup_glimagesink (void) -{ - GstCaps *caps = NULL; - - sinkelement = gst_check_setup_element ("glimagesink"); - srcpad = gst_check_setup_src_pad (sinkelement, &srctemplate); - gst_pad_set_active (srcpad, TRUE); - - caps = - gst_caps_from_string - ("video/x-raw, width=320, height=240, format=RGBA, framerate=30/1"); - gst_check_setup_events (srcpad, sinkelement, caps, GST_FORMAT_TIME); - gst_caps_unref (caps); -} - -static void -cleanup_glimagesink (void) -{ - gst_element_set_state (sinkelement, GST_STATE_NULL); - gst_element_get_state (sinkelement, NULL, NULL, GST_CLOCK_TIME_NONE); - gst_pad_set_active (srcpad, FALSE); - gst_check_teardown_src_pad (sinkelement); - gst_check_teardown_element (sinkelement); -} - -/* Verify that glimagesink releases the buffers it currently - * owns, upon a drain query. */ -GST_START_TEST (test_query_drain) -{ - GstBuffer *buf = NULL; - GstBufferPool *originpool = NULL; - GstBufferPool *pool = NULL; - GstCaps *caps = NULL; - GstQuery *query = NULL; - GstStructure *config = NULL; - gint i = 0; - guint min = 0; - guint max = 0; - guint size = 0; - const gint maxbuffers = 4; - -#ifdef __APPLE__ - _start_thread (); -#endif - - /* GstBaseSink handles the drain query as well. */ - g_object_set (sinkelement, "enable-last-sample", TRUE, NULL); - - ASSERT_SET_STATE (sinkelement, GST_STATE_PLAYING, GST_STATE_CHANGE_ASYNC); - - caps = gst_pad_get_current_caps (srcpad); - fail_unless (gst_caps_is_fixed (caps)); - - /* Let's retrieve the GstGLBufferPool to change its min - * and max nb buffers. For that just send an allocation - * query and change the pool config. */ - query = gst_query_new_allocation (caps, TRUE); - do_peer_query_func (query); - - fail_unless (gst_query_get_n_allocation_pools (query) == 1); - - gst_query_parse_nth_allocation_pool (query, 0, &originpool, &size, &min, - &max); - fail_unless (originpool != NULL); - gst_query_unref (query); - - config = gst_buffer_pool_get_config (originpool); - gst_buffer_pool_config_set_params (config, caps, size, maxbuffers, - maxbuffers); - fail_unless (gst_buffer_pool_set_config (originpool, config)); - - /* The gl pool is setup and ready to be activated. */ - fail_unless (gst_buffer_pool_set_active (originpool, TRUE)); - - /* Let's build an upstream pool that will be feed with - * gl buffers. */ - pool = gst_buffer_pool_new (); - config = gst_buffer_pool_get_config (pool); - gst_buffer_pool_config_set_params (config, caps, size, maxbuffers, - maxbuffers); - fail_unless (gst_buffer_pool_set_config (pool, config)); - gst_caps_unref (caps); - - fail_unless (gst_buffer_pool_set_active (pool, TRUE)); - - /* Unpopulate the pool and forget about its initial buffers - * It is necessary because the pool has to know there are - * N outstanding buffers. */ - for (i = 0; i < maxbuffers; ++i) { - fail_unless (gst_buffer_pool_acquire_buffer (pool, &buf, - NULL) == GST_FLOW_OK); - gst_object_replace ((GstObject **) & buf->pool, NULL); - gst_buffer_unref (buf); - } - - /* Transfer buffers from the gl pool to the upstream pool. */ - for (i = 0; i < maxbuffers; ++i) { - fail_unless (gst_buffer_pool_acquire_buffer (originpool, &buf, - NULL) == GST_FLOW_OK); - gst_object_replace ((GstObject **) & buf->pool, (GstObject *) pool); - gst_buffer_unref (buf); - } - - /* Push a lot of buffers like if a real pipeline was running. */ - for (i = 0; i < 10 * maxbuffers; ++i) { - fail_unless (gst_buffer_pool_acquire_buffer (pool, &buf, - NULL) == GST_FLOW_OK); - do_push_func (buf); - } - - /* Claim back buffers to the upstream pool. This is the point - * of this unit test, i.e. this test checks that glimagesink - * releases the buffers it currently owns, upon drain query. */ - query = gst_query_new_drain (); - do_peer_query_func (query); - gst_query_unref (query); - - /* Transfer buffers back to the downstream pool to be release - * properly. This also make sure that all buffers are returned. - * Indeed gst_buffer_pool_acquire_buffer is blocking here and - * we have set a maximum. */ - for (i = 0; i < maxbuffers; ++i) { - fail_unless (gst_buffer_pool_acquire_buffer (pool, &buf, - NULL) == GST_FLOW_OK); - gst_object_replace ((GstObject **) & buf->pool, (GstObject *) originpool); - gst_buffer_unref (buf); - } - - fail_unless (gst_buffer_pool_set_active (originpool, FALSE)); - gst_object_unref (originpool); - - /* At this point the gl pool contains all its buffers. We can - * inactivate it to release the textures. Note that only the gl - * pool can release the textures properly because it has a - * reference on the gl context. */ - fail_unless (gst_buffer_pool_set_active (pool, FALSE)); - gst_object_unref (pool); - -#ifdef __APPLE__ - _stop_thread (); -#endif -} - -GST_END_TEST; - -static Suite * -glimagesink_suite (void) -{ - Suite *s = suite_create ("glimagesink"); - TCase *tc = tcase_create ("general"); - - tcase_set_timeout (tc, 5); - - tcase_add_checked_fixture (tc, setup_glimagesink, cleanup_glimagesink); - tcase_add_test (tc, test_query_drain); - suite_add_tcase (s, tc); - - return s; -} - -int -main (int argc, char **argv) -{ - Suite *s; - g_setenv ("GST_GL_XINITTHREADS", "1", TRUE); - gst_check_init (&argc, &argv); - s = glimagesink_suite (); - return gst_check_run_suite (s, "glimagesink", __FILE__); -} diff --git a/tests/check/libs/gstglcolorconvert.c b/tests/check/libs/gstglcolorconvert.c deleted file mode 100644 index 8553fe5e5..000000000 --- a/tests/check/libs/gstglcolorconvert.c +++ /dev/null @@ -1,265 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2014 Matthew Waters <matthew@centricular.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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <gst/check/gstcheck.h> - -#include <gst/gl/gl.h> -#include <gst/gl/gstglfuncs.h> - -#include <stdio.h> - -static GstGLDisplay *display; -static GstGLContext *context; -static GstGLWindow *window; -static GstGLColorConvert *convert; - -typedef struct _TestFrame -{ - gint width; - gint height; - GstVideoFormat v_format; - gchar *data[GST_VIDEO_MAX_PLANES]; -} TestFrame; - -#define IGNORE_MAGIC 0x05 - -static const gchar rgba_reorder_data[] = { 0x49, 0x24, 0x72, 0xff }; -static const gchar rgbx_reorder_data[] = { 0x49, 0x24, 0x72, IGNORE_MAGIC }; -static const gchar argb_reorder_data[] = { 0xff, 0x49, 0x24, 0x72 }; -static const gchar xrgb_reorder_data[] = { IGNORE_MAGIC, 0x49, 0x24, 0x72 }; -static const gchar rgb_reorder_data[] = { 0x49, 0x24, 0x72, IGNORE_MAGIC }; -static const gchar bgr_reorder_data[] = { 0x72, 0x24, 0x49, IGNORE_MAGIC }; -static const gchar bgra_reorder_data[] = { 0x72, 0x24, 0x49, 0xff }; -static const gchar bgrx_reorder_data[] = { 0x72, 0x24, 0x49, IGNORE_MAGIC }; -static const gchar abgr_reorder_data[] = { 0xff, 0x72, 0x24, 0x49 }; -static const gchar xbgr_reorder_data[] = { IGNORE_MAGIC, 0x72, 0x24, 0x49 }; - -static TestFrame test_rgba_reorder[] = { - {1, 1, GST_VIDEO_FORMAT_RGBA, {(gchar *) & rgba_reorder_data}}, - {1, 1, GST_VIDEO_FORMAT_RGBx, {(gchar *) & rgbx_reorder_data}}, - {1, 1, GST_VIDEO_FORMAT_ARGB, {(gchar *) & argb_reorder_data}}, - {1, 1, GST_VIDEO_FORMAT_xRGB, {(gchar *) & xrgb_reorder_data}}, - {1, 1, GST_VIDEO_FORMAT_BGRA, {(gchar *) & bgra_reorder_data}}, - {1, 1, GST_VIDEO_FORMAT_BGRx, {(gchar *) & bgrx_reorder_data}}, - {1, 1, GST_VIDEO_FORMAT_ABGR, {(gchar *) & abgr_reorder_data}}, - {1, 1, GST_VIDEO_FORMAT_xBGR, {(gchar *) & xbgr_reorder_data}}, - {1, 1, GST_VIDEO_FORMAT_RGB, {(gchar *) & rgb_reorder_data}}, - {1, 1, GST_VIDEO_FORMAT_BGR, {(gchar *) & bgr_reorder_data}}, -}; - -static void -setup (void) -{ - GError *error = NULL; - - display = gst_gl_display_new (); - context = gst_gl_context_new (display); - - gst_gl_context_create (context, 0, &error); - window = gst_gl_context_get_window (context); - - fail_if (error != NULL, "Error creating context: %s\n", - error ? error->message : "Unknown Error"); - - convert = gst_gl_color_convert_new (context); -} - -static void -_check_gl_error (GstGLContext * context, gpointer data) -{ - GLuint error = context->gl_vtable->GetError (); - fail_if (error != GL_NONE, "GL error 0x%x encountered during processing\n", - error); -} - -static void -teardown (void) -{ - gst_object_unref (convert); - gst_object_unref (window); - - gst_gl_context_thread_add (context, (GstGLContextThreadFunc) _check_gl_error, - NULL); - gst_object_unref (context); - gst_object_unref (display); -} - -static gsize -_video_info_plane_size (GstVideoInfo * info, guint plane) -{ - if (GST_VIDEO_INFO_N_PLANES (info) == plane + 1) - return info->offset[0] + info->size - info->offset[plane]; - - return info->offset[plane + 1] - info->offset[plane]; -} - -static void -_frame_unref (gpointer user_data) -{ - gint *ref_count = user_data; - g_atomic_int_add (ref_count, -1); -} - -static void -check_conversion (TestFrame * frames, guint size) -{ - GstGLBaseMemoryAllocator *base_mem_alloc; - gint i, j, k, l; - gint ref_count = 0; - - base_mem_alloc = - GST_GL_BASE_MEMORY_ALLOCATOR (gst_allocator_find - (GST_GL_MEMORY_ALLOCATOR_NAME)); - - for (i = 0; i < size; i++) { - GstBuffer *inbuf; - GstVideoInfo in_info; - gint in_width = frames[i].width; - gint in_height = frames[i].height; - GstVideoFormat in_v_format = frames[i].v_format; - GstVideoFrame in_frame; - GstCaps *in_caps; - - gst_video_info_set_format (&in_info, in_v_format, in_width, in_height); - in_caps = gst_video_info_to_caps (&in_info); - gst_caps_set_features (in_caps, 0, - gst_caps_features_from_string (GST_CAPS_FEATURE_MEMORY_GL_MEMORY)); - - /* create GL buffer */ - inbuf = gst_buffer_new (); - for (j = 0; j < GST_VIDEO_INFO_N_PLANES (&in_info); j++) { - GstGLFormat tex_format = gst_gl_format_from_video_info (context, - &in_info, j); - GstGLVideoAllocationParams *params; - GstGLBaseMemory *mem; - - ref_count++; - params = gst_gl_video_allocation_params_new_wrapped_data (context, NULL, - &in_info, j, NULL, GST_GL_TEXTURE_TARGET_2D, tex_format, - frames[i].data[j], &ref_count, _frame_unref); - - mem = gst_gl_base_memory_alloc (base_mem_alloc, - (GstGLAllocationParams *) params); - gst_buffer_append_memory (inbuf, GST_MEMORY_CAST (mem)); - - gst_gl_allocation_params_free ((GstGLAllocationParams *) params); - } - - fail_unless (gst_video_frame_map (&in_frame, &in_info, inbuf, - GST_MAP_READ)); - - /* sanity check that the correct values were wrapped */ - for (j = 0; j < GST_VIDEO_INFO_N_PLANES (&in_info); j++) { - for (k = 0; k < _video_info_plane_size (&in_info, j); k++) { - if (frames[i].data[j][k] != IGNORE_MAGIC) - fail_unless (((gchar *) in_frame.data[j])[k] == frames[i].data[j][k]); - } - } - - for (j = 0; j < size; j++) { - GstBuffer *outbuf; - GstVideoInfo out_info; - gint out_width = frames[j].width; - gint out_height = frames[j].height; - GstVideoFormat out_v_format = frames[j].v_format; - gchar *out_data[GST_VIDEO_MAX_PLANES] = { 0 }; - GstVideoFrame out_frame; - GstCaps *out_caps; - - gst_video_info_set_format (&out_info, out_v_format, out_width, - out_height); - out_caps = gst_video_info_to_caps (&out_info); - gst_caps_set_features (out_caps, 0, - gst_caps_features_from_string (GST_CAPS_FEATURE_MEMORY_GL_MEMORY)); - - for (k = 0; k < GST_VIDEO_INFO_N_PLANES (&out_info); k++) { - out_data[k] = frames[j].data[k]; - } - - gst_gl_color_convert_set_caps (convert, in_caps, out_caps); - - /* convert the data */ - outbuf = gst_gl_color_convert_perform (convert, inbuf); - if (outbuf == NULL) { - const gchar *in_str = gst_video_format_to_string (in_v_format); - const gchar *out_str = gst_video_format_to_string (out_v_format); - GST_WARNING ("failed to convert from %s to %s", in_str, out_str); - } - - fail_unless (gst_video_frame_map (&out_frame, &out_info, outbuf, - GST_MAP_READ)); - - /* check that the converted values are correct */ - for (k = 0; k < GST_VIDEO_INFO_N_PLANES (&out_info); k++) { - for (l = 0; l < _video_info_plane_size (&out_info, k); l++) { - gchar out_pixel = ((gchar *) out_frame.data[k])[l]; - if (out_data[k][l] != IGNORE_MAGIC && out_pixel != IGNORE_MAGIC) - fail_unless (out_pixel == out_data[k][l]); - /* FIXME: check alpha clobbering */ - } - } - - gst_caps_unref (out_caps); - gst_video_frame_unmap (&out_frame); - gst_buffer_unref (outbuf); - } - - gst_caps_unref (in_caps); - gst_video_frame_unmap (&in_frame); - gst_buffer_unref (inbuf); - - fail_unless_equals_int (ref_count, 0); - } - - gst_object_unref (base_mem_alloc); -} - -GST_START_TEST (test_reorder_buffer) -{ - guint size = G_N_ELEMENTS (test_rgba_reorder); - - /* gles can't download rgb24 textures */ - if (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES2) - size -= 2; - - check_conversion (test_rgba_reorder, size); -} - -GST_END_TEST; - -static Suite * -gst_gl_color_convert_suite (void) -{ - Suite *s = suite_create ("GstGLColorConvert"); - TCase *tc_chain = tcase_create ("upload"); - - suite_add_tcase (s, tc_chain); - tcase_add_checked_fixture (tc_chain, setup, teardown); - tcase_add_test (tc_chain, test_reorder_buffer); - /* FIXME add YUV <--> RGB conversion tests */ - - return s; -} - -GST_CHECK_MAIN (gst_gl_color_convert); diff --git a/tests/check/libs/gstglcontext.c b/tests/check/libs/gstglcontext.c deleted file mode 100644 index 37bac2ca5..000000000 --- a/tests/check/libs/gstglcontext.c +++ /dev/null @@ -1,662 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2013 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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <gst/check/gstcheck.h> - -#include <gst/gl/gl.h> -#include <gst/gl/gstglfuncs.h> - -#include <stdio.h> - -static GstGLDisplay *display; - -static void -setup (void) -{ - display = gst_gl_display_new (); -} - -static void -teardown (void) -{ - gst_object_unref (display); -} - -static GstGLMemory *gl_tex, *gl_tex2; -static GLuint vbo, vbo_indices, vao; -static GstGLFramebuffer *fbo, *fbo2; -static GstGLShader *shader; -static GLint shader_attr_position_loc; -static GLint shader_attr_texture_loc; - -static const GLfloat vertices[] = { - /* x, y, z, s, t */ - 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, - -1.0f, 1.0f, 0.0f, 0.0f, 0.0f, - -1.0f, -1.0f, 0.0f, 0.0f, 1.0f, - 1.0f, -1.0f, 0.0f, 1.0f, 1.0f -}; - -static const GLushort indices[] = { 0, 1, 2, 0, 2, 3 }; - -static void -init (gpointer data) -{ - GstGLContext *context = data; - GError *error = NULL; - GstVideoInfo v_info; - GstGLMemoryAllocator *allocator; - GstGLVideoAllocationParams *params; - - gst_video_info_set_format (&v_info, GST_VIDEO_FORMAT_RGBA, 320, 240); - allocator = gst_gl_memory_allocator_get_default (context); - params = - gst_gl_video_allocation_params_new (context, NULL, &v_info, 0, NULL, - GST_GL_TEXTURE_TARGET_2D, GST_GL_RGBA); - - /* has to be called in the thread that is going to use the framebuffer */ - fbo = gst_gl_framebuffer_new_with_default_depth (context, 320, 240); - - fail_if (fbo == NULL, "failed to create framebuffer object"); - - gl_tex = - (GstGLMemory *) gst_gl_base_memory_alloc ((GstGLBaseMemoryAllocator *) - allocator, (GstGLAllocationParams *) params); - gl_tex2 = - (GstGLMemory *) gst_gl_base_memory_alloc ((GstGLBaseMemoryAllocator *) - allocator, (GstGLAllocationParams *) params); - gst_object_unref (allocator); - gst_gl_allocation_params_free ((GstGLAllocationParams *) params); - fail_if (gl_tex == NULL, "failed to create texture"); - - shader = gst_gl_shader_new_default (context, &error); - fail_if (shader == NULL, "failed to create shader object: %s", - error->message); - - shader_attr_position_loc = - gst_gl_shader_get_attribute_location (shader, "a_position"); - shader_attr_texture_loc = - gst_gl_shader_get_attribute_location (shader, "a_texcoord"); -} - -static void -deinit (gpointer data) -{ - GstGLContext *context = data; - GstGLFuncs *gl = context->gl_vtable; - if (vao) - gl->DeleteVertexArrays (1, &vao); - gst_object_unref (fbo); - gst_object_unref (shader); - gst_memory_unref (GST_MEMORY_CAST (gl_tex)); - gst_memory_unref (GST_MEMORY_CAST (gl_tex2)); -} - -static gboolean -clear_tex (gpointer data) -{ - GstGLContext *context = data; - GstGLFuncs *gl = context->gl_vtable; - static gfloat r = 0.0, g = 0.0, b = 0.0; - - gl->ClearColor (r, g, b, 1.0); - gl->Clear (GL_COLOR_BUFFER_BIT); - - r = r > 1.0 ? 0.0 : r + 0.03; - g = g > 1.0 ? 0.0 : g + 0.01; - b = b > 1.0 ? 0.0 : b + 0.015; - - return TRUE; -} - -static void -draw_tex (gpointer data) -{ - gst_gl_framebuffer_draw_to_texture (fbo, gl_tex, - (GstGLFramebufferFunc) clear_tex, data); -} - -static void -_bind_buffer (GstGLContext * context) -{ - const GstGLFuncs *gl = context->gl_vtable; - - gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, vbo_indices); - gl->BindBuffer (GL_ARRAY_BUFFER, vbo); - - /* Load the vertex position */ - gl->VertexAttribPointer (shader_attr_position_loc, 3, GL_FLOAT, GL_FALSE, - 5 * sizeof (GLfloat), (void *) 0); - - /* Load the texture coordinate */ - gl->VertexAttribPointer (shader_attr_texture_loc, 2, GL_FLOAT, GL_FALSE, - 5 * sizeof (GLfloat), (void *) (3 * sizeof (GLfloat))); - - gl->EnableVertexAttribArray (shader_attr_position_loc); - gl->EnableVertexAttribArray (shader_attr_texture_loc); -} - -static void -_unbind_buffer (GstGLContext * context) -{ - const GstGLFuncs *gl = context->gl_vtable; - - gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0); - gl->BindBuffer (GL_ARRAY_BUFFER, 0); - - gl->DisableVertexAttribArray (shader_attr_position_loc); - gl->DisableVertexAttribArray (shader_attr_texture_loc); -} - -static void -init_blit (gpointer data) -{ - GstGLContext *context = data; - const GstGLFuncs *gl = context->gl_vtable; - - if (!vbo) { - if (gl->GenVertexArrays) { - gl->GenVertexArrays (1, &vao); - gl->BindVertexArray (vao); - } - - gl->GenBuffers (1, &vbo); - gl->BindBuffer (GL_ARRAY_BUFFER, vbo); - gl->BufferData (GL_ARRAY_BUFFER, 4 * 5 * sizeof (GLfloat), vertices, - GL_STATIC_DRAW); - - gl->GenBuffers (1, &vbo_indices); - gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, vbo_indices); - gl->BufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (indices), indices, - GL_STATIC_DRAW); - - if (gl->GenVertexArrays) { - _bind_buffer (context); - gl->BindVertexArray (0); - } - - gl->BindBuffer (GL_ARRAY_BUFFER, 0); - gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0); - } - /* has to be called in the thread that is going to use the framebuffer */ - fbo2 = gst_gl_framebuffer_new_with_default_depth (context, 320, 240); - - fail_if (fbo2 == NULL, "failed to create framebuffer object"); -} - -static void -deinit_blit (gpointer data) -{ - GstGLContext *context = data; - const GstGLFuncs *gl = context->gl_vtable; - - if (vbo) - gl->DeleteBuffers (1, &vbo); - vbo = 0; - if (vbo_indices) - gl->DeleteBuffers (1, &vbo_indices); - vbo_indices = 0; - if (vao) - gl->DeleteVertexArrays (1, &vao); - vao = 0; - gst_object_unref (fbo2); - fbo2 = NULL; -} - -static gboolean -blit_tex (gpointer data) -{ - GstGLContext *context = data; - const GstGLFuncs *gl = context->gl_vtable; - - gl->Clear (GL_COLOR_BUFFER_BIT); - - gst_gl_shader_use (shader); - - gl->ActiveTexture (GL_TEXTURE0); - gl->BindTexture (GL_TEXTURE_2D, gst_gl_memory_get_texture_id (gl_tex)); - gst_gl_shader_set_uniform_1i (shader, "s_texture", 0); - - if (gl->GenVertexArrays) - gl->BindVertexArray (vao); - _bind_buffer (context); - - gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); - - if (gl->GenVertexArrays) - gl->BindVertexArray (0); - _unbind_buffer (context); - - return TRUE; -} - -static void -draw_render (gpointer data) -{ - gst_gl_framebuffer_draw_to_texture (fbo2, gl_tex2, - (GstGLFramebufferFunc) blit_tex, data); -} - -GST_START_TEST (test_share) -{ - GstGLContext *context; - GstGLWindow *window; - GstGLContext *other_context; - GstGLWindow *other_window; - GError *error = NULL; - gint i = 0; - - context = gst_gl_context_new (display); - - window = gst_gl_window_new (display); - gst_gl_context_set_window (context, window); - - gst_gl_context_create (context, 0, &error); - - fail_if (error != NULL, "Error creating master context %s\n", - error ? error->message : "Unknown Error"); - - other_window = gst_gl_window_new (display); - - other_context = gst_gl_context_new (display); - gst_gl_context_set_window (other_context, other_window); - - gst_gl_context_create (other_context, context, &error); - - fail_if (error != NULL, "Error creating secondary context %s\n", - error ? error->message : "Unknown Error"); - - /* make the window visible */ - gst_gl_window_set_preferred_size (window, 320, 240); - gst_gl_window_draw (window); - - gst_gl_window_send_message (other_window, GST_GL_WINDOW_CB (init), - other_context); - gst_gl_window_send_message (window, GST_GL_WINDOW_CB (init_blit), context); - - while (i < 10) { - gst_gl_window_send_message (other_window, GST_GL_WINDOW_CB (draw_tex), - context); - gst_gl_window_send_message (window, GST_GL_WINDOW_CB (draw_render), - context); - i++; - } - - gst_gl_window_send_message (other_window, GST_GL_WINDOW_CB (deinit), - other_context); - gst_gl_window_send_message (window, GST_GL_WINDOW_CB (deinit_blit), context); - - gst_object_unref (window); - gst_object_unref (other_window); - gst_object_unref (other_context); - gst_object_unref (context); -} - -GST_END_TEST; - -static void -accum_true (GstGLContext * context, gpointer data) -{ - gint *i = data; - *i = 1; -} - -static void -check_wrapped (gpointer data) -{ - GstGLContext *wrapped_context = data; - GError *error = NULL; - gint i = 0; - gboolean ret; - - /* check that scheduling on an unactivated wrapped context asserts */ - ASSERT_CRITICAL (gst_gl_context_thread_add (wrapped_context, - (GstGLContextThreadFunc) accum_true, &i)); - fail_if (i != 0); - - /* check that scheduling on an activated context succeeds */ - gst_gl_context_activate (wrapped_context, TRUE); - gst_gl_context_thread_add (wrapped_context, - (GstGLContextThreadFunc) accum_true, &i); - fail_if (i != 1); - - /* check filling out the wrapped context's info */ - fail_if (wrapped_context->gl_vtable->TexImage2D != NULL); - ret = gst_gl_context_fill_info (wrapped_context, &error); - fail_if (!ret, "error received %s\n", - error ? error->message : "Unknown error"); - fail_if (wrapped_context->gl_vtable->TexImage2D == NULL); - gst_gl_context_activate (wrapped_context, FALSE); -} - -GST_START_TEST (test_wrapped_context) -{ - GstGLContext *context, *other_context, *wrapped_context; - GstGLWindow *window, *other_window; - GError *error = NULL; - gint i = 0; - guintptr handle, handle2; - GstGLPlatform platform, platform2; - GstGLAPI apis, apis2; - - context = gst_gl_context_new (display); - - window = gst_gl_window_new (display); - gst_gl_context_set_window (context, window); - - gst_gl_context_create (context, 0, &error); - - fail_if (error != NULL, "Error creating master context %s\n", - error ? error->message : "Unknown Error"); - - handle = gst_gl_context_get_gl_context (context); - platform = gst_gl_context_get_gl_platform (context); - apis = gst_gl_context_get_gl_api (context); - - wrapped_context = - gst_gl_context_new_wrapped (display, handle, platform, apis); - - handle2 = gst_gl_context_get_gl_context (wrapped_context); - platform2 = gst_gl_context_get_gl_platform (wrapped_context); - apis2 = gst_gl_context_get_gl_api (wrapped_context); - - fail_if (handle != handle2); - fail_if (platform != platform2); - fail_if (apis != apis2); - - other_context = gst_gl_context_new (display); - other_window = gst_gl_window_new (display); - gst_gl_context_set_window (other_context, other_window); - - gst_gl_context_create (other_context, wrapped_context, &error); - - fail_if (error != NULL, "Error creating secondary context %s\n", - error ? error->message : "Unknown Error"); - - gst_gl_window_set_preferred_size (window, 320, 240); - gst_gl_window_draw (window); - - gst_gl_window_send_message (other_window, GST_GL_WINDOW_CB (init), - other_context); - gst_gl_window_send_message (window, GST_GL_WINDOW_CB (init_blit), context); - - while (i < 10) { - gst_gl_window_send_message (other_window, GST_GL_WINDOW_CB (draw_tex), - context); - gst_gl_window_send_message (window, GST_GL_WINDOW_CB (draw_render), - context); - i++; - } - - gst_gl_window_send_message (window, GST_GL_WINDOW_CB (check_wrapped), - wrapped_context); - - gst_gl_window_send_message (other_window, GST_GL_WINDOW_CB (deinit), - other_context); - gst_gl_window_send_message (window, GST_GL_WINDOW_CB (deinit_blit), context); - - gst_object_unref (other_context); - gst_object_unref (other_window); - gst_object_unref (window); - gst_object_unref (context); - gst_object_unref (wrapped_context); -} - -GST_END_TEST; - -struct context_info -{ - GstGLAPI api; - guint major; - guint minor; - GstGLPlatform platform; - guintptr handle; -}; - -static void -_fill_context_info (GstGLContext * context, struct context_info *info) -{ - info->handle = gst_gl_context_get_current_gl_context (info->platform); - info->api = - gst_gl_context_get_current_gl_api (info->platform, &info->major, - &info->minor); -} - -GST_START_TEST (test_current_context) -{ - GstGLContext *context; - GError *error = NULL; - guintptr handle; - GstGLPlatform platform; - GstGLAPI api; - gint major, minor; - struct context_info info; - - context = gst_gl_context_new (display); - - gst_gl_context_create (context, 0, &error); - - fail_if (error != NULL, "Error creating master context %s\n", - error ? error->message : "Unknown Error"); - - handle = gst_gl_context_get_gl_context (context); - platform = gst_gl_context_get_gl_platform (context); - api = gst_gl_context_get_gl_api (context); - gst_gl_context_get_gl_version (context, &major, &minor); - - info.platform = platform; - - gst_gl_context_thread_add (context, - (GstGLContextThreadFunc) _fill_context_info, &info); - - fail_if (info.platform != platform); - fail_if (info.api != api); - fail_if (info.major != major); - fail_if (info.minor != minor); - fail_if (info.handle != handle); - - gst_object_unref (context); -} - -GST_END_TEST; - -GST_START_TEST (test_context_can_share) -{ - GstGLContext *c1, *c2, *c3; - GError *error = NULL; - - c1 = gst_gl_context_new (display); - gst_gl_context_create (c1, NULL, &error); - fail_if (error != NULL, "Error creating context %s\n", - error ? error->message : "Unknown Error"); - - c2 = gst_gl_context_new (display); - gst_gl_context_create (c2, c1, &error); - fail_if (error != NULL, "Error creating context %s\n", - error ? error->message : "Unknown Error"); - - fail_unless (gst_gl_context_can_share (c1, c2)); - fail_unless (gst_gl_context_can_share (c2, c1)); - - c3 = gst_gl_context_new (display); - gst_gl_context_create (c3, c2, &error); - fail_if (error != NULL, "Error creating context %s\n", - error ? error->message : "Unknown Error"); - - fail_unless (gst_gl_context_can_share (c1, c3)); - fail_unless (gst_gl_context_can_share (c3, c1)); - fail_unless (gst_gl_context_can_share (c2, c3)); - fail_unless (gst_gl_context_can_share (c3, c2)); - - /* destroy the middle context */ - gst_object_unref (c2); - c2 = NULL; - - fail_unless (gst_gl_context_can_share (c1, c3)); - fail_unless (gst_gl_context_can_share (c3, c1)); - - gst_object_unref (c1); - gst_object_unref (c3); -} - -GST_END_TEST; - -GST_START_TEST (test_is_shared) -{ - GstGLContext *c1, *c2; - GError *error = NULL; - - c1 = gst_gl_context_new (display); - gst_gl_context_create (c1, NULL, &error); - fail_if (error != NULL, "Error creating context %s\n", - error ? error->message : "Unknown Error"); - - c2 = gst_gl_context_new (display); - gst_gl_context_create (c2, c1, &error); - fail_if (error != NULL, "Error creating context %s\n", - error ? error->message : "Unknown Error"); - - fail_unless (gst_gl_context_is_shared (c1)); - fail_unless (gst_gl_context_is_shared (c2)); - - gst_object_unref (c2); - c2 = NULL; - - fail_unless (!gst_gl_context_is_shared (c1)); - - gst_object_unref (c1); -} - -GST_END_TEST; - -GST_START_TEST (test_display_list) -{ - GstGLContext *c1, *c2; - GError *error = NULL; - - c1 = gst_gl_context_new (display); - gst_gl_context_create (c1, NULL, &error); - fail_if (error != NULL, "Error creating context %s\n", - error ? error->message : "Unknown Error"); - - GST_OBJECT_LOCK (display); - { - /* no context added so get should return NULL */ - GstGLContext *tmp = - gst_gl_display_get_gl_context_for_thread (display, NULL); - fail_unless (tmp == NULL); - } - - fail_unless (gst_gl_display_add_context (display, c1)); - /* re-adding the same context is a no-op */ - fail_unless (gst_gl_display_add_context (display, c1)); - - { - GThread *thread; - GstGLContext *tmp; - - thread = gst_gl_context_get_thread (c1); - fail_unless (thread != NULL); - - tmp = gst_gl_display_get_gl_context_for_thread (display, thread); - fail_unless (tmp == c1); - g_thread_unref (thread); - gst_object_unref (tmp); - - tmp = gst_gl_display_get_gl_context_for_thread (display, NULL); - fail_unless (tmp == c1); - gst_object_unref (tmp); - } - - c2 = gst_gl_context_new (display); - gst_gl_context_create (c2, c1, &error); - fail_if (error != NULL, "Error creating context %s\n", - error ? error->message : "Unknown Error"); - - fail_unless (gst_gl_display_add_context (display, c2)); - /* re-adding the same context is a no-op */ - fail_unless (gst_gl_display_add_context (display, c2)); - - { - GThread *thread; - GstGLContext *tmp; - - thread = gst_gl_context_get_thread (c2); - fail_unless (thread != NULL); - - tmp = gst_gl_display_get_gl_context_for_thread (display, thread); - fail_unless (tmp == c2); - g_thread_unref (thread); - gst_object_unref (tmp); - - /* undefined which context will be returned for the NULL thread */ - tmp = gst_gl_display_get_gl_context_for_thread (display, NULL); - fail_unless (tmp != NULL); - gst_object_unref (tmp); - } - - gst_object_unref (c1); - /* c1 is now dead */ - - { - GstGLContext *tmp; - - tmp = gst_gl_display_get_gl_context_for_thread (display, NULL); - fail_unless (tmp == c2); - gst_object_unref (tmp); - } - GST_OBJECT_UNLOCK (display); - - gst_object_unref (c2); - /* c2 is now dead */ - - { - /* no more contexts alive */ - GstGLContext *tmp = - gst_gl_display_get_gl_context_for_thread (display, NULL); - fail_unless (tmp == NULL); - } -} - -GST_END_TEST; - -static Suite * -gst_gl_context_suite (void) -{ - Suite *s = suite_create ("GstGLContext"); - 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_share); - tcase_add_test (tc_chain, test_wrapped_context); - tcase_add_test (tc_chain, test_current_context); - tcase_add_test (tc_chain, test_context_can_share); - tcase_add_test (tc_chain, test_is_shared); - tcase_add_test (tc_chain, test_display_list); - - return s; -} - -GST_CHECK_MAIN (gst_gl_context); diff --git a/tests/check/libs/gstglheaders.c b/tests/check/libs/gstglheaders.c deleted file mode 100644 index 5c359368c..000000000 --- a/tests/check/libs/gstglheaders.c +++ /dev/null @@ -1,173 +0,0 @@ -/* GStreamer - * - * unit test for state changes on all elements - * - * Copyright (C) <2017> Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -/* This test check that public gstgl headers does not include any - * GL headers. Except for gst/gl/gstglfuncs.h */ - -#include <gst/check/gstcheck.h> - -#include <gst/gl/gstgl_enums.h> -#include <gst/gl/gstglapi.h> -#include <gst/gl/gstglbasefilter.h> -#include <gst/gl/gstglbuffer.h> -#include <gst/gl/gstglbufferpool.h> -#include <gst/gl/gstglcolorconvert.h> -#include <gst/gl/gstglconfig.h> -#include <gst/gl/gstglcontext.h> -#include <gst/gl/gstgldebug.h> -#include <gst/gl/gstgldisplay.h> -#include <gst/gl/gstglfeature.h> -#include <gst/gl/gstglfilter.h> -#include <gst/gl/gstglformat.h> -#include <gst/gl/gstglframebuffer.h> -#include <gst/gl/gstglsl.h> -#include <gst/gl/gstglslstage.h> -#include <gst/gl/gstglmemory.h> -#include <gst/gl/gstglmemorypbo.h> -#include <gst/gl/gstglquery.h> -#include <gst/gl/gstgloverlaycompositor.h> -#include <gst/gl/gstglrenderbuffer.h> -#include <gst/gl/gstglshader.h> -#include <gst/gl/gstglshaderstrings.h> -#include <gst/gl/gstglsyncmeta.h> -#include <gst/gl/gstglupload.h> -#include <gst/gl/gstglutils.h> -#include <gst/gl/gstglviewconvert.h> -#include <gst/gl/gstglwindow.h> - -#if GST_GL_HAVE_PLATFORM_EGL -#include <gst/gl/egl/gstgldisplay_egl.h> -#include <gst/gl/egl/gstglcontext_egl.h> -#include <gst/gl/egl/gstglmemoryegl.h> -#endif - -#if GST_GL_HAVE_PLATFORM_X11 -#include <gst/gl/x11/gstgldisplay_x11.h> -#include <gst/gl/x11/gstglwindow_x11.h> -#endif - -#include <gst/gl/gl.h> - -#if defined(GLint) || defined(GLAPI) || defined(GL_GLEXT_VERSION) -#error gl headers should not be included -#endif - -#if defined(EGLint) || defined(EGLBoolean) || defined(EGLAPI) -#error egl headers should not be included -#endif - -static GstGLDisplay *display; -static GstGLContext *context; - -static void -setup (void) -{ - display = gst_gl_display_new (); - context = gst_gl_context_new (display); - gst_gl_context_create (context, 0, NULL); - gst_gl_buffer_init_once (); - gst_gl_memory_init_once (); - gst_gl_memory_pbo_init_once (); - gst_gl_renderbuffer_init_once (); -} - -static void -teardown (void) -{ - gst_object_unref (context); - gst_object_unref (display); -} - -GST_START_TEST (test_constructors) -{ - GstBufferPool *pool = NULL; - GstGLShader *shader = NULL; - GstGLSLStage *stage = NULL; - GstGLColorConvert *convert = NULL; - GstGLOverlayCompositor *compositor = NULL; - GstGLUpload *upload = NULL; - - pool = gst_gl_buffer_pool_new (context); - fail_if (pool == NULL); - gst_object_unref (pool); - - shader = gst_gl_shader_new (context); - fail_if (shader == NULL); - gst_object_unref (shader); - - stage = gst_glsl_stage_new_default_fragment (context); - fail_if (stage == NULL); - gst_object_unref (stage); - - convert = gst_gl_color_convert_new (context); - fail_if (convert == NULL); - gst_object_unref (convert); - - compositor = gst_gl_overlay_compositor_new (context); - fail_if (compositor == NULL); - gst_object_unref (compositor); - - upload = gst_gl_upload_new (context); - fail_if (upload == NULL); - gst_object_unref (upload); -} - -GST_END_TEST; - -GST_START_TEST (test_constructors_require_activated_context) -{ - gboolean ret = FALSE; - GstGLFramebuffer *framebuffer = NULL; - - ret = gst_gl_context_activate (context, TRUE); - fail_if (!ret); - - framebuffer = gst_gl_framebuffer_new (context); - fail_if (framebuffer == NULL); - gst_object_unref (framebuffer); - - ret = gst_gl_context_activate (context, FALSE); - fail_if (!ret); -} - -GST_END_TEST; - - -static Suite * -gst_gl_headers_suite (void) -{ - Suite *s = suite_create ("Gst GL Headers"); - 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_constructors); - tcase_add_test (tc_chain, test_constructors_require_activated_context); - - return s; -} - -GST_CHECK_MAIN (gst_gl_headers); diff --git a/tests/check/libs/gstglmatrix.c b/tests/check/libs/gstglmatrix.c deleted file mode 100644 index eb7a57e97..000000000 --- a/tests/check/libs/gstglmatrix.c +++ /dev/null @@ -1,262 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2014 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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <gst/gl/gstglutils.c> -#undef GST_CAT_DEFAULT -#include <gst/check/gstcheck.h> - -#define EPSILON 0.0001f -#define FEQ(a,b) (fabs(a-b) < EPSILON) - -static void -debug_matrix (const float *m) -{ - int i; - for (i = 0; i < 4; i++) { - GST_DEBUG ("%10.4f %10.4f %10.4f %10.4f", m[i * 4 + 0], m[i * 4 + 1], - m[i * 4 + 2], m[i * 4 + 3]); - } -} - -GST_START_TEST (test_matrix_multiply) -{ - /* A * B == C */ - const float A[] = { - 1., 1., 2., 5., - 0., 3., 0., 1., - 2., 0., 3., 1., - 3., 2., 1., 0., - }; - - const float B[] = { - 3., 1., 0., 2., - 1., 0., 3., 2., - 0., 1., 2., 3., - 3., 2., 1., 0., - }; - - const float C[] = { - 19., 13., 12., 10., - 6., 2., 10., 6., - 9., 7., 7., 13., - 11., 4., 8., 13., - }; - - float res[16]; - int i; - - gst_gl_multiply_matrix4 (A, B, res); - GST_DEBUG ("result"); - debug_matrix (res); - - for (i = 0; i < G_N_ELEMENTS (res); i++) { - fail_unless (FEQ (res[i], C[i]), "value %f at index %u does not match " - "expected value %f", res[i], i, C[i]); - } -} - -GST_END_TEST; - -GST_START_TEST (test_matrix_ndc) -{ - GstBuffer *buffer = gst_buffer_new (); - GstVideoAffineTransformationMeta *aff_meta; - float res[16]; - int i; - - const float m[] = { - 1., 0., 0., 0., - 0., 1., 0., 0., - 0., 0., 1., 0., - 0., 0., 0., 1., - }; - - const float n[] = { - 4., 6., 4., 9., - 1., 5., 8., 2., - 9., 3., 5., 8., - 3., 7., 9., 1., - }; - - aff_meta = gst_buffer_add_video_affine_transformation_meta (buffer); - - /* test default identity matrix */ - gst_gl_get_affine_transformation_meta_as_ndc (aff_meta, res); - GST_DEBUG ("result"); - debug_matrix (res); - - for (i = 0; i < G_N_ELEMENTS (res); i++) { - fail_unless (FEQ (res[i], m[i]), "value %f at index %u does not match " - "expected value %f", res[i], i, m[i]); - } - - /* test setting and receiving the same values */ - gst_gl_set_affine_transformation_meta_from_ndc (aff_meta, n); - gst_gl_get_affine_transformation_meta_as_ndc (aff_meta, res); - - GST_DEBUG ("result"); - debug_matrix (res); - - for (i = 0; i < G_N_ELEMENTS (res); i++) { - fail_unless (FEQ (res[i], n[i]), "value %f at index %u does not match " - "expected value %f", res[i], i, n[i]); - } - - gst_buffer_unref (buffer); -} - -GST_END_TEST; -#if 0 -static void -transpose_matrix4 (float *m, float *res) -{ - int i, j; - - for (i = 0; i < 4; i++) { - for (j = 0; j < 4; j++) { - int idx = i + (j * 4); - int swapped_idx = j + (i * 4); - - if (i == j) - fail_unless (idx == swapped_idx); - - res[swapped_idx] = m[idx]; - } - } -} - -static float -dot4 (float *v1, float *v2) -{ - GST_TRACE ("%.4f * %.4f + %.4f * %.4f + %.4f * %.4f + %.4f * %.4f", - v1[0], v2[0], v1[1], v2[1], v1[2], v2[2], v1[3], v2[3]); - return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2] + v1[3] * v2[3]; -} - -/* m * v */ -static void -_matrix_mult_vertex4 (float *m, float *v, float *res) -{ - res[0] = dot4 (&m[0], v); - res[1] = dot4 (&m[4], v); - res[2] = dot4 (&m[8], v); - res[3] = dot4 (&m[12], v); -} - -/* v * m */ -static void -_vertex_mult_matrix4 (float *v, float *m, float *res) -{ - float tmp[16] = { 0., }; - - transpose_matrix4 (m, tmp); - _matrix_mult_vertex4 (tmp, v, res); -} - -GST_START_TEST (test_matrix_vertex_identity) -{ - float identity[] = { - 1., 0., 0., 0., - 0., 1., 0., 0., - 0., 0., 1., 0., - 0., 0., 0., 1., - }; - - float v[] = { 1., 1., 1., 1. }; - float res[4] = { 0., }; - int i; - - _vertex_mult_matrix4 (v, identity, res); - GST_DEBUG ("vertex: %.4f %.4f %.4f %.4f", v[0], v[1], v[2], v[3]); - GST_DEBUG ("result: %.4f %.4f %.4f %.4f", res[0], res[1], res[2], res[3]); - - for (i = 0; i < 4; i++) { - fail_unless (FEQ (res[i], v[i]), "value %f at index %u does not match " - "expected value %f", res[i], i, v[i]); - } - - _matrix_mult_vertex4 (identity, v, res); - GST_DEBUG ("vertex: %.4f %.4f %.4f %.4f", v[0], v[1], v[2], v[3]); - GST_DEBUG ("result: %.4f %.4f %.4f %.4f", res[0], res[1], res[2], res[3]); - - for (i = 0; i < 4; i++) { - fail_unless (FEQ (res[i], v[i]), "value %f at index %u does not match " - "expected value %f", res[i], i, v[i]); - } -} - -GST_END_TEST; - -GST_START_TEST (test_matrix_vertex_scale) -{ - float scale[] = { - 1.5, 0., 0., 0., - 0., 2.5, 0., 0., - 0., 0., 3., 0., - 0., 0., 0., 1., - }; - - float v[] = { 1., 1., 1., 1. }; - float expected[] = { 1.5, 2.5, 3., 1. }; - float res[4] = { 0., }; - int i; - - _vertex_mult_matrix4 (v, scale, res); - GST_DEBUG ("vertex: %.4f %.4f %.4f %.4f", v[0], v[1], v[2], v[3]); - GST_DEBUG ("result: %.4f %.4f %.4f %.4f", res[0], res[1], res[2], res[3]); - - for (i = 0; i < 4; i++) { - fail_unless (FEQ (res[i], expected[i]), - "value %f at index %u does not match " "expected value %f", res[i], i, - expected[i]); - } - - _matrix_mult_vertex4 (scale, v, res); - GST_DEBUG ("vertex: %.4f %.4f %.4f %.4f", v[0], v[1], v[2], v[3]); - GST_DEBUG ("result: %.4f %.4f %.4f %.4f", res[0], res[1], res[2], res[3]); - - for (i = 0; i < 4; i++) { - fail_unless (FEQ (res[i], expected[i]), - "value %f at index %u does not match " "expected value %f", res[i], i, - expected[i]); - } -} - -GST_END_TEST; -#endif - -static Suite * -gst_gl_upload_suite (void) -{ - Suite *s = suite_create ("GstGLMatrix"); - TCase *tc_chain = tcase_create ("matrix"); - - suite_add_tcase (s, tc_chain); - tcase_add_test (tc_chain, test_matrix_multiply); - tcase_add_test (tc_chain, test_matrix_ndc); - - return s; -} - -GST_CHECK_MAIN (gst_gl_upload); diff --git a/tests/check/libs/gstglmemory.c b/tests/check/libs/gstglmemory.c deleted file mode 100644 index f1c3203a4..000000000 --- a/tests/check/libs/gstglmemory.c +++ /dev/null @@ -1,349 +0,0 @@ -/* 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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <gst/check/gstcheck.h> - -#include <gst/gl/gl.h> - -#include <stdio.h> - -static GstGLDisplay *display; -static GstGLContext *context; - -static void -setup (void) -{ - display = gst_gl_display_new (); - context = gst_gl_context_new (display); - gst_gl_context_create (context, 0, NULL); - gst_gl_memory_init_once (); -} - -static void -teardown (void) -{ - gst_object_unref (display); - gst_object_unref (context); -} - -GST_START_TEST (test_basic) -{ - GstMemory *mem, *mem2; - GstGLMemory *gl_mem, *gl_mem2; - GstAllocator *gl_allocator; - GstGLBaseMemoryAllocator *base_mem_alloc; - gint i, j; - static GstVideoFormat formats[] = { - GST_VIDEO_FORMAT_RGBA, GST_VIDEO_FORMAT_RGB, - GST_VIDEO_FORMAT_YUY2, GST_VIDEO_FORMAT_I420 - }; - - gl_allocator = gst_allocator_find (GST_GL_MEMORY_ALLOCATOR_NAME); - fail_if (gl_allocator == NULL); - base_mem_alloc = GST_GL_BASE_MEMORY_ALLOCATOR (gl_allocator); - - /* test allocator creation */ - ASSERT_WARNING (mem = gst_allocator_alloc (gl_allocator, 0, NULL)); - - for (i = 0; i < G_N_ELEMENTS (formats); i++) { - 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++) { - GstGLFormat tex_format = gst_gl_format_from_video_info (context, - &v_info, j); - GstGLVideoAllocationParams *params; - - params = gst_gl_video_allocation_params_new (context, NULL, &v_info, j, - NULL, GST_GL_TEXTURE_TARGET_2D, tex_format); - - mem = (GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc, - (GstGLAllocationParams *) params); - fail_if (mem == NULL); - gl_mem = (GstGLMemory *) mem; - - /* test init params */ - fail_if (gst_video_info_is_equal (&v_info, &gl_mem->info) == FALSE); - fail_if (gl_mem->mem.context != context); - 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); - fail_if (gl_mem->mem.context != gl_mem2->mem.context); - - gst_gl_allocation_params_free ((GstGLAllocationParams *) params); - gst_memory_unref (mem); - gst_memory_unref (mem2); - } - } - - gst_object_unref (gl_allocator); -} - -GST_END_TEST; - -/* one red rgba pixel */ -static gchar rgba_pixel[] = { - 0xff, 0x00, 0x00, 0xff, -}; - -static void -test_transfer_allocator (const gchar * allocator_name) -{ - GstAllocator *gl_allocator; - GstGLBaseMemoryAllocator *base_mem_alloc; - GstVideoInfo v_info; - GstMemory *mem, *mem2, *mem3; - GstMapInfo map_info; - GstGLVideoAllocationParams *params; - - gl_allocator = gst_allocator_find (allocator_name); - fail_if (gl_allocator == NULL); - base_mem_alloc = GST_GL_BASE_MEMORY_ALLOCATOR (gl_allocator); - - gst_video_info_set_format (&v_info, GST_VIDEO_FORMAT_RGBA, 1, 1); - - params = gst_gl_video_allocation_params_new (context, NULL, &v_info, 0, - NULL, GST_GL_TEXTURE_TARGET_2D, GST_GL_RGBA); - - /* texture creation */ - mem = (GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc, - (GstGLAllocationParams *) params); - gst_gl_allocation_params_free ((GstGLAllocationParams *) params); - fail_unless (!GST_MEMORY_FLAG_IS_SET (mem, - GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD)); - fail_unless (!GST_MEMORY_FLAG_IS_SET (mem, - GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD)); - - /* test wrapping raw data */ - params = gst_gl_video_allocation_params_new_wrapped_data (context, NULL, - &v_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D, - GST_GL_RGBA, rgba_pixel, NULL, NULL); - mem2 = - (GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc, - (GstGLAllocationParams *) params); - gst_gl_allocation_params_free ((GstGLAllocationParams *) params); - fail_if (mem == NULL); - - fail_unless (GST_MEMORY_FLAG_IS_SET (mem2, - GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD)); - fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2, - GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD)); - - /* wrapped texture creation */ - params = gst_gl_video_allocation_params_new_wrapped_texture (context, NULL, - &v_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D, - GST_GL_RGBA, ((GstGLMemory *) mem)->tex_id, NULL, NULL); - mem3 = - (GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc, - (GstGLAllocationParams *) params); - gst_gl_allocation_params_free ((GstGLAllocationParams *) params); - fail_unless (!GST_MEMORY_FLAG_IS_SET (mem3, - GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD)); - fail_unless (GST_MEMORY_FLAG_IS_SET (mem3, - GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD)); - - /* check data/flags are correct */ - fail_unless (gst_memory_map (mem2, &map_info, GST_MAP_READ)); - - fail_unless (GST_MEMORY_FLAG_IS_SET (mem2, - GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD)); - fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2, - GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD)); - - 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]); - - gst_memory_unmap (mem2, &map_info); - - fail_unless (GST_MEMORY_FLAG_IS_SET (mem2, - GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD)); - fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2, - GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD)); - - fail_unless (gst_memory_map (mem2, &map_info, GST_MAP_READ | GST_MAP_GL)); - - fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2, - GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD)); - fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2, - GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD)); - - /* test texture copy */ - fail_unless (gst_gl_memory_copy_into ((GstGLMemory *) mem2, - ((GstGLMemory *) mem)->tex_id, GST_GL_TEXTURE_TARGET_2D, - GST_GL_RGBA, 1, 1)); - GST_MINI_OBJECT_FLAG_SET (mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD); - - fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2, - GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD)); - fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2, - GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD)); - fail_unless (!GST_MEMORY_FLAG_IS_SET (mem, - GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD)); - fail_unless (GST_MEMORY_FLAG_IS_SET (mem, - GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD)); - - gst_memory_unmap (mem2, &map_info); - - /* test download of copied texture */ - fail_unless (gst_memory_map (mem, &map_info, GST_MAP_READ)); - - 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]); - - gst_memory_unmap (mem, &map_info); - - /* test download of wrapped copied texture */ - fail_unless (gst_memory_map (mem3, &map_info, GST_MAP_READ)); - - fail_unless (!GST_MEMORY_FLAG_IS_SET (mem, - GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD)); - fail_unless (!GST_MEMORY_FLAG_IS_SET (mem, - GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD)); - - 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]); - - 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); - - fail_unless (GST_MEMORY_FLAG_IS_SET (mem3, - GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD)); - fail_unless (!GST_MEMORY_FLAG_IS_SET (mem3, - GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD)); - - /* test download flag */ - fail_unless (gst_memory_map (mem3, &map_info, GST_MAP_WRITE | GST_MAP_GL)); - gst_memory_unmap (mem3, &map_info); - - fail_unless (!GST_MEMORY_FLAG_IS_SET (mem3, - GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD)); - fail_unless (GST_MEMORY_FLAG_IS_SET (mem3, - GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD)); - - gst_memory_unref (mem); - gst_memory_unref (mem2); - gst_memory_unref (mem3); - gst_object_unref (gl_allocator); -} - - -GST_START_TEST (test_transfer) -{ - test_transfer_allocator (GST_GL_MEMORY_ALLOCATOR_NAME); - test_transfer_allocator (GST_GL_MEMORY_PBO_ALLOCATOR_NAME); -} - -GST_END_TEST; - -GST_START_TEST (test_separate_transfer) -{ - GstGLBaseMemoryAllocator *base_mem_alloc; - GstGLVideoAllocationParams *params; - GstAllocator *gl_allocator; - GstVideoInfo v_info; - GstMemory *mem; - GstMapInfo info; - - gl_allocator = gst_allocator_find (GST_GL_MEMORY_PBO_ALLOCATOR_NAME); - fail_if (gl_allocator == NULL); - base_mem_alloc = GST_GL_BASE_MEMORY_ALLOCATOR (gl_allocator); - - gst_video_info_set_format (&v_info, GST_VIDEO_FORMAT_RGBA, 1, 1); - - params = gst_gl_video_allocation_params_new_wrapped_data (context, NULL, - &v_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D, - GST_GL_RGBA, rgba_pixel, NULL, NULL); - mem = - (GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc, - (GstGLAllocationParams *) params); - gst_gl_allocation_params_free ((GstGLAllocationParams *) params); - fail_if (mem == NULL); - fail_unless (!GST_MEMORY_FLAG_IS_SET (mem, - GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD)); - - gst_gl_memory_pbo_upload_transfer ((GstGLMemoryPBO *) mem); - - fail_unless (!GST_MEMORY_FLAG_IS_SET (mem, - GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD)); - - fail_unless (gst_memory_map (mem, &info, GST_MAP_READ)); - - 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]); - - gst_memory_unmap (mem, &info); - - /* FIXME: add download transfer */ - - gst_memory_unref (mem); - gst_object_unref (gl_allocator); -} - -GST_END_TEST; - -static Suite * -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); - tcase_add_test (tc_chain, test_transfer); - tcase_add_test (tc_chain, test_separate_transfer); - - return s; -} - -GST_CHECK_MAIN (gst_gl_memory); diff --git a/tests/check/libs/gstglquery.c b/tests/check/libs/gstglquery.c deleted file mode 100644 index 8563abbe5..000000000 --- a/tests/check/libs/gstglquery.c +++ /dev/null @@ -1,347 +0,0 @@ -/* GStreamer - * Copyright (C) 2016 Matthew Waters <matthew@centricular.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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <gst/check/gstcheck.h> - -#include <gst/gl/gl.h> - -#include <stdio.h> - -static GstGLDisplay *display; -static GstGLContext *context; - -GST_DEBUG_CATEGORY_STATIC (gst_test_debug_cat); - -static void -setup (void) -{ - GError *error = NULL; - - display = gst_gl_display_new (); - context = gst_gl_context_new (display); - - gst_gl_context_create (context, NULL, &error); - - fail_if (error != NULL, "Error creating context: %s\n", - error ? error->message : "Unknown Error"); -} - -static void -teardown (void) -{ - gst_object_unref (display); - gst_object_unref (context); -} - -static void -_test_query_init_gl (GstGLContext * context, gpointer data) -{ - GstGLQuery q1; - - /* no usage */ - gst_gl_query_init (&q1, context, GST_GL_QUERY_TIMESTAMP); - gst_gl_query_unset (&q1); -} - -GST_START_TEST (test_query_init) -{ - gst_gl_context_thread_add (context, - (GstGLContextThreadFunc) _test_query_init_gl, NULL); -} - -GST_END_TEST; - -static void -_test_query_init_invalid_query_gl (GstGLContext * context, gpointer data) -{ - GstGLQuery q1; - - /* no usage */ - ASSERT_CRITICAL (gst_gl_query_init (&q1, context, GST_GL_QUERY_NONE)); -} - -GST_START_TEST (test_query_init_invalid_query) -{ - gst_gl_context_thread_add (context, - (GstGLContextThreadFunc) _test_query_init_invalid_query_gl, NULL); -} - -GST_END_TEST; - -static void -_test_query_new_gl (GstGLContext * context, gpointer data) -{ - GstGLQuery *q1; - - /* no usage */ - q1 = gst_gl_query_new (context, GST_GL_QUERY_TIMESTAMP); - gst_gl_query_free (q1); -} - -GST_START_TEST (test_query_new) -{ - gst_gl_context_thread_add (context, - (GstGLContextThreadFunc) _test_query_new_gl, NULL); -} - -GST_END_TEST; - -static void -_test_query_time_elapsed_gl (GstGLContext * context, gpointer data) -{ - GstGLQuery *q1; - - q1 = gst_gl_query_new (context, GST_GL_QUERY_TIME_ELAPSED); - fail_if (q1 == NULL); - - gst_gl_query_start (q1); - gst_gl_query_end (q1); - /* GST_GL_QUERY_TIME_ELAPSED doesn't supported counter() */ - ASSERT_CRITICAL (gst_gl_query_counter (q1)); - gst_gl_query_result (q1); - - gst_gl_query_free (q1); -} - -GST_START_TEST (test_query_time_elapsed) -{ - gst_gl_context_thread_add (context, - (GstGLContextThreadFunc) _test_query_time_elapsed_gl, NULL); -} - -GST_END_TEST; - -static void -_test_query_start_log_gl (GstGLContext * context, gpointer data) -{ - GstGLQuery *q1; - - q1 = gst_gl_query_new (context, GST_GL_QUERY_TIME_ELAPSED); - fail_if (q1 == NULL); - - gst_gl_query_start_log (q1, NULL, GST_LEVEL_ERROR, NULL, "%s", - "testing query proxy-logging for gst_gl_query_start_log()"); - gst_gl_query_end (q1); - gst_gl_query_result (q1); - - gst_gl_query_free (q1); -} - -GST_START_TEST (test_query_start_log) -{ - gst_gl_context_thread_add (context, - (GstGLContextThreadFunc) _test_query_start_log_gl, NULL); -} - -GST_END_TEST; - -static void -_test_query_timestamp_gl (GstGLContext * context, gpointer data) -{ - GstGLQuery q2; - - gst_gl_query_init (&q2, context, GST_GL_QUERY_TIMESTAMP); - - /* GST_GL_QUERY_TIMESTAMP doesn't supported start()/end() */ - ASSERT_CRITICAL (gst_gl_query_start (&q2)); - ASSERT_CRITICAL (gst_gl_query_end (&q2)); - - gst_gl_query_counter (&q2); - gst_gl_query_result (&q2); - - gst_gl_query_unset (&q2); -} - -GST_START_TEST (test_query_timestamp) -{ - gst_gl_context_thread_add (context, - (GstGLContextThreadFunc) _test_query_timestamp_gl, NULL); -} - -GST_END_TEST; - -static void -_test_query_counter_log_gl (GstGLContext * context, gpointer data) -{ - GstGLQuery q2; - - gst_gl_query_init (&q2, context, GST_GL_QUERY_TIMESTAMP); - - gst_gl_query_counter_log (&q2, gst_test_debug_cat, GST_LEVEL_ERROR, NULL, - "%s", - "testing query proxy-logging works from gst_gl_query_counter_log()"); - gst_gl_query_result (&q2); - - gst_gl_query_unset (&q2); -} - -GST_START_TEST (test_query_counter_log) -{ - gst_gl_context_thread_add (context, - (GstGLContextThreadFunc) _test_query_counter_log_gl, NULL); -} - -GST_END_TEST; - -static void -_test_query_start_free_gl (GstGLContext * context, gpointer data) -{ - GstGLQuery *q1; - - /* test mismatched start()/free() */ - q1 = gst_gl_query_new (context, GST_GL_QUERY_TIME_ELAPSED); - fail_if (q1 == NULL); - - gst_gl_query_start (q1); - - ASSERT_CRITICAL (gst_gl_query_free (q1)); -} - -GST_START_TEST (test_query_start_free) -{ - gst_gl_context_thread_add (context, - (GstGLContextThreadFunc) _test_query_start_free_gl, NULL); -} - -GST_END_TEST; - -static void -_test_query_start_result_gl (GstGLContext * context, gpointer data) -{ - GstGLQuery *q1; - - /* test mismatched start()/result() */ - q1 = gst_gl_query_new (context, GST_GL_QUERY_TIME_ELAPSED); - fail_if (q1 == NULL); - - gst_gl_query_start (q1); - ASSERT_CRITICAL (gst_gl_query_result (q1)); - gst_gl_query_end (q1); - - gst_gl_query_free (q1); -} - -GST_START_TEST (test_query_start_result) -{ - gst_gl_context_thread_add (context, - (GstGLContextThreadFunc) _test_query_start_result_gl, NULL); -} - -GST_END_TEST; - -static void -_test_query_start_start_gl (GstGLContext * context, gpointer data) -{ - GstGLQuery *q1; - - /* test double end() */ - q1 = gst_gl_query_new (context, GST_GL_QUERY_TIME_ELAPSED); - fail_if (q1 == NULL); - - gst_gl_query_start (q1); - ASSERT_CRITICAL (gst_gl_query_start (q1)); - gst_gl_query_end (q1); - - gst_gl_query_free (q1); -} - -GST_START_TEST (test_query_start_start) -{ - gst_gl_context_thread_add (context, - (GstGLContextThreadFunc) _test_query_start_start_gl, NULL); -} - -GST_END_TEST; - -static void -_test_query_end_gl (GstGLContext * context, gpointer data) -{ - GstGLQuery *q1; - - /* test mismatched end() */ - q1 = gst_gl_query_new (context, GST_GL_QUERY_TIME_ELAPSED); - fail_if (q1 == NULL); - ASSERT_CRITICAL (gst_gl_query_end (q1)); - gst_gl_query_free (q1); -} - -GST_START_TEST (test_query_end) -{ - gst_gl_context_thread_add (context, - (GstGLContextThreadFunc) _test_query_end_gl, NULL); -} - -GST_END_TEST; - -static void -_test_query_end_end_gl (GstGLContext * context, gpointer data) -{ - GstGLQuery *q1; - - /* test double end() */ - q1 = gst_gl_query_new (context, GST_GL_QUERY_TIME_ELAPSED); - fail_if (q1 == NULL); - - gst_gl_query_start (q1); - gst_gl_query_end (q1); - ASSERT_CRITICAL (gst_gl_query_end (q1)); - - gst_gl_query_free (q1); -} - -GST_START_TEST (test_query_end_end) -{ - gst_gl_context_thread_add (context, - (GstGLContextThreadFunc) _test_query_end_end_gl, NULL); -} - -GST_END_TEST; - -static Suite * -gst_gl_upload_suite (void) -{ - Suite *s = suite_create ("GstGLQuery"); - TCase *tc_chain = tcase_create ("glquery"); - - GST_DEBUG_CATEGORY_INIT (gst_test_debug_cat, "test-debug", 0, - "proxy-logging test debug"); - - suite_add_tcase (s, tc_chain); - tcase_add_checked_fixture (tc_chain, setup, teardown); - tcase_add_test (tc_chain, test_query_init); - tcase_add_test (tc_chain, test_query_init_invalid_query); - tcase_add_test (tc_chain, test_query_new); - tcase_add_test (tc_chain, test_query_time_elapsed); - tcase_add_test (tc_chain, test_query_timestamp); - tcase_add_test (tc_chain, test_query_counter_log); - tcase_add_test (tc_chain, test_query_start_log); - tcase_add_test (tc_chain, test_query_start_free); - tcase_add_test (tc_chain, test_query_start_result); - tcase_add_test (tc_chain, test_query_start_start); - tcase_add_test (tc_chain, test_query_end); - tcase_add_test (tc_chain, test_query_end_end); - - return s; -} - -GST_CHECK_MAIN (gst_gl_upload); diff --git a/tests/check/libs/gstglshader.c b/tests/check/libs/gstglshader.c deleted file mode 100644 index 791872655..000000000 --- a/tests/check/libs/gstglshader.c +++ /dev/null @@ -1,225 +0,0 @@ -/* GStreamer - * Copyright (C) 2016 Matthew Waters <matthew@centricular.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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <gst/check/gstcheck.h> - -#include <gst/gl/gl.h> - -#include <stdio.h> - -static GstGLDisplay *display; -static GstGLContext *context; - -static void -setup (void) -{ - GError *error = NULL; - - display = gst_gl_display_new (); - context = gst_gl_context_new (display); - - gst_gl_context_create (context, NULL, &error); - - fail_if (error != NULL, "Error creating context: %s\n", - error ? error->message : "Unknown Error"); -} - -static void -teardown (void) -{ - gst_object_unref (display); - gst_object_unref (context); -} - -static void -_test_compile_attach_gl (GstGLContext * context, gpointer data) -{ - GstGLShader *shader; - GstGLSLStage *vert; - GError *error = NULL; - - shader = gst_gl_shader_new (context); - vert = gst_glsl_stage_new_default_vertex (context); - - fail_unless (gst_gl_shader_compile_attach_stage (shader, vert, &error)); - - gst_object_unref (shader); -} - -GST_START_TEST (test_compile_attach) -{ - gst_gl_context_thread_add (context, - (GstGLContextThreadFunc) _test_compile_attach_gl, NULL); -} - -GST_END_TEST; - -static void -_test_separate_compile_attach_gl (GstGLContext * context, gpointer data) -{ - GstGLShader *shader; - GstGLSLStage *vert; - GError *error = NULL; - - shader = gst_gl_shader_new (context); - vert = gst_glsl_stage_new_default_vertex (context); - - fail_unless (gst_glsl_stage_compile (vert, &error)); - fail_unless (gst_gl_shader_attach (shader, vert)); - fail_unless (gst_gl_shader_attach (shader, vert)); - - gst_object_unref (shader); -} - -GST_START_TEST (test_separate_compile_attach) -{ - gst_gl_context_thread_add (context, - (GstGLContextThreadFunc) _test_separate_compile_attach_gl, NULL); -} - -GST_END_TEST; - -static void -_test_detach_gl (GstGLContext * context, gpointer data) -{ - GstGLShader *shader; - GstGLSLStage *vert; - GError *error = NULL; - - shader = gst_gl_shader_new (context); - vert = gst_glsl_stage_new_default_vertex (context); - - fail_unless (gst_glsl_stage_compile (vert, &error)); - fail_unless (gst_gl_shader_attach (shader, vert)); - gst_gl_shader_detach (shader, vert); - - gst_object_unref (shader); -} - -GST_START_TEST (test_detach) -{ - gst_gl_context_thread_add (context, (GstGLContextThreadFunc) _test_detach_gl, - NULL); -} - -GST_END_TEST; - -static void -_test_link_gl (GstGLContext * context, gpointer data) -{ - GstGLShader *shader; - GstGLSLStage *vert, *frag; - GError *error = NULL; - - shader = gst_gl_shader_new (context); - vert = gst_glsl_stage_new_default_vertex (context); - frag = gst_glsl_stage_new_default_fragment (context); - - fail_unless (gst_gl_shader_compile_attach_stage (shader, vert, &error)); - fail_unless (gst_gl_shader_compile_attach_stage (shader, frag, &error)); - fail_unless (gst_gl_shader_link (shader, &error)); - fail_unless (gst_gl_shader_is_linked (shader)); - - gst_object_unref (shader); -} - -GST_START_TEST (test_link) -{ - gst_gl_context_thread_add (context, (GstGLContextThreadFunc) _test_link_gl, - NULL); -} - -GST_END_TEST; - -static void -_test_default_shader_gl (GstGLContext * context, gpointer data) -{ - GstGLShader *shader; - GError *error = NULL; - - shader = gst_gl_shader_new_default (context, &error); - fail_unless (shader != NULL); - fail_unless (error == NULL); - - gst_gl_shader_use (shader); - gst_gl_context_clear_shader (context); - - gst_object_unref (shader); -} - -GST_START_TEST (test_default_shader) -{ - gst_gl_context_thread_add (context, - (GstGLContextThreadFunc) _test_default_shader_gl, NULL); -} - -GST_END_TEST; - -static void -_test_get_attribute_location_gl (GstGLContext * context, gpointer data) -{ - GstGLShader *shader; - GError *error = NULL; - gint loc; - - shader = gst_gl_shader_new_default (context, &error); - - gst_gl_shader_use (shader); - - loc = gst_gl_shader_get_attribute_location (shader, "a_position"); - fail_unless (loc != -1); - loc = gst_gl_shader_get_attribute_location (shader, "a_texcoord"); - fail_unless (loc != -1); - loc = gst_gl_shader_get_attribute_location (shader, "unused_value_1928374"); - fail_unless (loc == -1); - - gst_object_unref (shader); -} - -GST_START_TEST (test_get_attribute_location) -{ - gst_gl_context_thread_add (context, - (GstGLContextThreadFunc) _test_get_attribute_location_gl, NULL); -} - -GST_END_TEST; - -static Suite * -gst_gl_shader_suite (void) -{ - Suite *s = suite_create ("GstGLShader"); - TCase *tc_chain = tcase_create ("glshader"); - - suite_add_tcase (s, tc_chain); - tcase_add_checked_fixture (tc_chain, setup, teardown); - tcase_add_test (tc_chain, test_compile_attach); - tcase_add_test (tc_chain, test_separate_compile_attach); - tcase_add_test (tc_chain, test_detach); - tcase_add_test (tc_chain, test_link); - tcase_add_test (tc_chain, test_default_shader); - tcase_add_test (tc_chain, test_get_attribute_location); - - return s; -} - -GST_CHECK_MAIN (gst_gl_shader); diff --git a/tests/check/libs/gstglsl.c b/tests/check/libs/gstglsl.c deleted file mode 100644 index 969d73d07..000000000 --- a/tests/check/libs/gstglsl.c +++ /dev/null @@ -1,374 +0,0 @@ -/* GStreamer - * Copyright (C) 2015 Matthew Waters <matthew@centricular.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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <gst/check/gstcheck.h> - -#include <gst/gl/gstglsl.h> - -#include <stdio.h> - -static void -setup (void) -{ -} - -static void -teardown (void) -{ -} - -/* *INDENT-OFF* */ -static const struct {GstGLSLVersion version; const gchar * name;} glsl_versions[] = { - {GST_GLSL_VERSION_100, "100"}, - {GST_GLSL_VERSION_110, "110"}, - {GST_GLSL_VERSION_120, "120"}, - {GST_GLSL_VERSION_130, "130"}, - {GST_GLSL_VERSION_140, "140"}, - {GST_GLSL_VERSION_150, "150"}, - {GST_GLSL_VERSION_300, "300"}, - {GST_GLSL_VERSION_310, "310"}, - {GST_GLSL_VERSION_320, "320"}, - {GST_GLSL_VERSION_330, "330"}, - {GST_GLSL_VERSION_400, "400"}, - {GST_GLSL_VERSION_410, "410"}, - {GST_GLSL_VERSION_420, "420"}, - {GST_GLSL_VERSION_430, "430"}, - {GST_GLSL_VERSION_440, "440"}, - {GST_GLSL_VERSION_450, "450"}, -}; - -static const struct {GstGLSLProfile profile; const gchar * name;} glsl_profiles[] = { - {GST_GLSL_PROFILE_ES, "es"}, - {GST_GLSL_PROFILE_CORE, "core"}, - {GST_GLSL_PROFILE_COMPATIBILITY, "compatibility"}, -}; - -struct version_profile_s -{ - GstGLSLVersion version; - GstGLSLProfile profile; - const gchar * name; -}; - -static const struct version_profile_s glsl_version_profiles_valid[] = { - {GST_GLSL_VERSION_100, GST_GLSL_PROFILE_ES, "100"}, - {GST_GLSL_VERSION_110, GST_GLSL_PROFILE_COMPATIBILITY, "110"}, - {GST_GLSL_VERSION_120, GST_GLSL_PROFILE_COMPATIBILITY, "120"}, - {GST_GLSL_VERSION_130, GST_GLSL_PROFILE_COMPATIBILITY, "130"}, - {GST_GLSL_VERSION_140, GST_GLSL_PROFILE_COMPATIBILITY, "140"}, - {GST_GLSL_VERSION_150, GST_GLSL_PROFILE_CORE, "150 core"}, - {GST_GLSL_VERSION_150, GST_GLSL_PROFILE_COMPATIBILITY, "150 compatibility"}, - {GST_GLSL_VERSION_300, GST_GLSL_PROFILE_ES, "300 es"}, - {GST_GLSL_VERSION_310, GST_GLSL_PROFILE_ES, "310 es"}, - {GST_GLSL_VERSION_320, GST_GLSL_PROFILE_ES, "320 es"}, - {GST_GLSL_VERSION_330, GST_GLSL_PROFILE_CORE, "330 core"}, - {GST_GLSL_VERSION_330, GST_GLSL_PROFILE_COMPATIBILITY, "330 compatibility"}, - {GST_GLSL_VERSION_400, GST_GLSL_PROFILE_CORE, "400 core"}, - {GST_GLSL_VERSION_400, GST_GLSL_PROFILE_COMPATIBILITY, "400 compatibility"}, - {GST_GLSL_VERSION_410, GST_GLSL_PROFILE_CORE, "410 core"}, - {GST_GLSL_VERSION_410, GST_GLSL_PROFILE_COMPATIBILITY, "410 compatibility"}, - {GST_GLSL_VERSION_420, GST_GLSL_PROFILE_CORE, "420 core"}, - {GST_GLSL_VERSION_420, GST_GLSL_PROFILE_COMPATIBILITY, "420 compatibility"}, - {GST_GLSL_VERSION_430, GST_GLSL_PROFILE_CORE, "430 core"}, - {GST_GLSL_VERSION_430, GST_GLSL_PROFILE_COMPATIBILITY, "430 compatibility"}, - {GST_GLSL_VERSION_440, GST_GLSL_PROFILE_CORE, "440 core"}, - {GST_GLSL_VERSION_440, GST_GLSL_PROFILE_COMPATIBILITY, "440 compatibility"}, - {GST_GLSL_VERSION_450, GST_GLSL_PROFILE_CORE, "450 core"}, - {GST_GLSL_VERSION_450, GST_GLSL_PROFILE_COMPATIBILITY, "450 compatibility"}, -}; - -/* combinations that produce different results between serializing/deserializing - * due to default values being imposed */ -static const struct version_profile_s glsl_version_profiles_valid_serialize[] = { - {GST_GLSL_VERSION_100, GST_GLSL_PROFILE_NONE, "100"}, - {GST_GLSL_VERSION_110, GST_GLSL_PROFILE_NONE, "110"}, - {GST_GLSL_VERSION_120, GST_GLSL_PROFILE_NONE, "120"}, - {GST_GLSL_VERSION_130, GST_GLSL_PROFILE_NONE, "130"}, - {GST_GLSL_VERSION_140, GST_GLSL_PROFILE_NONE, "140"}, - {GST_GLSL_VERSION_150, GST_GLSL_PROFILE_NONE, "150"}, - {GST_GLSL_VERSION_330, GST_GLSL_PROFILE_NONE, "330"}, - {GST_GLSL_VERSION_400, GST_GLSL_PROFILE_NONE, "400"}, - {GST_GLSL_VERSION_410, GST_GLSL_PROFILE_NONE, "410"}, - {GST_GLSL_VERSION_420, GST_GLSL_PROFILE_NONE, "420"}, - {GST_GLSL_VERSION_430, GST_GLSL_PROFILE_NONE, "430"}, - {GST_GLSL_VERSION_440, GST_GLSL_PROFILE_NONE, "440"}, - {GST_GLSL_VERSION_450, GST_GLSL_PROFILE_NONE, "450"}, -}; -static const struct version_profile_s glsl_version_profiles_valid_deserialize[] = { - {GST_GLSL_VERSION_100, GST_GLSL_PROFILE_ES, "100"}, - {GST_GLSL_VERSION_110, GST_GLSL_PROFILE_COMPATIBILITY, "110"}, - {GST_GLSL_VERSION_120, GST_GLSL_PROFILE_COMPATIBILITY, "120"}, - {GST_GLSL_VERSION_130, GST_GLSL_PROFILE_COMPATIBILITY, "130"}, - {GST_GLSL_VERSION_140, GST_GLSL_PROFILE_COMPATIBILITY, "140"}, - {GST_GLSL_VERSION_150, GST_GLSL_PROFILE_CORE, "150"}, - {GST_GLSL_VERSION_330, GST_GLSL_PROFILE_CORE, "330"}, - {GST_GLSL_VERSION_400, GST_GLSL_PROFILE_CORE, "400"}, - {GST_GLSL_VERSION_410, GST_GLSL_PROFILE_CORE, "410"}, - {GST_GLSL_VERSION_420, GST_GLSL_PROFILE_CORE, "420"}, - {GST_GLSL_VERSION_430, GST_GLSL_PROFILE_CORE, "430"}, - {GST_GLSL_VERSION_440, GST_GLSL_PROFILE_CORE, "440"}, - {GST_GLSL_VERSION_450, GST_GLSL_PROFILE_CORE, "450"}, -}; - -static const gchar * invalid_deserialize_glsl[] = { - "", - " \t\r\n", - "ael dja", - "es", - "core", - "compatibility", - "1000", - "100 es", - "100 core", - "100 compatibility", - "150 es", - "300 core", - "300 compatibility", - "310 core", - "310 compatibility", - "320 core", - "320 compatibility", - "330 es", -}; - -static const struct {GstGLSLVersion version; GstGLSLProfile profile;} invalid_serialize_glsl[] = { - {GST_GLSL_VERSION_100, GST_GLSL_PROFILE_CORE}, - {GST_GLSL_VERSION_100, GST_GLSL_PROFILE_COMPATIBILITY}, - {GST_GLSL_VERSION_110, GST_GLSL_PROFILE_ES}, - {GST_GLSL_VERSION_110, GST_GLSL_PROFILE_CORE}, - {GST_GLSL_VERSION_120, GST_GLSL_PROFILE_ES}, - {GST_GLSL_VERSION_120, GST_GLSL_PROFILE_CORE}, - {GST_GLSL_VERSION_130, GST_GLSL_PROFILE_ES}, - {GST_GLSL_VERSION_130, GST_GLSL_PROFILE_CORE}, - {GST_GLSL_VERSION_140, GST_GLSL_PROFILE_ES}, - {GST_GLSL_VERSION_140, GST_GLSL_PROFILE_CORE}, - {GST_GLSL_VERSION_150, GST_GLSL_PROFILE_ES}, - {GST_GLSL_VERSION_300, GST_GLSL_PROFILE_NONE}, - {GST_GLSL_VERSION_300, GST_GLSL_PROFILE_CORE}, - {GST_GLSL_VERSION_300, GST_GLSL_PROFILE_COMPATIBILITY}, - {GST_GLSL_VERSION_310, GST_GLSL_PROFILE_NONE}, - {GST_GLSL_VERSION_310, GST_GLSL_PROFILE_CORE}, - {GST_GLSL_VERSION_310, GST_GLSL_PROFILE_COMPATIBILITY}, - {GST_GLSL_VERSION_320, GST_GLSL_PROFILE_NONE}, - {GST_GLSL_VERSION_320, GST_GLSL_PROFILE_CORE}, - {GST_GLSL_VERSION_320, GST_GLSL_PROFILE_COMPATIBILITY}, - {GST_GLSL_VERSION_330, GST_GLSL_PROFILE_ES}, - {GST_GLSL_VERSION_400, GST_GLSL_PROFILE_ES}, - {GST_GLSL_VERSION_410, GST_GLSL_PROFILE_ES}, - {GST_GLSL_VERSION_420, GST_GLSL_PROFILE_ES}, - {GST_GLSL_VERSION_430, GST_GLSL_PROFILE_ES}, - {GST_GLSL_VERSION_440, GST_GLSL_PROFILE_ES}, - {GST_GLSL_VERSION_450, GST_GLSL_PROFILE_ES}, -}; - -static const struct {const gchar *name; gboolean succeed; GstGLSLVersion version; GstGLSLProfile profile;} glsl_str_map[] = { - {"//#version 100\n", FALSE, GST_GLSL_VERSION_NONE, GST_GLSL_PROFILE_NONE}, - {"/*\n#version 100*/\n", FALSE, GST_GLSL_VERSION_NONE, GST_GLSL_PROFILE_NONE}, - {"/*\r#version 100*/", FALSE, GST_GLSL_VERSION_NONE, GST_GLSL_PROFILE_NONE}, - {"#\rversion 100", FALSE, GST_GLSL_VERSION_NONE, GST_GLSL_PROFILE_NONE}, - {"#\nversion 100", FALSE, GST_GLSL_VERSION_NONE, GST_GLSL_PROFILE_NONE}, - {"\t#version 100", FALSE, GST_GLSL_VERSION_NONE, GST_GLSL_PROFILE_NONE}, - {"//\r#version 100", TRUE, GST_GLSL_VERSION_100, GST_GLSL_PROFILE_ES}, - {"//\n#version 100", TRUE, GST_GLSL_VERSION_100, GST_GLSL_PROFILE_ES}, - {"# \tversion 100", TRUE, GST_GLSL_VERSION_100, GST_GLSL_PROFILE_ES}, - {"\n#version 100", TRUE, GST_GLSL_VERSION_100, GST_GLSL_PROFILE_ES}, - {"\r#version 100", TRUE, GST_GLSL_VERSION_100, GST_GLSL_PROFILE_ES}, -}; -/* *INDENT-ON* */ - -GST_START_TEST (test_serialization) -{ - gint i; - - /* versions */ - for (i = 0; i < G_N_ELEMENTS (glsl_versions); i++) { - GstGLSLVersion version; - const gchar *version_s; - - version_s = gst_glsl_version_to_string (glsl_versions[i].version); - fail_unless (g_strcmp0 (version_s, glsl_versions[i].name) == 0, "%s != %s", - version_s, glsl_versions[i].name); - version = gst_glsl_version_from_string (glsl_versions[i].name); - fail_unless (version == glsl_versions[i].version, "%s != %s", - gst_glsl_version_to_string (glsl_versions[i].version), - gst_glsl_version_to_string (version)); - } - - /* profiles */ - for (i = 0; i < G_N_ELEMENTS (glsl_profiles); i++) { - GstGLSLProfile profile; - const gchar *profile_s; - - profile_s = gst_glsl_profile_to_string (glsl_profiles[i].profile); - fail_unless (g_strcmp0 (profile_s, glsl_profiles[i].name) == 0, "%s != %s", - profile_s, glsl_profiles[i].name); - profile = gst_glsl_profile_from_string (glsl_profiles[i].name); - fail_unless (profile == glsl_profiles[i].profile, "%s != %s", - gst_glsl_profile_to_string (glsl_profiles[i].profile), - gst_glsl_profile_to_string (profile)); - } - - for (i = 0; i < G_N_ELEMENTS (glsl_version_profiles_valid); i++) { - gchar *version_profile_s; - GstGLSLVersion version; - GstGLSLProfile profile; - - version_profile_s = - gst_glsl_version_profile_to_string (glsl_version_profiles_valid - [i].version, glsl_version_profiles_valid[i].profile); - fail_unless (g_strcmp0 (version_profile_s, - glsl_version_profiles_valid[i].name) == 0, "%s != %s", - version_profile_s, glsl_version_profiles_valid[i].name); - fail_unless (gst_glsl_version_profile_from_string - (glsl_version_profiles_valid[i].name, &version, &profile), - "Failed to parse %s", glsl_version_profiles_valid[i].name); - fail_unless (profile == glsl_version_profiles_valid[i].profile - && version == glsl_version_profiles_valid[i].version, "%s != %s %s", - glsl_version_profiles_valid[i].name, - gst_glsl_version_to_string (version), - gst_glsl_profile_to_string (profile)); - g_free (version_profile_s); - } - - for (i = 0; i < G_N_ELEMENTS (glsl_version_profiles_valid_serialize); i++) { - gchar *version_profile_s; - - version_profile_s = - gst_glsl_version_profile_to_string - (glsl_version_profiles_valid_serialize[i].version, - glsl_version_profiles_valid_serialize[i].profile); - fail_unless (g_strcmp0 (version_profile_s, - glsl_version_profiles_valid_serialize[i].name) == 0, "%s != %s", - version_profile_s, glsl_version_profiles_valid_serialize[i].name); - g_free (version_profile_s); - } - - for (i = 0; i < G_N_ELEMENTS (glsl_version_profiles_valid_deserialize); i++) { - GstGLSLVersion version; - GstGLSLProfile profile; - - fail_unless (gst_glsl_version_profile_from_string - (glsl_version_profiles_valid_deserialize[i].name, &version, &profile), - "Failed to parse %s", glsl_version_profiles_valid_deserialize[i].name); - fail_unless (profile == glsl_version_profiles_valid_deserialize[i].profile - && version == glsl_version_profiles_valid_deserialize[i].version, - "%s != %s %s", glsl_version_profiles_valid_deserialize[i].name, - gst_glsl_version_to_string (version), - gst_glsl_profile_to_string (profile)); - } - - /* failures */ - for (i = 0; i < G_N_ELEMENTS (invalid_deserialize_glsl); i++) { - GstGLSLVersion version; - GstGLSLProfile profile; - - fail_if (gst_glsl_version_profile_from_string (invalid_deserialize_glsl[i], - &version, &profile), - "successfully deserialized %s into %s %s (should have failed)", - invalid_deserialize_glsl[i], gst_glsl_version_to_string (version), - gst_glsl_profile_to_string (profile)); - } - - /* failures */ - for (i = 0; i < G_N_ELEMENTS (invalid_serialize_glsl); i++) { - gchar *version_profile_s; - - version_profile_s = - gst_glsl_version_profile_to_string (invalid_serialize_glsl[i].version, - invalid_serialize_glsl[i].profile); - - fail_if (version_profile_s != NULL, - "successfully serialized %s from %s %s (should have failed)", - version_profile_s, - gst_glsl_version_to_string (invalid_serialize_glsl[i].version), - gst_glsl_profile_to_string (invalid_serialize_glsl[i].profile)); - - g_free (version_profile_s); - } - - /* map strings to version/profile */ - for (i = 0; i < G_N_ELEMENTS (glsl_str_map); i++) { - GstGLSLVersion version; - GstGLSLProfile profile; - - fail_unless (glsl_str_map[i].succeed == - gst_glsl_string_get_version_profile (glsl_str_map[i].name, &version, - &profile), "Incorrect result for parsing \'%s\': %s", - glsl_str_map[i].name, glsl_str_map[i].succeed ? "false" : "true"); - if (glsl_str_map[i].succeed) { - fail_unless (version == glsl_str_map[i].version, "With %s: %s != %s", - glsl_str_map[i].name, - gst_glsl_version_to_string (glsl_str_map[i].version), - gst_glsl_version_to_string (version)); - fail_unless (profile == glsl_str_map[i].profile, "With %s: %s != %s", - glsl_str_map[i].name, - gst_glsl_profile_to_string (glsl_str_map[i].profile), - gst_glsl_profile_to_string (profile)); - } - } - - /* special ones */ - { - GstGLSLVersion version; - GstGLSLProfile profile; - gchar *version_profile_s; - - version_profile_s = - gst_glsl_version_profile_to_string (GST_GLSL_VERSION_100, - GST_GLSL_PROFILE_ES); - fail_unless (g_strcmp0 (version_profile_s, "100") == 0, "%s != 100", - version_profile_s); - g_free (version_profile_s); - - version_profile_s = - gst_glsl_version_profile_to_string (GST_GLSL_VERSION_100, - GST_GLSL_PROFILE_NONE); - fail_unless (g_strcmp0 (version_profile_s, "100") == 0, "%s != 100", - version_profile_s); - g_free (version_profile_s); - - fail_unless (gst_glsl_version_profile_from_string ("100", &version, - &profile)); - fail_unless (version == GST_GLSL_VERSION_100 - && profile == GST_GLSL_PROFILE_ES, "100 != %s %s", - gst_glsl_version_to_string (version), - gst_glsl_profile_to_string (profile)); - } -} - -GST_END_TEST; - -static Suite * -gst_gl_upload_suite (void) -{ - Suite *s = suite_create ("GstGLSL"); - TCase *tc_chain = tcase_create ("glsl"); - - suite_add_tcase (s, tc_chain); - tcase_add_checked_fixture (tc_chain, setup, teardown); - tcase_add_test (tc_chain, test_serialization); - - return s; -} - -GST_CHECK_MAIN (gst_gl_upload); diff --git a/tests/check/libs/gstglslstage.c b/tests/check/libs/gstglslstage.c deleted file mode 100644 index d497328b8..000000000 --- a/tests/check/libs/gstglslstage.c +++ /dev/null @@ -1,101 +0,0 @@ -/* GStreamer - * Copyright (C) 2015 Matthew Waters <matthew@centricular.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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <gst/check/gstcheck.h> - -#include <gst/gl/gl.h> -#include <gst/gl/gstglfuncs.h> - -#include <stdio.h> - -static GstGLDisplay *display; -static GstGLContext *context; - -static void -setup (void) -{ - GError *error = NULL; - - display = gst_gl_display_new (); - context = gst_gl_context_new (display); - - gst_gl_context_create (context, NULL, &error); - - fail_if (error != NULL, "Error creating context: %s\n", - error ? error->message : "Unknown Error"); -} - -static void -teardown (void) -{ - gst_object_unref (display); - gst_object_unref (context); -} - -GST_START_TEST (test_default_vertex) -{ - GstGLSLStage *stage; - GError *error = NULL; - - stage = gst_glsl_stage_new_default_vertex (context); - fail_unless (stage != NULL); - fail_unless (GL_VERTEX_SHADER == gst_glsl_stage_get_shader_type (stage)); - - fail_unless (gst_glsl_stage_compile (stage, &error)); - - gst_object_unref (stage); -} - -GST_END_TEST; - -GST_START_TEST (test_default_fragment) -{ - GstGLSLStage *stage; - GError *error = NULL; - - stage = gst_glsl_stage_new_default_fragment (context); - fail_unless (stage != NULL); - fail_unless (GL_FRAGMENT_SHADER == gst_glsl_stage_get_shader_type (stage)); - - fail_unless (gst_glsl_stage_compile (stage, &error)); - - gst_object_unref (stage); -} - -GST_END_TEST; - -static Suite * -gst_gl_upload_suite (void) -{ - Suite *s = suite_create ("GstGLSL"); - TCase *tc_chain = tcase_create ("glsl"); - - suite_add_tcase (s, tc_chain); - tcase_add_checked_fixture (tc_chain, setup, teardown); - tcase_add_test (tc_chain, test_default_vertex); - tcase_add_test (tc_chain, test_default_fragment); - - return s; -} - -GST_CHECK_MAIN (gst_gl_upload); diff --git a/tests/check/libs/gstglupload.c b/tests/check/libs/gstglupload.c deleted file mode 100644 index 94320b556..000000000 --- a/tests/check/libs/gstglupload.c +++ /dev/null @@ -1,432 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2014 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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <gst/check/gstcheck.h> -#include <gst/gl/gstglfuncs.h> - -#include <gst/gl/gl.h> - -#include <stdio.h> - -static GstGLDisplay *display; -static GstGLContext *context; -static GstGLWindow *window; -static GstGLUpload *upload; -static guint tex_id; -static GstGLShader *shader; -static GLint shader_attr_position_loc; -static GLint shader_attr_texture_loc; -static guint vbo, vbo_indices, vao; -static GstGLFramebuffer *fbo; -static GstGLMemory *fbo_tex; - -static const GLfloat vertices[] = { - 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, - -1.0f, 1.0f, 0.0f, 0.0f, 0.0f, - -1.0f, -1.0f, 0.0f, 0.0f, 1.0f, - 1.0f, -1.0f, 0.0f, 1.0f, 1.0f -}; - -static GLushort indices[] = { 0, 1, 2, 0, 2, 3 }; - -#define FORMAT GST_GL_RGBA -#define WIDTH 10 -#define HEIGHT 10 -#define RED 0xff, 0x00, 0x00, 0xff -#define GREEN 0x00, 0xff, 0x00, 0xff -#define BLUE 0x00, 0x00, 0xff, 0xff - -static gchar rgba_data[] = - { RED, GREEN, BLUE, RED, GREEN, BLUE, RED, GREEN, BLUE, RED, - GREEN, BLUE, RED, GREEN, BLUE, RED, GREEN, BLUE, RED, GREEN, - BLUE, RED, GREEN, BLUE, RED, GREEN, BLUE, RED, GREEN, BLUE, - RED, RED, RED, RED, RED, RED, RED, RED, RED, RED, - GREEN, GREEN, GREEN, GREEN, GREEN, GREEN, GREEN, GREEN, GREEN, GREEN, - BLUE, BLUE, BLUE, BLUE, BLUE, BLUE, BLUE, BLUE, BLUE, BLUE, - RED, GREEN, BLUE, RED, GREEN, BLUE, RED, GREEN, BLUE, RED, - RED, GREEN, BLUE, RED, GREEN, BLUE, RED, GREEN, BLUE, RED, - RED, GREEN, BLUE, RED, GREEN, BLUE, RED, GREEN, BLUE, RED, - RED, GREEN, BLUE, RED, GREEN, BLUE, RED, GREEN, BLUE, RED -}; - -static void -setup (void) -{ - GError *error = NULL; - - display = gst_gl_display_new (); - context = gst_gl_context_new (display); - - gst_gl_context_create (context, 0, &error); - window = gst_gl_context_get_window (context); - - fail_if (error != NULL, "Error creating context: %s\n", - error ? error->message : "Unknown Error"); - - upload = gst_gl_upload_new (context); -} - -static void -_check_gl_error (GstGLContext * context, gpointer data) -{ - GLuint error = context->gl_vtable->GetError (); - fail_if (error != GL_NONE, "GL error 0x%x encountered during processing\n", - error); -} - -static void -teardown (void) -{ - gst_object_unref (upload); - gst_object_unref (window); - - gst_gl_context_thread_add (context, (GstGLContextThreadFunc) _check_gl_error, - NULL); - gst_object_unref (context); - gst_object_unref (display); - if (shader) - gst_object_unref (shader); -} - -static void -_bind_buffer (GstGLContext * context) -{ - const GstGLFuncs *gl = context->gl_vtable; - - gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, vbo_indices); - gl->BindBuffer (GL_ARRAY_BUFFER, vbo); - - /* Load the vertex position */ - gl->VertexAttribPointer (shader_attr_position_loc, 3, GL_FLOAT, GL_FALSE, - 5 * sizeof (GLfloat), (void *) 0); - - /* Load the texture coordinate */ - gl->VertexAttribPointer (shader_attr_texture_loc, 2, GL_FLOAT, GL_FALSE, - 5 * sizeof (GLfloat), (void *) (3 * sizeof (GLfloat))); - - gl->EnableVertexAttribArray (shader_attr_position_loc); - gl->EnableVertexAttribArray (shader_attr_texture_loc); -} - -static void -_unbind_buffer (GstGLContext * context) -{ - const GstGLFuncs *gl = context->gl_vtable; - - gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0); - gl->BindBuffer (GL_ARRAY_BUFFER, 0); - - gl->DisableVertexAttribArray (shader_attr_position_loc); - gl->DisableVertexAttribArray (shader_attr_texture_loc); -} - -static void -init (gpointer data) -{ - const GstGLFuncs *gl = context->gl_vtable; - GError *error = NULL; - - shader = gst_gl_shader_new_default (context, &error); - fail_if (shader == NULL, "failed to create shader object %s", error->message); - - shader_attr_position_loc = - gst_gl_shader_get_attribute_location (shader, "a_position"); - shader_attr_texture_loc = - gst_gl_shader_get_attribute_location (shader, "a_texcoord"); - - fbo = gst_gl_framebuffer_new_with_default_depth (context, WIDTH, HEIGHT); - - { - GstGLMemoryAllocator *allocator; - GstGLVideoAllocationParams *params; - GstVideoInfo v_info; - - allocator = gst_gl_memory_allocator_get_default (context); - gst_video_info_set_format (&v_info, GST_VIDEO_FORMAT_RGBA, WIDTH, HEIGHT); - params = - gst_gl_video_allocation_params_new (context, NULL, &v_info, 0, NULL, - GST_GL_TEXTURE_TARGET_2D, FORMAT); - fbo_tex = - (GstGLMemory *) gst_gl_base_memory_alloc ((GstGLBaseMemoryAllocator *) - allocator, (GstGLAllocationParams *) params); - gst_object_unref (allocator); - gst_gl_allocation_params_free ((GstGLAllocationParams *) params); - } - - if (!vbo) { - if (gl->GenVertexArrays) { - gl->GenVertexArrays (1, &vao); - gl->BindVertexArray (vao); - } - - gl->GenBuffers (1, &vbo); - gl->BindBuffer (GL_ARRAY_BUFFER, vbo); - gl->BufferData (GL_ARRAY_BUFFER, 4 * 5 * sizeof (GLfloat), vertices, - GL_STATIC_DRAW); - - gl->GenBuffers (1, &vbo_indices); - gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, vbo_indices); - gl->BufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (indices), indices, - GL_STATIC_DRAW); - - if (gl->GenVertexArrays) { - _bind_buffer (context); - gl->BindVertexArray (0); - } - - gl->BindBuffer (GL_ARRAY_BUFFER, 0); - gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0); - } -} - -static void -deinit (gpointer data) -{ - GstGLContext *context = data; - const GstGLFuncs *gl = context->gl_vtable; - - if (vbo) - gl->DeleteBuffers (1, &vbo); - vbo = 0; - if (vbo_indices) - gl->DeleteBuffers (1, &vbo_indices); - vbo_indices = 0; - if (vao) - gl->DeleteVertexArrays (1, &vao); - vao = 0; - - if (fbo) - gst_object_unref (fbo); - fbo = NULL; - - if (fbo_tex) - gst_memory_unref (GST_MEMORY_CAST (fbo_tex)); - fbo_tex = NULL; -} - -static gboolean -blit_tex (gpointer data) -{ - GstGLContext *context = data; - const GstGLFuncs *gl = context->gl_vtable; - - gl->Clear (GL_COLOR_BUFFER_BIT); - - gst_gl_shader_use (shader); - - if (gl->GenVertexArrays) - gl->BindVertexArray (vao); - _bind_buffer (context); - - gl->ActiveTexture (GL_TEXTURE0); - gl->BindTexture (GL_TEXTURE_2D, tex_id); - gst_gl_shader_set_uniform_1i (shader, "s_texture", 0); - - gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices); - - if (gl->GenVertexArrays) - gl->BindVertexArray (0); - _unbind_buffer (context); - - return TRUE; -} - -static void -draw_render (gpointer data) -{ - gst_gl_framebuffer_draw_to_texture (fbo, fbo_tex, - (GstGLFramebufferFunc) blit_tex, data); -} - -GST_START_TEST (test_upload_data) -{ - GstCaps *in_caps, *out_caps; - GstBuffer *inbuf, *outbuf; - GstMapInfo map_info; - gboolean res; - gint i = 0; - - in_caps = gst_caps_from_string ("video/x-raw,format=RGBA," - "width=10,height=10"); - out_caps = gst_caps_from_string ("video/x-raw(memory:GLMemory)," - "format=RGBA,width=10,height=10"); - - gst_gl_upload_set_caps (upload, in_caps, out_caps); - - inbuf = gst_buffer_new_wrapped_full (0, rgba_data, WIDTH * HEIGHT * 4, - 0, WIDTH * HEIGHT * 4, NULL, NULL); - - res = gst_gl_upload_perform_with_buffer (upload, inbuf, &outbuf); - fail_if (res == FALSE, "Failed to upload buffer"); - fail_unless (GST_IS_BUFFER (outbuf)); - - res = gst_buffer_map (outbuf, &map_info, GST_MAP_READ | GST_MAP_GL); - fail_if (res == FALSE, "Failed to map gl memory"); - - tex_id = *(guint *) map_info.data; - - gst_buffer_unmap (outbuf, &map_info); - - gst_gl_window_set_preferred_size (window, WIDTH, HEIGHT); - gst_gl_window_draw (window); - - gst_gl_window_send_message (window, GST_GL_WINDOW_CB (init), context); - - while (i < 2) { - gst_gl_window_send_message (window, GST_GL_WINDOW_CB (draw_render), - context); - i++; - } - gst_gl_window_send_message (window, GST_GL_WINDOW_CB (deinit), context); - - gst_caps_unref (in_caps); - gst_caps_unref (out_caps); - gst_buffer_unref (inbuf); - gst_buffer_unref (outbuf); -} - -GST_END_TEST; - -GST_START_TEST (test_upload_gl_memory) -{ - GstGLBaseMemoryAllocator *base_mem_alloc; - GstGLVideoAllocationParams *params; - GstBuffer *buffer, *outbuf; - GstGLMemory *gl_mem; - GstCaps *in_caps, *out_caps; - GstStructure *out_s; - GstVideoInfo in_info; - GstMapInfo map_info; - gint i = 0; - gboolean res; - - base_mem_alloc = - GST_GL_BASE_MEMORY_ALLOCATOR (gst_allocator_find - (GST_GL_MEMORY_ALLOCATOR_NAME)); - - in_caps = gst_caps_from_string ("video/x-raw,format=RGBA,width=10,height=10"); - gst_video_info_from_caps (&in_info, in_caps); - - /* create GL buffer */ - buffer = gst_buffer_new (); - params = gst_gl_video_allocation_params_new_wrapped_data (context, NULL, - &in_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D, - GST_GL_RGBA, rgba_data, NULL, NULL); - gl_mem = (GstGLMemory *) gst_gl_base_memory_alloc (base_mem_alloc, - (GstGLAllocationParams *) params); - gst_gl_allocation_params_free ((GstGLAllocationParams *) params); - - res = - gst_memory_map ((GstMemory *) gl_mem, &map_info, - GST_MAP_READ | GST_MAP_GL); - fail_if (res == FALSE, "Failed to map gl memory\n"); - tex_id = *(guint *) map_info.data; - gst_memory_unmap ((GstMemory *) gl_mem, &map_info); - - gst_buffer_append_memory (buffer, (GstMemory *) gl_mem); - - /* at this point glupload hasn't received any buffers so can output anything */ - out_caps = gst_gl_upload_transform_caps (upload, context, - GST_PAD_SINK, in_caps, NULL); - out_s = gst_caps_get_structure (out_caps, 0); - fail_unless (gst_structure_has_field_typed (out_s, "texture-target", - GST_TYPE_LIST)); - gst_caps_unref (out_caps); - - /* set some output caps without setting texture-target: this should trigger RECONFIGURE */ - out_caps = gst_caps_from_string ("video/x-raw(memory:GLMemory)," - "format=RGBA,width=10,height=10"); - - /* set caps with texture-target not fixed. This should trigger RECONFIGURE. */ - gst_gl_upload_set_caps (upload, in_caps, out_caps); - gst_caps_unref (out_caps); - - /* push a texture-target=2D buffer */ - res = gst_gl_upload_perform_with_buffer (upload, buffer, &outbuf); - fail_unless (res == GST_GL_UPLOAD_RECONFIGURE); - fail_if (outbuf); - - /* now glupload has seen a 2D buffer and so wants to transform to that */ - out_caps = gst_gl_upload_transform_caps (upload, context, - GST_PAD_SINK, in_caps, NULL); - out_s = gst_caps_get_structure (out_caps, 0); - fail_unless_equals_string (gst_structure_get_string (out_s, "texture-target"), - "2D"); - gst_caps_unref (out_caps); - - /* try setting the wrong type first tho */ - out_caps = gst_caps_from_string ("video/x-raw(memory:GLMemory)," - "format=RGBA,width=10,height=10,texture-target=RECTANGLE"); - gst_gl_upload_set_caps (upload, in_caps, out_caps); - gst_caps_unref (out_caps); - - res = gst_gl_upload_perform_with_buffer (upload, buffer, &outbuf); - fail_unless (res == GST_GL_UPLOAD_RECONFIGURE); - fail_if (outbuf); - - /* finally do set the correct texture-target */ - out_caps = gst_caps_from_string ("video/x-raw(memory:GLMemory)," - "format=RGBA,width=10,height=10,texture-target=2D"); - gst_gl_upload_set_caps (upload, in_caps, out_caps); - gst_caps_unref (out_caps); - - res = gst_gl_upload_perform_with_buffer (upload, buffer, &outbuf); - fail_unless (res == GST_GL_UPLOAD_DONE, "Failed to upload buffer"); - fail_unless (GST_IS_BUFFER (outbuf)); - - gst_gl_window_set_preferred_size (window, WIDTH, HEIGHT); - gst_gl_window_draw (window); - gst_gl_window_send_message (window, GST_GL_WINDOW_CB (init), context); - - while (i < 2) { - gst_gl_window_send_message (window, GST_GL_WINDOW_CB (draw_render), - context); - i++; - } - gst_gl_window_send_message (window, GST_GL_WINDOW_CB (deinit), context); - - gst_caps_unref (in_caps); - gst_buffer_unref (buffer); - gst_buffer_unref (outbuf); - gst_object_unref (base_mem_alloc); -} - -GST_END_TEST; - - -static Suite * -gst_gl_upload_suite (void) -{ - Suite *s = suite_create ("GstGLUpload"); - TCase *tc_chain = tcase_create ("upload"); - - suite_add_tcase (s, tc_chain); - tcase_add_checked_fixture (tc_chain, setup, teardown); - tcase_add_test (tc_chain, test_upload_data); - tcase_add_test (tc_chain, test_upload_gl_memory); - - return s; -} - -GST_CHECK_MAIN (gst_gl_upload); diff --git a/tests/check/meson.build b/tests/check/meson.build index d2c7a0dc6..68a770504 100644 --- a/tests/check/meson.build +++ b/tests/check/meson.build @@ -57,14 +57,6 @@ base_tests = [ [['elements/voaacenc.c'], not voaac_dep.found(), [voaac_dep]], [['elements/x265enc.c'], not x265_dep.found(), [x265_dep]], [['elements/zbar.c'], not zbar_dep.found(), [zbar_dep]], - [['libs/gstglcolorconvert.c'], not build_gstgl, [gstgl_dep]], - [['libs/gstglcontext.c'], not build_gstgl, [gstgl_dep]], - [['libs/gstglheaders.c'], not build_gstgl, [gstgl_dep]], - [['libs/gstglmatrix.c'], not build_gstgl, [gstgl_dep]], - [['libs/gstglmemory.c'], not build_gstgl, [gstgl_dep]], - [['libs/gstglquery.c'], not build_gstgl, [gstgl_dep]], - [['libs/gstglsl.c'], not build_gstgl, [gstgl_dep]], - [['libs/gstglupload.c'], not build_gstgl, [gstgl_dep]], [['libs/h264parser.c'], false, [gstcodecparsers_dep]], [['libs/insertbin.c'], false, [gstinsertbin_dep]], [['libs/isoff.c'], not xml2_dep.found(), [gstisoff_dep, xml2_dep]], diff --git a/tests/check/pipelines/simple-launch-lines.c b/tests/check/pipelines/simple-launch-lines.c deleted file mode 100644 index f03fc94b5..000000000 --- a/tests/check/pipelines/simple-launch-lines.c +++ /dev/null @@ -1,361 +0,0 @@ -/* GStreamer - * Copyright (C) 2005 Andy Wingo <wingo@pobox.com> - * - * simple_launch_lines.c: Unit test for simple pipelines - * - * 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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gst/check/gstcheck.h> -#include <gst/gl/gstglconfig.h> - -#ifndef GST_DISABLE_PARSE - -static GstElement * -setup_pipeline (const gchar * pipe_descr) -{ - GstElement *pipeline; - - pipeline = gst_parse_launch (pipe_descr, NULL); - g_return_val_if_fail (GST_IS_PIPELINE (pipeline), NULL); - return pipeline; -} - -/* - * run_pipeline: - * @pipe: the pipeline to run - * @desc: the description for use in messages - * @events: is a mask of expected events - * @tevent: is the expected terminal event. - * - * the poll call will time out after half a second. - */ -static void -run_pipeline (GstElement * pipe, const gchar * descr, - GstMessageType events, GstMessageType tevent, GstState target_state) -{ - GstBus *bus; - GstMessage *message; - GstMessageType revent; - GstStateChangeReturn ret; - - g_assert (pipe); - bus = gst_element_get_bus (pipe); - g_assert (bus); - - fail_if (gst_element_set_state (pipe, target_state) == - GST_STATE_CHANGE_FAILURE, "Could not set pipeline %s to playing", descr); - ret = gst_element_get_state (pipe, NULL, NULL, 10 * GST_SECOND); - if (ret == GST_STATE_CHANGE_ASYNC) { - g_critical ("Pipeline '%s' failed to go to PAUSED fast enough", descr); - goto done; - } else if ((ret != GST_STATE_CHANGE_SUCCESS) - && (ret != GST_STATE_CHANGE_NO_PREROLL)) { - g_critical ("Pipeline '%s' failed to go into PAUSED state (%s)", descr, - gst_element_state_change_return_get_name (ret)); - goto done; - } - - while (1) { - message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 2); - - /* always have to pop the message before getting back into poll */ - if (message) { - revent = GST_MESSAGE_TYPE (message); - gst_message_unref (message); - } else { - revent = GST_MESSAGE_UNKNOWN; - } - - if (revent == tevent) { - break; - } else if (revent == GST_MESSAGE_UNKNOWN) { - g_critical ("Unexpected timeout in gst_bus_poll, looking for %d: %s", - tevent, descr); - break; - } else if (revent & events) { - continue; - } - g_critical - ("Unexpected message received of type %d, '%s', looking for %d: %s", - revent, gst_message_type_get_name (revent), tevent, descr); - } - -done: - fail_if (gst_element_set_state (pipe, GST_STATE_NULL) == - GST_STATE_CHANGE_FAILURE, "Could not set pipeline %s to NULL", descr); - gst_element_get_state (pipe, NULL, NULL, GST_CLOCK_TIME_NONE); - gst_object_unref (pipe); - - gst_bus_set_flushing (bus, TRUE); - gst_object_unref (bus); -} - -GST_START_TEST (test_glimagesink) -{ - const gchar *s; - GstState target_state = GST_STATE_PLAYING; - - s = "videotestsrc num-buffers=10 ! glimagesink"; - run_pipeline (setup_pipeline (s), s, - GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), - GST_MESSAGE_UNKNOWN, target_state); -} - -GST_END_TEST -GST_START_TEST (test_glfiltercube) -{ - const gchar *s; - GstState target_state = GST_STATE_PLAYING; - - s = "videotestsrc num-buffers=10 ! glupload ! glfiltercube ! fakesink"; - run_pipeline (setup_pipeline (s), s, - GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), - GST_MESSAGE_UNKNOWN, target_state); -} - -GST_END_TEST -#define N_EFFECTS 18 -GST_START_TEST (test_gleffects) -{ - gchar *s; - GstState target_state = GST_STATE_PLAYING; - guint i; - - for (i = 0; i < N_EFFECTS; i++) { - s = g_strdup_printf ("videotestsrc num-buffers=10 ! glupload ! " - "gleffects effect=%i ! fakesink", i); - run_pipeline (setup_pipeline (s), s, - GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), - GST_MESSAGE_UNKNOWN, target_state); - g_free (s); - } -} - -GST_END_TEST -#undef N_EFFECTS -GST_START_TEST (test_glshader) -{ - const gchar *s; - GstState target_state = GST_STATE_PLAYING; - - s = "videotestsrc num-buffers=10 ! glupload ! glshader ! fakesink"; - run_pipeline (setup_pipeline (s), s, - GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), - GST_MESSAGE_UNKNOWN, target_state); - -#if GST_GL_HAVE_OPENGL - s = "gltestsrc num-buffers=10 ! glshader ! fakesink"; - run_pipeline (setup_pipeline (s), s, - GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), - GST_MESSAGE_UNKNOWN, target_state); -#endif -} - -GST_END_TEST -GST_START_TEST (test_glfilterapp) -{ - const gchar *s; - GstState target_state = GST_STATE_PLAYING; - - s = "videotestsrc num-buffers=10 ! glupload ! glfilterapp ! fakesink"; - run_pipeline (setup_pipeline (s), s, - GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), - GST_MESSAGE_UNKNOWN, target_state); - -#if GST_GL_HAVE_OPENGL - s = "gltestsrc num-buffers=10 ! glfilterapp ! fakesink"; - run_pipeline (setup_pipeline (s), s, - GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), - GST_MESSAGE_UNKNOWN, target_state); -#endif -} - -GST_END_TEST -#ifdef HAVE_PNG -#if HAVE_JPEG -GST_START_TEST (test_gloverlay) -{ - const gchar *s; - GstState target_state = GST_STATE_PLAYING; - - s = "videotestsrc num-buffers=10 ! glupload ! gloverlay ! fakesink"; - run_pipeline (setup_pipeline (s), s, - GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), - GST_MESSAGE_UNKNOWN, target_state); - -#if GST_GL_HAVE_OPENGL - s = "gltestsrc num-buffers=10 ! gloverlay ! fakesink"; - run_pipeline (setup_pipeline (s), s, - GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), - GST_MESSAGE_UNKNOWN, target_state); -#endif -} - -GST_END_TEST -#endif -#endif -#if GST_GL_HAVE_OPENGL -#define N_SRCS 13 -GST_START_TEST (test_gltestsrc) -{ - gchar *s; - GstState target_state = GST_STATE_PLAYING; - guint i; - - for (i = 0; i < N_SRCS; i++) { - s = g_strdup_printf ("gltestsrc pattern=%i num-buffers=10 ! fakesink", i); - run_pipeline (setup_pipeline (s), s, - GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), - GST_MESSAGE_UNKNOWN, target_state); - g_free (s); - } -} - -GST_END_TEST -#undef N_SRCS -GST_START_TEST (test_glfilterglass) -{ - const gchar *s; - GstState target_state = GST_STATE_PLAYING; - - s = "videotestsrc num-buffers=10 ! glupload ! glfilterglass ! fakesink"; - run_pipeline (setup_pipeline (s), s, - GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), - GST_MESSAGE_UNKNOWN, target_state); - - s = "gltestsrc num-buffers=10 ! glfilterglass ! fakesink"; - run_pipeline (setup_pipeline (s), s, - GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), - GST_MESSAGE_UNKNOWN, target_state); -} - -GST_END_TEST -#if 0 -GST_START_TEST (test_glfilterreflectedscreen) -{ - const gchar *s; - GstState target_state = GST_STATE_PLAYING; - - s = "videotestsrc num-buffers=10 ! glupload ! glfilterreflectedscreen ! " - "fakesink"; - run_pipeline (setup_pipeline (s), s, - GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), - GST_MESSAGE_UNKNOWN, target_state); - - s = "gltestsrc num-buffers=10 ! glfilterreflectedscreen ! fakesink"; - run_pipeline (setup_pipeline (s), s, - GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), - GST_MESSAGE_UNKNOWN, target_state); -} - -GST_END_TEST -#endif -GST_START_TEST (test_gldeinterlace) -{ - const gchar *s; - GstState target_state = GST_STATE_PLAYING; - - s = "videotestsrc num-buffers=10 ! glupload ! gldeinterlace ! fakesink"; - run_pipeline (setup_pipeline (s), s, - GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), - GST_MESSAGE_UNKNOWN, target_state); - - s = "gltestsrc num-buffers=10 ! gldeinterlace ! fakesink"; - run_pipeline (setup_pipeline (s), s, - GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), - GST_MESSAGE_UNKNOWN, target_state); -} - -GST_END_TEST -GST_START_TEST (test_glmosaic) -{ - const gchar *s; - GstState target_state = GST_STATE_PLAYING; - - s = "videotestsrc num-buffers=10 ! glupload ! glmosaic ! fakesink"; - run_pipeline (setup_pipeline (s), s, - GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), - GST_MESSAGE_UNKNOWN, target_state); - - s = "gltestsrc num-buffers=10 ! glmosaic ! fakesink"; - run_pipeline (setup_pipeline (s), s, - GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), - GST_MESSAGE_UNKNOWN, target_state); -} - -GST_END_TEST -GST_START_TEST (test_gldifferencematte) -{ - const gchar *s; - GstState target_state = GST_STATE_PLAYING; - - s = "videotestsrc num-buffers=10 ! glupload ! gldifferencematte ! fakesink"; - run_pipeline (setup_pipeline (s), s, - GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), - GST_MESSAGE_UNKNOWN, target_state); - - s = "gltestsrc num-buffers=10 ! gldifferencematte ! fakesink"; - run_pipeline (setup_pipeline (s), s, - GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), - GST_MESSAGE_UNKNOWN, target_state); -} - -GST_END_TEST -#endif /* GST_GL_HAVE_OPENGL */ -#endif /* !GST_DISABLE_PARSE */ -static Suite * -simple_launch_lines_suite (void) -{ - Suite *s = suite_create ("Pipelines"); - TCase *tc_chain = tcase_create ("linear"); - - /* time out after 60s, not the default 3 */ - tcase_set_timeout (tc_chain, 60); - - suite_add_tcase (s, tc_chain); -#ifndef GST_DISABLE_PARSE - tcase_add_test (tc_chain, test_glimagesink); - tcase_add_test (tc_chain, test_glfiltercube); - tcase_add_test (tc_chain, test_gleffects); - tcase_add_test (tc_chain, test_glshader); - tcase_add_test (tc_chain, test_glfilterapp); -#ifdef HAVE_PNG -#if HAVE_JPEG - tcase_add_test (tc_chain, test_gloverlay); -#endif -#endif -#if GST_GL_HAVE_OPENGL - tcase_add_test (tc_chain, test_gltestsrc); - tcase_add_test (tc_chain, test_glfilterglass); -/* tcase_add_test (tc_chain, test_glfilterreflectedscreen);*/ - tcase_add_test (tc_chain, test_glmosaic); - tcase_add_test (tc_chain, test_gldeinterlace); -#ifdef HAVE_PNG - tcase_add_test (tc_chain, test_gldifferencematte); -/* tcase_add_test (tc_chain, test_glbumper);*/ -#if HAVE_JPEG -#endif /* HAVE_JPEG */ -#endif /* HAVE_PNG */ -#endif /* GST_GL_HAVE_OPENGL */ -#endif /* !GST_DISABLE_PARSE */ - return s; -} - -GST_CHECK_MAIN (simple_launch_lines); diff --git a/tests/examples/Makefile.am b/tests/examples/Makefile.am index 6bf9a2e58..220254c6c 100644 --- a/tests/examples/Makefile.am +++ b/tests/examples/Makefile.am @@ -20,12 +20,6 @@ OPENCV_EXAMPLES=opencv MATRIXMIX_DIR=audiomixmatrix -if USE_OPENGL -GL_DIR=gl -else -GL_DIR= -endif - if HAVE_AVFOUNDATION if HAVE_IOS AVSAMPLE_DIR= @@ -65,9 +59,9 @@ playout_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) playout_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_API_VERSION) $(GST_LIBS) SUBDIRS= codecparsers mpegts $(DIRECTFB_DIR) $(GTK_EXAMPLES) $(OPENCV_EXAMPLES) \ - $(GL_DIR) $(GTK3_DIR) $(AVSAMPLE_DIR) $(WAYLAND_DIR) $(MATRIXMIX_DIR) \ + $(GTK3_DIR) $(AVSAMPLE_DIR) $(WAYLAND_DIR) $(MATRIXMIX_DIR) \ $(IPCPIPELINE_DIR) -DIST_SUBDIRS= codecparsers mpegts camerabin2 directfb mxf opencv uvch264 gl gtk \ +DIST_SUBDIRS= codecparsers mpegts camerabin2 directfb mxf opencv uvch264 gtk \ avsamplesink waylandsink audiomixmatrix ipcpipeline include $(top_srcdir)/common/parallel-subdirs.mak diff --git a/tests/examples/gl/Makefile.am b/tests/examples/gl/Makefile.am deleted file mode 100644 index b48d59221..000000000 --- a/tests/examples/gl/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ - -SUBDIRS = - -if USE_OPENGL - -if HAVE_WINDOW_COCOA -SUBDIRS += cocoa -else - -SUBDIRS += generic qt - -if HAVE_CLUTTER -SUBDIRS += clutter -endif - -if HAVE_SDL -SUBDIRS += sdl -endif - -if HAVE_GTK3 -SUBDIRS += gtk -endif - -endif - -endif - -DIST_SUBDIRS=cocoa generic qt clutter sdl gtk diff --git a/tests/examples/gl/clutter/.gitignore b/tests/examples/gl/clutter/.gitignore deleted file mode 100644 index 9b1eb5393..000000000 --- a/tests/examples/gl/clutter/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -clutteractor -clutteractortee -cluttershare diff --git a/tests/examples/gl/clutter/Makefile.am b/tests/examples/gl/clutter/Makefile.am deleted file mode 100644 index a8e31159a..000000000 --- a/tests/examples/gl/clutter/Makefile.am +++ /dev/null @@ -1,48 +0,0 @@ -noinst_PROGRAMS = ## - -#works on win32 and X -if HAVE_CLUTTER - -noinst_PROGRAMS += cluttershare - -cluttershare_SOURCES = cluttershare.c - -cluttershare_CFLAGS=-I$(top_srcdir)/gst-libs -I$(top_builddir)/gst-libs \ - $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \ - $(GST_CFLAGS) $(GL_CFLAGS) $(CLUTTER_CFLAGS) -cluttershare_LDADD=$(CLUTTER_LIBS) $(GST_PLUGINS_BASE_LIBS) \ - $(GST_LIBS) $(GL_LIBS) \ - -lgstvideo-$(GST_API_VERSION) $(top_builddir)/gst-libs/gst/gl/libgstgl-@GST_API_VERSION@.la - -endif - - -if HAVE_CLUTTER_GLX -if HAVE_CLUTTER_X11 -if HAVE_XCOMPOSITE - -noinst_PROGRAMS += clutteractor clutteractortee - -clutteractor_SOURCES = clutteractor.c - -clutteractor_CFLAGS=-I$(top_srcdir)/gst-libs -I$(top_builddir)/gst-libs \ - $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) \ - $(GL_CFLAGS) $(CLUTTER_CFLAGS) \ - $(CLUTTER_GLX_CFLAGS) $(CLUTTER_X11_CFLAGS) $(XCOMPOSITE_CFLAGS) -clutteractor_LDADD=$(CLUTTER_LIBS) $(CLUTTER_GLX_LIBS) $(CLUTTER_X11_LIBS) \ - $(GST_PLUGINS_BASE_LIBS) $(GST_LIBS) \ - $(GL_LIBS) $(XCOMPOSITE_LIBS) -lgstvideo-$(GST_API_VERSION) - -clutteractortee_SOURCES = clutteractortee.c - -clutteractortee_CFLAGS=-I$(top_srcdir)/gst-libs -I$(top_builddir)/gst-libs \ - $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) \ - $(GL_CFLAGS) $(CLUTTER_CFLAGS) \ - $(CLUTTER_GLX_CFLAGS) $(CLUTTER_X11_CFLAGS) $(XCOMPOSITE_CFLAGS) -clutteractortee_LDADD=$(CLUTTER_LIBS) $(CLUTTER_GLX_LIBS) $(CLUTTER_X11_LIBS) \ - $(GST_PLUGINS_BASE_LIBS) $(GST_LIBS) \ - $(GL_LIBS) $(XCOMPOSITE_LIBS) -lgstvideo-$(GST_API_VERSION) - -endif -endif -endif diff --git a/tests/examples/gl/clutter/clutteractor.c b/tests/examples/gl/clutter/clutteractor.c deleted file mode 100644 index 3bcd4b0ea..000000000 --- a/tests/examples/gl/clutter/clutteractor.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#define CLUTTER_VERSION_MIN_REQUIRED CLUTTER_VERSION_1_8 - -#include <X11/Xlib.h> -#include <X11/extensions/Xcomposite.h> -#include <clutter/clutter.h> -#include <clutter/x11/clutter-x11.h> -#include <clutter/glx/clutter-glx.h> -#include <gst/gst.h> -#include <gst/video/videooverlay.h> - -#define W 320 -#define H 240 - -struct GstGLClutterActor_ -{ - Window win; - Window root; - ClutterActor *texture; - ClutterActor *stage; -}; - -typedef struct GstGLClutterActor_ GstGLClutterActor; - -static gboolean -create_actor (GstGLClutterActor * actor) -{ - //ClutterKnot knot[2]; - //ClutterTimeline *timeline; - ClutterAnimation *animation = NULL; - - actor->texture = g_object_new (CLUTTER_X11_TYPE_TEXTURE_PIXMAP, - "window", actor->win, "automatic-updates", TRUE, NULL); - clutter_container_add_actor (CLUTTER_CONTAINER (actor->stage), - actor->texture); - clutter_actor_set_scale (actor->texture, 0.2, 0.2); - clutter_actor_set_opacity (actor->texture, 0); - clutter_actor_show (actor->texture); - - //timeline = - // clutter_timeline_new (120 /* frames */ , 50 /* frames per second. */ ); - //clutter_timeline_set_loop (timeline, TRUE); - //clutter_timeline_start (timeline); - - /* Instead of our custom callback, - * we could use a standard callback. For instance, CLUTTER_ALPHA_SINE_INC. - */ - /*effect_template = - clutter_effect_template_new (timeline, CLUTTER_ALPHA_SINE_INC); */ - animation = - clutter_actor_animate (actor->texture, CLUTTER_LINEAR, 2400, - "x", 100.0, "y", 100.0, "opacity", 0, NULL); - - /* knot[0].x = -10; - knot[0].y = -10; - knot[1].x = 160; - knot[1].y = 120; */ - - // Move the actor along the path: - /* clutter_effect_path (effect_template, actor->texture, knot, - sizeof (knot) / sizeof (ClutterKnot), NULL, NULL); - clutter_effect_scale (effect_template, actor->texture, 1.0, 1.0, NULL, NULL); - clutter_effect_rotate (effect_template, actor->texture, - CLUTTER_Z_AXIS, 360.0, W / 2.0, H / 2.0, 0.0, - CLUTTER_ROTATE_CW, NULL, NULL); - clutter_effect_rotate (effect_template, actor->texture, - CLUTTER_X_AXIS, 360.0, 0.0, W / 4.0, 0.0, CLUTTER_ROTATE_CW, NULL, NULL); */ - - // Also change the actor's opacity while moving it along the path: - // (You would probably want to use a different ClutterEffectTemplate, - // so you could use a different alpha callback for this.) - //clutter_effect_fade (effect_template, actor->texture, 255, NULL, NULL); - - g_object_unref (animation); - //g_object_unref (timeline); - - return FALSE; -} - -static GstBusSyncReply -create_window (GstBus * bus, GstMessage * message, gpointer data) -{ - GstGLClutterActor *actor = (GstGLClutterActor *) data; - // ignore anything but 'prepare-window-handle' element messages - if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT) - return GST_BUS_PASS; - - if (!gst_is_video_overlay_prepare_window_handle_message (message)) - return GST_BUS_PASS; - - g_debug ("CREATING WINDOW"); - - gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (GST_MESSAGE_SRC - (message)), actor->win); - clutter_threads_add_idle ((GSourceFunc) create_actor, actor); - - gst_message_unref (message); - return GST_BUS_DROP; -} - -int -main (int argc, char *argv[]) -{ - GstPipeline *pipeline; - GstBus *bus; - ClutterActor *stage; - GstGLClutterActor *actor; - Display *disp; - Window stage_win; - ClutterInitError clutter_err = CLUTTER_INIT_ERROR_UNKNOWN; - - clutter_err = clutter_init (&argc, &argv); - if (clutter_err != CLUTTER_INIT_SUCCESS) - g_warning ("Failed to initalize clutter: %d\n", clutter_err); - - gst_init (&argc, &argv); - - disp = clutter_x11_get_default_display (); - if (!clutter_x11_has_composite_extension ()) { - g_error ("XComposite extension missing"); - } - - - stage = clutter_stage_get_default (); -// clutter_actor_set_size (CLUTTER_ACTOR (stage), W*3+2, H); - - stage_win = clutter_x11_get_stage_window (CLUTTER_STAGE (stage)); - - actor = g_new0 (GstGLClutterActor, 1); - actor->stage = stage; - actor->win = XCreateSimpleWindow (disp, stage_win, 0, 0, W, H, 0, 0, 0); - XCompositeRedirectWindow (disp, actor->win, CompositeRedirectManual); - XMapRaised (disp, actor->win); - XSync (disp, FALSE); - - pipeline = - GST_PIPELINE (gst_parse_launch - ("videotestsrc ! video/x-raw, width=320, height=240, framerate=(fraction)30/1 ! " - "gleffects effect=twirl ! glimagesink", NULL)); - - bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); - - gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, actor, - NULL); - gst_object_unref (bus); - - gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); - - clutter_actor_show_all (stage); - - clutter_main (); - - gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); - gst_object_unref (pipeline); - - return 0; -} diff --git a/tests/examples/gl/clutter/clutteractortee.c b/tests/examples/gl/clutter/clutteractortee.c deleted file mode 100644 index b05020f2d..000000000 --- a/tests/examples/gl/clutter/clutteractortee.c +++ /dev/null @@ -1,232 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#define GLIB_DISABLE_DEPRECATION_WARNINGS -#define CLUTTER_VERSION_MIN_REQUIRED CLUTTER_VERSION_1_8 - -#include <X11/Xlib.h> -#include <X11/extensions/Xcomposite.h> -#include <clutter/clutter.h> -#include <clutter/x11/clutter-x11.h> -#include <clutter/glx/clutter-glx.h> -#include <gst/gst.h> -#include <gst/video/videooverlay.h> - -#define ROWS 3 -#define COLS 3 -#define N_ACTORS ROWS*COLS -#define W 160 -#define H 120 - -struct GstGLClutterActor_ -{ - Window win; - Window root; - ClutterActor *texture; - ClutterActor *stage; -}; - -typedef struct GstGLClutterActor_ GstGLClutterActor; - -static gboolean -create_actor (GstGLClutterActor * actor) -{ - static gint xpos = 0; - static gint ypos = 0; - actor->texture = g_object_new (CLUTTER_X11_TYPE_TEXTURE_PIXMAP, - "window", actor->win, "automatic-updates", TRUE, NULL); - clutter_container_add_actor (CLUTTER_CONTAINER (actor->stage), - actor->texture); - clutter_actor_set_position (actor->texture, xpos, ypos); - - if (xpos > (COLS - 1) * W) { - xpos = 0; - ypos += H + 1; - } else - xpos += W + 1; - clutter_actor_show (actor->texture); - - return FALSE; -} - -static GstBusSyncReply -create_window (GstBus * bus, GstMessage * message, gpointer data) -{ - GstGLClutterActor **actor = (GstGLClutterActor **) data; - static gint count = 0; - static GMutex mutex; - // ignore anything but 'prepare-window-handle' element messages - if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT) - return GST_BUS_PASS; - - if (!gst_is_video_overlay_prepare_window_handle_message (message)) - return GST_BUS_PASS; - - g_mutex_lock (&mutex); - - if (count < N_ACTORS) { - g_message ("adding actor %d", count); - gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (GST_MESSAGE_SRC - (message)), actor[count]->win); - clutter_threads_add_idle ((GSourceFunc) create_actor, actor[count]); - count++; - } - - g_mutex_unlock (&mutex); - - gst_message_unref (message); - return GST_BUS_DROP; -} - -#if 0 -void -apply_fx (GstElement * element, const gchar * fx) -{ - GEnumClass *p_class; - - /* from fxtest ;) */ - /* heeeellppppp!! */ - p_class = - G_PARAM_SPEC_ENUM (g_object_class_find_property (G_OBJECT_GET_CLASS - (G_OBJECT (data)), "effect") - )->enum_class; - - g_print ("setting: %s - %s\n", fx, g_enum_get_value_by_nick (p_class, - fx)->value_name); - g_object_set (G_OBJECT (element), "effect", g_enum_get_value_by_nick (p_class, - fx)->value, NULL); -} -#endif - -int -main (int argc, char *argv[]) -{ - GstPipeline *pipeline; - GstBus *bus; - - GstElement *srcbin; - GstElement *tee; - GstElement *queue[N_ACTORS], *sink[N_ACTORS]; - GstElement *upload[N_ACTORS]; -/* - GstElement *effect[N_ACTORS]; -*/ - ClutterActor *stage; - GstGLClutterActor *actor[N_ACTORS]; - Display *disp; - Window stage_win; - const gchar *desc; - gint i; - gint ok = FALSE; - ClutterInitError clutter_err = CLUTTER_INIT_ERROR_UNKNOWN; - - clutter_err = clutter_init (&argc, &argv); - if (clutter_err != CLUTTER_INIT_SUCCESS) - g_warning ("Failed to initalize clutter: %d\n", clutter_err); - - gst_init (&argc, &argv); - - disp = clutter_x11_get_default_display (); - if (!clutter_x11_has_composite_extension ()) { - g_error ("XComposite extension missing"); - } - - stage = clutter_stage_get_default (); - clutter_actor_set_size (CLUTTER_ACTOR (stage), - W * COLS + (COLS - 1), H * ROWS + (ROWS - 1)); - - stage_win = clutter_x11_get_stage_window (CLUTTER_STAGE (stage)); - XCompositeRedirectSubwindows (disp, stage_win, CompositeRedirectManual); - - for (i = 0; i < N_ACTORS; i++) { - actor[i] = g_new0 (GstGLClutterActor, 1); - actor[i]->stage = stage; - actor[i]->win = XCreateSimpleWindow (disp, stage_win, 0, 0, W, H, 0, 0, 0); - XMapRaised (disp, actor[i]->win); - XSync (disp, FALSE); - } -/* - desc = g_strdup_printf ("v4l2src ! " - "video/x-raw, width=640, height=480, framerate=30/1 ! " - "videoscale !" - "video/x-raw, width=%d, height=%d ! " - "identity", W, H); -*/ - desc = g_strdup_printf ("videotestsrc ! " - "video/x-raw, format=RGB, width=%d, height=%d !" "identity", W, H); - pipeline = GST_PIPELINE (gst_pipeline_new (NULL)); - - srcbin = gst_parse_bin_from_description (desc, TRUE, NULL); - if (!srcbin) - g_error ("Source bin creation failed"); - - tee = gst_element_factory_make ("tee", NULL); - - gst_bin_add_many (GST_BIN (pipeline), srcbin, tee, NULL); - - for (i = 0; i < N_ACTORS; i++) { - queue[i] = gst_element_factory_make ("queue", NULL); - upload[i] = gst_element_factory_make ("glupload", NULL); -/* effect[i] = gst_element_factory_make ("gleffects", NULL); */ - sink[i] = gst_element_factory_make ("glimagesink", NULL); -/* gst_bin_add_many (GST_BIN (pipeline), - queue[i], upload[i], effect[i], sink[i], NULL); */ - gst_bin_add_many (GST_BIN (pipeline), queue[i], upload[i], sink[i], NULL); - } - - gst_element_link_many (srcbin, tee, NULL); - - for (i = 0; i < N_ACTORS; i++) { - ok |= -// gst_element_link_many (tee, queue[i], upload[i], effect[i], sink[i], - gst_element_link_many (tee, queue[i], upload[i], sink[i], NULL); - } - - if (!ok) - g_error ("Failed to link one or more elements"); - -/* - for (i = 0; i < N_ACTORS; i++) { - g_message ("setting effect %d on %s", i + 1, - gst_element_get_name (effect[i])); - g_object_set (G_OBJECT (effect[i]), "effect", i + 1, NULL); - } -*/ - - bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); - - gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, actor, - NULL); - gst_object_unref (bus); - - gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); - - clutter_actor_show_all (stage); - - clutter_main (); - - gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); - gst_object_unref (pipeline); - - return 0; -} diff --git a/tests/examples/gl/clutter/cluttershare.c b/tests/examples/gl/clutter/cluttershare.c deleted file mode 100644 index ee4eb7d31..000000000 --- a/tests/examples/gl/clutter/cluttershare.c +++ /dev/null @@ -1,383 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <GL/gl.h> - -#define CLUTTER_VERSION_MIN_REQUIRED CLUTTER_VERSION_1_8 -#define CLUTTER_VERSION_MAX_ALLOWED CLUTTER_VERSION_1_10 -#define COGL_VERSION_MIN_REQUIRED COGL_VERSION_ENCODE (1, 16, 0) -#define COGL_VERSION_MAX_ALLOWED COGL_VERSION_ENCODE (1, 18, 0) -#include <clutter/clutter.h> -#ifndef WIN32 -#include <clutter/x11/clutter-x11.h> -#include <GL/glx.h> -#endif - -#include <gst/gst.h> -#include <gst/video/video.h> -#include <gst/video/gstvideometa.h> -#include <gst/gl/gl.h> - -/* This example shows how to use textures that come from a - * gst-plugins-gl pipeline, into the clutter framework - * It requires at least clutter 0.8.6 - */ - -/* rotation */ -static void -on_new_frame (ClutterTimeline * timeline, gint msecs, gpointer data) -{ - ClutterActor *rect_actor = CLUTTER_ACTOR (data); - ClutterActor *texture_actor = - g_object_get_data (G_OBJECT (timeline), "texture_actor"); - - clutter_actor_set_rotation (rect_actor, CLUTTER_Z_AXIS, - 60.0 * (gdouble) msecs / 1000.0, clutter_actor_get_width (rect_actor) / 2, - clutter_actor_get_height (rect_actor) / 2, 0); - - clutter_actor_set_rotation (texture_actor, CLUTTER_Z_AXIS, - 60.0 * (gdouble) msecs / 1000.0, - clutter_actor_get_width (texture_actor) / 6, - clutter_actor_get_height (texture_actor) / 6, 0); -} - - -/* clutter scene */ -static ClutterActor * -setup_stage (ClutterStage * stage) -{ - ClutterTimeline *timeline = NULL; - ClutterActor *texture_actor = NULL; - ClutterColor rect_color = { 125, 50, 200, 255 }; - ClutterActor *rect_actor = NULL; - - /* texture actor */ - - texture_actor = clutter_texture_new (); - clutter_container_add_actor (CLUTTER_CONTAINER (stage), texture_actor); - clutter_actor_set_position (texture_actor, 300, 170); - clutter_actor_set_scale (texture_actor, 0.6, 0.6); - clutter_actor_show (texture_actor); - g_object_set_data (G_OBJECT (texture_actor), "stage", stage); - - /* rectangle actor */ - - rect_actor = clutter_rectangle_new_with_color (&rect_color); - clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect_actor); - clutter_actor_set_size (rect_actor, 50, 50); - clutter_actor_set_position (rect_actor, 300, 300); - clutter_actor_show (rect_actor); - - /* timeline */ - - timeline = clutter_timeline_new (6000); - g_object_set_data (G_OBJECT (timeline), "texture_actor", texture_actor); - clutter_timeline_set_loop (timeline, TRUE); - clutter_timeline_start (timeline); - g_signal_connect (timeline, "new-frame", G_CALLBACK (on_new_frame), - rect_actor); - - return texture_actor; -} - -/* put a gst gl buffer in the texture actor */ -static gboolean -update_texture_actor (gpointer data) -{ - ClutterTexture *texture_actor = (ClutterTexture *) data; - GAsyncQueue *queue_input_buf = - g_object_get_data (G_OBJECT (texture_actor), "queue_input_buf"); - GAsyncQueue *queue_output_buf = - g_object_get_data (G_OBJECT (texture_actor), "queue_output_buf"); - GstBuffer *inbuf = g_async_queue_pop (queue_input_buf); - ClutterActor *stage = g_object_get_data (G_OBJECT (texture_actor), "stage"); - CoglHandle cogl_texture = 0; - GstVideoMeta *v_meta; - GstVideoInfo info; - GstVideoFrame frame; - guint tex_id; - - v_meta = gst_buffer_get_video_meta (inbuf); - if (!v_meta) { - g_warning ("Required Meta was not found on buffers"); - return FALSE; - } - - gst_video_info_set_format (&info, v_meta->format, v_meta->width, - v_meta->height); - - if (!gst_video_frame_map (&frame, &info, inbuf, GST_MAP_READ | GST_MAP_GL)) { - g_warning ("Failed to map video frame"); - return FALSE; - } - - if (!gst_is_gl_memory (frame.map[0].memory)) { - g_warning ("Input buffer does not have GLMemory"); - gst_video_frame_unmap (&frame); - return FALSE; - } - - tex_id = *(guint *) frame.data[0]; - - /* Create a cogl texture from the gst gl texture */ - glEnable (GL_TEXTURE_2D); - glBindTexture (GL_TEXTURE_2D, tex_id); - if (glGetError () != GL_NO_ERROR) - g_debug ("failed to bind texture that comes from gst-gl\n"); - cogl_texture = cogl_texture_new_from_foreign (tex_id, - GL_TEXTURE_2D, v_meta->width, v_meta->height, 0, 0, - COGL_PIXEL_FORMAT_RGBA_8888); - glBindTexture (GL_TEXTURE_2D, 0); - - gst_video_frame_unmap (&frame); - - /* Previous cogl texture is replaced and so its ref counter discreases to 0. - * According to the source code, glDeleteTexture is not called when the previous - * ref counter of the previous cogl texture is reaching 0 because is_foreign is TRUE */ - clutter_texture_set_cogl_texture (CLUTTER_TEXTURE (texture_actor), - cogl_texture); - cogl_handle_unref (cogl_texture); - - /* we can now show the clutter scene if not yet visible */ - if (!CLUTTER_ACTOR_IS_VISIBLE (stage)) - clutter_actor_show_all (stage); - - /* push buffer so it can be unref later */ - g_async_queue_push (queue_output_buf, inbuf); - - return FALSE; -} - - -/* fakesink handoff callback */ -static void -on_gst_buffer (GstElement * element, GstBuffer * buf, GstPad * pad, - ClutterActor * texture_actor) -{ - GAsyncQueue *queue_input_buf = NULL; - GAsyncQueue *queue_output_buf = NULL; - - /* ref then push buffer to use it in clutter */ - gst_buffer_ref (buf); - queue_input_buf = - g_object_get_data (G_OBJECT (texture_actor), "queue_input_buf"); - g_async_queue_push (queue_input_buf, buf); - if (g_async_queue_length (queue_input_buf) > 2) - clutter_threads_add_idle_full (G_PRIORITY_HIGH, update_texture_actor, - texture_actor, NULL); - - /* pop then unref buffer we have finished to use in clutter */ - queue_output_buf = - g_object_get_data (G_OBJECT (texture_actor), "queue_output_buf"); - if (g_async_queue_length (queue_output_buf) > 2) { - GstBuffer *buf_old = g_async_queue_pop (queue_output_buf); - gst_buffer_unref (buf_old); - } -} - -/* gst bus signal watch callback */ -static void -end_stream_cb (GstBus * bus, GstMessage * msg, gpointer data) -{ - switch (GST_MESSAGE_TYPE (msg)) { - - case GST_MESSAGE_EOS: - g_print ("End-of-stream\n"); - g_print - ("For more information, try to run: GST_DEBUG=gldisplay:2 ./cluttershare\n"); - break; - - case GST_MESSAGE_ERROR: - { - gchar *debug = NULL; - GError *err = NULL; - - gst_message_parse_error (msg, &err, &debug); - - g_print ("Error: %s\n", err->message); - g_error_free (err); - - if (debug) { - g_print ("Debug deails: %s\n", debug); - g_free (debug); - } - - break; - } - - default: - break; - } - - clutter_main_quit (); -} - -int -main (int argc, char *argv[]) -{ - ClutterInitError clutter_err = CLUTTER_INIT_ERROR_UNKNOWN; -#ifdef WIN32 - HGLRC clutter_gl_context = 0; - HDC clutter_dc = 0; -#else - Display *clutter_display = NULL; - Window clutter_win = 0; - GLXContext clutter_gl_context = NULL; -#endif - GstPipeline *pipeline = NULL; - GstBus *bus = NULL; - GstElement *glfilter = NULL; - GstState state = 0; - ClutterActor *stage = NULL; - ClutterActor *clutter_texture = NULL; - GAsyncQueue *queue_input_buf = NULL; - GAsyncQueue *queue_output_buf = NULL; - GstElement *fakesink = NULL; - - /* init gstreamer then clutter */ - - gst_init (&argc, &argv); - clutter_threads_init (); - clutter_err = clutter_init (&argc, &argv); - if (clutter_err != CLUTTER_INIT_SUCCESS) - g_warning ("Failed to initalize clutter: %d\n", clutter_err); - clutter_threads_enter (); - g_print ("clutter version: %s\n", CLUTTER_VERSION_S); - clutter_set_default_frame_rate (2); - - /* avoid to dispatch unecesary events */ - clutter_ungrab_keyboard (); - clutter_ungrab_pointer (); - - /* retrieve and turn off clutter opengl context */ - stage = clutter_stage_get_default (); - -#ifdef WIN32 - clutter_gl_context = wglGetCurrentContext (); - clutter_dc = wglGetCurrentDC (); - wglMakeCurrent (0, 0); -#else - clutter_display = clutter_x11_get_default_display (); - clutter_win = clutter_x11_get_stage_window (CLUTTER_STAGE (stage)); - clutter_gl_context = glXGetCurrentContext (); - glXMakeCurrent (clutter_display, None, 0); -#endif - - /* setup gstreamer pipeline */ - - pipeline = - GST_PIPELINE (gst_parse_launch - ("videotestsrc ! video/x-raw, width=320, height=240, framerate=(fraction)30/1 ! " - "gleffects effect=5 ! glfiltercube ! fakesink sync=1", NULL)); - - /* setup bus */ - - bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); - gst_bus_add_signal_watch (bus); - g_signal_connect (bus, "message::error", G_CALLBACK (end_stream_cb), NULL); - g_signal_connect (bus, "message::warning", G_CALLBACK (end_stream_cb), NULL); - g_signal_connect (bus, "message::eos", G_CALLBACK (end_stream_cb), NULL); - gst_object_unref (bus); - - /* clutter_gl_context is an external OpenGL context with which gst-plugins-gl want to share textures */ - glfilter = gst_bin_get_by_name (GST_BIN (pipeline), "glfiltercube0"); - g_object_set (G_OBJECT (glfilter), "external-opengl-context", - clutter_gl_context, NULL); - gst_object_unref (glfilter); - - /* NULL to PAUSED state pipeline to make sure the gst opengl context is created and - * shared with the clutter one */ - gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED); - state = GST_STATE_PAUSED; - if (gst_element_get_state (GST_ELEMENT (pipeline), &state, NULL, - GST_CLOCK_TIME_NONE) != GST_STATE_CHANGE_SUCCESS) { - g_debug ("failed to pause pipeline\n"); - return -1; - } - - /* turn on back clutter opengl context */ -#ifdef WIN32 - wglMakeCurrent (clutter_dc, clutter_gl_context); -#else - glXMakeCurrent (clutter_display, clutter_win, clutter_gl_context); -#endif - - /* clutter stage */ - clutter_actor_set_size (stage, 640, 480); - clutter_actor_set_position (stage, 0, 0); - clutter_stage_set_title (CLUTTER_STAGE (stage), "clutter and gst-plugins-gl"); - clutter_texture = setup_stage (CLUTTER_STAGE (stage)); - - /* append a gst-gl texture to this queue when you do not need it no more */ - queue_input_buf = g_async_queue_new (); - queue_output_buf = g_async_queue_new (); - g_object_set_data (G_OBJECT (clutter_texture), "queue_input_buf", - queue_input_buf); - g_object_set_data (G_OBJECT (clutter_texture), "queue_output_buf", - queue_output_buf); - - /* set a callback to retrieve the gst gl textures */ - fakesink = gst_bin_get_by_name (GST_BIN (pipeline), "fakesink0"); - g_object_set (G_OBJECT (fakesink), "signal-handoffs", TRUE, NULL); - g_signal_connect (fakesink, "handoff", G_CALLBACK (on_gst_buffer), - clutter_texture); - gst_object_unref (fakesink); - - /* play gst */ - gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); - - /* main loop */ - clutter_main (); - - /* before to deinitialize the gst-gl-opengl context, - * no shared context (here the clutter one) must be current - */ -#ifdef WIN32 - wglMakeCurrent (0, 0); -#else - glXMakeCurrent (clutter_display, None, 0); -#endif - - clutter_threads_leave (); - - /* stop and clean up the pipeline */ - gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); - gst_object_unref (pipeline); - - /* make sure there is no pending gst gl buffer in the communication queues - * between clutter and gst-gl - */ - while (g_async_queue_length (queue_input_buf) > 0) { - GstBuffer *buf = g_async_queue_pop (queue_input_buf); - gst_buffer_unref (buf); - } - - while (g_async_queue_length (queue_output_buf) > 0) { - GstBuffer *buf = g_async_queue_pop (queue_output_buf); - gst_buffer_unref (buf); - } - - g_print ("END\n"); - - return 0; -} diff --git a/tests/examples/gl/clutter/cluttershare.cbp b/tests/examples/gl/clutter/cluttershare.cbp deleted file mode 100644 index cb4907e6d..000000000 --- a/tests/examples/gl/clutter/cluttershare.cbp +++ /dev/null @@ -1,76 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> -<CodeBlocks_project_file> - <FileVersion major="1" minor="6" /> - <Project> - <Option title="cluttershare" /> - <Option pch_mode="2" /> - <Option compiler="gcc" /> - <Build> - <Target title="Debug"> - <Option output="bin\Debug\cluttershare" prefix_auto="1" extension_auto="1" /> - <Option object_output="obj\Debug\" /> - <Option type="1" /> - <Option compiler="gcc" /> - <Compiler> - <Add option="-g" /> - </Compiler> - </Target> - <Target title="Release"> - <Option output="bin\Release\cluttershare" prefix_auto="1" extension_auto="1" /> - <Option object_output="obj\Release\" /> - <Option type="1" /> - <Option compiler="gcc" /> - <Compiler> - <Add option="-O2" /> - </Compiler> - <Linker> - <Add option="-s" /> - </Linker> - </Target> - </Build> - <Compiler> - <Add option="-Wall" /> - <Add option="-ansi" /> - <Add option="-std=c89" /> - <Add option="-DWIN32" /> - <Add directory="..\..\..\..\clutter\include\clutter-0.8" /> - <Add directory="C:\gstreamer\include\glib-2.0" /> - <Add directory="C:\gstreamer\lib\glib-2.0\include" /> - <Add directory="C:\gstreamer\include\gstreamer-1.0" /> - <Add directory="C:\gstreamer\include\pango-1.0" /> - <Add directory="C:\gstreamer\include\cairo" /> - <Add directory="C:\gstreamer\include\libxml2" /> - <Add directory="C:\gstreamer\include" /> - </Compiler> - <Linker> - <Add library="clutter-win32-0.8" /> - <Add library="gio-2.0" /> - <Add library="gthread-2.0" /> - <Add library="gobject-2.0" /> - <Add library="gstreamer-1.0" /> - <Add library="gmodule-2.0" /> - <Add library="gstvideo-1.0" /> - <Add library="glib-2.0" /> - <Add library="pangocairo-1.0" /> - <Add library="pangowin32-1.0" /> - <Add library="pango-1.0" /> - <Add library="gdk_pixbuf-2.0" /> - <Add library="cairo" /> - <Add library="glu32" /> - <Add library="opengl32" /> - <Add library="gdi32" /> - <Add library="winmm" /> - <Add directory="..\..\..\..\clutter\lib" /> - <Add directory="C:\gstreamer\lib" /> - <Add directory="C:\gstreamer\bin" /> - <Add directory="..\..\..\..\gtk+\lib" /> - </Linker> - <Unit filename="cluttershare.c"> - <Option compilerVar="CC" /> - </Unit> - <Extensions> - <code_completion /> - <debugger /> - </Extensions> - </Project> -</CodeBlocks_project_file> diff --git a/tests/examples/gl/cocoa/.gitignore b/tests/examples/gl/cocoa/.gitignore deleted file mode 100644 index 5cfb85ef2..000000000 --- a/tests/examples/gl/cocoa/.gitignore +++ /dev/null @@ -1 +0,0 @@ -cocoa-videooverlay diff --git a/tests/examples/gl/cocoa/Makefile.am b/tests/examples/gl/cocoa/Makefile.am deleted file mode 100755 index 9148f8a4a..000000000 --- a/tests/examples/gl/cocoa/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ -if HAVE_WINDOW_COCOA - -noinst_PROGRAMS = cocoa-videooverlay - -cocoa_videooverlay_SOURCES = cocoa-videooverlay.m - -cocoa_videooverlay_OBJCFLAGS=-Wno-error=unused-command-line-argument \ - -fobjc-arc \ - -I$(top_srcdir)/gst-libs -I$(top_builddir)/gst-libs \ - $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) \ - $(GL_CFLAGS) $(GL_OBJCFLAGS) - -cocoa_videooverlay_LDADD=$(GST_PLUGINS_BASE_LIBS) $(GST_LIBS) \ - $(GL_LIBS) -lgstvideo-$(GST_API_VERSION) - -endif diff --git a/tests/examples/gl/cocoa/cocoa-videooverlay.m b/tests/examples/gl/cocoa/cocoa-videooverlay.m deleted file mode 100755 index 3151726bc..000000000 --- a/tests/examples/gl/cocoa/cocoa-videooverlay.m +++ /dev/null @@ -1,233 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include <Cocoa/Cocoa.h> -#include <gst/gst.h> -#include <gst/video/videooverlay.h> - -#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200 -#define NSEventMaskAny NSAnyEventMask -#define NSWindowStyleMaskTitled NSTitledWindowMask -#define NSWindowStyleMaskClosable NSClosableWindowMask -#define NSWindowStyleMaskResizable NSResizableWindowMask -#define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask -#endif - -/* ============================================================= */ -/* */ -/* MainWindow */ -/* */ -/* ============================================================= */ - -@interface MainWindow: NSWindow <NSApplicationDelegate> { - GMainLoop *m_loop; - GstElement *m_pipeline; - gboolean m_isClosed; -} -- (id) initWithContentRect:(NSRect) contentRect Loop:(GMainLoop*)loop Pipeline:(GstElement*)pipeline; -- (GMainLoop*) loop; -- (GstElement*) pipeline; -- (gboolean) isClosed; -@end - -@implementation MainWindow - -- (id) initWithContentRect:(NSRect)contentRect Loop:(GMainLoop*)loop Pipeline:(GstElement*)pipeline -{ - m_loop = loop; - m_pipeline = pipeline; - m_isClosed = FALSE; - - self = [super initWithContentRect: contentRect - styleMask: (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | - NSWindowStyleMaskResizable | NSWindowStyleMaskMiniaturizable) - backing: NSBackingStoreBuffered defer: NO screen: nil]; - - [self setReleasedWhenClosed:NO]; - [[NSApplication sharedApplication] setDelegate:self]; - - [self setTitle:@"gst-plugins-gl implements videooverlay interface"]; - - return self; -} - -- (GMainLoop*) loop { - return m_loop; -} - -- (GstElement*) pipeline { - return m_pipeline; -} - -- (gboolean) isClosed { - return m_isClosed; -} - -- (void) customClose { - m_isClosed = TRUE; -} - -- (BOOL) windowShouldClose:(id)sender { - gst_element_send_event (m_pipeline, gst_event_new_eos ()); - return YES; -} - -- (void) applicationDidFinishLaunching: (NSNotification *) not { - [self makeMainWindow]; - [self center]; - [self orderFront:self]; -} - -- (BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)app { - return NO; -} - -@end - - -/* ============================================================= */ -/* */ -/* gstreamer callbacks */ -/* */ -/* ============================================================= */ - - -static GstBusSyncReply create_window (GstBus* bus, GstMessage* message, MainWindow* window) -{ - // ignore anything but 'prepare-window-handle' element messages - if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT) - return GST_BUS_PASS; - - if (!gst_is_video_overlay_prepare_window_handle_message (message)) - return GST_BUS_PASS; - - g_print ("setting window handle %lud\n", (gulong) window); - - gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (GST_MESSAGE_SRC (message)), (guintptr) [window contentView]); - - gst_message_unref (message); - - return GST_BUS_DROP; -} - - -static void end_stream_cb(GstBus* bus, GstMessage* message, MainWindow* window) -{ - g_print ("end of stream\n"); - - gst_element_set_state ([window pipeline], GST_STATE_NULL); - gst_object_unref ([window pipeline]); - g_main_loop_quit ([window loop]); - - [window performSelectorOnMainThread:@selector(customClose) withObject:nil waitUntilDone:YES]; -} - -static gpointer thread_func (MainWindow* window) -{ - g_main_loop_run ([window loop]); - - return NULL; -} - - -/* ============================================================= */ -/* */ -/* application */ -/* */ -/* ============================================================= */ - -int main(int argc, char **argv) -{ - int width = 640; - int height = 480; - - GMainLoop *loop = NULL; - GstElement *pipeline = NULL; - - GstElement *videosrc = NULL; - GstElement *videosink = NULL; - GstCaps *caps=NULL; - gboolean ok=FALSE; - GstBus *bus=NULL; - GThread *loop_thread=NULL; - NSRect rect; - MainWindow *window=nil; - - [NSApplication sharedApplication]; - - g_print("app created\n"); - - gst_init (&argc, &argv); - - loop = g_main_loop_new (NULL, FALSE); - pipeline = gst_pipeline_new ("pipeline"); - - videosrc = gst_element_factory_make ("videotestsrc", "videotestsrc"); - videosink = gst_element_factory_make ("glimagesink", "glimagesink"); - - g_object_set(G_OBJECT(videosrc), "num-buffers", 500, NULL); - - gst_bin_add_many (GST_BIN (pipeline), videosrc, videosink, NULL); - - caps = gst_caps_new_simple("video/x-raw", - "width", G_TYPE_INT, width, - "height", G_TYPE_INT, height, - "framerate", GST_TYPE_FRACTION, 25, 1, - "format", G_TYPE_STRING, "I420", - NULL); - - ok = gst_element_link_filtered(videosrc, videosink, caps); - gst_caps_unref(caps); - if (!ok) - g_warning("could not link videosrc to videosink\n"); - - rect.origin.x = 0; rect.origin.y = 0; - rect.size.width = width; rect.size.height = height; - - window = [[MainWindow alloc] initWithContentRect:rect Loop:loop Pipeline:pipeline]; - - bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); - gst_bus_add_signal_watch (bus); - /* NOTE: window is not bridge_retained because its lifetime is just this function */ - g_signal_connect(bus, "message::error", G_CALLBACK(end_stream_cb), (__bridge gpointer)window); - g_signal_connect(bus, "message::warning", G_CALLBACK(end_stream_cb), (__bridge gpointer)window); - g_signal_connect(bus, "message::eos", G_CALLBACK(end_stream_cb), (__bridge gpointer)window); - gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, (__bridge gpointer)window, NULL); - gst_object_unref (bus); - - loop_thread = g_thread_new (NULL, - (GThreadFunc) thread_func, (__bridge gpointer)window); - - gst_element_set_state (pipeline, GST_STATE_PLAYING); - - [window orderFront:window]; - - while (![window isClosed]) { - NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny - untilDate:[NSDate dateWithTimeIntervalSinceNow:1] - inMode:NSDefaultRunLoopMode dequeue:YES]; - if (event) - [NSApp sendEvent:event]; - } - - g_thread_join (loop_thread); - - return 0; -} diff --git a/tests/examples/gl/generic/Makefile.am b/tests/examples/gl/generic/Makefile.am deleted file mode 100644 index a334e12e3..000000000 --- a/tests/examples/gl/generic/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ - -SUBDIRS = cube cubeyuv doublecube recordgraphic diff --git a/tests/examples/gl/generic/README b/tests/examples/gl/generic/README deleted file mode 100644 index a91d6bffe..000000000 --- a/tests/examples/gl/generic/README +++ /dev/null @@ -1,21 +0,0 @@ ---- Description of the generic (no GUI) examples --- - -- cube: -Show how to have a graphic FPS greater than the input video frame rate. -The source is the videotestsrc rgb. - -- cubeyuv: -Show how to have a graphic FPS greater than the input video frame rate. -The source is a local video file needed in argument. -The colorspace conversion is maded by the glupload element. - -- doublecube: -A local video source is displayed into two renderers. -The first one is a normal 2D screen, the second is a 3D cube. -We can visually check that the video is displayed at the same speed -in the two renderers. - -- recordgraphic: -Show how to use the glfilterapp to define the draw callback in a gstreamer client code. -The scene is recorded into an avi file using mpeg4 encoder. -The colorspace conversion is made by the gldownload element. diff --git a/tests/examples/gl/generic/cube/.gitignore b/tests/examples/gl/generic/cube/.gitignore deleted file mode 100644 index 3c088ddc8..000000000 --- a/tests/examples/gl/generic/cube/.gitignore +++ /dev/null @@ -1 +0,0 @@ -cube diff --git a/tests/examples/gl/generic/cube/Makefile.am b/tests/examples/gl/generic/cube/Makefile.am deleted file mode 100644 index e1b0cef6f..000000000 --- a/tests/examples/gl/generic/cube/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ - -noinst_PROGRAMS = cube - -cube_SOURCES = main.cpp - -cube_CXXFLAGS=-I$(top_srcdir)/gst-libs -I$(top_builddir)/gst-libs \ - $(GST_PLUGINS_BASE_CFLAGS) $(GST_CXXFLAGS) $(GL_CFLAGS) -cube_LDADD=$(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_API_VERSION) $(GST_LIBS) $(GL_LIBS) - diff --git a/tests/examples/gl/generic/cube/main.cpp b/tests/examples/gl/generic/cube/main.cpp deleted file mode 100644 index 730d952cb..000000000 --- a/tests/examples/gl/generic/cube/main.cpp +++ /dev/null @@ -1,267 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008-2009 Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include <gst/gst.h> -#include <gst/gl/gl.h> -#include <gst/gl/gstglfuncs.h> - - -#include <iostream> -#include <string> - -static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data) -{ - GMainLoop *loop = (GMainLoop*)data; - - switch (GST_MESSAGE_TYPE (msg)) - { - case GST_MESSAGE_EOS: - g_print ("End-of-stream\n"); - g_main_loop_quit (loop); - break; - case GST_MESSAGE_ERROR: - { - gchar *debug = NULL; - GError *err = NULL; - - gst_message_parse_error (msg, &err, &debug); - - g_print ("Error: %s\n", err->message); - g_error_free (err); - - if (debug) - { - g_print ("Debug deails: %s\n", debug); - g_free (debug); - } - - g_main_loop_quit (loop); - break; - } - default: - break; - } - - return TRUE; -} - -//client reshape callback -static gboolean reshapeCallback (void *gl_sink, void *context, GLuint width, GLuint height, gpointer data) -{ - glViewport(0, 0, width, height); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - - return TRUE; -} - -//client draw callback -static gboolean drawCallback (GstElement * gl_sink, GstGLContext *context, GstSample * sample, gpointer data) -{ - static GLfloat xrot = 0; - static GLfloat yrot = 0; - static GLfloat zrot = 0; - static GTimeVal current_time; - static glong last_sec = current_time.tv_sec; - static gint nbFrames = 0; - - GstVideoFrame v_frame; - GstVideoInfo v_info; - guint texture = 0; - GstBuffer *buf = gst_sample_get_buffer (sample); - GstCaps *caps = gst_sample_get_caps (sample); - - gst_video_info_from_caps (&v_info, caps); - - if (!gst_video_frame_map (&v_frame, &v_info, buf, (GstMapFlags) (GST_MAP_READ | GST_MAP_GL))) { - g_warning ("Failed to map the video buffer"); - return TRUE; - } - - texture = *(guint *) v_frame.data[0]; - - g_get_current_time (¤t_time); - nbFrames++ ; - - if ((current_time.tv_sec - last_sec) >= 1) - { - std::cout << "GRPHIC FPS = " << nbFrames << std::endl; - nbFrames = 0; - last_sec = current_time.tv_sec; - } - - glEnable(GL_DEPTH_TEST); - - glEnable (GL_TEXTURE_2D); - glBindTexture (GL_TEXTURE_2D, texture); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - /* invert the y-axis to get the front face the correct way up */ - glScalef (0.5f, -0.5f, 0.5f); - - glRotatef(xrot,1.0f,0.0f,0.0f); - glRotatef(yrot,0.0f,1.0f,0.0f); - glRotatef(zrot,0.0f,0.0f,1.0f); - - glBegin(GL_QUADS); - // Front Face - glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); - // Back Face - glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); - glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); - // Top Face - glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); - glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); - // Bottom Face - glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, 1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, 1.0f); - // Right face - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); - glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); - // Left Face - glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); - glEnd(); - - gst_video_frame_unmap (&v_frame); - - xrot+=0.3f; - yrot+=0.2f; - zrot+=0.4f; - - glDisable (GL_DEPTH_TEST); - glDisable (GL_TEXTURE_2D); - - return TRUE; -} - - -//gst-launch-1.0 videotestsrc num_buffers=400 ! video/x-raw, width=320, height=240 ! -//glgraphicmaker ! glfiltercube ! video/x-raw, width=800, height=600 ! glimagesink -gint main (gint argc, gchar *argv[]) -{ - GstStateChangeReturn ret; - GstElement *pipeline, *videosrc, *glimagesink; - - GMainLoop *loop; - GstBus *bus; - - /* FIXME: remove once the example supports gl3 and/or gles2 */ - g_setenv ("GST_GL_API", "opengl", FALSE); - - /* initialization */ - gst_init (&argc, &argv); - loop = g_main_loop_new (NULL, FALSE); - - /* create elements */ - pipeline = gst_pipeline_new ("pipeline"); - - /* watch for messages on the pipeline's bus (note that this will only - * work like this when a GLib main loop is running) */ - bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); - gst_bus_add_watch (bus, bus_call, loop); - gst_object_unref (bus); - - /* create elements */ - videosrc = gst_element_factory_make ("videotestsrc", "videotestsrc0"); - glimagesink = gst_element_factory_make ("glimagesink", "glimagesink0"); - - - if (!videosrc || !glimagesink) - { - g_print ("one element could not be found \n"); - return -1; - } - - /* change video source caps */ - GstCaps *caps = gst_caps_new_simple("video/x-raw", - "format", G_TYPE_STRING, "RGB", - "width", G_TYPE_INT, 320, - "height", G_TYPE_INT, 240, - "framerate", GST_TYPE_FRACTION, 25, 1, - NULL) ; - - /* configure elements */ - g_object_set(G_OBJECT(videosrc), "num-buffers", 400, NULL); - g_signal_connect(G_OBJECT(glimagesink), "client-reshape", G_CALLBACK (reshapeCallback), NULL); - g_signal_connect(G_OBJECT(glimagesink), "client-draw", G_CALLBACK (drawCallback), NULL); - - /* add elements */ - gst_bin_add_many (GST_BIN (pipeline), videosrc, glimagesink, NULL); - - /* link elements */ - gboolean link_ok = gst_element_link_filtered(videosrc, glimagesink, caps) ; - gst_caps_unref(caps) ; - if(!link_ok) - { - g_warning("Failed to link videosrc to glimagesink!\n") ; - return -1 ; - } - - /* run */ - ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); - if (ret == GST_STATE_CHANGE_FAILURE) - { - g_print ("Failed to start up pipeline!\n"); - - /* check if there is an error message with details on the bus */ - GstMessage* msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0); - if (msg) - { - GError *err = NULL; - - gst_message_parse_error (msg, &err, NULL); - g_print ("ERROR: %s\n", err->message); - g_error_free (err); - gst_message_unref (msg); - } - return -1; - } - - g_main_loop_run (loop); - - /* clean up */ - gst_element_set_state (pipeline, GST_STATE_NULL); - gst_object_unref (pipeline); - - return 0; -} diff --git a/tests/examples/gl/generic/cubeyuv/.gitignore b/tests/examples/gl/generic/cubeyuv/.gitignore deleted file mode 100644 index bd5c0cee3..000000000 --- a/tests/examples/gl/generic/cubeyuv/.gitignore +++ /dev/null @@ -1 +0,0 @@ -cubeyuv diff --git a/tests/examples/gl/generic/cubeyuv/Makefile.am b/tests/examples/gl/generic/cubeyuv/Makefile.am deleted file mode 100644 index b23287127..000000000 --- a/tests/examples/gl/generic/cubeyuv/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ - -noinst_PROGRAMS = cubeyuv - -cubeyuv_SOURCES = main.cpp - -cubeyuv_CXXFLAGS=-I$(top_srcdir)/gst-libs -I$(top_builddir)/gst-libs \ - $(GST_PLUGINS_BASE_CFLAGS) $(GST_CXXFLAGS) $(GL_CFLAGS) -cubeyuv_LDADD=$(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_API_VERSION) $(GST_LIBS) $(GL_LIBS) diff --git a/tests/examples/gl/generic/cubeyuv/main.cpp b/tests/examples/gl/generic/cubeyuv/main.cpp deleted file mode 100644 index e1f843ec4..000000000 --- a/tests/examples/gl/generic/cubeyuv/main.cpp +++ /dev/null @@ -1,323 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008-2009 Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include <gst/gst.h> -#include <gst/gl/gl.h> -#include <gst/gl/gstglfuncs.h> - -#include <iostream> -#include <sstream> -#include <string> - -static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data) -{ - GMainLoop *loop = (GMainLoop*)data; - - switch (GST_MESSAGE_TYPE (msg)) - { - case GST_MESSAGE_EOS: - g_print ("End-of-stream\n"); - g_main_loop_quit (loop); - break; - case GST_MESSAGE_ERROR: - { - gchar *debug = NULL; - GError *err = NULL; - - gst_message_parse_error (msg, &err, &debug); - - g_print ("Error: %s\n", err->message); - g_error_free (err); - - if (debug) - { - g_print ("Debug deails: %s\n", debug); - g_free (debug); - } - - g_main_loop_quit (loop); - break; - } - default: - break; - } - - return TRUE; -} - - -//display video framerate -static void identityCallback (GstElement *src, GstBuffer *buffer, GstElement* textoverlay) -{ - static GstClockTime last_timestamp = 0; - static gint nbFrames = 0 ; - - //display estimated video FPS - nbFrames++ ; - if (GST_BUFFER_TIMESTAMP(buffer) - last_timestamp >= 1000000000) - { - std::ostringstream oss ; - oss << "video framerate = " << nbFrames ; - std::string s(oss.str()) ; - g_object_set(G_OBJECT(textoverlay), "text", s.c_str(), NULL); - last_timestamp = GST_BUFFER_TIMESTAMP(buffer) ; - nbFrames = 0 ; - } -} - - -//client reshape callback -static gboolean reshapeCallback (void * gl_sink, void *context, GLuint width, GLuint height, gpointer data) -{ - glViewport(0, 0, width, height); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - - return TRUE; -} - - -//client draw callback -static gboolean drawCallback (GstElement * gl_sink, GstGLContext *context, GstSample * sample, gpointer data) -{ - static GLfloat xrot = 0; - static GLfloat yrot = 0; - static GLfloat zrot = 0; - static GTimeVal current_time; - static glong last_sec = current_time.tv_sec; - static gint nbFrames = 0; - - GstVideoFrame v_frame; - GstVideoInfo v_info; - guint texture = 0; - GstBuffer *buf = gst_sample_get_buffer (sample); - GstCaps *caps = gst_sample_get_caps (sample); - - gst_video_info_from_caps (&v_info, caps); - - if (!gst_video_frame_map (&v_frame, &v_info, buf, (GstMapFlags) (GST_MAP_READ | GST_MAP_GL))) { - g_warning ("Failed to map the video buffer"); - return TRUE; - } - - texture = *(guint *) v_frame.data[0]; - - g_get_current_time (¤t_time); - nbFrames++ ; - - if ((current_time.tv_sec - last_sec) >= 1) - { - std::cout << "GRPHIC FPS = " << nbFrames << std::endl; - nbFrames = 0; - last_sec = current_time.tv_sec; - } - - glEnable(GL_DEPTH_TEST); - - glEnable (GL_TEXTURE_2D); - glBindTexture (GL_TEXTURE_2D, texture); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - glRotatef(xrot,1.0f,0.0f,0.0f); - glRotatef(yrot,0.0f,1.0f,0.0f); - glRotatef(zrot,0.0f,0.0f,1.0f); - - /* invert the y-axis to get the front face the correct way up */ - glScalef (0.5f, -0.5f, 0.5f); - - glBegin(GL_QUADS); - // Front Face - glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); - // Back Face - glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); - glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); - // Top Face - glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); - glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); - // Bottom Face - glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, 1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, 1.0f); - // Right face - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); - glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); - // Left Face - glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); - glEnd(); - - glDisable(GL_DEPTH_TEST); - - gst_video_frame_unmap (&v_frame); - - xrot+=0.03f; - yrot+=0.02f; - zrot+=0.04f; - - return TRUE; -} - - -static void cb_new_pad (GstElement* decodebin, GstPad* pad, GstElement* identity) -{ - GstPad* identity_pad = gst_element_get_static_pad (identity, "sink"); - - //only link once - if (GST_PAD_IS_LINKED (identity_pad)) - { - gst_object_unref (identity_pad); - return; - } - - GstCaps* caps = gst_pad_get_current_caps (pad); - GstStructure* str = gst_caps_get_structure (caps, 0); - if (!g_strrstr (gst_structure_get_name (str), "video")) - { - gst_caps_unref (caps); - gst_object_unref (identity_pad); - return; - } - gst_caps_unref (caps); - - GstPadLinkReturn ret = gst_pad_link (pad, identity_pad); - if (ret != GST_PAD_LINK_OK) - g_warning ("Failed to link with decodebin!\n"); -} - - -gint main (gint argc, gchar *argv[]) -{ - if (argc != 2) - { - g_warning ("usage: cubeyuv.exe videolocation\n"); - return -1; - } - - /* FIXME: remove once the example supports gl3 and/or gles2 */ - g_setenv ("GST_GL_API", "opengl", FALSE); - - std::string video_location(argv[1]); - - /* initialization */ - gst_init (&argc, &argv); - GMainLoop* loop = g_main_loop_new (NULL, FALSE); - - /* create elements */ - GstElement* pipeline = gst_pipeline_new ("pipeline"); - - /* watch for messages on the pipeline's bus (note that this will only - * work like this when a GLib main loop is running) */ - GstBus* bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); - gst_bus_add_watch (bus, bus_call, loop); - gst_object_unref (bus); - - /* create elements */ - GstElement* videosrc = gst_element_factory_make ("filesrc", "filesrc0"); - GstElement* decodebin = gst_element_factory_make ("decodebin", "decodebin"); - GstElement* identity = gst_element_factory_make ("identity", "identity0"); - GstElement* textoverlay = gst_element_factory_make ("textoverlay", "textoverlay0"); - GstElement* glimagesink = gst_element_factory_make ("glimagesink", "glimagesink0"); - - - if (!videosrc || !decodebin || !identity || !textoverlay || !glimagesink) - { - g_print ("one element could not be found \n"); - return -1; - } - - /* configure elements */ - g_object_set(G_OBJECT(videosrc), "num-buffers", 800, NULL); - g_object_set(G_OBJECT(videosrc), "location", video_location.c_str(), NULL); - g_signal_connect(identity, "handoff", G_CALLBACK(identityCallback), textoverlay) ; - g_object_set(G_OBJECT(textoverlay), "font_desc", "Ahafoni CLM Bold 30", NULL); - g_signal_connect(G_OBJECT(glimagesink), "client-reshape", G_CALLBACK (reshapeCallback), NULL); - g_signal_connect(G_OBJECT(glimagesink), "client-draw", G_CALLBACK (drawCallback), NULL); - - /* add elements */ - gst_bin_add_many (GST_BIN (pipeline), videosrc, decodebin, identity, - textoverlay, glimagesink, NULL); - - /* link elements */ - gst_element_link_pads (videosrc, "src", decodebin, "sink"); - - g_signal_connect (decodebin, "pad-added", G_CALLBACK (cb_new_pad), identity); - - if (!gst_element_link_pads(identity, "src", textoverlay, "video_sink")) - { - g_print ("Failed to link identity to textoverlay!\n"); - return -1; - } - - gboolean link_ok = gst_element_link (textoverlay, glimagesink); - if(!link_ok) - { - g_warning("Failed to link textoverlay to glimagesink!\n") ; - return -1 ; - } - - /* run */ - GstStateChangeReturn ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); - if (ret == GST_STATE_CHANGE_FAILURE) - { - g_print ("Failed to start up pipeline!\n"); - - /* check if there is an error message with details on the bus */ - GstMessage* msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0); - if (msg) - { - GError *err = NULL; - - gst_message_parse_error (msg, &err, NULL); - g_print ("ERROR: %s\n", err->message); - g_error_free (err); - gst_message_unref (msg); - } - return -1; - } - - g_main_loop_run (loop); - - /* clean up */ - gst_element_set_state (pipeline, GST_STATE_NULL); - gst_object_unref (pipeline); - - return 0; -} diff --git a/tests/examples/gl/generic/doublecube/.gitignore b/tests/examples/gl/generic/doublecube/.gitignore deleted file mode 100644 index e9f4f133b..000000000 --- a/tests/examples/gl/generic/doublecube/.gitignore +++ /dev/null @@ -1 +0,0 @@ -doublecube diff --git a/tests/examples/gl/generic/doublecube/Makefile.am b/tests/examples/gl/generic/doublecube/Makefile.am deleted file mode 100644 index 7f1489561..000000000 --- a/tests/examples/gl/generic/doublecube/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ - -noinst_PROGRAMS = doublecube - -doublecube_SOURCES = main.cpp - -doublecube_CXXFLAGS=-I$(top_srcdir)/gst-libs -I$(top_builddir)/gst-libs \ - $(GST_PLUGINS_BASE_CFLAGS) $(GST_CXXFLAGS) $(GL_CFLAGS) -doublecube_LDADD=$(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_API_VERSION) $(GST_LIBS) $(GL_LIBS) - diff --git a/tests/examples/gl/generic/doublecube/main.cpp b/tests/examples/gl/generic/doublecube/main.cpp deleted file mode 100644 index 631a28581..000000000 --- a/tests/examples/gl/generic/doublecube/main.cpp +++ /dev/null @@ -1,370 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008-2009 Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include <gst/gst.h> -#include <gst/gl/gl.h> -#include <gst/gl/gstglfuncs.h> - -#include <iostream> -#include <sstream> -#include <string> - -static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data) -{ - GMainLoop *loop = (GMainLoop*)data; - - switch (GST_MESSAGE_TYPE (msg)) - { - case GST_MESSAGE_EOS: - g_print ("End-of-stream\n"); - g_main_loop_quit (loop); - break; - case GST_MESSAGE_ERROR: - { - gchar *debug = NULL; - GError *err = NULL; - - gst_message_parse_error (msg, &err, &debug); - - g_print ("Error: %s\n", err->message); - g_error_free (err); - - if (debug) - { - g_print ("Debug details: %s\n", debug); - g_free (debug); - } - - g_main_loop_quit (loop); - break; - } - default: - break; - } - - return TRUE; -} - - -//display video framerate -static GstPadProbeReturn textoverlay_sink_pad_probe_cb (GstPad *pad, GstPadProbeInfo *info, GstElement* textoverlay) -{ - static GstClockTime last_timestamp = 0; - static gint nbFrames = 0 ; - - //display estimated video FPS - nbFrames++ ; - if (GST_BUFFER_TIMESTAMP(info->data) - last_timestamp >= 1000000000) - { - std::ostringstream oss; - oss << "video framerate = " << nbFrames ; - std::string s(oss.str()); - g_object_set(G_OBJECT(textoverlay), "text", s.c_str(), NULL); - last_timestamp = GST_BUFFER_TIMESTAMP(info->data) ; - nbFrames = 0; - } - - return GST_PAD_PROBE_OK; -} - - -//client reshape callback -static gboolean reshapeCallback (void *gl_sink, void *context, GLuint width, GLuint height) -{ - glViewport(0, 0, width, height); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - - return TRUE; -} - - -//client draw callback -static gboolean drawCallback (GstElement * gl_sink, GstGLContext *context, GstSample * sample, gpointer data) -{ - static GLfloat xrot = 0; - static GLfloat yrot = 0; - static GLfloat zrot = 0; - static GTimeVal current_time; - static glong last_sec = current_time.tv_sec; - static gint nbFrames = 0; - - GstVideoFrame v_frame; - GstVideoInfo v_info; - guint texture = 0; - GstBuffer *buf = gst_sample_get_buffer (sample); - GstCaps *caps = gst_sample_get_caps (sample); - - gst_video_info_from_caps (&v_info, caps); - - if (!gst_video_frame_map (&v_frame, &v_info, buf, (GstMapFlags) (GST_MAP_READ | GST_MAP_GL))) { - g_warning ("Failed to map the video buffer"); - return TRUE; - } - - texture = *(guint *) v_frame.data[0]; - - g_get_current_time (¤t_time); - nbFrames++ ; - - if ((current_time.tv_sec - last_sec) >= 1) - { - std::cout << "GRAPHIC FPS of the scene which contains the custom cube) = " << nbFrames << std::endl; - nbFrames = 0; - last_sec = current_time.tv_sec; - } - - glEnable(GL_DEPTH_TEST); - - glEnable (GL_TEXTURE_2D); - glBindTexture (GL_TEXTURE_2D, texture); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - glTranslatef(0.0f,0.0f,-5.0f); - - glRotatef(xrot,1.0f,0.0f,0.0f); - glRotatef(yrot,0.0f,1.0f,0.0f); - glRotatef(zrot,0.0f,0.0f,1.0f); - - glBegin(GL_QUADS); - // Front Face - glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); - // Back Face - glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); - glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); - // Top Face - glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); - glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); - // Bottom Face - glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, 1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, 1.0f); - // Right face - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); - glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); - // Left Face - glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); - glEnd(); - - gst_video_frame_unmap (&v_frame); - - xrot+=0.03f; - yrot+=0.02f; - zrot+=0.04f; - - return TRUE; -} - - -static void cb_new_pad (GstElement* decodebin, GstPad* pad, GstElement* element) -{ - GstPad* element_pad = gst_element_get_static_pad (element, "sink"); - - //only link once - if (!element_pad || GST_PAD_IS_LINKED (element_pad)) - { - gst_object_unref (element_pad); - return; - } - - GstCaps* caps = gst_pad_get_current_caps (pad); - GstStructure* str = gst_caps_get_structure (caps, 0); - - GstCaps* caps2 = gst_pad_query_caps (element_pad, NULL); - gst_caps_unref (caps2); - - if (!g_strrstr (gst_structure_get_name (str), "video")) - { - gst_caps_unref (caps); - gst_object_unref (element_pad); - return; - } - gst_caps_unref (caps); - - GstPadLinkReturn ret = gst_pad_link (pad, element_pad); - if (ret != GST_PAD_LINK_OK) - g_warning ("Failed to link with decodebin %d!\n", ret); - gst_object_unref (element_pad); -} - - -gint main (gint argc, gchar *argv[]) -{ - if (argc != 2) - { - g_warning ("usage: doublecube.exe videolocation\n"); - return -1; - } - - std::string video_location(argv[1]); - - /* initialization */ - gst_init (&argc, &argv); - GMainLoop* loop = g_main_loop_new (NULL, FALSE); - - /* create elements */ - GstElement* pipeline = gst_pipeline_new ("pipeline"); - - /* watch for messages on the pipeline's bus (note that this will only - * work like this when a GLib main loop is running) */ - GstBus* bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); - gst_bus_add_watch (bus, bus_call, loop); - gst_object_unref (bus); - - /* create elements */ - GstElement* videosrc = gst_element_factory_make ("filesrc", "filesrc0"); - GstElement* decodebin = gst_element_factory_make ("decodebin", "decodebin0"); - GstElement* videoconvert = gst_element_factory_make ("videoscale", "videoconvert0"); - GstElement* textoverlay = gst_element_factory_make ("textoverlay", "textoverlay0"); //textoverlay required I420 - GstElement* tee = gst_element_factory_make ("tee", "tee0"); - - GstElement* queue0 = gst_element_factory_make ("queue", "queue0"); - GstElement* glimagesink0 = gst_element_factory_make ("glimagesink", "glimagesink0"); - - GstElement* queue1 = gst_element_factory_make ("queue", "queue1"); - GstElement* glfiltercube = gst_element_factory_make ("glfiltercube", "glfiltercube"); - GstElement* glimagesink1 = gst_element_factory_make ("glimagesink", "glimagesink1"); - - GstElement* queue2 = gst_element_factory_make ("queue", "queue2"); - GstElement* glimagesink2 = gst_element_factory_make ("glimagesink", "glimagesink2"); - - - if (!videosrc || !decodebin || !videoconvert || !textoverlay || !tee || - !queue0 || !glimagesink0 || - !queue1 || !glfiltercube || !glimagesink1 || - !queue2 || !glimagesink2) - { - g_warning ("one element could not be found \n"); - return -1; - } - - GstCaps* cubecaps = gst_caps_new_simple("video/x-raw", - "width", G_TYPE_INT, 600, - "height", G_TYPE_INT, 400, - NULL); - - /* configure elements */ - g_object_set(G_OBJECT(videosrc), "num-buffers", 1000, NULL); - g_object_set(G_OBJECT(videosrc), "location", video_location.c_str(), NULL); - g_object_set(G_OBJECT(textoverlay), "font_desc", "Ahafoni CLM Bold 30", NULL); - g_signal_connect(G_OBJECT(glimagesink0), "client-reshape", G_CALLBACK (reshapeCallback), NULL); - g_signal_connect(G_OBJECT(glimagesink0), "client-draw", G_CALLBACK (drawCallback), NULL); - - /* add elements */ - gst_bin_add_many (GST_BIN (pipeline), videosrc, decodebin, videoconvert, textoverlay, tee, - queue0, glimagesink0, - queue1, glfiltercube, glimagesink1, - queue2, glimagesink2, NULL); - - GstPad* textoverlay_sink_pad = gst_element_get_static_pad (textoverlay, "video_sink"); - gst_pad_add_probe (textoverlay_sink_pad, GST_PAD_PROBE_TYPE_BUFFER, - (GstPadProbeCallback) textoverlay_sink_pad_probe_cb, (gpointer)textoverlay, NULL); - gst_object_unref (textoverlay_sink_pad); - - if (!gst_element_link_many(videoconvert, textoverlay, tee, NULL)) - { - g_print ("Failed to link videoconvert to tee!\n"); - return -1; - } - - if (!gst_element_link(videosrc, decodebin)) - { - g_print ("Failed to link videosrc to decodebin!\n"); - return -1; - } - - g_signal_connect (decodebin, "pad-added", G_CALLBACK (cb_new_pad), videoconvert); - - if (!gst_element_link_many(tee, queue0, NULL)) - { - g_warning ("Failed to link one or more elements bettween tee and queue0!\n"); - return -1; - } - - gboolean link_ok = gst_element_link_filtered(queue0, glimagesink0, cubecaps) ; - gst_caps_unref(cubecaps) ; - if(!link_ok) - { - g_warning("Failed to link queue0 to glimagesink0!\n") ; - return -1 ; - } - - if (!gst_element_link_many(tee, queue1, glfiltercube, glimagesink1, NULL)) - { - g_warning ("Failed to link one or more elements bettween tee and glimagesink1!\n"); - return -1; - } - - if (!gst_element_link_many(tee, queue2, glimagesink2, NULL)) - { - g_warning ("Failed to link one or more elements bettween tee and glimagesink2!\n"); - return -1; - } - - /* run */ - GstStateChangeReturn ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); - if (ret == GST_STATE_CHANGE_FAILURE) - { - g_print ("Failed to start up pipeline!\n"); - - /* check if there is an error message with details on the bus */ - GstMessage* msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0); - if (msg) - { - GError *err = NULL; - - gst_message_parse_error (msg, &err, NULL); - g_print ("ERROR: %s\n", err->message); - g_error_free (err); - gst_message_unref (msg); - } - return -1; - } - - g_main_loop_run (loop); - - /* clean up */ - gst_element_set_state (pipeline, GST_STATE_NULL); - gst_object_unref (pipeline); - - return 0; -} diff --git a/tests/examples/gl/generic/generic.sln b/tests/examples/gl/generic/generic.sln deleted file mode 100644 index 22e86f64e..000000000 --- a/tests/examples/gl/generic/generic.sln +++ /dev/null @@ -1,38 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cube", "cube\cube.vcproj", "{DA41FBFF-E1DE-4DA1-BB96-C56C63D5CDBE}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cubeyuv", "cubeyuv\cubeyuv.vcproj", "{6C94B86A-8E34-4163-840A-BFD5C80B1F2E}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "doublecube", "doublecube\doublecube.vcproj", "{4EC968E0-5B6C-418A-8A75-F390D56DFFE8}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "recordgraphic", "recordgraphic\recordgraphic.vcproj", "{E9A5E91B-5F8B-4322-9531-00CCFCB29A2D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {DA41FBFF-E1DE-4DA1-BB96-C56C63D5CDBE}.Debug|Win32.ActiveCfg = Debug|Win32 - {DA41FBFF-E1DE-4DA1-BB96-C56C63D5CDBE}.Debug|Win32.Build.0 = Debug|Win32 - {DA41FBFF-E1DE-4DA1-BB96-C56C63D5CDBE}.Release|Win32.ActiveCfg = Release|Win32 - {DA41FBFF-E1DE-4DA1-BB96-C56C63D5CDBE}.Release|Win32.Build.0 = Release|Win32 - {6C94B86A-8E34-4163-840A-BFD5C80B1F2E}.Debug|Win32.ActiveCfg = Debug|Win32 - {6C94B86A-8E34-4163-840A-BFD5C80B1F2E}.Debug|Win32.Build.0 = Debug|Win32 - {6C94B86A-8E34-4163-840A-BFD5C80B1F2E}.Release|Win32.ActiveCfg = Release|Win32 - {6C94B86A-8E34-4163-840A-BFD5C80B1F2E}.Release|Win32.Build.0 = Release|Win32 - {4EC968E0-5B6C-418A-8A75-F390D56DFFE8}.Debug|Win32.ActiveCfg = Debug|Win32 - {4EC968E0-5B6C-418A-8A75-F390D56DFFE8}.Debug|Win32.Build.0 = Debug|Win32 - {4EC968E0-5B6C-418A-8A75-F390D56DFFE8}.Release|Win32.ActiveCfg = Release|Win32 - {4EC968E0-5B6C-418A-8A75-F390D56DFFE8}.Release|Win32.Build.0 = Release|Win32 - {E9A5E91B-5F8B-4322-9531-00CCFCB29A2D}.Debug|Win32.ActiveCfg = Debug|Win32 - {E9A5E91B-5F8B-4322-9531-00CCFCB29A2D}.Debug|Win32.Build.0 = Debug|Win32 - {E9A5E91B-5F8B-4322-9531-00CCFCB29A2D}.Release|Win32.ActiveCfg = Release|Win32 - {E9A5E91B-5F8B-4322-9531-00CCFCB29A2D}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/tests/examples/gl/generic/recordgraphic/.gitignore b/tests/examples/gl/generic/recordgraphic/.gitignore deleted file mode 100644 index 8127d8360..000000000 --- a/tests/examples/gl/generic/recordgraphic/.gitignore +++ /dev/null @@ -1 +0,0 @@ -recordgraphic diff --git a/tests/examples/gl/generic/recordgraphic/Makefile.am b/tests/examples/gl/generic/recordgraphic/Makefile.am deleted file mode 100644 index 6a25c281f..000000000 --- a/tests/examples/gl/generic/recordgraphic/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ - -noinst_PROGRAMS = recordgraphic - -recordgraphic_SOURCES = main.cpp - -recordgraphic_CXXFLAGS=-I$(top_srcdir)/gst-libs -I$(top_builddir)/gst-libs \ - $(GST_CXXFLAGS) $(GL_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) -recordgraphic_LDADD=$(GST_PLUGINS_BASE_LIBS) -lgstvideo-@GST_API_VERSION@ $(GST_LIBS) $(GL_LIBS) - diff --git a/tests/examples/gl/generic/recordgraphic/main.cpp b/tests/examples/gl/generic/recordgraphic/main.cpp deleted file mode 100644 index 9cac1e974..000000000 --- a/tests/examples/gl/generic/recordgraphic/main.cpp +++ /dev/null @@ -1,263 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008-2009 Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include <GL/gl.h> -#if __WIN32__ || _WIN32 -# include <GL/glext.h> -#endif -#include <gst/gst.h> -#include <gst/video/video.h> - -#include <iostream> -#include <string> - -static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data) -{ - GMainLoop *loop = (GMainLoop*)data; - - switch (GST_MESSAGE_TYPE (msg)) - { - case GST_MESSAGE_EOS: - g_print ("End-of-stream\n"); - g_main_loop_quit (loop); - break; - case GST_MESSAGE_ERROR: - { - gchar *debug = NULL; - GError *err = NULL; - - gst_message_parse_error (msg, &err, &debug); - - g_print ("Error: %s\n", err->message); - g_error_free (err); - - if (debug) - { - g_print ("Debug details: %s\n", debug); - g_free (debug); - } - - g_main_loop_quit (loop); - break; - } - default: - break; - } - - return TRUE; -} - -//client draw callback -static gboolean drawCallback (void *filter, void *context, GLuint texture, GLuint width, GLuint height, gpointer data) -{ - static GLfloat xrot = 0; - static GLfloat yrot = 0; - static GLfloat zrot = 0; - static GTimeVal current_time; - static glong last_sec = current_time.tv_sec; - static gint nbFrames = 0; - - g_get_current_time (¤t_time); - nbFrames++ ; - - if ((current_time.tv_sec - last_sec) >= 1) - { - std::cout << "GRPHIC FPS = " << nbFrames << std::endl; - nbFrames = 0; - last_sec = current_time.tv_sec; - } - - glEnable(GL_DEPTH_TEST); - - glEnable (GL_TEXTURE_2D); - glBindTexture (GL_TEXTURE_2D, texture); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - glTranslatef(0.0f,0.0f,-5.0f); - - glRotatef(xrot,1.0f,0.0f,0.0f); - glRotatef(yrot,0.0f,1.0f,0.0f); - glRotatef(zrot,0.0f,0.0f,1.0f); - - //cube - glBegin(GL_QUADS); - // Front Face - glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); - // Back Face - glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); - glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); - // Top Face - glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); - glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); - // Bottom Face - glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, 1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, 1.0f); - // Right face - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); - glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); - // Left Face - glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); - glEnd(); - - xrot+=0.3f; - yrot+=0.2f; - zrot+=0.4f; - - //return TRUE because we dealt with the texture - return TRUE; -} - - -//equivalent command line: -//gst-launch-1.0 videotestsrc num_buffers=400 ! gleffects effect=0 ! -//avenc_mpeg4 ! avimux ! filesink location="record.avi" -// or -//gst-launch-1.0 videotestsrc num_buffers=400 ! gleffects effect=0 ! "video/x-raw, width=320, height=240" ! glfiltercube ! "video/x-raw, width=720, height=576" ! -//avenc_mpeg4 ! avimux ! filesink location="record.avi" -gint main (gint argc, gchar *argv[]) -{ - GstStateChangeReturn ret; - GstElement *pipeline, *videosrc, *glfilterapp, *avenc_mpeg4, *avimux, *filesink; - GMainLoop *loop; - GstBus *bus; - - /* initialization */ - gst_init (&argc, &argv); - loop = g_main_loop_new (NULL, FALSE); - - /* create elements */ - pipeline = gst_pipeline_new ("pipeline"); - - /* watch for messages on the pipeline's bus (note that this will only - * work like this when a GLib main loop is running) */ - bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); - gst_bus_add_watch (bus, bus_call, loop); - gst_object_unref (bus); - - /* create elements */ - videosrc = gst_element_factory_make ("videotestsrc", "videotestsrc0"); - glfilterapp = gst_element_factory_make ("glfilterapp", "glfilterapp0"); - avenc_mpeg4 = gst_element_factory_make ("avenc_mpeg4", "avenc_mpeg40"); - avimux = gst_element_factory_make ("avimux", "avimux0"); - filesink = gst_element_factory_make ("filesink", "filesink0"); - - - if (!videosrc || !glfilterapp || !avenc_mpeg4 || !avimux || !filesink) - { - g_print ("one element could not be found \n"); - return -1; - } - - /* change video source caps */ - GstCaps *caps = gst_caps_new_simple("video/x-raw", - "format", G_TYPE_STRING, "UYVY", - "width", G_TYPE_INT, 320, - "height", G_TYPE_INT, 240, - "framerate", GST_TYPE_FRACTION, 25, 1, - NULL); - - /* change video source caps */ - GstCaps *outcaps = gst_caps_new_simple("video/x-raw", - "width", G_TYPE_INT, 640, - "height", G_TYPE_INT, 480, - NULL); - - /* configure elements */ - g_object_set(G_OBJECT(videosrc), "num-buffers", 400, NULL); - g_signal_connect(G_OBJECT(glfilterapp), "client-draw", G_CALLBACK (drawCallback), NULL); - g_object_set(G_OBJECT(filesink), "location", "record.avi", NULL); - - /* add elements */ - gst_bin_add_many (GST_BIN (pipeline), videosrc, glfilterapp, - avenc_mpeg4, avimux, filesink, NULL); - - /* link elements */ - gboolean link_ok = gst_element_link_filtered(videosrc, glfilterapp, caps) ; - gst_caps_unref(caps) ; - if(!link_ok) - { - g_warning("Failed to link videosrc to glfilterapp!\n") ; - return -1 ; - } - - link_ok = gst_element_link_filtered(glfilterapp, avenc_mpeg4, outcaps) ; - gst_caps_unref(outcaps) ; - if(!link_ok) - { - g_warning("Failed to link glfilterapp to avenc_mpeg4!\n") ; - return -1 ; - } - if (!gst_element_link_many(avenc_mpeg4, avimux, filesink, NULL)) - { - g_print ("Failed to link one or more elements!\n"); - return -1; - } - - - /* run */ - ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); - if (ret == GST_STATE_CHANGE_FAILURE) - { - g_print ("Failed to start up pipeline!\n"); - - /* check if there is an error message with details on the bus */ - GstMessage* msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0); - if (msg) - { - GError *err = NULL; - - gst_message_parse_error (msg, &err, NULL); - g_print ("ERROR: %s\n", err->message); - g_error_free (err); - gst_message_unref (msg); - } - return -1; - } - - g_main_loop_run (loop); - - /* clean up */ - gst_element_set_state (pipeline, GST_STATE_NULL); - gst_object_unref (pipeline); - - return 0; -} diff --git a/tests/examples/gl/gtk/3dvideo/.gitignore b/tests/examples/gl/gtk/3dvideo/.gitignore deleted file mode 100644 index 7c46573b5..000000000 --- a/tests/examples/gl/gtk/3dvideo/.gitignore +++ /dev/null @@ -1 +0,0 @@ -3dvideo diff --git a/tests/examples/gl/gtk/3dvideo/Makefile.am b/tests/examples/gl/gtk/3dvideo/Makefile.am deleted file mode 100644 index 94c8d1619..000000000 --- a/tests/examples/gl/gtk/3dvideo/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ -noinst_PROGRAMS = 3dvideo - -noinst_HEADERS = mviewwidget.h - -3dvideo_SOURCES = mviewwidget.c main.cpp - -3dvideo_CXXFLAGS=$(GST_CXXFLAGS) - -3dvideo_CPPFLAGS=-I$(top_srcdir)/gst-libs -I$(top_builddir)/gst-libs \ - $(GST_PLUGINS_BASE_CFLAGS) \ - $(GL_CFLAGS) $(GTK3_CFLAGS) -3dvideo_LDADD=../libgstgtkhelper.la \ - $(top_builddir)/gst-libs/gst/gl/libgstgl-$(GST_API_VERSION).la \ - $(GTK3_LIBS) $(GST_PLUGINS_BASE_LIBS) $(GST_LIBS) \ - $(GL_LIBS) -lgstvideo-$(GST_API_VERSION) - diff --git a/tests/examples/gl/gtk/3dvideo/main.cpp b/tests/examples/gl/gtk/3dvideo/main.cpp deleted file mode 100644 index 4f12b11cc..000000000 --- a/tests/examples/gl/gtk/3dvideo/main.cpp +++ /dev/null @@ -1,444 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008-2009 Julien Isorce <julien.isorce@gmail.com> - * Copyright (C) 2014-2015 Jan Schmidt <jan@centricular.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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <string.h> - -#include <gdk/gdk.h> -#if defined (GDK_WINDOWING_X11) -#include <X11/Xlib.h> -#endif - -#include <gst/gst.h> -#include <gtk/gtk.h> -#include <gst/video/video-info.h> - -#include "../gstgtk.h" -#include "mviewwidget.h" - -/* Until playbin properties support dynamic changes, - * use our own glviewconvert */ -#define USE_GLCONVERT_FOR_INPUT 1 - -typedef struct _localstate -{ - GstVideoMultiviewFramePacking in_mode; - GstVideoMultiviewFlags out_mode; - GstVideoMultiviewFlags in_flags, out_flags; -} LocalState; - -static GstBusSyncReply -create_window (GstBus * bus, GstMessage * message, GtkWidget * widget) -{ - if (gst_gtk_handle_need_context (bus, message, NULL)) - return GST_BUS_DROP; - - /* ignore anything but 'prepare-window-handle' element messages */ - if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT) - return GST_BUS_PASS; - - if (!gst_is_video_overlay_prepare_window_handle_message (message)) - return GST_BUS_PASS; - - /* do not call gdk_window_ensure_native for the first time here because - * we are in a different thread than the main thread */ - gst_video_overlay_set_gtk_window (GST_VIDEO_OVERLAY (GST_MESSAGE_SRC - (message)), widget); - - gst_message_unref (message); - - return GST_BUS_DROP; -} - -static void -end_stream_cb (GstBus * bus, GstMessage * message, GstElement * pipeline) -{ - switch (GST_MESSAGE_TYPE (message)) { - case GST_MESSAGE_EOS: - g_print ("End of stream\n"); - - gst_element_set_state (pipeline, GST_STATE_NULL); - gst_object_unref (pipeline); - gtk_main_quit (); - break; - case GST_MESSAGE_ERROR: - { - gchar *debug = NULL; - GError *err = NULL; - - gst_message_parse_error (message, &err, &debug); - - g_print ("Error: %s\n", err->message); - g_error_free (err); - - if (debug) { - g_print ("Debug details: %s\n", debug); - g_free (debug); - } - - gst_element_set_state (pipeline, GST_STATE_NULL); - gst_object_unref (pipeline); - gtk_main_quit (); - break; - } - default: - break; - } -} - -static gboolean -draw_cb (GtkWidget * widget, cairo_t * cr, GstElement * videosink) -{ - gst_video_overlay_expose (GST_VIDEO_OVERLAY (videosink)); - return FALSE; -} - -static gboolean -resize_cb (GtkWidget * widget, GdkEvent * event, gpointer sink) -{ - GtkAllocation allocation; - gint scale = 1; - -#if GTK_CHECK_VERSION(3, 10, 0) - scale = gtk_widget_get_scale_factor (widget); -#endif - - gtk_widget_get_allocation (widget, &allocation); - gst_video_overlay_set_render_rectangle (GST_VIDEO_OVERLAY (sink), - allocation.x * scale, allocation.y * scale, allocation.width * scale, - allocation.height * scale); - - return G_SOURCE_CONTINUE; -} - -static void -destroy_cb (GtkWidget * widget, GdkEvent * event, GstElement * pipeline) -{ - gst_element_set_state (pipeline, GST_STATE_NULL); - gst_object_unref (pipeline); - - gtk_main_quit (); -} - -static void -button_state_ready_cb (GtkWidget * widget, GstElement * pipeline) -{ - gst_element_set_state (pipeline, GST_STATE_READY); -} - -static void -button_state_paused_cb (GtkWidget * widget, GstElement * pipeline) -{ - gst_element_set_state (pipeline, GST_STATE_PAUSED); -} - -static void -button_state_playing_cb (GtkWidget * widget, GstElement * pipeline) -{ - gst_element_set_state (pipeline, GST_STATE_PLAYING); -} - -static gboolean -set_mview_mode (GtkWidget * combo, GObject * target, const gchar * prop_name) -{ - gchar *mview_mode = NULL; - GEnumClass *p_class; - GEnumValue *v; - GParamSpec *p = - g_object_class_find_property (G_OBJECT_GET_CLASS (target), prop_name); - - g_return_val_if_fail (p != NULL, FALSE); - - p_class = G_PARAM_SPEC_ENUM (p)->enum_class; - g_return_val_if_fail (p_class != NULL, FALSE); - - g_object_get (G_OBJECT (combo), "active-id", &mview_mode, NULL); - g_return_val_if_fail (mview_mode != NULL, FALSE); - - v = g_enum_get_value_by_nick (p_class, mview_mode); - g_return_val_if_fail (v != NULL, FALSE); - - g_object_set (target, prop_name, v->value, NULL); - - return FALSE; -} - -static gboolean -set_mview_input_mode (GtkWidget * widget, gpointer data) -{ -#if USE_GLCONVERT_FOR_INPUT - return set_mview_mode (widget, G_OBJECT (data), "input-mode-override"); -#else - return set_mview_mode (widget, G_OBJECT (data), "video-multiview-mode"); -#endif -} - -static gboolean -set_mview_output_mode (GtkWidget * widget, gpointer data) -{ - GstElement *sink = gst_bin_get_by_name (GST_BIN (data), "sink"); - set_mview_mode (widget, G_OBJECT (sink), "output-multiview-mode"); - gst_object_unref (GST_OBJECT (sink)); - return FALSE; -} - -static void -input_flags_changed (GObject * gobject, GParamSpec * pspec, gpointer user_data) -{ - GObject *target = G_OBJECT (user_data); - GstVideoMultiviewFlags flags; - - g_object_get (gobject, "flags", &flags, NULL); -#if USE_GLCONVERT_FOR_INPUT - g_object_set (target, "input-flags-override", flags, NULL); -#else - g_object_set (target, "video-multiview-flags", flags, NULL); -#endif -} - -static void -output_flags_changed (GObject * gobject, GParamSpec * pspec, gpointer user_data) -{ - GObject *target = G_OBJECT (user_data); - GstVideoMultiviewFlags flags; - GstElement *sink = gst_bin_get_by_name (GST_BIN (target), "sink"); - - g_object_get (gobject, "flags", &flags, NULL); - g_object_set (G_OBJECT (sink), "output-multiview-flags", flags, NULL); - - gst_object_unref (GST_OBJECT (sink)); -} - -static void -downmix_method_changed (GObject * gobject, GParamSpec * pspec, gpointer user_data) -{ - GObject *target = G_OBJECT (user_data); - GstGLStereoDownmix downmix_method; - GstElement *sink = gst_bin_get_by_name (GST_BIN (target), "sink"); - - g_object_get (gobject, "downmix-mode", &downmix_method, NULL); - g_object_set (sink, "output-multiview-downmix-mode", downmix_method, NULL); - gst_object_unref (GST_OBJECT (sink)); -} - -static const gchar * -enum_value_to_nick (GType enum_type, guint value) -{ - GEnumClass *enum_info; - GEnumValue *v; - const gchar *nick; - - enum_info = (GEnumClass *) (g_type_class_ref (enum_type)); - g_return_val_if_fail (enum_info != NULL, NULL); - - v = g_enum_get_value (enum_info, value); - g_return_val_if_fail (v != NULL, NULL); - - nick = v->value_nick; - - g_type_class_unref (enum_info); - - return nick; -} - -static void -detect_mode_from_uri (LocalState * state, const gchar * uri) -{ - if (strstr (uri, "HSBS")) { - state->in_mode = GST_VIDEO_MULTIVIEW_FRAME_PACKING_SIDE_BY_SIDE; - state->in_flags = GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT; - } else if (strstr (uri, "SBS")) { - state->in_mode = GST_VIDEO_MULTIVIEW_FRAME_PACKING_SIDE_BY_SIDE; - if (g_regex_match_simple ("half", uri, G_REGEX_CASELESS, - (GRegexMatchFlags) 0)) { - state->in_flags = GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT; - } - } -} - -gint -main (gint argc, gchar * argv[]) -{ - LocalState state; - GtkWidget *area, *combo, *w; - const gchar *uri; - -#if defined (GDK_WINDOWING_X11) - XInitThreads (); -#endif - - gst_init (&argc, &argv); - gtk_init (&argc, &argv); - - if (argc < 2) { - g_print ("Usage: 3dvideo <uri-to-play>\n"); - return 1; - } - - uri = argv[1]; - - GstElement *pipeline = gst_element_factory_make ("playbin", NULL); - GstBin *sinkbin = (GstBin *) gst_parse_bin_from_description ("glupload ! glcolorconvert ! glviewconvert name=viewconvert ! glimagesink name=sink", TRUE, NULL); -#if USE_GLCONVERT_FOR_INPUT - GstElement *glconvert = gst_bin_get_by_name (sinkbin, "viewconvert"); -#endif - GstElement *videosink = gst_bin_get_by_name (sinkbin, "sink"); - - /* Get defaults */ - g_object_get (pipeline, "video-multiview-mode", &state.in_mode, - "video-multiview-flags", &state.in_flags, NULL); - gst_child_proxy_get (GST_CHILD_PROXY (videosink), "sink::output-multiview-mode", &state.out_mode, - "sink::output-multiview-flags", &state.out_flags, NULL); - - detect_mode_from_uri (&state, uri); - - g_return_val_if_fail (pipeline != NULL, 1); - g_return_val_if_fail (videosink != NULL, 1); - - g_object_set (G_OBJECT (pipeline), "video-sink", sinkbin, NULL); - g_object_set (G_OBJECT (pipeline), "uri", uri, NULL); - -#if USE_GLCONVERT_FOR_INPUT - g_object_set (G_OBJECT (glconvert), "input-mode-override", state.in_mode, - NULL); - g_object_set (G_OBJECT (glconvert), "input-flags-override", state.in_flags, - NULL); -#else - g_object_set (G_OBJECT (pipeline), "video-multiview-mode", state.in_mode, - NULL); - g_object_set (G_OBJECT (pipeline), "video-multiview-flags", state.in_flags, - NULL); -#endif - - /* Connect to bus for signal handling */ - GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); - gst_bus_add_signal_watch (bus); - g_signal_connect (bus, "message::error", G_CALLBACK (end_stream_cb), - pipeline); - g_signal_connect (bus, "message::warning", G_CALLBACK (end_stream_cb), - pipeline); - g_signal_connect (bus, "message::eos", G_CALLBACK (end_stream_cb), pipeline); - - gst_element_set_state (pipeline, GST_STATE_READY); - - area = gtk_drawing_area_new (); - gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, area, NULL); - gst_object_unref (bus); - - /* Toplevel window */ - GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_default_size (GTK_WINDOW (window), 800, 600); - gtk_window_set_title (GTK_WINDOW (window), "Stereoscopic video demo"); - GdkGeometry geometry; - geometry.min_width = 1; - geometry.min_height = 1; - geometry.max_width = -1; - geometry.max_height = -1; - gtk_window_set_geometry_hints (GTK_WINDOW (window), window, &geometry, - GDK_HINT_MIN_SIZE); - - GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); - gtk_container_add (GTK_CONTAINER (window), vbox); - - /* area where the video is drawn */ - gtk_box_pack_start (GTK_BOX (vbox), area, TRUE, TRUE, 0); - - /* Buttons to control the pipeline state */ - GtkWidget *table = gtk_grid_new (); - gtk_container_add (GTK_CONTAINER (vbox), table); - - GtkWidget *button_state_ready = gtk_button_new_with_label ("Stop"); - g_signal_connect (G_OBJECT (button_state_ready), "clicked", - G_CALLBACK (button_state_ready_cb), pipeline); - gtk_grid_attach (GTK_GRID (table), button_state_ready, 1, 0, 1, 1); - gtk_widget_show (button_state_ready); - - //control state paused - GtkWidget *button_state_paused = gtk_button_new_with_label ("Pause"); - g_signal_connect (G_OBJECT (button_state_paused), "clicked", - G_CALLBACK (button_state_paused_cb), pipeline); - gtk_grid_attach (GTK_GRID (table), button_state_paused, 2, 0, 1, 1); - gtk_widget_show (button_state_paused); - - //control state playing - GtkWidget *button_state_playing = gtk_button_new_with_label ("Play"); - g_signal_connect (G_OBJECT (button_state_playing), "clicked", - G_CALLBACK (button_state_playing_cb), pipeline); - gtk_grid_attach (GTK_GRID (table), button_state_playing, 3, 0, 1, 1); - //gtk_widget_show (button_state_playing); - - w = gst_mview_widget_new (FALSE); - combo = GST_MVIEW_WIDGET (w)->mode_selector; - gtk_combo_box_set_active_id (GTK_COMBO_BOX (combo), - enum_value_to_nick (GST_TYPE_VIDEO_MULTIVIEW_FRAME_PACKING, - state.in_mode)); -#if USE_GLCONVERT_FOR_INPUT - g_signal_connect (G_OBJECT (combo), "changed", - G_CALLBACK (set_mview_input_mode), glconvert); -#else - g_signal_connect (G_OBJECT (combo), "changed", - G_CALLBACK (set_mview_input_mode), pipeline); -#endif - - g_object_set (G_OBJECT (w), "flags", state.in_flags, NULL); -#if USE_GLCONVERT_FOR_INPUT - g_signal_connect (G_OBJECT (w), "notify::flags", - G_CALLBACK (input_flags_changed), glconvert); -#else - g_signal_connect (G_OBJECT (w), "notify::flags", - G_CALLBACK (input_flags_changed), pipeline); -#endif - gtk_container_add (GTK_CONTAINER (vbox), w); - - w = gst_mview_widget_new (TRUE); - combo = GST_MVIEW_WIDGET (w)->mode_selector; - gtk_combo_box_set_active_id (GTK_COMBO_BOX (combo), - enum_value_to_nick (GST_TYPE_VIDEO_MULTIVIEW_MODE, state.out_mode)); - g_signal_connect (G_OBJECT (combo), "changed", - G_CALLBACK (set_mview_output_mode), videosink); - - g_object_set (G_OBJECT (w), "flags", state.out_flags, NULL); - g_signal_connect (G_OBJECT (w), "notify::flags", - G_CALLBACK (output_flags_changed), videosink); - g_signal_connect (G_OBJECT (w), "notify::downmix-mode", - G_CALLBACK (downmix_method_changed), videosink); - gtk_container_add (GTK_CONTAINER (vbox), w); - - //configure the pipeline - g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (destroy_cb), - pipeline); - - gtk_widget_realize (area); - - /* Redraw needed when paused or stopped (PAUSED or READY) */ - g_signal_connect (area, "draw", G_CALLBACK (draw_cb), videosink); - g_signal_connect(area, "configure-event", G_CALLBACK(resize_cb), videosink); - - gtk_widget_show_all (window); - - gst_element_set_state (pipeline, GST_STATE_PLAYING); - - gtk_main (); - - return 0; -} diff --git a/tests/examples/gl/gtk/3dvideo/mviewwidget.c b/tests/examples/gl/gtk/3dvideo/mviewwidget.c deleted file mode 100644 index b74409c13..000000000 --- a/tests/examples/gl/gtk/3dvideo/mviewwidget.c +++ /dev/null @@ -1,324 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2014-2015 Jan Schmidt <jan@centricular.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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "mviewwidget.h" - -G_DEFINE_TYPE (GstMViewWidget, gst_mview_widget, GTK_TYPE_GRID); - -static void gst_mview_widget_constructed (GObject * o); -static void gst_mview_widget_set_property (GObject * object, - guint prop_id, const GValue * value, GParamSpec * pspec); -static void gst_mview_widget_get_property (GObject * object, - guint prop_id, GValue * value, GParamSpec * pspec); - -#define DEFAULT_DOWNMIX GST_GL_STEREO_DOWNMIX_ANAGLYPH_GREEN_MAGENTA_DUBOIS - -enum -{ - PROP_0, - PROP_IS_OUTPUT, - PROP_MODE_SELECTOR, - PROP_FLAGS, - PROP_DOWNMIX_MODE -}; - -typedef struct _ToggleClosure -{ - GstMViewWidget *mv; - GstVideoMultiviewFlags flag; -} ToggleClosure; - -static GtkWidget *combo_box_from_enum (GType enum_type); - -static void -gst_mview_widget_class_init (GstMViewWidgetClass * klass) -{ - GObjectClass *object_klass = (GObjectClass *) (klass); - - object_klass->constructed = gst_mview_widget_constructed; - object_klass->set_property = gst_mview_widget_set_property; - object_klass->get_property = gst_mview_widget_get_property; - - g_object_class_install_property (object_klass, PROP_IS_OUTPUT, - g_param_spec_boolean ("is-output", "Is an Output widget", - "TRUE if the widget should have downmix mode", FALSE, - G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property (object_klass, PROP_MODE_SELECTOR, - g_param_spec_object ("mode-selector", "Multiview Mode selector", - "Multiview Mode selector widget", - GTK_TYPE_WIDGET, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - g_object_class_install_property (object_klass, PROP_FLAGS, - g_param_spec_flags ("flags", "Multiview Flags", - "multiview flags", GST_TYPE_VIDEO_MULTIVIEW_FLAGS, - GST_VIDEO_MULTIVIEW_FLAGS_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - g_object_class_install_property (object_klass, PROP_DOWNMIX_MODE, - g_param_spec_enum ("downmix-mode", - "Mode for mono downmixed output", - "Output anaglyph type to generate when downmixing to mono", - GST_TYPE_GL_STEREO_DOWNMIX_MODE_TYPE, DEFAULT_DOWNMIX, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); -} - -static void -gst_mview_widget_init (GstMViewWidget * mv) -{ -} - -static void -flag_changed (GObject * w, ToggleClosure * c) -{ - GstMViewWidget *mv = GST_MVIEW_WIDGET (c->mv); - gboolean flag_set; - - g_object_get (w, "active", &flag_set, NULL); - - if (flag_set) - mv->flags |= c->flag; - else - mv->flags &= ~(c->flag); - if (!mv->synching) - g_object_notify (G_OBJECT (mv), "flags"); -} - -static void -link_button_to_flag (GstMViewWidget * mv, GtkWidget * w, - GstVideoMultiviewFlags flag) -{ - ToggleClosure *c = g_new0 (ToggleClosure, 1); - - c->mv = mv; - c->flag = flag; - - g_signal_connect_data (G_OBJECT (w), "toggled", G_CALLBACK (flag_changed), - c, (GClosureNotify) g_free, 0); -} - -static void -sync_flags (GstMViewWidget * mv) -{ - mv->synching = TRUE; - g_object_set (G_OBJECT (mv->lflip), "active", - ! !(mv->flags & GST_VIDEO_MULTIVIEW_FLAGS_LEFT_FLIPPED), NULL); - g_object_set (G_OBJECT (mv->lflop), "active", - ! !(mv->flags & GST_VIDEO_MULTIVIEW_FLAGS_LEFT_FLOPPED), NULL); - g_object_set (G_OBJECT (mv->rflip), "active", - ! !(mv->flags & GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLIPPED), NULL); - g_object_set (G_OBJECT (mv->rflop), "active", - ! !(mv->flags & GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLOPPED), NULL); - g_object_set (G_OBJECT (mv->right_first), "active", - ! !(mv->flags & GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_VIEW_FIRST), NULL); - g_object_set (G_OBJECT (mv->half_aspect), "active", - ! !(mv->flags & GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT), NULL); - mv->synching = FALSE; -} - -static const gchar * -enum_value_to_nick (GType enum_type, guint value) -{ - GEnumClass *enum_info; - GEnumValue *v; - const gchar *nick; - - enum_info = (GEnumClass *) (g_type_class_ref (enum_type)); - g_return_val_if_fail (enum_info != NULL, NULL); - - v = g_enum_get_value (enum_info, value); - g_return_val_if_fail (v != NULL, NULL); - - nick = v->value_nick; - - g_type_class_unref (enum_info); - - return nick; -} - -static void -sync_downmix (GstMViewWidget * mv) -{ - mv->synching = TRUE; - gtk_combo_box_set_active_id (GTK_COMBO_BOX (mv->downmix_combo), - enum_value_to_nick (GST_TYPE_GL_STEREO_DOWNMIX_MODE_TYPE, - mv->downmix_mode)); - mv->synching = FALSE; -} - -static gboolean -set_downmix_mode (GtkWidget * widget, gpointer data) -{ - GstMViewWidget *mv = GST_MVIEW_WIDGET (data); - gchar *downmix_mode = NULL; - GEnumClass *p_class; - GEnumValue *v; - GParamSpec *p = - g_object_class_find_property (G_OBJECT_GET_CLASS (mv), "downmix-mode"); - - g_return_val_if_fail (p != NULL, FALSE); - - p_class = G_PARAM_SPEC_ENUM (p)->enum_class; - g_return_val_if_fail (p_class != NULL, FALSE); - - g_object_get (G_OBJECT (widget), "active-id", &downmix_mode, NULL); - g_return_val_if_fail (downmix_mode != NULL, FALSE); - - v = g_enum_get_value_by_nick (p_class, downmix_mode); - g_return_val_if_fail (v != NULL, FALSE); - - mv->downmix_mode = v->value; - if (!mv->synching) - g_object_notify (G_OBJECT (mv), "downmix-mode"); - - return FALSE; -} - -static void -gst_mview_widget_constructed (GObject * o) -{ - GstMViewWidget *mv = GST_MVIEW_WIDGET (o); - GtkGrid *g = GTK_GRID (mv); - GtkWidget *w; - - gtk_widget_set_has_window (GTK_WIDGET (mv), FALSE); - - if (mv->is_output) { - mv->mode_selector = w = combo_box_from_enum (GST_TYPE_VIDEO_MULTIVIEW_MODE); - gtk_grid_attach (g, gtk_label_new ("Output:"), 0, 0, 1, 1); - } else { - mv->mode_selector = w = - combo_box_from_enum (GST_TYPE_VIDEO_MULTIVIEW_FRAME_PACKING); - gtk_grid_attach (g, gtk_label_new ("Input:"), 0, 0, 1, 1); - } - gtk_grid_attach (g, mv->mode_selector, 1, 0, 3, 1); - - gtk_grid_attach (g, gtk_label_new (" Left "), 4, 0, 1, 1); - mv->lflip = w = gtk_toggle_button_new_with_label ("Flip"); - link_button_to_flag (mv, w, GST_VIDEO_MULTIVIEW_FLAGS_LEFT_FLIPPED); - gtk_grid_attach (g, w, 5, 0, 1, 1); - mv->lflop = w = gtk_toggle_button_new_with_label ("Flop"); - link_button_to_flag (mv, w, GST_VIDEO_MULTIVIEW_FLAGS_LEFT_FLOPPED); - gtk_grid_attach (g, w, 6, 0, 1, 1); - - gtk_grid_attach (g, gtk_label_new (" Right "), 4, 1, 1, 1); - mv->rflip = w = gtk_toggle_button_new_with_label ("Flip"); - link_button_to_flag (mv, w, GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLIPPED); - gtk_grid_attach (g, w, 5, 1, 1, 1); - mv->rflop = w = gtk_toggle_button_new_with_label ("Flop"); - link_button_to_flag (mv, w, GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLOPPED); - gtk_grid_attach (g, w, 6, 1, 1, 1); - - mv->right_first = w = gtk_toggle_button_new_with_label ("Left/Right swap"); - link_button_to_flag (mv, w, GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_VIEW_FIRST); - gtk_grid_attach (g, w, 1, 1, 1, 1); - mv->half_aspect = w = gtk_toggle_button_new_with_label ("Half-Aspect"); - link_button_to_flag (mv, w, GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT); - gtk_grid_attach (g, w, 2, 1, 1, 1); - - if (mv->is_output) { - mv->downmix_combo = w = - combo_box_from_enum (GST_TYPE_GL_STEREO_DOWNMIX_MODE_TYPE); - gtk_grid_attach (g, w, 1, 2, 3, 1); - sync_downmix (mv); - g_signal_connect (G_OBJECT (w), "changed", - G_CALLBACK (set_downmix_mode), mv); - } -} - -static void -gst_mview_widget_set_property (GObject * object, - guint prop_id, const GValue * value, GParamSpec * pspec) -{ - GstMViewWidget *mv = GST_MVIEW_WIDGET (object); - switch (prop_id) { - case PROP_IS_OUTPUT: - mv->is_output = g_value_get_boolean (value); - break; - case PROP_FLAGS: - mv->flags = (GstVideoMultiviewFlags) g_value_get_flags (value); - sync_flags (mv); - break; - case PROP_DOWNMIX_MODE: - mv->downmix_mode = g_value_get_enum (value); - sync_downmix (mv); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gst_mview_widget_get_property (GObject * object, - guint prop_id, GValue * value, GParamSpec * pspec) -{ - GstMViewWidget *mv = GST_MVIEW_WIDGET (object); - switch (prop_id) { - case PROP_IS_OUTPUT: - g_value_set_boolean (value, mv->is_output); - break; - case PROP_MODE_SELECTOR: - g_value_set_object (value, mv->mode_selector); - break; - case PROP_FLAGS: - g_value_set_flags (value, mv->flags); - break; - case PROP_DOWNMIX_MODE: - g_value_set_enum (value, mv->downmix_mode); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static GtkWidget * -combo_box_from_enum (GType enum_type) -{ - GEnumClass *enum_info; - GtkWidget *combo; - guint i; - - enum_info = (GEnumClass *) (g_type_class_ref (enum_type)); - g_return_val_if_fail (enum_info != NULL, NULL); - - combo = gtk_combo_box_text_new (); - for (i = 0; i < enum_info->n_values; i++) { - GEnumValue *v = enum_info->values + i; - gtk_combo_box_text_insert (GTK_COMBO_BOX_TEXT (combo), - i, v->value_nick, v->value_name); - } - - g_type_class_unref (enum_info); - - return combo; -} - -GtkWidget * -gst_mview_widget_new (gboolean is_output) -{ - GtkWidget *ret; - - ret = g_object_new (GST_TYPE_MVIEW_WIDGET, "is-output", is_output, NULL); - - return ret; -} diff --git a/tests/examples/gl/gtk/3dvideo/mviewwidget.h b/tests/examples/gl/gtk/3dvideo/mviewwidget.h deleted file mode 100644 index b63d7a944..000000000 --- a/tests/examples/gl/gtk/3dvideo/mviewwidget.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2014-2015 Jan Schmidt <jan@centricular.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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ -#include <string.h> - -#define GST_USE_UNSTABLE_API 1 - -#include <gst/gst.h> -#include <gtk/gtk.h> -#include <gdk/gdk.h> -#include <gst/video/video-info.h> -#include <gst/gl/gstglviewconvert.h> - -G_BEGIN_DECLS - -#define GST_TYPE_MVIEW_WIDGET (gst_mview_widget_get_type()) -#define GST_MVIEW_WIDGET(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MVIEW_WIDGET, GstMViewWidget)) -#define GST_MVIEW_WIDGET_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MVIEW_WIDGET, GstMViewWidgetClass)) -#define GST_IS_MVIEW_WIDGET(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MVIEW_WIDGET)) -#define GST_IS_MVIEW_WIDGET_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MVIEW_WIDGET)) -#define GST_MVIEW_WIDGET_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_MVIEW_WIDGET,GstMViewWidgetClass)) - -typedef struct _GstMViewWidget GstMViewWidget; -typedef struct _GstMViewWidgetClass GstMViewWidgetClass; - -struct _GstMViewWidget { - GtkGrid parent; - - gboolean is_output; - - GtkWidget *mode_selector; - - GstVideoMultiviewMode mode; - GstVideoMultiviewFlags flags; - GstGLStereoDownmix downmix_mode; - - /* Array of toggle buttons for flags */ - GtkWidget *lflip; - GtkWidget *lflop; - GtkWidget *rflip; - GtkWidget *rflop; - GtkWidget *half_aspect; - GtkWidget *right_first; - - GtkWidget *downmix_combo; - - gboolean synching; -}; - -struct _GstMViewWidgetClass { - GtkGridClass parent; -}; - -GType gst_mview_widget_get_type (); -GtkWidget *gst_mview_widget_new (gboolean is_output); - -G_END_DECLS diff --git a/tests/examples/gl/gtk/Makefile.am b/tests/examples/gl/gtk/Makefile.am deleted file mode 100644 index 572890523..000000000 --- a/tests/examples/gl/gtk/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ - -SUBDIRS = . filternovideooverlay filtervideooverlay fxtest switchvideooverlay 3dvideo - -noinst_LTLIBRARIES = libgstgtkhelper.la - -libgstgtkhelper_la_SOURCES = gstgtk.c gstgtk.h -libgstgtkhelper_la_CFLAGS = -I$(top_srcdir)/gst-libs -I$(top_builddir)/gst-libs \ - $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(GTK3_CFLAGS) - -if HAVE_WINDOW_COCOA -libgstgtkhelper_la_CFLAGS += -x objective-c -endif - diff --git a/tests/examples/gl/gtk/README b/tests/examples/gl/gtk/README deleted file mode 100644 index 76595c6bf..000000000 --- a/tests/examples/gl/gtk/README +++ /dev/null @@ -1,27 +0,0 @@ ---- Description of the GTK examples --- - -- gtkvideooverlay: -Show how to use the videooverlay interface through GTK. -It's possible to switch bettween GST_STATE through four buttons. - --filternovideooverlay: -A more complex pipeline is switched bettween the GST states -without using the videooverlay interface. - --filtervideooverlay: -A more complex pipeline is switched bettween the GST states. -using the videooverlay interface. - --fxtest: -switch bettween effects of the gleffects filter. - --pixbufdrop: -drag and drop a png file and overlay it using alpha channel. -It uses gloverlay filter. - --switchvideooverlay: -change the videooverlay window while the stream is playing. - ---- How to build the GTK examples --- - -Using autotools or using tests/examples/gtk/gtk.sln diff --git a/tests/examples/gl/gtk/filternovideooverlay/.gitignore b/tests/examples/gl/gtk/filternovideooverlay/.gitignore deleted file mode 100644 index f6e41625b..000000000 --- a/tests/examples/gl/gtk/filternovideooverlay/.gitignore +++ /dev/null @@ -1 +0,0 @@ -filternovideooverlay diff --git a/tests/examples/gl/gtk/filternovideooverlay/Makefile.am b/tests/examples/gl/gtk/filternovideooverlay/Makefile.am deleted file mode 100644 index 61526c544..000000000 --- a/tests/examples/gl/gtk/filternovideooverlay/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -noinst_PROGRAMS = filternovideooverlay - -filternovideooverlay_SOURCES = main.cpp - -filternovideooverlay_CXXFLAGS= \ - -I$(top_srcdir)/gst-libs \ - -I$(top_builddir)/gst-libs \ - $(GST_PLUGINS_BASE_CFLAGS) \ - $(GST_CXXFLAGS) \ - $(GL_CFLAGS) \ - $(GTK3_CFLAGS) - -filternovideooverlay_LDADD= \ - $(GTK3_LIBS) \ - $(GST_PLUGINS_BASE_LIBS) \ - $(GST_LIBS) \ - $(GL_LIBS) - diff --git a/tests/examples/gl/gtk/filternovideooverlay/main.cpp b/tests/examples/gl/gtk/filternovideooverlay/main.cpp deleted file mode 100644 index dc9e04b68..000000000 --- a/tests/examples/gl/gtk/filternovideooverlay/main.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008-2009 Julien Isorce <julien.isorce@gmail.com> - * Copyright (C) 2014 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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include <gst/gst.h> -#include <gtk/gtk.h> -#include <gdk/gdk.h> - - -static void end_stream_cb(GstBus* bus, GstMessage* message, GstElement* pipeline) -{ - g_print("End of stream\n"); - - gst_element_set_state (pipeline, GST_STATE_NULL); - gst_object_unref(pipeline); - - gtk_main_quit(); -} - -static void button_state_null_cb(GtkWidget* widget, GstElement* pipeline) -{ - gst_element_set_state (pipeline, GST_STATE_NULL); - g_print ("GST_STATE_NULL\n"); -} - - -static void button_state_ready_cb(GtkWidget* widget, GstElement* pipeline) -{ - gst_element_set_state (pipeline, GST_STATE_READY); - g_print ("GST_STATE_READY\n"); -} - - -static void button_state_paused_cb(GtkWidget* widget, GstElement* pipeline) -{ - gst_element_set_state (pipeline, GST_STATE_PAUSED); - g_print ("GST_STATE_PAUSED\n"); -} - - -static void button_state_playing_cb(GtkWidget* widget, GstElement* pipeline) -{ - gst_element_set_state (pipeline, GST_STATE_PLAYING); - g_print ("GST_STATE_PLAYING\n"); -} - - -static gchar* slider_fps_cb (GtkScale* scale, gdouble value, GstElement* pipeline) -{ - //change the video frame rate dynamically - return g_strdup_printf ("video framerate: %0.*g", gtk_scale_get_digits (scale), value); -} - - - -gint main (gint argc, gchar *argv[]) -{ - gtk_init (&argc, &argv); - gst_init (&argc, &argv); - - GstElement* pipeline = gst_pipeline_new ("pipeline"); - - //window to control the states - GtkWidget* window_control = gtk_window_new (GTK_WINDOW_TOPLEVEL); - GdkGeometry geometry; - geometry.min_width = 1; - geometry.min_height = 1; - geometry.max_width = -1; - geometry.max_height = -1; - gtk_window_set_geometry_hints (GTK_WINDOW (window_control), window_control, &geometry, GDK_HINT_MIN_SIZE); - gtk_window_set_resizable (GTK_WINDOW (window_control), FALSE); - gtk_window_move (GTK_WINDOW (window_control), 10, 10); - GtkWidget* table = gtk_grid_new (); - gtk_container_add (GTK_CONTAINER (window_control), table); - - //control state null - GtkWidget* button_state_null = gtk_button_new_with_label ("GST_STATE_NULL"); - g_signal_connect (G_OBJECT (button_state_null), "clicked", - G_CALLBACK (button_state_null_cb), pipeline); - gtk_grid_attach (GTK_GRID (table), button_state_null, 0, 0, 1, 1); - gtk_widget_show (button_state_null); - - //control state ready - GtkWidget* button_state_ready = gtk_button_new_with_label ("GST_STATE_READY"); - g_signal_connect (G_OBJECT (button_state_ready), "clicked", - G_CALLBACK (button_state_ready_cb), pipeline); - gtk_grid_attach (GTK_GRID (table), button_state_ready, 0, 1, 1, 1); - gtk_widget_show (button_state_ready); - - //control state paused - GtkWidget* button_state_paused = gtk_button_new_with_label ("GST_STATE_PAUSED"); - g_signal_connect (G_OBJECT (button_state_paused), "clicked", - G_CALLBACK (button_state_paused_cb), pipeline); - gtk_grid_attach (GTK_GRID (table), button_state_paused, 0, 2, 1, 1); - gtk_widget_show (button_state_paused); - - //control state playing - GtkWidget* button_state_playing = gtk_button_new_with_label ("GST_STATE_PLAYING"); - g_signal_connect (G_OBJECT (button_state_playing), "clicked", - G_CALLBACK (button_state_playing_cb), pipeline); - gtk_grid_attach (GTK_GRID (table), button_state_playing, 0, 3, 1, 1); - gtk_widget_show (button_state_playing); - - //change framerate - GtkWidget* slider_fps = gtk_scale_new_with_range (GTK_ORIENTATION_VERTICAL, - 1, 30, 2); - g_signal_connect (G_OBJECT (slider_fps), "format-value", - G_CALLBACK (slider_fps_cb), pipeline); - gtk_grid_attach (GTK_GRID (table), slider_fps, 1, 0, 1, 3); - gtk_widget_show (slider_fps); - - gtk_widget_show (table); - gtk_widget_show (window_control); - - GstElement* videosrc = gst_element_factory_make ("videotestsrc", "videotestsrc"); - GstElement* upload = gst_element_factory_make ("glupload", "glupload"); - GstElement* glfiltercube = gst_element_factory_make ("glfiltercube", "glfiltercube"); - GstElement* videosink = gst_element_factory_make ("glimagesink", "glimagesink"); - - GstCaps *caps = gst_caps_new_simple("video/x-raw", - "width", G_TYPE_INT, 640, - "height", G_TYPE_INT, 480, - "framerate", GST_TYPE_FRACTION, 25, 1, - "format", G_TYPE_STRING, "RGBA", - NULL) ; - - gst_bin_add_many (GST_BIN (pipeline), videosrc, upload, glfiltercube, videosink, NULL); - - gboolean link_ok = gst_element_link_filtered(videosrc, upload, caps) ; - gst_caps_unref(caps) ; - if(!link_ok) - { - g_warning("Failed to link videosrc to glfiltercube!\n") ; - return -1; - } - - if(!gst_element_link_many(upload, glfiltercube, videosink, NULL)) - { - g_warning("Failed to link glfiltercube to videosink!\n") ; - return -1; - } - - //set window id on this event - GstBus* bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); - gst_bus_add_signal_watch (bus); - g_signal_connect(bus, "message::error", G_CALLBACK(end_stream_cb), pipeline); - g_signal_connect(bus, "message::warning", G_CALLBACK(end_stream_cb), pipeline); - g_signal_connect(bus, "message::eos", G_CALLBACK(end_stream_cb), pipeline); - gst_object_unref (bus); - - //start - GstStateChangeReturn ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); - if (ret == GST_STATE_CHANGE_FAILURE) - { - g_print ("Failed to start up pipeline!\n"); - return -1; - } - - gtk_main(); - - return 0; -} - diff --git a/tests/examples/gl/gtk/filtervideooverlay/.gitignore b/tests/examples/gl/gtk/filtervideooverlay/.gitignore deleted file mode 100644 index c5e1611f6..000000000 --- a/tests/examples/gl/gtk/filtervideooverlay/.gitignore +++ /dev/null @@ -1 +0,0 @@ -filtervideooverlay diff --git a/tests/examples/gl/gtk/filtervideooverlay/Makefile.am b/tests/examples/gl/gtk/filtervideooverlay/Makefile.am deleted file mode 100644 index 301b2aae6..000000000 --- a/tests/examples/gl/gtk/filtervideooverlay/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -noinst_PROGRAMS = filtervideooverlay - -filtervideooverlay_SOURCES = main.cpp - -filtervideooverlay_CXXFLAGS=-I$(top_srcdir)/gst-libs -I$(top_builddir)/gst-libs \ - $(GST_PLUGINS_BASE_CFLAGS) $(GST_CXXFLAGS) \ - $(GL_CFLAGS) $(GTK3_CFLAGS) $(X11_CFLAGS) -filtervideooverlay_LDADD=../libgstgtkhelper.la \ - $(GTK3_LIBS) $(GST_PLUGINS_BASE_LIBS) $(GST_LIBS) \ - $(GL_LIBS) -lgstvideo-$(GST_API_VERSION) $(X11_LIBS) - diff --git a/tests/examples/gl/gtk/filtervideooverlay/main.cpp b/tests/examples/gl/gtk/filtervideooverlay/main.cpp deleted file mode 100644 index 6850a7da2..000000000 --- a/tests/examples/gl/gtk/filtervideooverlay/main.cpp +++ /dev/null @@ -1,296 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008-2009 Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gst/gst.h> -#include <gtk/gtk.h> -#include <gdk/gdk.h> - -#include "../gstgtk.h" - -#ifdef HAVE_X11 -#include <X11/Xlib.h> -#endif - -static GstBusSyncReply create_window (GstBus* bus, GstMessage* message, GtkWidget* widget) -{ - GtkAllocation allocation; - - if (gst_gtk_handle_need_context (bus, message, NULL)) - return GST_BUS_DROP; - - // ignore anything but 'prepare-window-handle' element messages - if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT) - return GST_BUS_PASS; - - if (!gst_is_video_overlay_prepare_window_handle_message (message)) - return GST_BUS_PASS; - - g_print ("setting window handle %p\n", widget); - - gst_video_overlay_set_gtk_window (GST_VIDEO_OVERLAY (GST_MESSAGE_SRC (message)), widget); - - gtk_widget_get_allocation (widget, &allocation); - gst_video_overlay_set_render_rectangle (GST_VIDEO_OVERLAY (GST_MESSAGE_SRC (message)), allocation.x, allocation.y, allocation.width, allocation.height); - - gst_message_unref (message); - - return GST_BUS_DROP; -} - -static gboolean -resize_cb (GtkWidget * widget, GdkEvent * event, gpointer sink) -{ - GtkAllocation allocation; - - gtk_widget_get_allocation (widget, &allocation); - gst_video_overlay_set_render_rectangle (GST_VIDEO_OVERLAY (sink), allocation.x, allocation.y, allocation.width, allocation.height); - - return G_SOURCE_CONTINUE; -} - -static void end_stream_cb(GstBus* bus, GstMessage* message, GstElement* pipeline) -{ - GError *error = NULL; - gchar *details; - - switch (GST_MESSAGE_TYPE (message)) { - case GST_MESSAGE_ERROR: - gst_message_parse_error (message, &error, &details); - - g_print("Error %s\n", error->message); - g_print("Details %s\n", details); - /* fallthrough */ - case GST_MESSAGE_EOS: - g_print("End of stream\n"); - - gst_element_set_state (pipeline, GST_STATE_NULL); - gst_object_unref(pipeline); - - gtk_main_quit(); - break; - case GST_MESSAGE_WARNING: - gst_message_parse_warning (message, &error, &details); - - g_print("Warning %s\n", error->message); - g_print("Details %s\n", details); - break; - default: - break; - } -} - -static gboolean expose_cb(GtkWidget* widget, cairo_t *cr, GstElement* videosink) -{ - gst_video_overlay_expose (GST_VIDEO_OVERLAY (videosink)); - return FALSE; -} - - -static void destroy_cb(GtkWidget* widget, GdkEvent* event, GstElement* pipeline) -{ - g_print("Close\n"); - - gst_element_set_state (pipeline, GST_STATE_NULL); - gst_object_unref(pipeline); - - gtk_main_quit(); -} - - -static void button_state_null_cb(GtkWidget* widget, GstElement* pipeline) -{ - gst_element_set_state (pipeline, GST_STATE_NULL); - g_print ("GST_STATE_NULL\n"); -} - - -static void button_state_ready_cb(GtkWidget* widget, GstElement* pipeline) -{ - gst_element_set_state (pipeline, GST_STATE_READY); - g_print ("GST_STATE_READY\n"); -} - - -static void button_state_paused_cb(GtkWidget* widget, GstElement* pipeline) -{ - gst_element_set_state (pipeline, GST_STATE_PAUSED); - g_print ("GST_STATE_PAUSED\n"); -} - - -static void button_state_playing_cb(GtkWidget* widget, GstElement* pipeline) -{ - gst_element_set_state (pipeline, GST_STATE_PLAYING); - g_print ("GST_STATE_PLAYING\n"); -} - - -static gchar* slider_fps_cb (GtkScale* scale, gdouble value, GstElement* pipeline) -{ - //change the video frame rate dynamically - return g_strdup_printf ("video framerate: %0.*g", gtk_scale_get_digits (scale), value); -} - - - -gint main (gint argc, gchar *argv[]) -{ -#ifdef HAVE_X11 - XInitThreads (); -#endif - - gtk_init (&argc, &argv); - gst_init (&argc, &argv); - - GstElement* pipeline = gst_pipeline_new ("pipeline"); - - //window that contains an area where the video is drawn - GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_widget_set_size_request (window, 640, 480); - gtk_window_move (GTK_WINDOW (window), 300, 10); - gtk_window_set_title (GTK_WINDOW (window), "glimagesink implement the gstvideooverlay interface"); - GdkGeometry geometry; - geometry.min_width = 1; - geometry.min_height = 1; - geometry.max_width = -1; - geometry.max_height = -1; - gtk_window_set_geometry_hints (GTK_WINDOW (window), window, &geometry, GDK_HINT_MIN_SIZE); - - //window to control the states - GtkWidget* window_control = gtk_window_new (GTK_WINDOW_TOPLEVEL); - geometry.min_width = 1; - geometry.min_height = 1; - geometry.max_width = -1; - geometry.max_height = -1; - gtk_window_set_geometry_hints (GTK_WINDOW (window_control), window_control, &geometry, GDK_HINT_MIN_SIZE); - gtk_window_set_resizable (GTK_WINDOW (window_control), FALSE); - gtk_window_move (GTK_WINDOW (window_control), 10, 10); - GtkWidget* grid = gtk_grid_new (); - gtk_container_add (GTK_CONTAINER (window_control), grid); - - //control state null - GtkWidget* button_state_null = gtk_button_new_with_label ("GST_STATE_NULL"); - g_signal_connect (G_OBJECT (button_state_null), "clicked", - G_CALLBACK (button_state_null_cb), pipeline); - gtk_grid_attach (GTK_GRID (grid), button_state_null, 0, 1, 1, 1); - gtk_widget_show (button_state_null); - - //control state ready - GtkWidget* button_state_ready = gtk_button_new_with_label ("GST_STATE_READY"); - g_signal_connect (G_OBJECT (button_state_ready), "clicked", - G_CALLBACK (button_state_ready_cb), pipeline); - gtk_grid_attach (GTK_GRID (grid), button_state_ready, 0, 2, 1, 1); - gtk_widget_show (button_state_ready); - - //control state paused - GtkWidget* button_state_paused = gtk_button_new_with_label ("GST_STATE_PAUSED"); - g_signal_connect (G_OBJECT (button_state_paused), "clicked", - G_CALLBACK (button_state_paused_cb), pipeline); - gtk_grid_attach (GTK_GRID (grid), button_state_paused, 0, 3, 1, 1); - gtk_widget_show (button_state_paused); - - //control state playing - GtkWidget* button_state_playing = gtk_button_new_with_label ("GST_STATE_PLAYING"); - g_signal_connect (G_OBJECT (button_state_playing), "clicked", - G_CALLBACK (button_state_playing_cb), pipeline); - gtk_grid_attach (GTK_GRID (grid), button_state_playing, 0, 4, 1, 1); - gtk_widget_show (button_state_playing); - - //change framerate - GtkWidget* slider_fps = gtk_scale_new_with_range (GTK_ORIENTATION_VERTICAL, 1, 30, 2); - g_signal_connect (G_OBJECT (slider_fps), "format-value", - G_CALLBACK (slider_fps_cb), pipeline); - gtk_grid_attach (GTK_GRID (grid), slider_fps, 1, 0, 1, 5); - gtk_widget_show (slider_fps); - - gtk_widget_show (grid); - gtk_widget_show (window_control); - - //configure the pipeline - g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(destroy_cb), pipeline); - - GstElement* videosrc = gst_element_factory_make ("videotestsrc", "videotestsrc"); - GstElement* upload = gst_element_factory_make ("glupload", "glupload"); - GstElement* glfiltercube = gst_element_factory_make ("glfiltercube", "glfiltercube"); - GstElement* videosink = gst_element_factory_make ("glimagesink", "glimagesink"); - - GstCaps *caps = gst_caps_new_simple("video/x-raw", - "width", G_TYPE_INT, 640, - "height", G_TYPE_INT, 480, - "framerate", GST_TYPE_FRACTION, 25, 1, - "format", G_TYPE_STRING, "RGBA", - NULL) ; - - gst_bin_add_many (GST_BIN (pipeline), videosrc, upload, glfiltercube, videosink, NULL); - - gboolean link_ok = gst_element_link_filtered(videosrc, upload, caps) ; - gst_caps_unref(caps) ; - if(!link_ok) - { - g_warning("Failed to link videosrc to glfiltercube!\n") ; - return -1; - } - - if(!gst_element_link_many(upload, glfiltercube, videosink, NULL)) - { - g_warning("Failed to link glfiltercube to videosink!\n") ; - return -1; - } - - //area where the video is drawn - GtkWidget* area = gtk_drawing_area_new(); - gtk_widget_set_redraw_on_allocate (area, TRUE); - gtk_container_add (GTK_CONTAINER (window), area); - - gtk_widget_realize(area); - - //set window id on this event - GstBus* bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); - gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, area, NULL); - gst_bus_add_signal_watch (bus); - g_signal_connect(bus, "message::error", G_CALLBACK(end_stream_cb), pipeline); - g_signal_connect(bus, "message::warning", G_CALLBACK(end_stream_cb), pipeline); - g_signal_connect(bus, "message::eos", G_CALLBACK(end_stream_cb), pipeline); - gst_object_unref (bus); - - //needed when being in GST_STATE_READY, GST_STATE_PAUSED - //or resizing/obscuring the window - g_signal_connect(area, "draw", G_CALLBACK(expose_cb), videosink); - g_signal_connect(area, "configure-event", G_CALLBACK(resize_cb), videosink); - - //start - GstStateChangeReturn ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); - if (ret == GST_STATE_CHANGE_FAILURE) - { - g_print ("Failed to start up pipeline!\n"); - return -1; - } - - gtk_widget_show_all (window); - - gtk_main(); - - return 0; -} - diff --git a/tests/examples/gl/gtk/fxtest/.gitignore b/tests/examples/gl/gtk/fxtest/.gitignore deleted file mode 100644 index c35569775..000000000 --- a/tests/examples/gl/gtk/fxtest/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -fxtest -pixbufdrop diff --git a/tests/examples/gl/gtk/fxtest/Makefile.am b/tests/examples/gl/gtk/fxtest/Makefile.am deleted file mode 100644 index e078906f5..000000000 --- a/tests/examples/gl/gtk/fxtest/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -noinst_PROGRAMS = fxtest -noinst_PROGRAMS += pixbufdrop - -fxtest_SOURCES = fxtest.c - -fxtest_CFLAGS=-I$(top_srcdir)/gst-libs -I$(top_builddir)/gst-libs \ - $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) \ - $(GL_CFLAGS) $(GTK3_CFLAGS) $(X11_CFLAGS) -fxtest_LDADD=../libgstgtkhelper.la \ - $(GTK3_LIBS) $(GST_PLUGINS_BASE_LIBS) $(GST_LIBS) \ - $(GL_LIBS) -lgstvideo-$(GST_API_VERSION) $(X11_LIBS) - -pixbufdrop_SOURCES = pixbufdrop.c - -pixbufdrop_CFLAGS=-I$(top_srcdir)/gst-libs -I$(top_builddir)/gst-libs \ - $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) \ - $(GL_CFLAGS) $(GTK3_CFLAGS) $(X11_CFLAGS) -pixbufdrop_LDADD=../libgstgtkhelper.la \ - $(GTK3_LIBS) $(GST_PLUGINS_BASE_LIBS) $(GST_LIBS) \ - $(GL_LIBS) -lgstvideo-$(GST_API_VERSION) $(X11_LIBS) diff --git a/tests/examples/gl/gtk/fxtest/fxtest.c b/tests/examples/gl/gtk/fxtest/fxtest.c deleted file mode 100644 index 8b56b969f..000000000 --- a/tests/examples/gl/gtk/fxtest/fxtest.c +++ /dev/null @@ -1,367 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008-2009 Filippo Argiolas <filippo.argiolas@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#define GLIB_DISABLE_DEPRECATION_WARNINGS - -#include <gst/gst.h> -#include <gtk/gtk.h> -#include <gdk/gdk.h> -#include <gdk-pixbuf/gdk-pixbuf.h> - -#include "../gstgtk.h" - -#include <gst/video/videooverlay.h> - -#ifdef HAVE_X11 -#include <X11/Xlib.h> -#endif - - -static GstBusSyncReply -create_window (GstBus * bus, GstMessage * message, GtkWidget * widget) -{ - if (gst_gtk_handle_need_context (bus, message, NULL)) - return GST_BUS_DROP; - - /* ignore anything but 'prepare-window-handle' element messages */ - if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT) - return GST_BUS_PASS; - - if (!gst_is_video_overlay_prepare_window_handle_message (message)) - return GST_BUS_PASS; - - g_print ("setting window handle\n"); - - /* do not call gdk_window_ensure_native for the first time here because - * we are in a different thread than the main thread - * (and the main thread the one) */ - gst_video_overlay_set_gtk_window (GST_VIDEO_OVERLAY (GST_MESSAGE_SRC - (message)), widget); - - gst_message_unref (message); - - return GST_BUS_DROP; -} - - -static void -end_stream_cb (GstBus * bus, GstMessage * message, GstElement * pipeline) -{ - switch (GST_MESSAGE_TYPE (message)) { - case GST_MESSAGE_EOS: - g_print ("End of stream\n"); - - gst_element_set_state (pipeline, GST_STATE_NULL); - gst_object_unref (pipeline); - gtk_main_quit (); - break; - case GST_MESSAGE_ERROR: - { - gchar *debug = NULL; - GError *err = NULL; - - gst_message_parse_error (message, &err, &debug); - - g_print ("Error: %s\n", err->message); - g_clear_error (&err); - - if (debug) { - g_print ("Debug details: %s\n", debug); - g_free (debug); - } - - gst_element_set_state (pipeline, GST_STATE_NULL); - gst_object_unref (pipeline); - gtk_main_quit (); - break; - } - default: - break; - } -} - -static gboolean -resize_cb (GtkWidget * widget, GdkEvent * event, gpointer data) -{ - GtkAllocation allocation; - GstVideoOverlay *overlay = - GST_VIDEO_OVERLAY (gst_bin_get_by_interface (GST_BIN (data), - GST_TYPE_VIDEO_OVERLAY)); - - gtk_widget_get_allocation (widget, &allocation); - gst_video_overlay_set_render_rectangle (overlay, allocation.x, allocation.y, - allocation.width, allocation.height); - gst_object_unref (overlay); - - return G_SOURCE_CONTINUE; -} - -static gboolean -expose_cb (GtkWidget * widget, gpointer unused, gpointer data) -{ - GstVideoOverlay *overlay = - GST_VIDEO_OVERLAY (gst_bin_get_by_interface (GST_BIN (data), - GST_TYPE_VIDEO_OVERLAY)); - - gst_video_overlay_expose (overlay); - gst_object_unref (overlay); - - return FALSE; -} - -static void -destroy_cb (GtkWidget * widget, GdkEvent * event, GstElement * pipeline) -{ - g_message ("destroy callback"); - - gst_element_set_state (pipeline, GST_STATE_NULL); - gst_object_unref (pipeline); - - gtk_main_quit (); -} - -static gboolean -apply_fx (GtkWidget * widget, gpointer data) -{ - gchar *fx; - GEnumClass *p_class; - -/* heeeellppppp!! */ - p_class = - G_PARAM_SPEC_ENUM (g_object_class_find_property (G_OBJECT_GET_CLASS - (G_OBJECT (data)), "effect") - )->enum_class; - - fx = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (widget)); - g_print ("setting: %s - %s\n", fx, g_enum_get_value_by_nick (p_class, - fx)->value_name); - g_object_set (G_OBJECT (data), "effect", g_enum_get_value_by_nick (p_class, - fx)->value, NULL); - return FALSE; -} - -static gboolean -play_cb (GtkWidget * widget, gpointer data) -{ - g_message ("playing"); - gst_element_set_state (GST_ELEMENT (data), GST_STATE_PLAYING); - return FALSE; -} - -static gboolean -null_cb (GtkWidget * widget, gpointer data) -{ - g_message ("nulling"); - gst_element_set_state (GST_ELEMENT (data), GST_STATE_NULL); - return FALSE; -} - -static gboolean -ready_cb (GtkWidget * widget, gpointer data) -{ - g_message ("readying"); - gst_element_set_state (GST_ELEMENT (data), GST_STATE_READY); - return FALSE; -} - -static gboolean -pause_cb (GtkWidget * widget, gpointer data) -{ - g_message ("pausing"); - gst_element_set_state (GST_ELEMENT (data), GST_STATE_PAUSED); - return FALSE; -} - -gint -main (gint argc, gchar * argv[]) -{ - GstStateChangeReturn ret; - GstElement *pipeline; - GstElement *upload, *filter, *sink; - GstElement *sourcebin; - GstBus *bus; - GError *error = NULL; - - GtkWidget *window; - GtkWidget *screen; - GtkWidget *vbox, *combo; - GtkWidget *hbox; - GtkWidget *play, *pause, *null, *ready; - - gchar **source_desc_array = NULL; - gchar *source_desc = NULL; - - GOptionContext *context; - GOptionEntry options[] = { - {"source-bin", 's', 0, G_OPTION_ARG_STRING_ARRAY, &source_desc_array, - "Use a custom source bin description (gst-launch style)", NULL} - , - {NULL} - }; - -#ifdef HAVE_X11 - XInitThreads (); -#endif - - context = g_option_context_new (NULL); - g_option_context_add_main_entries (context, options, NULL); - g_option_context_add_group (context, gst_init_get_option_group ()); - g_option_context_add_group (context, gtk_get_option_group (TRUE)); - if (!g_option_context_parse (context, &argc, &argv, &error)) { - g_print ("Inizialization error: %s\n", GST_STR_NULL (error->message)); - g_option_context_free (context); - g_clear_error (&error); - return -1; - } - g_option_context_free (context); - - if (source_desc_array != NULL) { - source_desc = g_strjoinv (" ", source_desc_array); - g_strfreev (source_desc_array); - } - if (source_desc == NULL) { - source_desc = - g_strdup - ("videotestsrc ! video/x-raw, width=352, height=288 ! identity"); - } - - sourcebin = - gst_parse_bin_from_description (g_strdup (source_desc), TRUE, &error); - g_free (source_desc); - if (error) { - g_print ("Error while parsing source bin description: %s\n", - GST_STR_NULL (error->message)); - return -1; - } - - g_set_application_name ("gst-gl-effects test app"); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_container_set_border_width (GTK_CONTAINER (window), 3); - - pipeline = gst_pipeline_new ("pipeline"); - - upload = gst_element_factory_make ("glupload", NULL); - filter = gst_element_factory_make ("gleffects", "flt"); - sink = gst_element_factory_make ("glimagesink", "glsink"); - - gst_bin_add_many (GST_BIN (pipeline), sourcebin, upload, filter, sink, NULL); - - if (!gst_element_link_many (sourcebin, upload, filter, sink, NULL)) { - g_print ("Failed to link one or more elements!\n"); - return -1; - } - - g_signal_connect (G_OBJECT (window), "delete-event", - G_CALLBACK (destroy_cb), pipeline); - g_signal_connect (G_OBJECT (window), "destroy-event", - G_CALLBACK (destroy_cb), pipeline); - - screen = gtk_drawing_area_new (); - bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); - gst_bus_add_signal_watch (bus); - g_signal_connect (bus, "message::error", G_CALLBACK (end_stream_cb), - pipeline); - g_signal_connect (bus, "message::warning", G_CALLBACK (end_stream_cb), - pipeline); - g_signal_connect (bus, "message::eos", G_CALLBACK (end_stream_cb), pipeline); - - gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, screen, - NULL); - gst_object_unref (bus); - - gtk_widget_set_size_request (screen, 640, 480); // 500 x 376 - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); - - gtk_box_pack_start (GTK_BOX (vbox), screen, TRUE, TRUE, 0); - - combo = gtk_combo_box_text_new (); - - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "identity"); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "mirror"); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "squeeze"); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "stretch"); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "fisheye"); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "twirl"); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "bulge"); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "tunnel"); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "square"); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "heat"); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "xpro"); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "lumaxpro"); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "sepia"); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "xray"); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "sin"); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "glow"); - - g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK (apply_fx), filter); - - gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0); - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - - play = gtk_button_new_with_label ("PLAY"); - - g_signal_connect (G_OBJECT (play), "clicked", G_CALLBACK (play_cb), pipeline); - - pause = gtk_button_new_with_label ("PAUSE"); - - g_signal_connect (G_OBJECT (pause), "clicked", - G_CALLBACK (pause_cb), pipeline); - - null = gtk_button_new_with_label ("NULL"); - - g_signal_connect (G_OBJECT (null), "clicked", G_CALLBACK (null_cb), pipeline); - - ready = gtk_button_new_with_label ("READY"); - - g_signal_connect (G_OBJECT (ready), "clicked", - G_CALLBACK (ready_cb), pipeline); - - gtk_box_pack_start (GTK_BOX (hbox), null, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (hbox), ready, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (hbox), play, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (hbox), pause, TRUE, TRUE, 0); - - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - - gtk_container_add (GTK_CONTAINER (window), vbox); - - g_signal_connect (screen, "draw", G_CALLBACK (expose_cb), pipeline); - g_signal_connect (screen, "configure-event", G_CALLBACK (resize_cb), - pipeline); - gtk_widget_realize (screen); - - ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); - if (ret == GST_STATE_CHANGE_FAILURE) { - g_print ("Failed to start up pipeline!\n"); - return -1; - } - - gtk_widget_show_all (GTK_WIDGET (window)); - - gtk_main (); - - return 0; -} diff --git a/tests/examples/gl/gtk/fxtest/pixbufdrop.c b/tests/examples/gl/gtk/fxtest/pixbufdrop.c deleted file mode 100644 index 3a43de2e0..000000000 --- a/tests/examples/gl/gtk/fxtest/pixbufdrop.c +++ /dev/null @@ -1,330 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008-2009 Filippo Argiolas <filippo.argiolas@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#define GLIB_DISABLE_DEPRECATION_WARNINGS - -#include <gst/gst.h> -#include <gtk/gtk.h> -#include <gdk/gdk.h> -#include <gdk-pixbuf/gdk-pixbuf.h> - -#include "../gstgtk.h" - -#include <gst/video/videooverlay.h> - -#ifdef HAVE_X11 -#include <X11/Xlib.h> -#endif - -static gint delay = 0; -static gint saveddelay = 0; -static gint method = 1; - -struct _SourceData -{ - gpointer data; - gpointer nick; - gpointer value; -}; -typedef struct _SourceData SourceData; - -static GstBusSyncReply -create_window (GstBus * bus, GstMessage * message, GtkWidget * widget) -{ - // ignore anything but 'prepare-window-handle' element messages - if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT) - return GST_BUS_PASS; - - if (!gst_is_video_overlay_prepare_window_handle_message (message)) - return GST_BUS_PASS; - - gst_video_overlay_set_gtk_window (GST_VIDEO_OVERLAY (GST_MESSAGE_SRC - (message)), widget); - - gst_message_unref (message); - - return GST_BUS_DROP; -} - -static void -message_cb (GstBus * bus, GstMessage * message, GstElement * pipeline) -{ - gst_element_set_state (pipeline, GST_STATE_NULL); - gst_object_unref (pipeline); - - gtk_main_quit (); -} - -static gboolean -expose_cb (GtkWidget * widget, cairo_t * cr, GstElement * videosink) -{ - gst_video_overlay_expose (GST_VIDEO_OVERLAY (videosink)); - return FALSE; -} - -static void -destroy_cb (GtkWidget * widget, GdkEvent * event, GstElement * pipeline) -{ - g_message ("destroy callback"); - - gst_element_set_state (pipeline, GST_STATE_NULL); - gst_object_unref (pipeline); - - gtk_main_quit (); -} - -static gboolean -play_cb (GtkWidget * widget, gpointer data) -{ - g_message ("playing"); - gst_element_set_state (GST_ELEMENT (data), GST_STATE_PLAYING); - return FALSE; -} - -static gboolean -null_cb (GtkWidget * widget, gpointer data) -{ - g_message ("nulling"); - gst_element_set_state (GST_ELEMENT (data), GST_STATE_NULL); - return FALSE; -} - -static gboolean -ready_cb (GtkWidget * widget, gpointer data) -{ - g_message ("readying"); - gst_element_set_state (GST_ELEMENT (data), GST_STATE_READY); - return FALSE; -} - -static gboolean -pause_cb (GtkWidget * widget, gpointer data) -{ - g_message ("pausing"); - gst_element_set_state (GST_ELEMENT (data), GST_STATE_PAUSED); - return FALSE; -} - -static gboolean -set_location_delayed (gpointer data) -{ - SourceData *sdata = (SourceData *) data; - delay--; - g_print ("%d\n", delay); - if (delay > 0) { - return TRUE; - } - g_object_set (G_OBJECT (sdata->data), sdata->nick, sdata->value, NULL); - delay = saveddelay; - return FALSE; -} - -static void -on_drag_data_received (GtkWidget * widget, - GdkDragContext * context, int x, int y, - GtkSelectionData * seldata, guint inf, guint time, gpointer data) -{ - SourceData *userdata = g_new0 (SourceData, 1); - GdkPixbufFormat *format; - gchar **uris = gtk_selection_data_get_uris (seldata); - gchar *filename = NULL; - - g_return_if_fail (uris != NULL); - filename = g_filename_from_uri (uris[0], NULL, NULL); - g_return_if_fail (filename != NULL); - format = gdk_pixbuf_get_file_info (filename, NULL, NULL); - g_return_if_fail (format); - g_print ("received %s image: %s\n", filename, - gdk_pixbuf_format_get_name (format)); - - userdata->nick = (gchar *) "location"; - userdata->value = g_strdup (filename); - userdata->data = data; - saveddelay = delay; - if (delay > 0) { - g_print ("%d\n", delay); - g_timeout_add_seconds (1, set_location_delayed, userdata); - } else - g_object_set (G_OBJECT (userdata->data), userdata->nick, userdata->value, - NULL); - g_free (filename); -} - - -gint -main (gint argc, gchar * argv[]) -{ - GstElement *pipeline; - GstElement *filter, *sink; - GstElement *sourcebin; - GstBus *bus; - GError *error = NULL; - - GtkWidget *window; - GtkWidget *screen; - GtkWidget *vbox; - GtkWidget *hbox; - GtkWidget *play, *pause, *null, *ready; - - gchar **source_desc_array = NULL; - gchar *source_desc = NULL; - - GOptionContext *context; - GOptionEntry options[] = { - {"source-bin", 's', 0, G_OPTION_ARG_STRING_ARRAY, &source_desc_array, - "Use a custom source bin description (gst-launch style)", NULL} - , - {"method", 'm', 0, G_OPTION_ARG_INT, &method, - "1 for gstdifferencematte, 2 for gloverlay", "M"} - , - {"delay", 'd', 0, G_OPTION_ARG_INT, &delay, - "Wait N seconds before to send the image to gstreamer (useful with differencematte)", - "N"} - , - {NULL} - }; - -#ifdef HAVE_X11 - XInitThreads (); -#endif - - context = g_option_context_new (NULL); - g_option_context_add_main_entries (context, options, NULL); - g_option_context_add_group (context, gst_init_get_option_group ()); - g_option_context_add_group (context, gtk_get_option_group (TRUE)); - if (!g_option_context_parse (context, &argc, &argv, &error)) { - g_print ("Inizialization error: %s\n", GST_STR_NULL (error->message)); - g_option_context_free (context); - g_clear_error (&error); - return -1; - } - g_option_context_free (context); - - if (source_desc_array != NULL) { - source_desc = g_strjoinv (" ", source_desc_array); - g_strfreev (source_desc_array); - } - if (source_desc == NULL) { - source_desc = - g_strdup - ("videotestsrc ! video/x-raw, width=352, height=288 ! identity ! glupload"); - } - - sourcebin = - gst_parse_bin_from_description (g_strdup (source_desc), TRUE, &error); - g_free (source_desc); - if (error) { - g_print ("Error while parsing source bin description: %s\n", - GST_STR_NULL (error->message)); - return -1; - } - - g_set_application_name ("gst-gl-effects test app"); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_container_set_border_width (GTK_CONTAINER (window), 3); - - pipeline = gst_pipeline_new ("pipeline"); - - if (method == 2) { - filter = gst_element_factory_make ("gloverlay", "flt"); - } else { - filter = gst_element_factory_make ("gldifferencematte", "flt"); - } - sink = gst_element_factory_make ("glimagesink", "glsink"); - - gst_bin_add_many (GST_BIN (pipeline), sourcebin, filter, sink, NULL); - - if (!gst_element_link_many (sourcebin, filter, sink, NULL)) { - g_print ("Failed to link one or more elements!\n"); - return -1; - } - - g_signal_connect (G_OBJECT (window), "delete-event", - G_CALLBACK (destroy_cb), pipeline); - g_signal_connect (G_OBJECT (window), "destroy-event", - G_CALLBACK (destroy_cb), pipeline); - - screen = gtk_drawing_area_new (); - - gtk_widget_set_size_request (screen, 640, 480); // 500 x 376 - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); - - gtk_box_pack_start (GTK_BOX (vbox), screen, TRUE, TRUE, 0); - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - - play = gtk_button_new_with_label ("PLAY"); - - g_signal_connect (G_OBJECT (play), "clicked", G_CALLBACK (play_cb), pipeline); - - pause = gtk_button_new_with_label ("PAUSE"); - - g_signal_connect (G_OBJECT (pause), "clicked", - G_CALLBACK (pause_cb), pipeline); - - null = gtk_button_new_with_label ("NULL"); - - g_signal_connect (G_OBJECT (null), "clicked", G_CALLBACK (null_cb), pipeline); - - ready = gtk_button_new_with_label ("READY"); - - g_signal_connect (G_OBJECT (ready), "clicked", - G_CALLBACK (ready_cb), pipeline); - - gtk_box_pack_start (GTK_BOX (hbox), null, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (hbox), ready, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (hbox), play, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (hbox), pause, TRUE, TRUE, 0); - - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - - gtk_container_add (GTK_CONTAINER (window), vbox); - - gtk_widget_realize (screen); - - bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); - gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, screen, - NULL); - gst_bus_add_signal_watch (bus); - g_signal_connect (bus, "message::error", G_CALLBACK (message_cb), pipeline); - g_signal_connect (bus, "message::warning", G_CALLBACK (message_cb), pipeline); - g_signal_connect (bus, "message::eos", G_CALLBACK (message_cb), pipeline); - gst_object_unref (bus); - g_signal_connect (screen, "draw", G_CALLBACK (expose_cb), sink); - - gtk_drag_dest_set (screen, GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_COPY); - gtk_drag_dest_add_uri_targets (screen); - - g_signal_connect (screen, "drag-data-received", - G_CALLBACK (on_drag_data_received), filter); - - gtk_widget_show_all (GTK_WIDGET (window)); - - gst_element_set_state (pipeline, GST_STATE_PLAYING); - - gtk_main (); - - return 0; -} diff --git a/tests/examples/gl/gtk/gstgtk.c b/tests/examples/gl/gtk/gstgtk.c deleted file mode 100644 index 40caa8da6..000000000 --- a/tests/examples/gl/gtk/gstgtk.c +++ /dev/null @@ -1,127 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 David A. Schleef <ds@schleef.org> - * - * 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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gst/gl/gl.h> -#include "gstgtk.h" - -#if GST_GL_HAVE_WINDOW_WIN32 && defined(GDK_WINDOWING_WIN32) -#include <gdk/gdkwin32.h> -#endif -#if GST_GL_HAVE_WINDOW_X11 && defined(GDK_WINDOWING_X11) -#include <gdk/gdkx.h> -#endif -#if GST_GL_HAVE_WINDOW_WAYLAND && defined(GDK_WINDOWING_WAYLAND) -#include <gdk/gdkwayland.h> -#endif -#if GST_GL_HAVE_WINDOW_COCOA && defined(GDK_WINDOWING_QUARTZ) -#include <gdk/gdkquartz.h> -#endif - -gboolean -gst_gtk_handle_need_context (GstBus * bus, GstMessage * msg, gpointer data) -{ - gboolean ret = FALSE; - - switch (GST_MESSAGE_TYPE (msg)) { - case GST_MESSAGE_NEED_CONTEXT: - { - const gchar *context_type; - - gst_message_parse_context_type (msg, &context_type); - g_print ("got need context %s\n", context_type); - - if (g_strcmp0 (context_type, "GstWaylandDisplayHandleContextType") == 0) { -#if GST_GL_HAVE_WINDOW_WAYLAND && defined(GDK_WINDOWING_WAYLAND) - GstContext *context = NULL; - GdkDisplay *gdk_display = gdk_display_get_default (); - if (GDK_IS_WAYLAND_DISPLAY (gdk_display)) { - struct wl_display *wayland_display = - gdk_wayland_display_get_wl_display (gdk_display); - if (wayland_display) { - GstStructure *s; - - context = - gst_context_new ("GstWaylandDisplayHandleContextType", TRUE); - - s = gst_context_writable_structure (context); - gst_structure_set (s, "display", G_TYPE_POINTER, wayland_display, - NULL); - - gst_element_set_context (GST_ELEMENT (msg->src), context); - - ret = TRUE; - } - } -#else - GST_ERROR - ("Asked for wayland display context, but compiled without wayland support"); -#endif - } - } - default: - break; - } - - return ret; -} - -void -gst_video_overlay_set_gtk_window (GstVideoOverlay * videooverlay, - GtkWidget * widget) -{ - GdkWindow *window; - GdkDisplay *display; - const gchar *user_choice = g_getenv ("GST_GL_WINDOW"); - - window = gtk_widget_get_window (widget); - display = gdk_window_get_display (window); - -#if GST_GL_HAVE_WINDOW_WIN32 && defined(GDK_WINDOWING_WIN32) - if (GDK_IS_WIN32_DISPLAY (display) && (!user_choice - || g_strcmp0 (user_choice, "win32") == 0)) { - gst_video_overlay_set_window_handle (videooverlay, - (guintptr) GDK_WINDOW_HWND (window)); - } else -#endif -#if GST_GL_HAVE_WINDOW_COCOA && defined(GDK_WINDOWING_QUARTZ) - if (GDK_IS_QUARTZ_DISPLAY (display) && (!user_choice - || g_strcmp0 (user_choice, "cocoa") == 0)) { - gst_video_overlay_set_window_handle (videooverlay, (guintptr) - gdk_quartz_window_get_nsview (window)); - } else -#endif -#if GST_GL_HAVE_WINDOW_X11 && defined(GDK_WINDOWING_X11) - if (GDK_IS_X11_DISPLAY (display) && (!user_choice - || g_strcmp0 (user_choice, "x11") == 0)) { - gst_video_overlay_set_window_handle (videooverlay, GDK_WINDOW_XID (window)); - } else -#endif -#if GST_GL_HAVE_WINDOW_WAYLAND && defined(GDK_WINDOWING_WAYLAND) - if (GDK_IS_WAYLAND_DISPLAY (display) && (!user_choice - || g_strcmp0 (user_choice, "wayland") == 0)) { - gst_video_overlay_set_window_handle (videooverlay, - (guintptr) gdk_wayland_window_get_wl_surface (window)); - } else -#endif - g_error ("Unsupported Gtk+ backend"); -} diff --git a/tests/examples/gl/gtk/gstgtk.h b/tests/examples/gl/gtk/gstgtk.h deleted file mode 100644 index 2aeec5960..000000000 --- a/tests/examples/gl/gtk/gstgtk.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 David A. Schleef <ds@schleef.org> - * - * 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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __GST_GTK_H__ -#define __GST_GTK_H__ - -#include <gst/video/videooverlay.h> -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -void gst_video_overlay_set_gtk_window (GstVideoOverlay *videooverlay, GtkWidget *window); -gboolean gst_gtk_handle_need_context (GstBus *bus, GstMessage *msg, gpointer data); - -G_END_DECLS - -#endif - diff --git a/tests/examples/gl/gtk/gtk.sln b/tests/examples/gl/gtk/gtk.sln deleted file mode 100644 index 5bf66dcfe..000000000 --- a/tests/examples/gl/gtk/gtk.sln +++ /dev/null @@ -1,50 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "filtervideooverlay", "filtervideooverlay\filtervideooverlay.vcproj", "{F9CC027E-CC9F-4B34-AA8F-58852EC32CD0}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtkvideooverlay", "gtkvideooverlay\gtkvideooverlay.vcproj", "{E83070C2-58E4-48AE-AEB3-A4580EDE1212}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fxtest", "fxtest\fxtest.vcproj", "{59075FDD-68CD-4F1A-948B-46D142800798}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pixbufdrop", "pixbufdrop\pixbufdrop.vcproj", "{09F68B62-1D4C-4C24-A6AD-AA76A9F3237C}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "filternovideooverlay", "filternovideooverlay\filternovideooverlay.vcproj", "{F41F3034-3E0B-4630-8D1E-35E14C606863}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "switchvideooverlay", "switchvideooverlay\switchvideooverlay.vcproj", "{BA78B4B4-3268-483E-9676-911E29FD2C69}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F9CC027E-CC9F-4B34-AA8F-58852EC32CD0}.Debug|Win32.ActiveCfg = Debug|Win32 - {F9CC027E-CC9F-4B34-AA8F-58852EC32CD0}.Debug|Win32.Build.0 = Debug|Win32 - {F9CC027E-CC9F-4B34-AA8F-58852EC32CD0}.Release|Win32.ActiveCfg = Release|Win32 - {F9CC027E-CC9F-4B34-AA8F-58852EC32CD0}.Release|Win32.Build.0 = Release|Win32 - {E83070C2-58E4-48AE-AEB3-A4580EDE1212}.Debug|Win32.ActiveCfg = Debug|Win32 - {E83070C2-58E4-48AE-AEB3-A4580EDE1212}.Debug|Win32.Build.0 = Debug|Win32 - {E83070C2-58E4-48AE-AEB3-A4580EDE1212}.Release|Win32.ActiveCfg = Release|Win32 - {E83070C2-58E4-48AE-AEB3-A4580EDE1212}.Release|Win32.Build.0 = Release|Win32 - {59075FDD-68CD-4F1A-948B-46D142800798}.Debug|Win32.ActiveCfg = Debug|Win32 - {59075FDD-68CD-4F1A-948B-46D142800798}.Debug|Win32.Build.0 = Debug|Win32 - {59075FDD-68CD-4F1A-948B-46D142800798}.Release|Win32.ActiveCfg = Release|Win32 - {59075FDD-68CD-4F1A-948B-46D142800798}.Release|Win32.Build.0 = Release|Win32 - {09F68B62-1D4C-4C24-A6AD-AA76A9F3237C}.Debug|Win32.ActiveCfg = Debug|Win32 - {09F68B62-1D4C-4C24-A6AD-AA76A9F3237C}.Debug|Win32.Build.0 = Debug|Win32 - {09F68B62-1D4C-4C24-A6AD-AA76A9F3237C}.Release|Win32.ActiveCfg = Release|Win32 - {09F68B62-1D4C-4C24-A6AD-AA76A9F3237C}.Release|Win32.Build.0 = Release|Win32 - {F41F3034-3E0B-4630-8D1E-35E14C606863}.Debug|Win32.ActiveCfg = Debug|Win32 - {F41F3034-3E0B-4630-8D1E-35E14C606863}.Debug|Win32.Build.0 = Debug|Win32 - {F41F3034-3E0B-4630-8D1E-35E14C606863}.Release|Win32.ActiveCfg = Release|Win32 - {F41F3034-3E0B-4630-8D1E-35E14C606863}.Release|Win32.Build.0 = Release|Win32 - {BA78B4B4-3268-483E-9676-911E29FD2C69}.Debug|Win32.ActiveCfg = Debug|Win32 - {BA78B4B4-3268-483E-9676-911E29FD2C69}.Debug|Win32.Build.0 = Debug|Win32 - {BA78B4B4-3268-483E-9676-911E29FD2C69}.Release|Win32.ActiveCfg = Release|Win32 - {BA78B4B4-3268-483E-9676-911E29FD2C69}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/tests/examples/gl/gtk/switchvideooverlay/.gitignore b/tests/examples/gl/gtk/switchvideooverlay/.gitignore deleted file mode 100644 index 64c6de420..000000000 --- a/tests/examples/gl/gtk/switchvideooverlay/.gitignore +++ /dev/null @@ -1 +0,0 @@ -switchvideooverlay diff --git a/tests/examples/gl/gtk/switchvideooverlay/Makefile.am b/tests/examples/gl/gtk/switchvideooverlay/Makefile.am deleted file mode 100644 index e6ebf70bf..000000000 --- a/tests/examples/gl/gtk/switchvideooverlay/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -noinst_PROGRAMS = switchvideooverlay - -switchvideooverlay_SOURCES = main.cpp - -switchvideooverlay_CXXFLAGS=-I$(top_srcdir)/gst-libs -I$(top_builddir)/gst-libs \ - $(GST_PLUGINS_BASE_CFLAGS) $(GST_CXXFLAGS) \ - $(GL_CFLAGS) $(GTK3_CFLAGS) $(X_CFLAGS) -switchvideooverlay_LDADD=../libgstgtkhelper.la \ - $(GTK3_LIBS) $(GST_PLUGINS_BASE_LIBS) $(GST_LIBS) \ - $(GL_LIBS) -lgstvideo-$(GST_API_VERSION) $(X_LIBS) - diff --git a/tests/examples/gl/gtk/switchvideooverlay/main.cpp b/tests/examples/gl/gtk/switchvideooverlay/main.cpp deleted file mode 100644 index 476478d75..000000000 --- a/tests/examples/gl/gtk/switchvideooverlay/main.cpp +++ /dev/null @@ -1,294 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008-2009 Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gst/gst.h> -#include <gtk/gtk.h> -#include <gdk/gdk.h> - -#include "../gstgtk.h" - -#ifdef HAVE_X11 -#include <X11/Xlib.h> -#endif - -static GstBusSyncReply create_window (GstBus* bus, GstMessage* message, GtkWidget* widget) -{ - GtkAllocation allocation; - - if (gst_gtk_handle_need_context (bus, message, NULL)) - return GST_BUS_DROP; - - // ignore anything but 'prepare-window-handle' element messages - if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT) - return GST_BUS_PASS; - - if (!gst_is_video_overlay_prepare_window_handle_message (message)) - return GST_BUS_PASS; - - g_print ("setting window handle %p\n", widget); - - gst_video_overlay_set_gtk_window (GST_VIDEO_OVERLAY (GST_MESSAGE_SRC (message)), widget); - - gtk_widget_get_allocation (widget, &allocation); - gst_video_overlay_set_render_rectangle (GST_VIDEO_OVERLAY (GST_MESSAGE_SRC (message)), allocation.x, allocation.y, allocation.width, allocation.height); - - gst_message_unref (message); - - return GST_BUS_DROP; -} - -static gboolean -resize_cb (GtkWidget * widget, GdkEvent * event, gpointer sink) -{ - GtkAllocation allocation; - - gtk_widget_get_allocation (widget, &allocation); - gst_video_overlay_set_render_rectangle (GST_VIDEO_OVERLAY (sink), allocation.x, allocation.y, allocation.width, allocation.height); - - return FALSE; -} - -static void end_stream_cb(GstBus* bus, GstMessage* message, GstElement* pipeline) -{ - GError *error = NULL; - gchar *details; - - switch (GST_MESSAGE_TYPE (message)) { - case GST_MESSAGE_ERROR: - gst_message_parse_error (message, &error, &details); - - g_print("Error %s\n", error->message); - g_print("Details %s\n", details); - /* fallthrough */ - case GST_MESSAGE_EOS: - g_print("End of stream\n"); - - gst_element_set_state (pipeline, GST_STATE_NULL); - gst_object_unref(pipeline); - - gtk_main_quit(); - break; - case GST_MESSAGE_WARNING: - gst_message_parse_warning (message, &error, &details); - - g_print("Warning %s\n", error->message); - g_print("Details %s\n", details); - break; - default: - break; - } -} - -static gboolean expose_cb(GtkWidget* widget, cairo_t *cr, GstElement* videosink) -{ - g_print ("expose %p\n", widget); - g_print ("event mask: 0x%x, button_press 0x%x\n", gtk_widget_get_events (widget), GDK_BUTTON_PRESS_MASK); - gst_video_overlay_expose (GST_VIDEO_OVERLAY (videosink)); - return FALSE; -} - -static gboolean on_click_drawing_area(GtkWidget* widget, GdkEventButton* event, GstElement* videosink) -{ - GtkAllocation allocation; - GtkWidget *parent = gtk_widget_get_parent (widget); - - g_print ("switch the drawing area %p\n", widget); - gst_video_overlay_set_gtk_window (GST_VIDEO_OVERLAY (videosink), widget); - - gtk_widget_get_allocation (widget, &allocation); - gst_video_overlay_set_render_rectangle (GST_VIDEO_OVERLAY (videosink), allocation.x, allocation.y, allocation.width, allocation.height); - - /* XXX: required on wayland as changing the window handle (subsurface) - * requires a wl_surface::commit from the parent */ - if (parent) - gtk_widget_queue_draw (parent); - - return FALSE; -} - - -static void destroy_cb(GtkWidget* widget, GdkEvent* event, GstElement* pipeline) -{ - g_print("Close\n"); - - gst_element_set_state (pipeline, GST_STATE_NULL); - gst_object_unref(pipeline); - - gtk_main_quit(); -} - - -static void button_state_null_cb(GtkWidget* widget, GstElement* pipeline) -{ - gst_element_set_state (pipeline, GST_STATE_NULL); - g_print ("GST_STATE_NULL\n"); -} - - -static void button_state_ready_cb(GtkWidget* widget, GstElement* pipeline) -{ - gst_element_set_state (pipeline, GST_STATE_READY); - g_print ("GST_STATE_READY\n"); -} - - -static void button_state_paused_cb(GtkWidget* widget, GstElement* pipeline) -{ - gst_element_set_state (pipeline, GST_STATE_PAUSED); - g_print ("GST_STATE_PAUSED\n"); -} - - -static void button_state_playing_cb(GtkWidget* widget, GstElement* pipeline) -{ - gst_element_set_state (pipeline, GST_STATE_PLAYING); - g_print ("GST_STATE_PLAYING\n"); -} - -gint main (gint argc, gchar *argv[]) -{ -#ifdef HAVE_X11 - XInitThreads(); -#endif - - gtk_init (&argc, &argv); - gst_init (&argc, &argv); - - GstElement* pipeline = gst_pipeline_new ("pipeline"); - - //window that contains several ares where the video is drawn - GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_widget_set_size_request (window, 640, 240); - gtk_window_move (GTK_WINDOW (window), 300, 10); - gtk_window_set_title (GTK_WINDOW (window), "click on left, right or outside the main window to switch the drawing area"); - GdkGeometry geometry; - geometry.min_width = 1; - geometry.min_height = 1; - geometry.max_width = -1; - geometry.max_height = -1; - gtk_window_set_geometry_hints (GTK_WINDOW (window), window, &geometry, GDK_HINT_MIN_SIZE); - - //window to control the states - GtkWidget* window_control = gtk_window_new (GTK_WINDOW_TOPLEVEL); - geometry.min_width = 1; - geometry.min_height = 1; - geometry.max_width = -1; - geometry.max_height = -1; - gtk_window_set_geometry_hints (GTK_WINDOW (window_control), window_control, &geometry, GDK_HINT_MIN_SIZE); - gtk_window_set_resizable (GTK_WINDOW (window_control), FALSE); - gtk_window_move (GTK_WINDOW (window_control), 10, 10); - GtkWidget* table = gtk_grid_new (); - gtk_container_add (GTK_CONTAINER (window_control), table); - - //control state null - GtkWidget* button_state_null = gtk_button_new_with_label ("GST_STATE_NULL"); - g_signal_connect (G_OBJECT (button_state_null), "clicked", - G_CALLBACK (button_state_null_cb), pipeline); - gtk_grid_attach (GTK_GRID (table), button_state_null, 0, 0, 1, 1); - gtk_widget_show (button_state_null); - - //control state ready - GtkWidget* button_state_ready = gtk_button_new_with_label ("GST_STATE_READY"); - g_signal_connect (G_OBJECT (button_state_ready), "clicked", - G_CALLBACK (button_state_ready_cb), pipeline); - gtk_grid_attach (GTK_GRID (table), button_state_ready, 0, 1, 1, 1); - gtk_widget_show (button_state_ready); - - //control state paused - GtkWidget* button_state_paused = gtk_button_new_with_label ("GST_STATE_PAUSED"); - g_signal_connect (G_OBJECT (button_state_paused), "clicked", - G_CALLBACK (button_state_paused_cb), pipeline); - gtk_grid_attach (GTK_GRID (table), button_state_paused, 0, 2, 1, 1); - gtk_widget_show (button_state_paused); - - //control state playing - GtkWidget* button_state_playing = gtk_button_new_with_label ("GST_STATE_PLAYING"); - g_signal_connect (G_OBJECT (button_state_playing), "clicked", - G_CALLBACK (button_state_playing_cb), pipeline); - gtk_grid_attach (GTK_GRID (table), button_state_playing, 0, 3, 1, 1); - gtk_widget_show (button_state_playing); - - gtk_widget_show (table); - gtk_widget_show (window_control); - - //configure the pipeline - g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(destroy_cb), pipeline); - - GstElement* videosrc = gst_element_factory_make ("videotestsrc", "videotestsrc"); - GstElement* videosink = gst_element_factory_make ("glimagesink", "glimagesink"); - - gst_bin_add_many (GST_BIN (pipeline), videosrc, videosink, NULL); - - gboolean link_ok = gst_element_link_many(videosrc, videosink, NULL); - if(!link_ok) - { - g_warning("Failed to link videosrc to videosink!\n") ; - return -1; - } - - //areas where the video is drawn - GtkWidget* table_areas = gtk_grid_new (); - gtk_container_add (GTK_CONTAINER (window), table_areas); - GtkWidget* area_top_left = gtk_drawing_area_new(); - gtk_widget_add_events(area_top_left, GDK_BUTTON_PRESS_MASK); - gtk_widget_set_size_request (area_top_left, 320, 240); - gtk_grid_attach (GTK_GRID (table_areas), area_top_left, 0, 0, 1, 1); - GtkWidget* area_top_right = gtk_drawing_area_new(); - gtk_widget_add_events(area_top_right, GDK_BUTTON_PRESS_MASK); - gtk_widget_set_size_request (area_top_right, 320, 240); - gtk_grid_attach (GTK_GRID (table_areas), area_top_right, 1, 0, 1, 1); - - gtk_widget_set_redraw_on_allocate (area_top_left, TRUE); - gtk_widget_set_redraw_on_allocate (area_top_right, TRUE); - gtk_widget_realize(area_top_left); - gtk_widget_realize(area_top_right); - - GstBus* bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); - gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, area_top_right, NULL); - gst_bus_add_signal_watch (bus); - g_signal_connect(bus, "message::error", G_CALLBACK(end_stream_cb), pipeline); - g_signal_connect(bus, "message::warning", G_CALLBACK(end_stream_cb), pipeline); - g_signal_connect(bus, "message::eos", G_CALLBACK(end_stream_cb), pipeline); - gst_object_unref (bus); - - //needed when being in GST_STATE_READY, GST_STATE_PAUSED - //or resizing/obscuring the window - g_signal_connect(area_top_left, "draw", G_CALLBACK(expose_cb), videosink); - g_signal_connect(area_top_left, "configure-event", G_CALLBACK(resize_cb), videosink); - g_signal_connect(area_top_right, "draw", G_CALLBACK(expose_cb), videosink); - g_signal_connect(area_top_right, "configure-event", G_CALLBACK(resize_cb), videosink); - - //switch the drawing area - g_signal_connect(area_top_left, "button-press-event", G_CALLBACK(on_click_drawing_area), videosink); - g_signal_connect(area_top_right, "button-press-event", G_CALLBACK(on_click_drawing_area), videosink); - - gtk_widget_show_all (window); - - gst_element_set_state(pipeline, GST_STATE_PLAYING); - - gtk_main(); - - return 0; -} - diff --git a/tests/examples/gl/meson.build b/tests/examples/gl/meson.build deleted file mode 100644 index a1f4889fa..000000000 --- a/tests/examples/gl/meson.build +++ /dev/null @@ -1,7 +0,0 @@ -# FIXME - Add other missing examples! -#subdir('clutter') -#subdir('cocoa') -#subdir('generic') -#subdir('gtk') -#subdir('qt') -subdir('sdl') diff --git a/tests/examples/gl/qt/.gitignore b/tests/examples/gl/qt/.gitignore deleted file mode 100644 index 6be72a266..000000000 --- a/tests/examples/gl/qt/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -GeneratedFiles/ -debug/ diff --git a/tests/examples/gl/qt/Makefile.am b/tests/examples/gl/qt/Makefile.am deleted file mode 100644 index 629415b29..000000000 --- a/tests/examples/gl/qt/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ - -#SUBDIRS = videooverlay qglwidgetvideooverlay mousevideooverlay diff --git a/tests/examples/gl/qt/README b/tests/examples/gl/qt/README deleted file mode 100644 index a050fc2fd..000000000 --- a/tests/examples/gl/qt/README +++ /dev/null @@ -1,24 +0,0 @@ ---- Description of the Qt examples --- - -- videooverlay: -Show how to use the videooverlay interface through Qt. -The video is displayed as normal 2D scene. -The window is dynamically resized to have the same size as the original video. - -- mousevideooverlay: -Show how to use the videooverlay interface through Qt. -The cube is rotating when moving the mouse (+ click maintained) - -- qglwidgetvideooverlay: -Show how to use the videooverlay interface through Qt. -The cube is rotating automatically into a QGLWidget - - ---- How to build the Qt examples --- - -sudo apt-get install g++ libqt5-dev - -cd qglvideooverlay -qmake -make -./debug/qglvideooverlay diff --git a/tests/examples/gl/qt/mousevideooverlay/gstthread.cpp b/tests/examples/gl/qt/mousevideooverlay/gstthread.cpp deleted file mode 100644 index ce14a4715..000000000 --- a/tests/examples/gl/qt/mousevideooverlay/gstthread.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008-2009 Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "gstthread.h" - -GstThread::GstThread(const WId winId, const QString videoLocation, QObject *parent): - QThread(parent), - m_winId(winId), - m_videoLocation(videoLocation) -{ -} - -GstThread::~GstThread() -{ -} - -void GstThread::exposeRequested() -{ - m_pipeline->exposeRequested(); -} - -void GstThread::onMouseMove() -{ - m_pipeline->rotateRequested(); -} - -void GstThread::show() -{ - emit showRequested(); -} - -void GstThread::stop() -{ - m_pipeline->stop(); -} - -void GstThread::run() -{ - m_pipeline = new Pipeline(m_winId, m_videoLocation); - connect(m_pipeline, SIGNAL(showRequested()), this, SLOT(show())); - m_pipeline->start(); //it runs the gmainloop on win32 - -#ifndef WIN32 - //works like the gmainloop on linux (GstEvent are handled) - connect(m_pipeline, SIGNAL(stopRequested()), this, SLOT(quit())); - exec(); -#endif - - m_pipeline->unconfigure(); -} diff --git a/tests/examples/gl/qt/mousevideooverlay/gstthread.h b/tests/examples/gl/qt/mousevideooverlay/gstthread.h deleted file mode 100644 index 74f1322c7..000000000 --- a/tests/examples/gl/qt/mousevideooverlay/gstthread.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008-2009 Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef GSTTHREAD_H -#define GSTTHREAD_H - -#include <QtGui> -#include <QtCore/QThread> - -#include "pipeline.h" - -class GstThread : public QThread -{ - Q_OBJECT - -public: - GstThread(const WId winId, const QString videoLocation, QObject *parent = 0); - ~GstThread(); - -public slots: - void exposeRequested(); - void onMouseMove(); - void show(); - void stop(); - -signals: - void showRequested(); - -protected: - void run(); - -private: - const WId m_winId; - const QString m_videoLocation; - Pipeline* m_pipeline; - -}; - -#endif diff --git a/tests/examples/gl/qt/mousevideooverlay/main.cpp b/tests/examples/gl/qt/mousevideooverlay/main.cpp deleted file mode 100644 index 52c539d00..000000000 --- a/tests/examples/gl/qt/mousevideooverlay/main.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008-2009 Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include <QApplication> -#include <QFileDialog> -#include "qrenderer.h" - -int main(int argc, char *argv[]) -{ - /* FIXME: port the example to shaders and remove this */ - g_setenv ("GST_GL_API", "opengl", FALSE); - - QApplication a(argc, argv); - a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); - - QString videolocation = QFileDialog::getOpenFileName(0, "Select a video file", - ".", "Format (*.avi *.mkv *.ogg *.asf *.mov *.mp4)"); - - if (videolocation.isEmpty()) - return -1; - - QRenderer w(videolocation); - w.setWindowTitle("glimagesink implements the gstvideooverlay interface"); - - return a.exec(); -} diff --git a/tests/examples/gl/qt/mousevideooverlay/mousevideooverlay.pri b/tests/examples/gl/qt/mousevideooverlay/mousevideooverlay.pri deleted file mode 100644 index 75b23cdd7..000000000 --- a/tests/examples/gl/qt/mousevideooverlay/mousevideooverlay.pri +++ /dev/null @@ -1,10 +0,0 @@ -#Header files -HEADERS += ./gstthread.h \ - ./pipeline.h \ - ./qrenderer.h - -#Source files -SOURCES += ./gstthread.cpp \ - ./main.cpp \ - ./pipeline.cpp \ - ./qrenderer.cpp diff --git a/tests/examples/gl/qt/mousevideooverlay/mousevideooverlay.pro b/tests/examples/gl/qt/mousevideooverlay/mousevideooverlay.pro deleted file mode 100644 index 14fb48df6..000000000 --- a/tests/examples/gl/qt/mousevideooverlay/mousevideooverlay.pro +++ /dev/null @@ -1,44 +0,0 @@ -TEMPLATE = app -TARGET = mousevideooverlay -DESTDIR = ./debug -QT += gui widgets opengl -CONFIG += debug link_pkgconfig -DEFINES += UNICODE QT_THREAD_SUPPORT QT_CORE_LIB QT_GUI_LIB -PKGCONFIG = gstreamer-1.0 gstreamer-video-1.0 - -win32 { -DEFINES += WIN32 -INCLUDEPATH += ./GeneratedFiles \ - ./GeneratedFiles/Debug \ - C:/gstreamer/include \ - C:/gstreamer/include/libxml2 \ - C:/gstreamer/include/glib-2.0 \ - C:/gstreamer/lib/glib-2.0/include \ - C:/gstreamer/include/gstreamer-1.0 -LIBS += -L"C:/gstreamer/lib" \ - -L"C:/gstreamer/bin" \ - -lgstreamer-1.0 \ - -lgstvideo-1.0 \ - -lglib-2.0 \ - -lgmodule-2.0 \ - -lgobject-2.0 \ - -lgthread-2.0 \ - -lopengl32 \ - -lglu32 -} - -unix { -DEFINES += UNIX -INCLUDEPATH += GeneratedFiles \ - GeneratedFiles/Debug -LIBS += -lGLU -lGL -} - -DEPENDPATH += . -MOC_DIR += ./GeneratedFiles/debug -OBJECTS_DIR += debug -UI_DIR += ./GeneratedFiles -RCC_DIR += ./GeneratedFiles - -#Include file(s) -include(mousevideooverlay.pri) diff --git a/tests/examples/gl/qt/mousevideooverlay/mousevideooverlay.sln b/tests/examples/gl/qt/mousevideooverlay/mousevideooverlay.sln deleted file mode 100644 index 8d310d810..000000000 --- a/tests/examples/gl/qt/mousevideooverlay/mousevideooverlay.sln +++ /dev/null @@ -1,26 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mousevideooverlay", "mousevideooverlay.vcproj", "{E94F8CAA-628F-4872-8E73-AD56D34899CB}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E94F8CAA-628F-4872-8E73-AD56D34899CB}.Debug|Win32.ActiveCfg = Debug|Win32 - {E94F8CAA-628F-4872-8E73-AD56D34899CB}.Debug|Win32.Build.0 = Debug|Win32 - {E94F8CAA-628F-4872-8E73-AD56D34899CB}.Release|Win32.ActiveCfg = Release|Win32 - {E94F8CAA-628F-4872-8E73-AD56D34899CB}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(Qt) = preSolution - Integration = True - EndGlobalSection - GlobalSection(Qt) = preSolution - Integration = True - EndGlobalSection -EndGlobal diff --git a/tests/examples/gl/qt/mousevideooverlay/pipeline.cpp b/tests/examples/gl/qt/mousevideooverlay/pipeline.cpp deleted file mode 100644 index 28d8cf814..000000000 --- a/tests/examples/gl/qt/mousevideooverlay/pipeline.cpp +++ /dev/null @@ -1,358 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008-2009 Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include <gst/video/videooverlay.h> -#include <gst/video/video.h> -#include <GL/gl.h> -#include "pipeline.h" - -#define GST_MAP_GL (GST_MAP_FLAG_LAST << 1) - -Pipeline::Pipeline(const WId id, const QString videoLocation): - m_winId(id), - m_videoLocation(videoLocation), - m_loop(NULL), - m_bus(NULL), - m_pipeline(NULL), - m_glimagesink(NULL) -{ - create(); -} - -Pipeline::~Pipeline() -{ -} - -void Pipeline::create() -{ - qDebug("Loading video: %s", m_videoLocation.toLatin1().data()); - - gst_init (NULL, NULL); - -#ifdef WIN32 - m_loop = g_main_loop_new (NULL, FALSE); -#endif - m_pipeline = gst_pipeline_new ("pipeline"); - - m_bus = gst_pipeline_get_bus (GST_PIPELINE (m_pipeline)); - gst_bus_add_watch (m_bus, (GstBusFunc) bus_call, this); - gst_bus_set_sync_handler (m_bus, (GstBusSyncHandler) create_window, this, NULL); - gst_object_unref (m_bus); - - GstElement* videosrc = gst_element_factory_make ("filesrc", "filesrc0"); - GstElement* decodebin = gst_element_factory_make ("decodebin", "decodebin0"); - m_glimagesink = gst_element_factory_make ("glimagesink", "sink0"); - - if (!videosrc || !decodebin || !m_glimagesink ) - { - qDebug ("one element could not be found"); - return; - } - - g_object_set(G_OBJECT(videosrc), "num-buffers", 800, NULL); - g_object_set(G_OBJECT(videosrc), "location", m_videoLocation.toLatin1().data(), NULL); - g_signal_connect(G_OBJECT(m_glimagesink), "client-reshape", G_CALLBACK (reshapeCallback), NULL); - g_signal_connect(G_OBJECT(m_glimagesink), "client-draw", G_CALLBACK (drawCallback), NULL); - - gst_bin_add_many (GST_BIN (m_pipeline), videosrc, decodebin, m_glimagesink, NULL); - - gst_element_link_pads (videosrc, "src", decodebin, "sink"); - - g_signal_connect (decodebin, "pad-added", G_CALLBACK (cb_new_pad), this); -} - -void Pipeline::start() -{ - GstStateChangeReturn ret = gst_element_set_state (m_pipeline, GST_STATE_PLAYING); - if (ret == GST_STATE_CHANGE_FAILURE) - { - qDebug ("Failed to start up pipeline!"); - - /* check if there is an error message with details on the bus */ - GstMessage* msg = gst_bus_poll (m_bus, GST_MESSAGE_ERROR, 0); - if (msg) - { - GError *err = NULL; - gst_message_parse_error (msg, &err, NULL); - qDebug ("ERROR: %s", err->message); - g_error_free (err); - gst_message_unref (msg); - } - return; - } - -#ifdef WIN32 - g_main_loop_run(m_loop); -#endif -} - -//we don't want a thread safe stop in this example -void Pipeline::stop() -{ -#ifdef WIN32 - g_main_loop_quit(m_loop); -#else - emit stopRequested(); -#endif -} - -void Pipeline::unconfigure() const -{ - gst_element_set_state (m_pipeline, GST_STATE_NULL); - gst_object_unref (m_pipeline); -} - -void Pipeline::show() -{ - emit showRequested(); -} - -//redraw the current frame in the drawable -void Pipeline::doExpose() const -{ - if (m_pipeline && m_glimagesink) - gst_video_overlay_expose (GST_VIDEO_OVERLAY (m_glimagesink)); -} - -//post message to g_main_loop in order to call expose -//in the gt thread -void Pipeline::exposeRequested() -{ - g_idle_add(cb_expose, this); -} - -//rotate the cube -void Pipeline::doRotate() -{ - m_xrot += 3.0f; - m_yrot += 2.0f; - m_zrot += 4.0f; -} - -//post message to g_main_loop in order to call rotate -//in the gt thread -void Pipeline::rotateRequested() -{ - g_idle_add(cb_rotate, this); -} - -//----------------------------------------------------------------------- -//----------------------------- static members -------------------------- -//----------------------------------------------------------------------- - -float Pipeline::m_xrot = 0; -float Pipeline::m_yrot = 0; -float Pipeline::m_zrot = 0; - -//client reshape callback -gboolean Pipeline::reshapeCallback (void *sink, void *context, guint width, guint height, gpointer data) -{ - glViewport(0, 0, width, height); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - - return TRUE; -} - -//client draw callback -gboolean Pipeline::drawCallback (void * sink, void *context, GstSample * sample, gpointer data) -{ - static GTimeVal current_time; - static glong last_sec = current_time.tv_sec; - static gint nbFrames = 0; - - GstVideoFrame v_frame; - GstVideoInfo v_info; - guint texture = 0; - GstBuffer *buf = gst_sample_get_buffer (sample); - GstCaps *caps = gst_sample_get_caps (sample); - - gst_video_info_from_caps (&v_info, caps); - - if (!gst_video_frame_map (&v_frame, &v_info, buf, (GstMapFlags) (GST_MAP_READ | GST_MAP_GL))) { - g_warning ("Failed to map the video buffer"); - return TRUE; - } - - texture = *(guint *) v_frame.data[0]; - - g_get_current_time (¤t_time); - nbFrames++ ; - - if ((current_time.tv_sec - last_sec) >= 1) - { - qDebug ("GRAPHIC FPS = %d", nbFrames); - nbFrames = 0; - last_sec = current_time.tv_sec; - } - - glEnable(GL_DEPTH_TEST); - - glEnable (GL_TEXTURE_2D); - glBindTexture (GL_TEXTURE_2D, texture); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - glScalef(0.5f,0.5f,0.5f); - - glRotatef(m_xrot,1.0f,0.0f,0.0f); - glRotatef(m_yrot,0.0f,1.0f,0.0f); - glRotatef(m_zrot,0.0f,0.0f,1.0f); - - glBegin(GL_QUADS); - // Front Face - glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); - // Back Face - glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); - glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); - // Top Face - glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); - glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); - // Bottom Face - glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, 1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, 1.0f); - // Right face - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); - glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); - // Left Face - glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); - glEnd(); - - glLoadIdentity(); - glDisable(GL_DEPTH_TEST); - glBindTexture (GL_TEXTURE_2D, 0); - - gst_video_frame_unmap (&v_frame); - - return TRUE; -} - -gboolean Pipeline::bus_call (GstBus *bus, GstMessage *msg, Pipeline* p) -{ - switch (GST_MESSAGE_TYPE (msg)) - { - case GST_MESSAGE_EOS: - qDebug ("End-of-stream"); - p->stop(); - break; - case GST_MESSAGE_ERROR: - { - gchar *debug = NULL; - GError *err = NULL; - gst_message_parse_error (msg, &err, &debug); - qDebug ("Error: %s", err->message); - g_error_free (err); - if (debug) - { - qDebug ("Debug deails: %s", debug); - g_free (debug); - } - p->stop(); - break; - } - default: - break; - } - - return TRUE; -} - -void Pipeline::cb_new_pad (GstElement* decodebin, GstPad* pad, Pipeline* p) -{ - GstElement* glimagesink = p->getVideoSink(); - GstPad* glpad = gst_element_get_static_pad (glimagesink, "sink"); - - //only link once - if (GST_PAD_IS_LINKED (glpad)) - { - gst_object_unref (glpad); - return; - } - - GstCaps* caps = gst_pad_get_current_caps (pad); - GstStructure* str = gst_caps_get_structure (caps, 0); - if (!g_strrstr (gst_structure_get_name (str), "video")) - { - gst_caps_unref (caps); - gst_object_unref (glpad); - return; - } - gst_caps_unref (caps); - - GstPadLinkReturn ret = gst_pad_link (pad, glpad); - if (ret != GST_PAD_LINK_OK) - g_warning ("Failed to link with decodebin!\n"); - - p->show(); -} - -gboolean Pipeline::cb_expose (gpointer data) -{ - ((Pipeline*)data)->doExpose(); - return FALSE; -} - -gboolean Pipeline::cb_rotate (gpointer data) -{ - ((Pipeline*)data)->doRotate(); - return FALSE; -} - -GstBusSyncReply Pipeline::create_window (GstBus* bus, GstMessage* message, const Pipeline* p) -{ - // ignore anything but 'prepare-window-handle' element messages - if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT) - return GST_BUS_PASS; - - if (!gst_is_video_overlay_prepare_window_handle_message (message)) - return GST_BUS_PASS; - - qDebug ("setting window handle"); - - //Passing 0 as the window_handle will tell the overlay to stop using that window and create an internal one. - //In the directdrawsink's gst_video_overlay_set_window_handle implementation, window_handle (parameter 2) is casted to HWND before it used. - gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (GST_MESSAGE_SRC (message)), (guintptr)p->winId()); - - gst_message_unref (message); - - return GST_BUS_DROP; -} diff --git a/tests/examples/gl/qt/mousevideooverlay/pipeline.h b/tests/examples/gl/qt/mousevideooverlay/pipeline.h deleted file mode 100644 index b2fe97be1..000000000 --- a/tests/examples/gl/qt/mousevideooverlay/pipeline.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008-2009 Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef PIPELINE_H -#define PIPELINE_H - -#include <QObject> -#include <QtGui> -#include <gst/gst.h> -//#include <QtCore/private/qeventdispatcher_glib_p.h> - -class Pipeline : public QObject -{ - Q_OBJECT - -public: - Pipeline(const WId windId, const QString videoLocation); - ~Pipeline(); - void start(); - void exposeRequested(); - void rotateRequested(); - void stop(); - void unconfigure() const; - void show(); - GstElement* getVideoSink() { return m_glimagesink; } ; - -signals: - void showRequested(); - void stopRequested(); - -private: - const WId m_winId; - const QString m_videoLocation; - GMainLoop* m_loop; - GstBus* m_bus; - GstElement* m_pipeline; - GstElement* m_glimagesink; - static float m_xrot; - static float m_yrot; - static float m_zrot; - - void create(); - WId winId() const { return m_winId; } - void doExpose() const; - void doRotate(); - - static gboolean reshapeCallback (void *sink, void *context, guint width, guint height, gpointer data); - static gboolean drawCallback (void * sink, void *context, GstSample * sample, gpointer data); - static gboolean bus_call (GstBus *bus, GstMessage *msg, Pipeline* p); - static void cb_new_pad (GstElement* decodebin, GstPad* pad, Pipeline* p); - static gboolean cb_expose (gpointer data); - static gboolean cb_rotate (gpointer data); - static GstBusSyncReply create_window (GstBus* bus, GstMessage* message, const Pipeline* pipeline); -}; - -#endif diff --git a/tests/examples/gl/qt/mousevideooverlay/qrenderer.cpp b/tests/examples/gl/qt/mousevideooverlay/qrenderer.cpp deleted file mode 100644 index b5187bda5..000000000 --- a/tests/examples/gl/qt/mousevideooverlay/qrenderer.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008-2009 Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "qrenderer.h" - -QRenderer::QRenderer(const QString videoLocation, QWidget *parent, Qt::WindowFlags flags) - : QWidget(parent, flags), - m_gt(winId(), videoLocation) -{ - setAttribute(Qt::WA_NoSystemBackground); - setVisible(false); - move(20, 10); - resize(640, 480); - - QObject::connect(&m_gt, SIGNAL(finished()), this, SLOT(close())); - QObject::connect(this, SIGNAL(exposeRequested()), &m_gt, SLOT(exposeRequested())); - QObject::connect(this, SIGNAL(closeRequested()), &m_gt, SLOT(stop()), Qt::DirectConnection); - QObject::connect(&m_gt, SIGNAL(showRequested()), this, SLOT(show())); - QObject::connect(this, SIGNAL(mouseMoved()), &m_gt, SLOT(onMouseMove())); - m_gt.start(); -} - -QRenderer::~QRenderer() -{ -} - -void QRenderer::paintEvent(QPaintEvent* event) -{ - emit exposeRequested(); -} - -void QRenderer::mouseMoveEvent(QMouseEvent* event) -{ - emit mouseMoved(); -} - -void QRenderer::closeEvent(QCloseEvent* event) -{ - emit closeRequested(); - m_gt.wait(); -} diff --git a/tests/examples/gl/qt/mousevideooverlay/qrenderer.h b/tests/examples/gl/qt/mousevideooverlay/qrenderer.h deleted file mode 100644 index 90e85fffd..000000000 --- a/tests/examples/gl/qt/mousevideooverlay/qrenderer.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008-2009 Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef QRENDERER_H -#define QRENDERER_H - -#include <QWidget> -#include <QString> -#include "gstthread.h" - -class QRenderer : public QWidget -{ - Q_OBJECT - -public: - QRenderer(const QString videoLocation, QWidget *parent = 0, Qt::WindowFlags flags = 0); - ~QRenderer(); - void paintEvent(QPaintEvent* event); - void mouseMoveEvent(QMouseEvent* event); - void closeEvent (QCloseEvent* event); - -signals: - void exposeRequested(); - void closeRequested(); - void mouseMoved(); - -private: - GstThread m_gt; -}; - -#endif // QRENDERER_H diff --git a/tests/examples/gl/qt/qglwidgetvideooverlay/gstthread.cpp b/tests/examples/gl/qt/qglwidgetvideooverlay/gstthread.cpp deleted file mode 100644 index a31f8d634..000000000 --- a/tests/examples/gl/qt/qglwidgetvideooverlay/gstthread.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008-2009 Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "gstthread.h" - -GstThread::GstThread(const WId winId, const QString videoLocation, QObject *parent): - QThread(parent), - m_winId(winId), - m_videoLocation(videoLocation) -{ -} - -GstThread::~GstThread() -{ -} - -void GstThread::exposeRequested() -{ - m_pipeline->exposeRequested(); -} - -void GstThread::show() -{ - emit showRequested(); -} - -void GstThread::stop() -{ - m_pipeline->stop(); -} - -void GstThread::run() -{ - m_pipeline = new Pipeline(m_winId, m_videoLocation); - connect(m_pipeline, SIGNAL(showRequested()), this, SLOT(show())); - m_pipeline->start(); //it runs the gmainloop on win32 - -#ifndef WIN32 - //works like the gmainloop on linux (GstEvent are handled) - connect(m_pipeline, SIGNAL(stopRequested()), this, SLOT(quit())); - exec(); -#endif - - m_pipeline->unconfigure(); -} diff --git a/tests/examples/gl/qt/qglwidgetvideooverlay/gstthread.h b/tests/examples/gl/qt/qglwidgetvideooverlay/gstthread.h deleted file mode 100644 index 676b9870d..000000000 --- a/tests/examples/gl/qt/qglwidgetvideooverlay/gstthread.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008-2009 Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef GSTTHREAD_H -#define GSTTHREAD_H - -#include <QtGui> -#include <QtCore/QThread> - -#include "pipeline.h" - -class GstThread : public QThread -{ - Q_OBJECT - -public: - GstThread(const WId winId, const QString videoLocation, QObject *parent = 0); - ~GstThread(); - -public slots: - void exposeRequested(); - void show(); - void stop(); - -signals: - void showRequested(); - -protected: - void run(); - -private: - const WId m_winId; - const QString m_videoLocation; - Pipeline* m_pipeline; - -}; - -#endif diff --git a/tests/examples/gl/qt/qglwidgetvideooverlay/main.cpp b/tests/examples/gl/qt/qglwidgetvideooverlay/main.cpp deleted file mode 100644 index f782baa8b..000000000 --- a/tests/examples/gl/qt/qglwidgetvideooverlay/main.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008-2009 Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include <QApplication> -#include <QFileDialog> -#include "qglrenderer.h" - -int main(int argc, char *argv[]) -{ - /* FIXME: port the example to shaders and remove this */ - g_setenv ("GST_GL_API", "opengl", FALSE); - - QApplication a(argc, argv); - a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); - - QString videolocation = QFileDialog::getOpenFileName(0, "Select a video file", - ".", "Format (*.avi *.mkv *.ogg *.asf *.mov *.mp4)"); - - if (videolocation.isEmpty()) - return -1; - - QGLRenderer w(videolocation); - w.setWindowTitle("glimagesink implements the gstvideooverlay interface"); - - return a.exec(); -} diff --git a/tests/examples/gl/qt/qglwidgetvideooverlay/pipeline.cpp b/tests/examples/gl/qt/qglwidgetvideooverlay/pipeline.cpp deleted file mode 100644 index 301d3b614..000000000 --- a/tests/examples/gl/qt/qglwidgetvideooverlay/pipeline.cpp +++ /dev/null @@ -1,341 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008-2009 Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include <gst/video/videooverlay.h> -#include <gst/video/video.h> -#include <GL/gl.h> -#include "pipeline.h" - -#define GST_MAP_GL (GST_MAP_FLAG_LAST << 1) - -Pipeline::Pipeline(const WId id, const QString videoLocation): - m_winId(id), - m_videoLocation(videoLocation), - m_loop(NULL), - m_bus(NULL), - m_pipeline(NULL), - m_glimagesink(NULL) -{ - create(); -} - -Pipeline::~Pipeline() -{ -} - -void Pipeline::create() -{ - qDebug("Loading video: %s", m_videoLocation.toLatin1().data()); - - gst_init (NULL, NULL); - -#ifdef WIN32 - m_loop = g_main_loop_new (NULL, FALSE); -#endif - m_pipeline = gst_pipeline_new ("pipeline"); - - m_bus = gst_pipeline_get_bus (GST_PIPELINE (m_pipeline)); - gst_bus_add_watch (m_bus, (GstBusFunc) bus_call, this); - gst_bus_set_sync_handler (m_bus, (GstBusSyncHandler) create_window, this, NULL); - gst_object_unref (m_bus); - - GstElement* videosrc = gst_element_factory_make ("filesrc", "filesrc0"); - GstElement* decodebin = gst_element_factory_make ("decodebin", "decodebin0"); - m_glimagesink = gst_element_factory_make ("glimagesink", "sink0"); - - if (!videosrc || !decodebin || !m_glimagesink ) - { - qDebug ("one element could not be found"); - return; - } - - g_object_set(G_OBJECT(videosrc), "num-buffers", 800, NULL); - g_object_set(G_OBJECT(videosrc), "location", m_videoLocation.toLatin1().data(), NULL); - g_signal_connect_object (G_OBJECT(m_glimagesink), "client-reshape", (GCallback) reshapeCallback, NULL, G_CONNECT_AFTER); - g_signal_connect_object (G_OBJECT(m_glimagesink), "client-draw", (GCallback) drawCallback, NULL, G_CONNECT_AFTER); - - gst_bin_add_many (GST_BIN (m_pipeline), videosrc, decodebin, m_glimagesink, NULL); - - gst_element_link_pads (videosrc, "src", decodebin, "sink"); - - g_signal_connect (decodebin, "pad-added", G_CALLBACK (cb_new_pad), this); -} - -void Pipeline::start() -{ - GstStateChangeReturn ret = gst_element_set_state (m_pipeline, GST_STATE_PLAYING); - if (ret == GST_STATE_CHANGE_FAILURE) - { - qDebug ("Failed to start up pipeline!"); - - /* check if there is an error message with details on the bus */ - GstMessage* msg = gst_bus_poll (m_bus, GST_MESSAGE_ERROR, 0); - if (msg) - { - GError *err = NULL; - gst_message_parse_error (msg, &err, NULL); - qDebug ("ERROR: %s", err->message); - g_error_free (err); - gst_message_unref (msg); - } - return; - } - -#ifdef WIN32 - g_main_loop_run(m_loop); -#endif -} - -//we don't want a thread safe stop in this example -void Pipeline::stop() -{ -#ifdef WIN32 - g_main_loop_quit(m_loop); -#else - emit stopRequested(); -#endif -} - -void Pipeline::unconfigure() const -{ - gst_element_set_state (m_pipeline, GST_STATE_NULL); - gst_object_unref (m_pipeline); -} - -void Pipeline::show() -{ - emit showRequested(); -} - -//redraw the current frame in the drawable -void Pipeline::doExpose() const -{ - if (m_pipeline && m_glimagesink) - gst_video_overlay_expose (GST_VIDEO_OVERLAY (m_glimagesink)); -} - -//post message to g_main_loop in order to call expose -//in the gt thread -void Pipeline::exposeRequested() -{ - g_idle_add(cb_expose, this); -} - - -//----------------------------------------------------------------------- -//----------------------------- static members -------------------------- -//----------------------------------------------------------------------- - -//client reshape callback -gboolean Pipeline::reshapeCallback (GstElement *sink, void *context, guint width, guint height, gpointer data) -{ - glViewport(0, 0, width, height); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - - return TRUE; -} - -//client draw callback -gboolean Pipeline::drawCallback (GstElement * gl_sink, void *context, GstSample * sample, gpointer data) -{ - static GLfloat xrot = 0; - static GLfloat yrot = 0; - static GLfloat zrot = 0; - static GTimeVal current_time; - static glong last_sec = current_time.tv_sec; - static gint nbFrames = 0; - - GstVideoFrame v_frame; - GstVideoInfo v_info; - guint texture = 0; - GstBuffer *buf = gst_sample_get_buffer (sample); - GstCaps *caps = gst_sample_get_caps (sample); - - gst_video_info_from_caps (&v_info, caps); - - if (!gst_video_frame_map (&v_frame, &v_info, buf, (GstMapFlags) (GST_MAP_READ | GST_MAP_GL))) { - g_warning ("Failed to map the video buffer"); - return TRUE; - } - - texture = *(guint *) v_frame.data[0]; - - g_get_current_time (¤t_time); - nbFrames++ ; - - if ((current_time.tv_sec - last_sec) >= 1) - { - qDebug ("GRPHIC FPS = %d", nbFrames); - nbFrames = 0; - last_sec = current_time.tv_sec; - } - - glEnable(GL_DEPTH_TEST); - - glEnable (GL_TEXTURE_2D); - glBindTexture (GL_TEXTURE_2D, texture); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - glScalef (0.5, 0.5, 0.5); - - glRotatef(xrot,1.0f,0.0f,0.0f); - glRotatef(yrot,0.0f,1.0f,0.0f); - glRotatef(zrot,0.0f,0.0f,1.0f); - - glBegin(GL_QUADS); - // Front Face - glTexCoord2f(1.0, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); - glTexCoord2f(1.0, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); - // Back Face - glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); - glTexCoord2f(1.0, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); - glTexCoord2f(1.0, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); - // Top Face - glTexCoord2f(1.0, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); - glTexCoord2f(1.0, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); - // Bottom Face - glTexCoord2f(1.0, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, 1.0f); - glTexCoord2f(1.0,1.0f); glVertex3f(-1.0f, -1.0f, 1.0f); - // Right face - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); - glTexCoord2f(1.0, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); - glTexCoord2f(1.0, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); - // Left Face - glTexCoord2f(1.0, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); - glTexCoord2f(1.0, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); - glEnd(); - - glLoadIdentity(); - glDisable(GL_DEPTH_TEST); - glBindTexture (GL_TEXTURE_2D, 0); - - gst_video_frame_unmap (&v_frame); - - xrot+=0.03f; - yrot+=0.02f; - zrot+=0.04f; - - return TRUE; -} - -gboolean Pipeline::bus_call (GstBus *bus, GstMessage *msg, Pipeline* p) -{ - switch (GST_MESSAGE_TYPE (msg)) - { - case GST_MESSAGE_EOS: - qDebug ("End-of-stream"); - p->stop(); - break; - case GST_MESSAGE_ERROR: - { - gchar *debug = NULL; - GError *err = NULL; - gst_message_parse_error (msg, &err, &debug); - qDebug ("Error: %s", err->message); - g_error_free (err); - if (debug) - { - qDebug ("Debug deails: %s", debug); - g_free (debug); - } - p->stop(); - break; - } - default: - break; - } - - return TRUE; -} - -void Pipeline::cb_new_pad (GstElement* decodebin, GstPad* pad, Pipeline* p) -{ - GstElement* sink = p->getVideoSink(); - GstPad* glpad = gst_element_get_static_pad (sink, "sink"); - - //only link once - if (GST_PAD_IS_LINKED (glpad)) - { - gst_object_unref (glpad); - return; - } - - GstCaps* caps = gst_pad_get_current_caps (pad); - GstStructure* str = gst_caps_get_structure (caps, 0); - if (!g_strrstr (gst_structure_get_name (str), "video")) - { - gst_caps_unref (caps); - gst_object_unref (glpad); - return; - } - gst_caps_unref (caps); - - GstPadLinkReturn ret = gst_pad_link (pad, glpad); - if (ret != GST_PAD_LINK_OK) - g_warning ("Failed to link with decodebin!\n"); - - p->show(); -} - -gboolean Pipeline::cb_expose (gpointer data) -{ - ((Pipeline*)data)->doExpose(); - return FALSE; -} - -GstBusSyncReply Pipeline::create_window (GstBus* bus, GstMessage* message, const Pipeline* p) -{ - // ignore anything but 'prepare-window-handle' element messages - if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT) - return GST_BUS_PASS; - - if (!gst_is_video_overlay_prepare_window_handle_message (message)) - return GST_BUS_PASS; - - qDebug ("setting window handle"); - - //Passing 0 as the window_handle will tell the overlay to stop using that window and create an internal one. - //In the directdrawsink's gst_video_overlay_set_window_handle implementation, window_handle (parameter 2) is casted to HWND before it used. - gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (GST_MESSAGE_SRC (message)), (guintptr)p->winId()); - - gst_message_unref (message); - - return GST_BUS_DROP; -} diff --git a/tests/examples/gl/qt/qglwidgetvideooverlay/pipeline.h b/tests/examples/gl/qt/qglwidgetvideooverlay/pipeline.h deleted file mode 100644 index 294cb8fe5..000000000 --- a/tests/examples/gl/qt/qglwidgetvideooverlay/pipeline.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008-2009 Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef PIPELINE_H -#define PIPELINE_H - -#include <QtGui> -#include <gst/gst.h> -//#include <QtCore/private/qeventdispatcher_glib_p.h> - -class Pipeline : public QObject -{ - Q_OBJECT - -public: - Pipeline(const WId windId, const QString videoLocation); - ~Pipeline(); - void start(); - void exposeRequested(); - void stop(); - void unconfigure() const; - void show(); - GstElement* getVideoSink() { return m_glimagesink; } ; - -signals: - void showRequested(); - void stopRequested(); - -private: - const WId m_winId; - const QString m_videoLocation; - GMainLoop* m_loop; - GstBus* m_bus; - GstElement* m_pipeline; - GstElement* m_glimagesink; - static float m_xrot; - static float m_yrot; - static float m_zrot; - - void create(); - WId winId() const { return m_winId; } - void doExpose() const; - - static gboolean reshapeCallback (GstElement *sink, void *context, guint width, guint height, gpointer data); - static gboolean drawCallback (GstElement *sink, void *context, GstSample * sample, gpointer data); - static gboolean bus_call (GstBus *bus, GstMessage *msg, Pipeline* p); - static void cb_new_pad (GstElement* decodebin, GstPad* pad, Pipeline* p); - static gboolean cb_expose (gpointer data); - static GstBusSyncReply create_window (GstBus* bus, GstMessage* message, const Pipeline* pipeline); -}; - -#endif diff --git a/tests/examples/gl/qt/qglwidgetvideooverlay/qglrenderer.cpp b/tests/examples/gl/qt/qglwidgetvideooverlay/qglrenderer.cpp deleted file mode 100644 index a54625efd..000000000 --- a/tests/examples/gl/qt/qglwidgetvideooverlay/qglrenderer.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008-2009 Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "qglrenderer.h" - -QGLRenderer::QGLRenderer(const QString videoLocation, QWidget *parent) - : QGLWidget(parent), - m_gt(winId(), videoLocation) -{ - setAttribute(Qt::WA_NoSystemBackground); - setVisible(false); - move(20, 10); - resize(640, 480); - - QObject::connect(&m_gt, SIGNAL(finished()), this, SLOT(close())); - QObject::connect(this, SIGNAL(exposeRequested()), &m_gt, SLOT(exposeRequested())); - QObject::connect(this, SIGNAL(closeRequested()), &m_gt, SLOT(stop()), Qt::DirectConnection); - QObject::connect(&m_gt, SIGNAL(showRequested()), this, SLOT(show())); - m_gt.start(); -} - -QGLRenderer::~QGLRenderer() -{ -} - -void QGLRenderer::paintEvent(QPaintEvent* event) -{ - emit exposeRequested(); -} - -void QGLRenderer::closeEvent(QCloseEvent* event) -{ - emit closeRequested(); - m_gt.wait(); -} diff --git a/tests/examples/gl/qt/qglwidgetvideooverlay/qglrenderer.h b/tests/examples/gl/qt/qglwidgetvideooverlay/qglrenderer.h deleted file mode 100644 index aaf0d029e..000000000 --- a/tests/examples/gl/qt/qglwidgetvideooverlay/qglrenderer.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008-2009 Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef QGLRENDERER_H -#define QGLRENDERER_H - -#include <QGLWidget> -#include "gstthread.h" - -class QGLRenderer : public QGLWidget -{ - Q_OBJECT - -public: - QGLRenderer(const QString videoLocation, QWidget *parent = 0); - ~QGLRenderer(); - void paintEvent(QPaintEvent* event); - void closeEvent (QCloseEvent* event); - -signals: - void exposeRequested(); - void closeRequested(); - -private: - GstThread m_gt; -}; - -#endif // QGLRENDERER_H diff --git a/tests/examples/gl/qt/qglwidgetvideooverlay/qglwidgetvideooverlay.pri b/tests/examples/gl/qt/qglwidgetvideooverlay/qglwidgetvideooverlay.pri deleted file mode 100644 index 772d1d4ec..000000000 --- a/tests/examples/gl/qt/qglwidgetvideooverlay/qglwidgetvideooverlay.pri +++ /dev/null @@ -1,10 +0,0 @@ -#Header files -HEADERS += ./gstthread.h \ - ./pipeline.h \ - ./qglrenderer.h - -#Source files -SOURCES += ./gstthread.cpp \ - ./main.cpp \ - ./pipeline.cpp \ - ./qglrenderer.cpp diff --git a/tests/examples/gl/qt/qglwidgetvideooverlay/qglwidgetvideooverlay.pro b/tests/examples/gl/qt/qglwidgetvideooverlay/qglwidgetvideooverlay.pro deleted file mode 100644 index 45837b200..000000000 --- a/tests/examples/gl/qt/qglwidgetvideooverlay/qglwidgetvideooverlay.pro +++ /dev/null @@ -1,47 +0,0 @@ -TEMPLATE = app -TARGET = qglwidgetvideooverlay -DESTDIR = ./debug -QT += opengl -CONFIG += debug -CONFIG += link_pkgconfig -DEFINES += UNICODE QT_THREAD_SUPPORT QT_CORE_LIB QT_GUI_LIB -PKGCONFIG = gstreamer-1.0 gstreamer-video-1.0 - -win32 { -DEFINES += WIN32 -INCLUDEPATH += ./GeneratedFiles \ - ./GeneratedFiles/Debug \ - C:/gstreamer/include \ - C:/gstreamer/include/libxml2 \ - C:/gstreamer/include/glib-2.0 \ - C:/gstreamer/lib/glib-2.0/include \ - C:/gstreamer/include/gstreamer-1.0 -LIBS += -L"C:/gstreamer/lib" \ - -L"C:/gstreamer/bin" \ - -lgstreamer-1.0 \ - -lgstvideo-1.0 \ - -lglib-2.0 \ - -lgmodule-2.0 \ - -lgobject-2.0 \ - -lgthread-2.0 \ - -lopengl32 \ - -lglu32 -} - -unix { -DEFINES += UNIX -INCLUDEPATH += GeneratedFiles \ - GeneratedFiles/Debug -LIBS += \ - -lGLU \ - -lGL -} - -DEPENDPATH += . -MOC_DIR += ./GeneratedFiles/debug -OBJECTS_DIR += debug -UI_DIR += ./GeneratedFiles -RCC_DIR += ./GeneratedFiles - -#Include file(s) -include(qglwidgetvideooverlay.pri) diff --git a/tests/examples/gl/qt/qglwidgetvideooverlay/qglwidgetvideooverlay.sln b/tests/examples/gl/qt/qglwidgetvideooverlay/qglwidgetvideooverlay.sln deleted file mode 100644 index 3842be042..000000000 --- a/tests/examples/gl/qt/qglwidgetvideooverlay/qglwidgetvideooverlay.sln +++ /dev/null @@ -1,26 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qglwidgetvideooverlay", "qglwidgetvideooverlay.vcproj", "{F40D2D98-281E-465F-B63F-2D473E1C2616}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F40D2D98-281E-465F-B63F-2D473E1C2616}.Debug|Win32.ActiveCfg = Debug|Win32 - {F40D2D98-281E-465F-B63F-2D473E1C2616}.Debug|Win32.Build.0 = Debug|Win32 - {F40D2D98-281E-465F-B63F-2D473E1C2616}.Release|Win32.ActiveCfg = Release|Win32 - {F40D2D98-281E-465F-B63F-2D473E1C2616}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(Qt) = preSolution - Integration = True - EndGlobalSection - GlobalSection(Qt) = preSolution - Integration = True - EndGlobalSection -EndGlobal diff --git a/tests/examples/gl/qt/qglwtextureshare/.gitignore b/tests/examples/gl/qt/qglwtextureshare/.gitignore deleted file mode 100644 index 091c6f073..000000000 --- a/tests/examples/gl/qt/qglwtextureshare/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -moc_*.cpp -qglwtextureshare diff --git a/tests/examples/gl/qt/qglwtextureshare/AsyncQueue.h b/tests/examples/gl/qt/qglwtextureshare/AsyncQueue.h deleted file mode 100644 index 4582bcbbe..000000000 --- a/tests/examples/gl/qt/qglwtextureshare/AsyncQueue.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Andrey Nechypurenko <andreynech@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __ASYNCQUEUE_H -#define __ASYNCQUEUE_H - -#include <QMutex> -#include <QWaitCondition> -#include <QList> - -/** - * This is the thread safe implementation of the Queue. It can be - * used in classical producers/consumers multithreaded scenario. The - * template parameter is the class which can be put/get to/from the - * queue. - */ -template<class T> -class AsyncQueue -{ -public: - AsyncQueue() : waitingReaders(0) {} - - int size() - { - QMutexLocker locker(&mutex); - return this->buffer.size(); - } - - void put(const T& item) - { - QMutexLocker locker(&mutex); - this->buffer.push_back(item); - if(this->waitingReaders) - this->bufferIsNotEmpty.wakeOne(); - } - - T get() - { - QMutexLocker locker(&mutex); - while(this->buffer.size() == 0) - { - ++(this->waitingReaders); - this->bufferIsNotEmpty.wait(&mutex); - --(this->waitingReaders); - } - T item = this->buffer.front(); - this->buffer.pop_front(); - return item; - } - -private: - typedef QList<T> Container; - QMutex mutex; - QWaitCondition bufferIsNotEmpty; - Container buffer; - short waitingReaders; -}; - - -#endif // __ASYNCQUEUE_H diff --git a/tests/examples/gl/qt/qglwtextureshare/README b/tests/examples/gl/qt/qglwtextureshare/README deleted file mode 100644 index 9a97c56e9..000000000 --- a/tests/examples/gl/qt/qglwtextureshare/README +++ /dev/null @@ -1,32 +0,0 @@ -Requires: >= Qt 5.1 for the x11extras module (or else you need to -get x11extras from gitorious yourself) - -This example illustrates how to integrate Gstreamer GL plugin with -Qt. In particular it uses glupload with fakesink elements to create -texture with decoded video frame. This texture is shared with -QGLWidget derived class, which paints a cube with video texture on -each face. - -To compile the example, include and library paths might be adjusted in -.pro file according to your installation of the gstreamer and -corresponding development files. Most probably, the adjustments will -be necessary on Windows. - -To run the example simply start executable file after compilation. If -there is no command line arguments provided, then videotestsrc element -will be used to generate video. The following pipeline will be created -in this case: - -videotestsrc ! video/x-raw, width=640, height=480, framerate=(fraction)30/1 ! glupload ! fakesink sync=1 - -It is also possible to provide the video file name as a first command -line parameter, i.e. ./qglwtextureshare myvideo.ogv . In this case, -the following pipeline will be executed: - -filesrc location=myvideo.ogv ! decodebin2 ! glupload ! fakesink sync=1 - -I would appreciate any feedback and improvement suggestions for this -example. - -Have fun :-) -Andrey Nechypurenko (andreynech@gmail.com) diff --git a/tests/examples/gl/qt/qglwtextureshare/cocoa_utils.mm b/tests/examples/gl/qt/qglwtextureshare/cocoa_utils.mm deleted file mode 100644 index 245ec0fe4..000000000 --- a/tests/examples/gl/qt/qglwtextureshare/cocoa_utils.mm +++ /dev/null @@ -1,26 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2010 Julien Isorce <julien.isorce@gmail.com> - * Copyright (C) 2010 Nuno Santos <nunosantos@imaginando.net> - * - * 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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#import <Cocoa/Cocoa.h> -void *qt_current_nsopengl_context() -{ - return CGLGetCurrentContext (); -} diff --git a/tests/examples/gl/qt/qglwtextureshare/gstthread.cpp b/tests/examples/gl/qt/qglwtextureshare/gstthread.cpp deleted file mode 100644 index 25d1890bd..000000000 --- a/tests/examples/gl/qt/qglwtextureshare/gstthread.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Julien Isorce <julien.isorce@gmail.com> - * Copyright (C) 2009 Andrey Nechypurenko <andreynech@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "pipeline.h" -#include "gstthread.h" - - -GstThread::GstThread(GstGLDisplay *display, - GstGLContext *context, - const QString &videoLocation, - const char *renderer_slot, - QObject *parent): - QThread(parent), - m_videoLocation(videoLocation) -{ - m_pipeline = new Pipeline(display, context, m_videoLocation, this); - QObject::connect(m_pipeline, SIGNAL(newFrameReady()), this->parent(), renderer_slot, Qt::QueuedConnection); -} - -GstThread::~GstThread() -{ -} - -void GstThread::stop() -{ - if(m_pipeline) - m_pipeline->stop(); -} - -void GstThread::run() -{ - qDebug("Starting gst pipeline"); - m_pipeline->start(); //it runs the gmainloop on win32 - -#ifndef Q_WS_WIN - //works like the gmainloop on linux (GstEvent are handled) - connect(m_pipeline, SIGNAL(stopRequested()), this, SLOT(quit())); - exec(); -#endif - - m_pipeline->unconfigure(); - - m_pipeline = NULL; - // This is not a memory leak. Pipeline will be deleted - // when the parent object (this) will be destroyed. - // We set m_pipeline to NULL to prevent further attempts - // to stop already stopped pipeline -} diff --git a/tests/examples/gl/qt/qglwtextureshare/gstthread.h b/tests/examples/gl/qt/qglwtextureshare/gstthread.h deleted file mode 100644 index bd34dd551..000000000 --- a/tests/examples/gl/qt/qglwtextureshare/gstthread.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Julien Isorce <julien.isorce@gmail.com> - * Copyright (C) 2009 Andrey Nechypurenko <andreynech@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef GSTTHREAD_H -#define GSTTHREAD_H - -#include <QThread> - -#include <gst/gl/gstglcontext.h> - - -class Pipeline; - -class GstThread : public QThread -{ - Q_OBJECT - -public: - GstThread(GstGLDisplay *display, - GstGLContext *context, - const QString &videoLocation, - const char *renderer_slot, - QObject *parent = 0); - - ~GstThread(); - - Pipeline *getPipeline() {return this->m_pipeline;} - -public Q_SLOTS: - void stop(); - -protected: - void run(); - -private: - const QString m_videoLocation; - Pipeline* m_pipeline; -}; - -#endif diff --git a/tests/examples/gl/qt/qglwtextureshare/main.cpp b/tests/examples/gl/qt/qglwtextureshare/main.cpp deleted file mode 100644 index ebe81cf86..000000000 --- a/tests/examples/gl/qt/qglwtextureshare/main.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Julien Isorce <julien.isorce@gmail.com> - * Copyright (C) 2009 Andrey Nechypurenko <andreynech@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include <QApplication> -#include "qglrenderer.h" - -#include <gst/gst.h> - -int -main(int argc, char *argv[]) -{ - /* FIXME: port the example to shaders and remove this */ - g_setenv ("GST_GL_API", "opengl", FALSE); - - gst_init (NULL, NULL); - QApplication a(argc, argv); - a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); - QGLRenderer w(argc > 1 ? argv[1] : ""); - w.setWindowTitle("Texture sharing example"); - w.show(); - return a.exec(); -} - diff --git a/tests/examples/gl/qt/qglwtextureshare/pipeline.cpp b/tests/examples/gl/qt/qglwtextureshare/pipeline.cpp deleted file mode 100644 index 1cff8a4f6..000000000 --- a/tests/examples/gl/qt/qglwtextureshare/pipeline.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Julien Isorce <julien.isorce@gmail.com> - * Copyright (C) 2009 Andrey Nechypurenko <andreynech@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "pipeline.h" - - -Pipeline::Pipeline (GstGLDisplay *display, - GstGLContext * context, const QString & videoLocation, QObject * parent) - : -QObject (parent), -m_videoLocation (videoLocation), -m_loop (NULL), -m_bus (NULL), -m_pipeline (NULL) -{ - this->display = display; - this->context = context; - this->configure (); -} - -Pipeline::~Pipeline () -{ -} - -void -Pipeline::configure () -{ - -#ifdef Q_WS_WIN - m_loop = g_main_loop_new (NULL, FALSE); -#endif - - if (m_videoLocation.isEmpty ()) { - qDebug ("No video file specified. Using video test source."); - m_pipeline = - GST_PIPELINE (gst_parse_launch - ("videotestsrc ! " - "video/x-raw, width=640, height=480, " - "framerate=(fraction)30/1 ! " - "glupload ! gleffects effect=5 ! fakesink sync=1", NULL)); - } else { - QByteArray ba = m_videoLocation.toLocal8Bit (); - qDebug ("Loading video: %s", ba.data ()); - gchar *pipeline = g_strdup_printf ("filesrc name=f ! " - "decodebin ! gleffects effect=5 ! " "fakesink sync=1"); - m_pipeline = GST_PIPELINE (gst_parse_launch (pipeline, NULL)); - GstElement *f = gst_bin_get_by_name (GST_BIN (m_pipeline), "f"); - g_object_set (G_OBJECT (f), "location", ba.data (), NULL); - gst_object_unref (GST_OBJECT (f)); - g_free (pipeline); - } - - m_bus = gst_pipeline_get_bus (GST_PIPELINE (m_pipeline)); - gst_bus_add_watch (m_bus, (GstBusFunc) bus_call, this); - gst_bus_enable_sync_message_emission (m_bus); - g_signal_connect (m_bus, "sync-message", G_CALLBACK (sync_bus_call), this); - gst_object_unref (m_bus); - - gst_element_set_state (GST_ELEMENT (this->m_pipeline), GST_STATE_PAUSED); - GstState state = GST_STATE_PAUSED; - if (gst_element_get_state (GST_ELEMENT (this->m_pipeline), - &state, NULL, GST_CLOCK_TIME_NONE) - != GST_STATE_CHANGE_SUCCESS) { - qDebug ("failed to pause pipeline"); - return; - } -} - -void -Pipeline::start () -{ - // set a callback to retrieve the gst gl textures - GstElement *fakesink = gst_bin_get_by_name (GST_BIN (this->m_pipeline), - "fakesink0"); - g_object_set (G_OBJECT (fakesink), "signal-handoffs", TRUE, NULL); - g_signal_connect (fakesink, "handoff", G_CALLBACK (on_gst_buffer), this); - gst_object_unref (fakesink); - - GstStateChangeReturn ret = - gst_element_set_state (GST_ELEMENT (this->m_pipeline), GST_STATE_PLAYING); - if (ret == GST_STATE_CHANGE_FAILURE) { - qDebug ("Failed to start up pipeline!"); - - /* check if there is an error message with details on the bus */ - GstMessage *msg = gst_bus_poll (this->m_bus, GST_MESSAGE_ERROR, 0); - if (msg) { - GError *err = NULL; - gst_message_parse_error (msg, &err, NULL); - qDebug ("ERROR: %s", err->message); - g_error_free (err); - gst_message_unref (msg); - } - return; - } -#ifdef Q_WS_WIN - g_main_loop_run (m_loop); -#endif -} - -/* fakesink handoff callback */ -void -Pipeline::on_gst_buffer (GstElement * element, - GstBuffer * buf, GstPad * pad, Pipeline * p) -{ - Q_UNUSED (pad) - Q_UNUSED (element) - - /* ref then push buffer to use it in qt */ - gst_buffer_ref (buf); - p->queue_input_buf.put (buf); - - if (p->queue_input_buf.size () > 3) - p->notifyNewFrame (); - - /* pop then unref buffer we have finished to use in qt */ - if (p->queue_output_buf.size () > 3) { - GstBuffer *buf_old = (p->queue_output_buf.get ()); - if (buf_old) - gst_buffer_unref (buf_old); - } -} - -void -Pipeline::stop () -{ -#ifdef Q_WS_WIN - g_main_loop_quit (m_loop); -#else - emit stopRequested (); -#endif -} - -void -Pipeline::unconfigure () -{ - gst_element_set_state (GST_ELEMENT (this->m_pipeline), GST_STATE_NULL); - - GstBuffer *buf; - while (this->queue_input_buf.size ()) { - buf = (GstBuffer *) (this->queue_input_buf.get ()); - gst_buffer_unref (buf); - } - while (this->queue_output_buf.size ()) { - buf = (GstBuffer *) (this->queue_output_buf.get ()); - gst_buffer_unref (buf); - } - - gst_object_unref (m_pipeline); -} - -gboolean Pipeline::bus_call (GstBus * bus, GstMessage * msg, Pipeline * p) -{ - Q_UNUSED (bus) - - switch (GST_MESSAGE_TYPE (msg)) { - case GST_MESSAGE_EOS: - qDebug ("End-of-stream received. Stopping."); - p->stop (); - break; - - case GST_MESSAGE_ERROR: - { - gchar * - debug = NULL; - GError * - err = NULL; - gst_message_parse_error (msg, &err, &debug); - qDebug ("Error: %s", err->message); - g_error_free (err); - if (debug) { - qDebug ("Debug deails: %s", debug); - g_free (debug); - } - p->stop (); - break; - } - - default: - break; - } - - return TRUE; -} - -gboolean Pipeline::sync_bus_call (GstBus * bus, GstMessage * msg, Pipeline * p) -{ - switch (GST_MESSAGE_TYPE (msg)) { - case GST_MESSAGE_NEED_CONTEXT: - { - const gchar * - context_type; - - gst_message_parse_context_type (msg, &context_type); - g_print ("got need context %s\n", context_type); - - if (g_strcmp0 (context_type, GST_GL_DISPLAY_CONTEXT_TYPE) == 0) { - GstContext *display_context = gst_context_new (GST_GL_DISPLAY_CONTEXT_TYPE, TRUE); - gst_context_set_gl_display (display_context, p->display); - gst_element_set_context (GST_ELEMENT (msg->src), display_context); - } else if (g_strcmp0 (context_type, "gst.gl.app_context") == 0) { - GstContext *app_context = gst_context_new ("gst.gl.app_context", TRUE); - GstStructure *s = gst_context_writable_structure (app_context); - gst_structure_set (s, "context", GST_TYPE_GL_CONTEXT, p->context, NULL); - gst_element_set_context (GST_ELEMENT (msg->src), app_context); - } - break; - } - default: - break; - } - return FALSE; -} diff --git a/tests/examples/gl/qt/qglwtextureshare/pipeline.h b/tests/examples/gl/qt/qglwtextureshare/pipeline.h deleted file mode 100644 index e517a12d7..000000000 --- a/tests/examples/gl/qt/qglwtextureshare/pipeline.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Julien Isorce <julien.isorce@gmail.com> - * Copyright (C) 2009 Andrey Nechypurenko <andreynech@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef PIPELINE_H -#define PIPELINE_H - -#include <QObject> - -#include <gst/gl/gstglcontext.h> - -#include "AsyncQueue.h" - - -class Pipeline : public QObject -{ - Q_OBJECT - -public: - Pipeline(GstGLDisplay *display, GstGLContext *context, - const QString &videoLocation, - QObject *parent); - ~Pipeline(); - - void configure(); - void start(); - void notifyNewFrame() {emit newFrameReady();} - void stop(); - void unconfigure(); - - AsyncQueue<GstBuffer*> queue_input_buf; - AsyncQueue<GstBuffer*> queue_output_buf; - -Q_SIGNALS: - void newFrameReady(); - void stopRequested(); - -private: - GstGLDisplay *display; - GstGLContext *context; - const QString m_videoLocation; - GMainLoop* m_loop; - GstBus* m_bus; - GstPipeline* m_pipeline; - static float m_xrot; - static float m_yrot; - static float m_zrot; - - static void on_gst_buffer(GstElement * element, GstBuffer * buf, GstPad * pad, Pipeline* p); - static gboolean bus_call (GstBus *bus, GstMessage *msg, Pipeline* p); - static gboolean sync_bus_call (GstBus *bus, GstMessage *msg, Pipeline* p); -}; - -#endif diff --git a/tests/examples/gl/qt/qglwtextureshare/qglrenderer.cpp b/tests/examples/gl/qt/qglwtextureshare/qglrenderer.cpp deleted file mode 100644 index 629cc895f..000000000 --- a/tests/examples/gl/qt/qglwtextureshare/qglrenderer.cpp +++ /dev/null @@ -1,285 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Julien Isorce <julien.isorce@gmail.com> - * Copyright (C) 2009 Andrey Nechypurenko <andreynech@gmail.com> - * Copyright (C) 2010 Nuno Santos <nunosantos@imaginando.net> - * - * 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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include <QGLWidget> -#include <QApplication> -#include <QDebug> -#include <QCloseEvent> - -#include <GL/glx.h> - -#include <gst/video/video.h> -#include <gst/gl/gl.h> - -#if GST_GL_HAVE_PLATFORM_GLX -#include <QX11Info> -#include <gst/gl/x11/gstgldisplay_x11.h> -#endif - -#include "gstthread.h" -#include "qglrenderer.h" -#include "pipeline.h" - -#if defined(Q_WS_MAC) -extern void *qt_current_nsopengl_context (); -#endif - -QGLRenderer::QGLRenderer (const QString & videoLocation, QWidget * parent) - : -QGLWidget (parent), -videoLoc (videoLocation), -gst_thread (NULL), -closing (false), -frame (NULL) -{ - move (20, 10); - resize (640, 480); -} - -QGLRenderer::~QGLRenderer () -{ -} - -void -QGLRenderer::initializeGL () -{ - GstGLContext *context; - GstGLDisplay *display; - -#if GST_GL_HAVE_PLATFORM_GLX - display = - (GstGLDisplay *) gst_gl_display_x11_new_with_display (QX11Info:: - display ()); -#else - display = gst_gl_display_new (); -#endif - - /* FIXME: Allow the choice at runtime */ -#if GST_GL_HAVE_PLATFORM_WGL - context = - gst_gl_context_new_wrapped (display, (guintptr) wglGetCurrentContext (), - GST_GL_PLATFORM_WGL, GST_GL_API_OPENGL); -#elif GST_GL_HAVE_PLATFORM_CGL - context = - gst_gl_context_new_wrapped (display, - (guintptr) qt_current_nsopengl_context (), GST_GL_PLATFORM_CGL, - GST_GL_API_OPENGL); -#elif GST_GL_HAVE_PLATFORM_GLX - context = - gst_gl_context_new_wrapped (display, (guintptr) glXGetCurrentContext (), - GST_GL_PLATFORM_GLX, GST_GL_API_OPENGL); -#endif - gst_object_unref (display); - - // We need to unset Qt context before initializing gst-gl plugin. - // Otherwise the attempt to share gst-gl context with Qt will fail. - this->doneCurrent (); - this->gst_thread = - new GstThread (display, context, this->videoLoc, - SLOT (newFrame ()), this); - this->makeCurrent (); - - QObject::connect (this->gst_thread, SIGNAL (finished ()), - this, SLOT (close ())); - QObject::connect (this, SIGNAL (closeRequested ()), - this->gst_thread, SLOT (stop ()), Qt::QueuedConnection); - - qglClearColor (QApplication::palette ().color (QPalette::Active, - QPalette::Window)); - //glShadeModel(GL_FLAT); - //glEnable(GL_DEPTH_TEST); - //glEnable(GL_CULL_FACE); - glEnable (GL_TEXTURE_2D); // Enable Texture Mapping - - this->gst_thread->start (); -} - -void -QGLRenderer::resizeGL (int width, int height) -{ - // Reset The Current Viewport And Perspective Transformation - glViewport (0, 0, width, height); - - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - - glMatrixMode (GL_MODELVIEW); -} - -void -QGLRenderer::newFrame () -{ - Pipeline *pipeline = this->gst_thread->getPipeline (); - if (!pipeline) - return; - - /* frame is initialized as null */ - if (this->frame) - pipeline->queue_output_buf.put (this->frame); - - this->frame = pipeline->queue_input_buf.get (); - - /* direct call to paintGL (no queued) */ - this->updateGL (); -} - -static void -flushGstreamerGL (GstGLContext * context, void *data G_GNUC_UNUSED) -{ - context->gl_vtable->Flush (); -} - -void -QGLRenderer::paintGL () -{ - static GLfloat xrot = 0; - static GLfloat yrot = 0; - static GLfloat zrot = 0; - - if (this->frame) { - guint tex_id; - GstMemory *mem; - GstVideoInfo v_info; - GstVideoFrame v_frame; - GstVideoMeta *v_meta; - - mem = gst_buffer_peek_memory (this->frame, 0); - v_meta = gst_buffer_get_video_meta (this->frame); - - Q_ASSERT (gst_is_gl_memory (mem)); - - GstGLMemory *gl_memory = (GstGLMemory *) mem; - - gst_gl_context_thread_add (gl_memory->mem.context, flushGstreamerGL, NULL); - - gst_video_info_set_format (&v_info, v_meta->format, v_meta->width, - v_meta->height); - - gst_video_frame_map (&v_frame, &v_info, this->frame, - (GstMapFlags) (GST_MAP_READ | GST_MAP_GL)); - - tex_id = *(guint *) v_frame.data[0]; - - glEnable (GL_DEPTH_TEST); - - glEnable (GL_TEXTURE_2D); - glBindTexture (GL_TEXTURE_2D, tex_id); - if (glGetError () != GL_NO_ERROR) { - qDebug ("failed to bind texture that comes from gst-gl"); - emit closeRequested (); - return; - } - - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - - glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glMatrixMode (GL_MODELVIEW); - glLoadIdentity (); - - glScalef (0.5f, 0.5f, 0.5f); - - glRotatef (xrot, 1.0f, 0.0f, 0.0f); - glRotatef (yrot, 0.0f, 1.0f, 0.0f); - glRotatef (zrot, 0.0f, 0.0f, 1.0f); - - glBegin (GL_QUADS); - // Front Face - glTexCoord2f (1.0f, 0.0f); - glVertex3f (-1.0f, -1.0f, 1.0f); - glTexCoord2f (0.0f, 0.0f); - glVertex3f (1.0f, -1.0f, 1.0f); - glTexCoord2f (0.0f, 1.0f); - glVertex3f (1.0f, 1.0f, 1.0f); - glTexCoord2f (1.0f, 1.0f); - glVertex3f (-1.0f, 1.0f, 1.0f); - // Back Face - glTexCoord2f (0.0f, 0.0f); - glVertex3f (-1.0f, -1.0f, -1.0f); - glTexCoord2f (0.0f, 1.0f); - glVertex3f (-1.0f, 1.0f, -1.0f); - glTexCoord2f (1.0f, 1.0f); - glVertex3f (1.0f, 1.0f, -1.0f); - glTexCoord2f (1.0f, 0.0f); - glVertex3f (1.0f, -1.0f, -1.0f); - // Top Face - glTexCoord2f (1.0f, 1.0f); - glVertex3f (-1.0f, 1.0f, -1.0f); - glTexCoord2f (1.0f, 0.0f); - glVertex3f (-1.0f, 1.0f, 1.0f); - glTexCoord2f (0.0f, 0.0f); - glVertex3f (1.0f, 1.0f, 1.0f); - glTexCoord2f (0.0f, 1.0f); - glVertex3f (1.0f, 1.0f, -1.0f); - // Bottom Face - glTexCoord2f (1.0f, 0.0f); - glVertex3f (-1.0f, -1.0f, -1.0f); - glTexCoord2f (0.0f, 0.0f); - glVertex3f (1.0f, -1.0f, -1.0f); - glTexCoord2f (0.0f, 1.0f); - glVertex3f (1.0f, -1.0f, 1.0f); - glTexCoord2f (1.0f, 1.0f); - glVertex3f (-1.0f, -1.0f, 1.0f); - // Right face - glTexCoord2f (0.0f, 0.0f); - glVertex3f (1.0f, -1.0f, -1.0f); - glTexCoord2f (0.0f, 1.0f); - glVertex3f (1.0f, 1.0f, -1.0f); - glTexCoord2f (1.0f, 1.0f); - glVertex3f (1.0f, 1.0f, 1.0f); - glTexCoord2f (1.0f, 0.0f); - glVertex3f (1.0f, -1.0f, 1.0f); - // Left Face - glTexCoord2f (1.0f, 0.0f); - glVertex3f (-1.0f, -1.0f, -1.0f); - glTexCoord2f (0.0f, 0.0f); - glVertex3f (-1.0f, -1.0f, 1.0f); - glTexCoord2f (0.0f, 1.0f); - glVertex3f (-1.0f, 1.0f, 1.0f); - glTexCoord2f (1.0f, 1.0f); - glVertex3f (-1.0f, 1.0f, -1.0f); - glEnd (); - - xrot += 0.3f; - yrot += 0.2f; - zrot += 0.4f; - - glLoadIdentity(); - glDisable(GL_DEPTH_TEST); - glBindTexture (GL_TEXTURE_2D, 0); - - gst_video_frame_unmap (&v_frame); - } -} - -void -QGLRenderer::closeEvent (QCloseEvent * event) -{ - if (this->closing == false) { - this->closing = true; - emit closeRequested (); - event->ignore (); - } -} diff --git a/tests/examples/gl/qt/qglwtextureshare/qglrenderer.h b/tests/examples/gl/qt/qglwtextureshare/qglrenderer.h deleted file mode 100644 index 0bf354ba5..000000000 --- a/tests/examples/gl/qt/qglwtextureshare/qglrenderer.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Julien Isorce <julien.isorce@gmail.com> - * Copyright (C) 2009 Andrey Nechypurenko <andreynech@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef QGLRENDERER_H -#define QGLRENDERER_H - -#include <QGLWidget> - -#include <gst/gl/gstglcontext.h> - - -class GstThread; - -class QGLRenderer : public QGLWidget -{ - Q_OBJECT - -public: - QGLRenderer(const QString &videoLocation, QWidget *parent = 0); - ~QGLRenderer(); - - void closeEvent(QCloseEvent* event); - -Q_SIGNALS: - void closeRequested(); - -public Q_SLOTS: - void newFrame(); - -protected: - virtual void initializeGL(); - virtual void resizeGL(int width, int height); - virtual void paintGL(); - -private: - QString videoLoc; - GstThread *gst_thread; - bool closing; - GstBuffer *frame; -}; - -#endif // QGLRENDERER_H diff --git a/tests/examples/gl/qt/qglwtextureshare/qglwtextureshare.pro b/tests/examples/gl/qt/qglwtextureshare/qglwtextureshare.pro deleted file mode 100644 index 9f60bf5e8..000000000 --- a/tests/examples/gl/qt/qglwtextureshare/qglwtextureshare.pro +++ /dev/null @@ -1,80 +0,0 @@ -TEMPLATE = app -TARGET = qglwtextureshare -QT += opengl - -# Add console to the CONFIG to see debug messages printed in -# the console on Windows -# CONFIG += console -DESTDIR = ./debug -DEFINES += UNICODE QT_THREAD_SUPPORT QT_CORE_LIB QT_GUI_LIB -CONFIG += link_pkgconfig -PKGCONFIG=gstreamer-1.0 gstreamer-video-1.0 gstreamer-gl-1.0 - -win32 { -DEFINES += WIN32 -INCLUDEPATH += \ - C:/gstreamer/include \ - C:/gstreamer/include/libxml2 \ - C:/gstreamer/include/glib-2.0 \ - C:/gstreamer/lib/glib-2.0/include \ - C:/gstreamer/include/gstreamer-1.0 -LIBS += -L"C:/gstreamer/lib" \ - -L"C:/gstreamer/bin" \ - -lgstreamer-1.0 \ - -lgstgl-1.0 \ - -lgstvideo-1.0 \ - -lglib-2.0 \ - -lgmodule-2.0 \ - -lgobject-2.0 \ - -lgthread-2.0 \ - -lgstvideo-1.0 \ - -lopengl32 \ - -lglu32 -} -unix:!mac { - DEFINES += UNIX - LIBS += \ - -lgstvideo-1.0 \ - -lgstgl-1.0 \ - -lGLU \ - -lGL - QT += x11extras -} -mac { - DEFINES += MACOSX - INCLUDEPATH += /opt/local/include/ \ - /opt/local/include/gstreamer-1.0/ \ - /opt/local/include/glib-2.0/ \ - /opt/local/lib/glib-2.0/include \ - /opt/local/include/libxml2 - LIBS += -L/opt/local/lib \ - -lgstreamer-1.0 \ - -lgstapp-1.0 \ - -lgstvideo-1.0 \ - -lglib-2.0 \ - -lgobject-2.0 \ - -lcxcore \ - -lcvaux \ - -lcv - OBJECTIVE_SOURCES += cocoa_utils.mm - LIBS += -framework AppKit -} -DEPENDPATH += . - -# Header files -HEADERS += gstthread.h \ - pipeline.h \ - qglrenderer.h \ - AsyncQueue.h \ - -# Source files -SOURCES += gstthread.cpp \ - main.cpp \ - pipeline.cpp \ - qglrenderer.cpp - -DEPENDPATH += . -MOC_DIR += ./GeneratedFiles/debug -OBJECTS_DIR += debug -UI_DIR += ./GeneratedFiles -RCC_DIR += ./GeneratedFiles diff --git a/tests/examples/gl/qt/videooverlay/GeneratedFiles/debug/moc_gstthread.cpp b/tests/examples/gl/qt/videooverlay/GeneratedFiles/debug/moc_gstthread.cpp deleted file mode 100644 index 79823067f..000000000 --- a/tests/examples/gl/qt/videooverlay/GeneratedFiles/debug/moc_gstthread.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** -** Meta object code from reading C++ file 'gstthread.h' -** -** Created by: The Qt Meta Object Compiler version 67 (Qt 5.2.1) -** -** WARNING! All changes made in this file will be lost! -*****************************************************************************/ - -#include "../../gstthread.h" -#include <QtCore/qbytearray.h> -#include <QtCore/qmetatype.h> -#if !defined(Q_MOC_OUTPUT_REVISION) -#error "The header file 'gstthread.h' doesn't include <QObject>." -#elif Q_MOC_OUTPUT_REVISION != 67 -#error "This file was generated using the moc from 5.2.1. It" -#error "cannot be used with the include files from this version of Qt." -#error "(The moc has changed too much.)" -#endif - -QT_BEGIN_MOC_NAMESPACE -struct qt_meta_stringdata_GstThread_t { - QByteArrayData data[8]; - char stringdata[69]; -}; -#define QT_MOC_LITERAL(idx, ofs, len) \ - Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ - offsetof(qt_meta_stringdata_GstThread_t, stringdata) + ofs \ - - idx * sizeof(QByteArrayData) \ - ) -static const qt_meta_stringdata_GstThread_t qt_meta_stringdata_GstThread = { - { -QT_MOC_LITERAL(0, 0, 9), -QT_MOC_LITERAL(1, 10, 15), -QT_MOC_LITERAL(2, 26, 0), -QT_MOC_LITERAL(3, 27, 5), -QT_MOC_LITERAL(4, 33, 6), -QT_MOC_LITERAL(5, 40, 15), -QT_MOC_LITERAL(6, 56, 6), -QT_MOC_LITERAL(7, 63, 4) - }, - "GstThread\0resizeRequested\0\0width\0" - "height\0exposeRequested\0resize\0stop\0" -}; -#undef QT_MOC_LITERAL - -static const uint qt_meta_data_GstThread[] = { - - // content: - 7, // revision - 0, // classname - 0, 0, // classinfo - 4, 14, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 1, // signalCount - - // signals: name, argc, parameters, tag, flags - 1, 2, 34, 2, 0x06, - - // slots: name, argc, parameters, tag, flags - 5, 0, 39, 2, 0x0a, - 6, 2, 40, 2, 0x0a, - 7, 0, 45, 2, 0x0a, - - // signals: parameters - QMetaType::Void, QMetaType::Int, QMetaType::Int, 3, 4, - - // slots: parameters - QMetaType::Void, - QMetaType::Void, QMetaType::Int, QMetaType::Int, 3, 4, - QMetaType::Void, - - 0 // eod -}; - -void GstThread::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) -{ - if (_c == QMetaObject::InvokeMetaMethod) { - GstThread *_t = static_cast<GstThread *>(_o); - switch (_id) { - case 0: _t->resizeRequested((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; - case 1: _t->exposeRequested(); break; - case 2: _t->resize((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; - case 3: _t->stop(); break; - default: ; - } - } else if (_c == QMetaObject::IndexOfMethod) { - int *result = reinterpret_cast<int *>(_a[0]); - void **func = reinterpret_cast<void **>(_a[1]); - { - typedef void (GstThread::*_t)(int , int ); - if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&GstThread::resizeRequested)) { - *result = 0; - } - } - } -} - -const QMetaObject GstThread::staticMetaObject = { - { &QThread::staticMetaObject, qt_meta_stringdata_GstThread.data, - qt_meta_data_GstThread, qt_static_metacall, 0, 0} -}; - - -const QMetaObject *GstThread::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; -} - -void *GstThread::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_GstThread.stringdata)) - return static_cast<void*>(const_cast< GstThread*>(this)); - return QThread::qt_metacast(_clname); -} - -int GstThread::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QThread::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod) { - if (_id < 4) - qt_static_metacall(this, _c, _id, _a); - _id -= 4; - } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { - if (_id < 4) - *reinterpret_cast<int*>(_a[0]) = -1; - _id -= 4; - } - return _id; -} - -// SIGNAL 0 -void GstThread::resizeRequested(int _t1, int _t2) -{ - void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)), const_cast<void*>(reinterpret_cast<const void*>(&_t2)) }; - QMetaObject::activate(this, &staticMetaObject, 0, _a); -} -QT_END_MOC_NAMESPACE diff --git a/tests/examples/gl/qt/videooverlay/GeneratedFiles/debug/moc_pipeline.cpp b/tests/examples/gl/qt/videooverlay/GeneratedFiles/debug/moc_pipeline.cpp deleted file mode 100644 index dff3f77aa..000000000 --- a/tests/examples/gl/qt/videooverlay/GeneratedFiles/debug/moc_pipeline.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** -** Meta object code from reading C++ file 'pipeline.h' -** -** Created by: The Qt Meta Object Compiler version 67 (Qt 5.2.1) -** -** WARNING! All changes made in this file will be lost! -*****************************************************************************/ - -#include "../../pipeline.h" -#include <QtCore/qbytearray.h> -#include <QtCore/qmetatype.h> -#if !defined(Q_MOC_OUTPUT_REVISION) -#error "The header file 'pipeline.h' doesn't include <QObject>." -#elif Q_MOC_OUTPUT_REVISION != 67 -#error "This file was generated using the moc from 5.2.1. It" -#error "cannot be used with the include files from this version of Qt." -#error "(The moc has changed too much.)" -#endif - -QT_BEGIN_MOC_NAMESPACE -struct qt_meta_stringdata_Pipeline_t { - QByteArrayData data[6]; - char stringdata[54]; -}; -#define QT_MOC_LITERAL(idx, ofs, len) \ - Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ - offsetof(qt_meta_stringdata_Pipeline_t, stringdata) + ofs \ - - idx * sizeof(QByteArrayData) \ - ) -static const qt_meta_stringdata_Pipeline_t qt_meta_stringdata_Pipeline = { - { -QT_MOC_LITERAL(0, 0, 8), -QT_MOC_LITERAL(1, 9, 15), -QT_MOC_LITERAL(2, 25, 0), -QT_MOC_LITERAL(3, 26, 5), -QT_MOC_LITERAL(4, 32, 6), -QT_MOC_LITERAL(5, 39, 13) - }, - "Pipeline\0resizeRequested\0\0width\0height\0" - "stopRequested\0" -}; -#undef QT_MOC_LITERAL - -static const uint qt_meta_data_Pipeline[] = { - - // content: - 7, // revision - 0, // classname - 0, 0, // classinfo - 2, 14, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 2, // signalCount - - // signals: name, argc, parameters, tag, flags - 1, 2, 24, 2, 0x06, - 5, 0, 29, 2, 0x06, - - // signals: parameters - QMetaType::Void, QMetaType::Int, QMetaType::Int, 3, 4, - QMetaType::Void, - - 0 // eod -}; - -void Pipeline::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) -{ - if (_c == QMetaObject::InvokeMetaMethod) { - Pipeline *_t = static_cast<Pipeline *>(_o); - switch (_id) { - case 0: _t->resizeRequested((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; - case 1: _t->stopRequested(); break; - default: ; - } - } else if (_c == QMetaObject::IndexOfMethod) { - int *result = reinterpret_cast<int *>(_a[0]); - void **func = reinterpret_cast<void **>(_a[1]); - { - typedef void (Pipeline::*_t)(int , int ); - if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&Pipeline::resizeRequested)) { - *result = 0; - } - } - { - typedef void (Pipeline::*_t)(); - if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&Pipeline::stopRequested)) { - *result = 1; - } - } - } -} - -const QMetaObject Pipeline::staticMetaObject = { - { &QObject::staticMetaObject, qt_meta_stringdata_Pipeline.data, - qt_meta_data_Pipeline, qt_static_metacall, 0, 0} -}; - - -const QMetaObject *Pipeline::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; -} - -void *Pipeline::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_Pipeline.stringdata)) - return static_cast<void*>(const_cast< Pipeline*>(this)); - return QObject::qt_metacast(_clname); -} - -int Pipeline::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QObject::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod) { - if (_id < 2) - qt_static_metacall(this, _c, _id, _a); - _id -= 2; - } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { - if (_id < 2) - *reinterpret_cast<int*>(_a[0]) = -1; - _id -= 2; - } - return _id; -} - -// SIGNAL 0 -void Pipeline::resizeRequested(int _t1, int _t2) -{ - void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)), const_cast<void*>(reinterpret_cast<const void*>(&_t2)) }; - QMetaObject::activate(this, &staticMetaObject, 0, _a); -} - -// SIGNAL 1 -void Pipeline::stopRequested() -{ - QMetaObject::activate(this, &staticMetaObject, 1, 0); -} -QT_END_MOC_NAMESPACE diff --git a/tests/examples/gl/qt/videooverlay/GeneratedFiles/debug/moc_qrenderer.cpp b/tests/examples/gl/qt/videooverlay/GeneratedFiles/debug/moc_qrenderer.cpp deleted file mode 100644 index 007373ba7..000000000 --- a/tests/examples/gl/qt/videooverlay/GeneratedFiles/debug/moc_qrenderer.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/**************************************************************************** -** Meta object code from reading C++ file 'qrenderer.h' -** -** Created by: The Qt Meta Object Compiler version 67 (Qt 5.2.1) -** -** WARNING! All changes made in this file will be lost! -*****************************************************************************/ - -#include "../../qrenderer.h" -#include <QtCore/qbytearray.h> -#include <QtCore/qmetatype.h> -#if !defined(Q_MOC_OUTPUT_REVISION) -#error "The header file 'qrenderer.h' doesn't include <QObject>." -#elif Q_MOC_OUTPUT_REVISION != 67 -#error "This file was generated using the moc from 5.2.1. It" -#error "cannot be used with the include files from this version of Qt." -#error "(The moc has changed too much.)" -#endif - -QT_BEGIN_MOC_NAMESPACE -struct qt_meta_stringdata_QRenderer_t { - QByteArrayData data[7]; - char stringdata[72]; -}; -#define QT_MOC_LITERAL(idx, ofs, len) \ - Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ - offsetof(qt_meta_stringdata_QRenderer_t, stringdata) + ofs \ - - idx * sizeof(QByteArrayData) \ - ) -static const qt_meta_stringdata_QRenderer_t qt_meta_stringdata_QRenderer = { - { -QT_MOC_LITERAL(0, 0, 9), -QT_MOC_LITERAL(1, 10, 15), -QT_MOC_LITERAL(2, 26, 0), -QT_MOC_LITERAL(3, 27, 14), -QT_MOC_LITERAL(4, 42, 15), -QT_MOC_LITERAL(5, 58, 5), -QT_MOC_LITERAL(6, 64, 6) - }, - "QRenderer\0exposeRequested\0\0closeRequested\0" - "resizeRequested\0width\0height\0" -}; -#undef QT_MOC_LITERAL - -static const uint qt_meta_data_QRenderer[] = { - - // content: - 7, // revision - 0, // classname - 0, 0, // classinfo - 3, 14, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 2, // signalCount - - // signals: name, argc, parameters, tag, flags - 1, 0, 29, 2, 0x06, - 3, 0, 30, 2, 0x06, - - // slots: name, argc, parameters, tag, flags - 4, 2, 31, 2, 0x0a, - - // signals: parameters - QMetaType::Void, - QMetaType::Void, - - // slots: parameters - QMetaType::Void, QMetaType::Int, QMetaType::Int, 5, 6, - - 0 // eod -}; - -void QRenderer::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) -{ - if (_c == QMetaObject::InvokeMetaMethod) { - QRenderer *_t = static_cast<QRenderer *>(_o); - switch (_id) { - case 0: _t->exposeRequested(); break; - case 1: _t->closeRequested(); break; - case 2: _t->resizeRequested((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; - default: ; - } - } else if (_c == QMetaObject::IndexOfMethod) { - int *result = reinterpret_cast<int *>(_a[0]); - void **func = reinterpret_cast<void **>(_a[1]); - { - typedef void (QRenderer::*_t)(); - if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&QRenderer::exposeRequested)) { - *result = 0; - } - } - { - typedef void (QRenderer::*_t)(); - if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&QRenderer::closeRequested)) { - *result = 1; - } - } - } -} - -const QMetaObject QRenderer::staticMetaObject = { - { &QWidget::staticMetaObject, qt_meta_stringdata_QRenderer.data, - qt_meta_data_QRenderer, qt_static_metacall, 0, 0} -}; - - -const QMetaObject *QRenderer::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; -} - -void *QRenderer::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_QRenderer.stringdata)) - return static_cast<void*>(const_cast< QRenderer*>(this)); - return QWidget::qt_metacast(_clname); -} - -int QRenderer::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QWidget::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod) { - if (_id < 3) - qt_static_metacall(this, _c, _id, _a); - _id -= 3; - } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { - if (_id < 3) - *reinterpret_cast<int*>(_a[0]) = -1; - _id -= 3; - } - return _id; -} - -// SIGNAL 0 -void QRenderer::exposeRequested() -{ - QMetaObject::activate(this, &staticMetaObject, 0, 0); -} - -// SIGNAL 1 -void QRenderer::closeRequested() -{ - QMetaObject::activate(this, &staticMetaObject, 1, 0); -} -QT_END_MOC_NAMESPACE diff --git a/tests/examples/gl/qt/videooverlay/videooverlay.cpp b/tests/examples/gl/qt/videooverlay/videooverlay.cpp deleted file mode 100644 index 9a95e906b..000000000 --- a/tests/examples/gl/qt/videooverlay/videooverlay.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* GStreamer - * Copyright (C) <2010> Stefan Kost <ensonic@users.sf.net> - * - * qt-xoverlay: demonstrate overlay handling using qt - * - * 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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <glib.h> -#include <gst/gst.h> -#include <gst/video/videooverlay.h> - -#include <QApplication> -#include <QTimer> -#include <QWidget> - -int main(int argc, char *argv[]) -{ - gst_init (&argc, &argv); - QApplication app(argc, argv); - app.setQuitOnLastWindowClosed(true); - - /* prepare the pipeline */ - - GstElement *pipeline = gst_pipeline_new ("xvoverlay"); - GstElement *src = gst_element_factory_make ("videotestsrc", NULL); - GstElement *sink = gst_element_factory_make ("glimagesink", NULL); - - if (sink == NULL) - g_error ("Couldn't create glimagesink."); - - gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL); - gst_element_link (src, sink); - - /* prepare the ui */ - - QWidget window; - window.resize(320, 240); - window.setWindowTitle("GstVideoOverlay Qt demo"); - window.show(); - - WId xwinid = window.winId(); - gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (sink), xwinid); - - /* run the pipeline */ - - GstStateChangeReturn sret = gst_element_set_state (pipeline, - GST_STATE_PLAYING); - if (sret == GST_STATE_CHANGE_FAILURE) { - gst_element_set_state (pipeline, GST_STATE_NULL); - gst_object_unref (pipeline); - /* Exit application */ - QTimer::singleShot(0, QApplication::activeWindow(), SLOT(quit())); - } - - int ret = app.exec(); - - window.hide(); - gst_element_set_state (pipeline, GST_STATE_NULL); - gst_object_unref (pipeline); - - return ret; -} diff --git a/tests/examples/gl/qt/videooverlay/videooverlay.pri b/tests/examples/gl/qt/videooverlay/videooverlay.pri deleted file mode 100644 index 0a53a9024..000000000 --- a/tests/examples/gl/qt/videooverlay/videooverlay.pri +++ /dev/null @@ -1,4 +0,0 @@ -#Header files - -#Source files -SOURCES += videooverlay.cpp diff --git a/tests/examples/gl/qt/videooverlay/videooverlay.pro b/tests/examples/gl/qt/videooverlay/videooverlay.pro deleted file mode 100644 index 697341445..000000000 --- a/tests/examples/gl/qt/videooverlay/videooverlay.pro +++ /dev/null @@ -1,42 +0,0 @@ -TEMPLATE = app -TARGET = videooverlay -DESTDIR = ./debug -CONFIG += debug link_pkgconfig -DEFINES += UNICODE QT_THREAD_SUPPORT QT_CORE_LIB QT_GUI_LIB -QT += gui widgets -PKGCONFIG=gstreamer-1.0 gstreamer-video-1.0 - -win32 { -DEFINES += WIN32 -INCLUDEPATH += ./GeneratedFiles \ - ./GeneratedFiles/Debug \ - C:/gstreamer/include \ - C:/gstreamer/include/libxml2 \ - C:/gstreamer/include/glib-2.0 \ - C:/gstreamer/lib/glib-2.0/include \ - C:/gstreamer/include/gstreamer-1.0 -LIBS += -L"C:/gstreamer/bin" \ - -L"C:/gstreamer/lib" \ - -lgstreamer-1.0 \ - -lgstvideo-1.0 \ - -lglib-2.0 \ - -lgmodule-2.0 \ - -lgobject-2.0 \ - -lgthread-2.0 -} - -unix { -DEFINES += UNIX -INCLUDEPATH += GeneratedFiles \ - GeneratedFiles/Debug -LIBS += -lGLU -lGL -} - -DEPENDPATH += . -MOC_DIR += ./GeneratedFiles/debug -OBJECTS_DIR += debug -UI_DIR += ./GeneratedFiles -RCC_DIR += ./GeneratedFiles - -#Include file(s) -include(videooverlay.pri) diff --git a/tests/examples/gl/qt/videooverlay/videooverlay.sln b/tests/examples/gl/qt/videooverlay/videooverlay.sln deleted file mode 100644 index f56635778..000000000 --- a/tests/examples/gl/qt/videooverlay/videooverlay.sln +++ /dev/null @@ -1,26 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "videooverlay", "videooverlay.vcproj", "{7B8654F9-23A9-4C88-A751-6BBE09ED4CAF}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7B8654F9-23A9-4C88-A751-6BBE09ED4CAF}.Debug|Win32.ActiveCfg = Debug|Win32 - {7B8654F9-23A9-4C88-A751-6BBE09ED4CAF}.Debug|Win32.Build.0 = Debug|Win32 - {7B8654F9-23A9-4C88-A751-6BBE09ED4CAF}.Release|Win32.ActiveCfg = Release|Win32 - {7B8654F9-23A9-4C88-A751-6BBE09ED4CAF}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(Qt) = preSolution - Integration = True - EndGlobalSection - GlobalSection(Qt) = preSolution - Integration = True - EndGlobalSection -EndGlobal diff --git a/tests/examples/gl/sdl/.gitignore b/tests/examples/gl/sdl/.gitignore deleted file mode 100644 index f476096d6..000000000 --- a/tests/examples/gl/sdl/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -sdlshare -sdlshare2 diff --git a/tests/examples/gl/sdl/Makefile.am b/tests/examples/gl/sdl/Makefile.am deleted file mode 100644 index dd575097d..000000000 --- a/tests/examples/gl/sdl/Makefile.am +++ /dev/null @@ -1,34 +0,0 @@ -noinst_PROGRAMS = ## - -#works on win32 and X -if HAVE_SDL - -noinst_PROGRAMS += sdlshare sdlshare2 - -sdlshare_SOURCES = sdlshare.c - -sdlshare_CFLAGS= \ - -I$(top_srcdir)/gst-libs \ - -I$(top_builddir)/gst-libs \ - $(GST_PLUGINS_BASE_CFLAGS) \ - $(GST_CFLAGS) \ - $(GL_CFLAGS) \ - $(SDL_CFLAGS) -sdlshare_LDADD= $(GST_LIBS) $(GL_LIBS) $(SDL_LIBS) \ - $(top_builddir)/gst-libs/gst/gl/libgstgl-$(GST_API_VERSION).la \ - -lgstvideo-$(GST_API_VERSION) - -sdlshare2_SOURCES = sdlshare2.c - -sdlshare2_CFLAGS= \ - -I$(top_srcdir)/gst-libs \ - -I$(top_builddir)/gst-libs \ - $(GST_PLUGINS_BASE_CFLAGS) \ - $(GST_CFLAGS) \ - $(GL_CFLAGS) \ - $(SDL_CFLAGS) -sdlshare2_LDADD= $(GST_LIBS) $(GL_LIBS) $(SDL_LIBS) \ - $(top_builddir)/gst-libs/gst/gl/libgstgl-$(GST_API_VERSION).la \ - -lgstvideo-$(GST_API_VERSION) - -endif diff --git a/tests/examples/gl/sdl/meson.build b/tests/examples/gl/sdl/meson.build deleted file mode 100644 index 8285f87f1..000000000 --- a/tests/examples/gl/sdl/meson.build +++ /dev/null @@ -1,16 +0,0 @@ -sdl_dep = dependency('sdl', version : '>=1.2.0', required : false) -if sdl_dep.found() and build_gstgl - executable('sdlshare', - 'sdlshare.c', - install: false, - dependencies : [gstbase_dep, gstgl_dep, sdl_dep, gl_dep], - c_args : ['-DGST_USE_UNSTABLE_API', ], - ) - - executable('sdlshare2', - 'sdlshare2.c', - install: false, - dependencies : [gstbase_dep, gstgl_dep, sdl_dep, gl_dep], - c_args : ['-DGST_USE_UNSTABLE_API', ], -) -endif diff --git a/tests/examples/gl/sdl/sdl.sln b/tests/examples/gl/sdl/sdl.sln deleted file mode 100644 index 0ecdd0057..000000000 --- a/tests/examples/gl/sdl/sdl.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdlshare", "sdlshare.vcproj", "{2C29F5A2-5982-428A-8068-9A5788FD2277}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {2C29F5A2-5982-428A-8068-9A5788FD2277}.Debug|Win32.ActiveCfg = Debug|Win32 - {2C29F5A2-5982-428A-8068-9A5788FD2277}.Debug|Win32.Build.0 = Debug|Win32 - {2C29F5A2-5982-428A-8068-9A5788FD2277}.Release|Win32.ActiveCfg = Release|Win32 - {2C29F5A2-5982-428A-8068-9A5788FD2277}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/tests/examples/gl/sdl/sdlshare.c b/tests/examples/gl/sdl/sdlshare.c deleted file mode 100644 index 29272f224..000000000 --- a/tests/examples/gl/sdl/sdlshare.c +++ /dev/null @@ -1,420 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef WIN32 -#include <windows.h> -#endif - -#include <GL/gl.h> -#include "SDL/SDL.h" -#include "SDL/SDL_opengl.h" - -#ifndef WIN32 -#include <GL/glx.h> -#include "SDL/SDL_syswm.h" -#include <gst/gl/x11/gstgldisplay_x11.h> -#endif - -#include <gst/gst.h> -#include <gst/gl/gl.h> - -static GstGLContext *sdl_context; -static GstGLDisplay *sdl_gl_display; - -/* rotation angle for the triangle. */ -float rtri = 0.0f; - -/* rotation angle for the quadrilateral. */ -float rquad = 0.0f; - -/* A general OpenGL initialization function. Sets all of the initial parameters. */ -static void -InitGL (int Width, int Height) // We call this right after our OpenGL window is created. -{ - glViewport (0, 0, Width, Height); - glClearColor (0.0f, 0.0f, 0.0f, 0.0f); // This Will Clear The Background Color To Black - glClearDepth (1.0); // Enables Clearing Of The Depth Buffer - glDepthFunc (GL_LESS); // The Type Of Depth Test To Do - glEnable (GL_DEPTH_TEST); // Enables Depth Testing - glShadeModel (GL_SMOOTH); // Enables Smooth Color Shading - - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); // Reset The Projection Matrix - - glMatrixMode (GL_MODELVIEW); -} - -/* The main drawing function. */ -static void -DrawGLScene (GstBuffer * buf) -{ - GstVideoFrame v_frame; - GstVideoInfo v_info; - guint texture; - - gst_video_info_set_format (&v_info, GST_VIDEO_FORMAT_RGBA, 320, 240); - - if (!gst_video_frame_map (&v_frame, &v_info, buf, GST_MAP_READ | GST_MAP_GL)) { - g_warning ("Failed to map the video buffer"); - return; - } - - texture = *(guint *) v_frame.data[0]; - - glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer - glLoadIdentity (); // Reset The View - - glTranslatef (-0.4f, 0.0f, 0.0f); // Move Left 1.5 Units And Into The Screen 6.0 - - glRotatef (rtri, 0.0f, 1.0f, 0.0f); // Rotate The Triangle On The Y axis - // draw a triangle (in smooth coloring mode) - glBegin (GL_POLYGON); // start drawing a polygon - glColor3f (1.0f, 0.0f, 0.0f); // Set The Color To Red - glVertex3f (0.0f, 0.4f, 0.0f); // Top - glColor3f (0.0f, 1.0f, 0.0f); // Set The Color To Green - glVertex3f (0.4f, -0.4f, 0.0f); // Bottom Right - glColor3f (0.0f, 0.0f, 1.0f); // Set The Color To Blue - glVertex3f (-0.4f, -0.4f, 0.0f); // Bottom Left - glEnd (); // we're done with the polygon (smooth color interpolation) - - glEnable (GL_TEXTURE_2D); - glBindTexture (GL_TEXTURE_2D, texture); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - - glLoadIdentity (); // make sure we're no longer rotated. - glTranslatef (0.5f, 0.0f, 0.0f); // Move Right 3 Units, and back into the screen 6.0 - - glRotatef (rquad, 1.0f, 0.0f, 0.0f); // Rotate The Quad On The X axis - // draw a square (quadrilateral) - glColor3f (0.4f, 0.4f, 1.0f); // set color to a blue shade. - glBegin (GL_QUADS); // start drawing a polygon (4 sided) - glTexCoord3f (0.0f, 1.0f, 0.0f); - glVertex3f (-0.4f, 0.4f, 0.0f); // Top Left - glTexCoord3f (1.0f, 1.0f, 0.0f); - glVertex3f (0.4f, 0.4f, 0.0f); // Top Right - glTexCoord3f (1.0f, 0.0f, 0.0f); - glVertex3f (0.4f, -0.4f, 0.0f); // Bottom Right - glTexCoord3f (0.0f, 0.0f, 0.0f); - glVertex3f (-0.4f, -0.4f, 0.0f); // Bottom Left - glEnd (); // done with the polygon - - glBindTexture (GL_TEXTURE_2D, 0); - - rtri += 1.0f; // Increase The Rotation Variable For The Triangle - rquad -= 1.0f; // Decrease The Rotation Variable For The Quad - - // swap buffers to display, since we're double buffered. - SDL_GL_SwapBuffers (); - - gst_video_frame_unmap (&v_frame); -} - -static gboolean -update_sdl_scene (void *fk) -{ - GstElement *fakesink = (GstElement *) fk; - GMainLoop *loop = - (GMainLoop *) g_object_get_data (G_OBJECT (fakesink), "loop"); - GAsyncQueue *queue_input_buf = - (GAsyncQueue *) g_object_get_data (G_OBJECT (fakesink), - "queue_input_buf"); - GAsyncQueue *queue_output_buf = - (GAsyncQueue *) g_object_get_data (G_OBJECT (fakesink), - "queue_output_buf"); - GstBuffer *buf = (GstBuffer *) g_async_queue_pop (queue_input_buf); - - SDL_Event event; - while (SDL_PollEvent (&event)) { - if (event.type == SDL_QUIT) { - g_main_loop_quit (loop); - } - if (event.type == SDL_KEYDOWN) { - if (event.key.keysym.sym == SDLK_ESCAPE) { - g_main_loop_quit (loop); - } - } - } - - DrawGLScene (buf); - - /* push buffer so it can be unref later */ - g_async_queue_push (queue_output_buf, buf); - - return FALSE; -} - -/* fakesink handoff callback */ -static void -on_gst_buffer (GstElement * fakesink, GstBuffer * buf, GstPad * pad, - gpointer data) -{ - GAsyncQueue *queue_input_buf = NULL; - GAsyncQueue *queue_output_buf = NULL; - - /* ref then push buffer to use it in sdl */ - gst_buffer_ref (buf); - queue_input_buf = - (GAsyncQueue *) g_object_get_data (G_OBJECT (fakesink), - "queue_input_buf"); - g_async_queue_push (queue_input_buf, buf); - if (g_async_queue_length (queue_input_buf) > 3) - g_idle_add (update_sdl_scene, (gpointer) fakesink); - - /* pop then unref buffer we have finished to use in sdl */ - queue_output_buf = - (GAsyncQueue *) g_object_get_data (G_OBJECT (fakesink), - "queue_output_buf"); - if (g_async_queue_length (queue_output_buf) > 3) { - GstBuffer *buf_old = (GstBuffer *) g_async_queue_pop (queue_output_buf); - gst_buffer_unref (buf_old); - } -} - -/* gst bus signal watch callback */ -static void -end_stream_cb (GstBus * bus, GstMessage * msg, GMainLoop * loop) -{ - switch (GST_MESSAGE_TYPE (msg)) { - - case GST_MESSAGE_EOS: - g_print ("End-of-stream\n"); - g_print - ("For more information, try to run: GST_DEBUG=gl*:3 ./sdlshare\n"); - break; - - case GST_MESSAGE_ERROR: - { - gchar *debug = NULL; - GError *err = NULL; - - gst_message_parse_error (msg, &err, &debug); - - g_print ("Error: %s\n", err->message); - g_error_free (err); - - if (debug) { - g_print ("Debug deails: %s\n", debug); - g_free (debug); - } - - break; - } - - default: - break; - } - - g_main_loop_quit (loop); -} - -static gboolean -sync_bus_call (GstBus * bus, GstMessage * msg, gpointer data) -{ - switch (GST_MESSAGE_TYPE (msg)) { - case GST_MESSAGE_NEED_CONTEXT: - { - const gchar *context_type; - - gst_message_parse_context_type (msg, &context_type); - g_print ("got need context %s\n", context_type); - - if (g_strcmp0 (context_type, GST_GL_DISPLAY_CONTEXT_TYPE) == 0) { - GstContext *display_context = - gst_context_new (GST_GL_DISPLAY_CONTEXT_TYPE, TRUE); - gst_context_set_gl_display (display_context, sdl_gl_display); - gst_element_set_context (GST_ELEMENT (msg->src), display_context); - return TRUE; - } else if (g_strcmp0 (context_type, "gst.gl.app_context") == 0) { - GstContext *app_context = gst_context_new ("gst.gl.app_context", TRUE); - GstStructure *s = gst_context_writable_structure (app_context); - gst_structure_set (s, "context", GST_TYPE_GL_CONTEXT, sdl_context, - NULL); - gst_element_set_context (GST_ELEMENT (msg->src), app_context); - return TRUE; - } - break; - } - default: - break; - } - return FALSE; -} - -int -main (int argc, char **argv) -{ - -#ifdef WIN32 - HGLRC sdl_gl_context = 0; - HDC sdl_dc = 0; -#else - SDL_SysWMinfo info; - Display *sdl_display = NULL; - Window sdl_win = 0; - GLXContext sdl_gl_context = NULL; -#endif - - GMainLoop *loop = NULL; - GstPipeline *pipeline = NULL; - GstBus *bus = NULL; - GstElement *fakesink = NULL; - GstState state; - GAsyncQueue *queue_input_buf = NULL; - GAsyncQueue *queue_output_buf = NULL; - const gchar *platform; - - /* Initialize SDL for video output */ - if (SDL_Init (SDL_INIT_VIDEO) < 0) { - fprintf (stderr, "Unable to initialize SDL: %s\n", SDL_GetError ()); - return -1; - } - - /* Create a 640x480 OpenGL screen */ - if (SDL_SetVideoMode (640, 480, 0, SDL_OPENGL) == NULL) { - fprintf (stderr, "Unable to create OpenGL screen: %s\n", SDL_GetError ()); - SDL_Quit (); - return -1; - } - - /* Set the title bar in environments that support it */ - SDL_WM_SetCaption ("SDL and gst-plugins-gl", NULL); - - - /* Loop, drawing and checking events */ - InitGL (640, 480); - - gst_init (&argc, &argv); - loop = g_main_loop_new (NULL, FALSE); - - /* retrieve and turn off sdl opengl context */ -#ifdef WIN32 - sdl_gl_context = wglGetCurrentContext (); - sdl_dc = wglGetCurrentDC (); - wglMakeCurrent (0, 0); - platform = "wgl"; - sdl_gl_display = gst_gl_display_new (); -#else - SDL_VERSION (&info.version); - SDL_GetWMInfo (&info); - /* FIXME: This display is different to the one that SDL uses to create the - * GL context inside SDL_SetVideoMode() above which fails on Intel hardware - */ - sdl_display = info.info.x11.gfxdisplay; - sdl_win = info.info.x11.window; - sdl_gl_context = glXGetCurrentContext (); - glXMakeCurrent (sdl_display, None, 0); - platform = "glx"; - sdl_gl_display = - (GstGLDisplay *) gst_gl_display_x11_new_with_display (sdl_display); -#endif - - sdl_context = - gst_gl_context_new_wrapped (sdl_gl_display, (guintptr) sdl_gl_context, - gst_gl_platform_from_string (platform), GST_GL_API_OPENGL); - - pipeline = - GST_PIPELINE (gst_parse_launch - ("videotestsrc ! video/x-raw, width=320, height=240, framerate=(fraction)30/1 ! " - "glupload ! gleffects effect=5 ! fakesink sync=1", NULL)); - - bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); - gst_bus_add_signal_watch (bus); - g_signal_connect (bus, "message::error", G_CALLBACK (end_stream_cb), loop); - g_signal_connect (bus, "message::warning", G_CALLBACK (end_stream_cb), loop); - g_signal_connect (bus, "message::eos", G_CALLBACK (end_stream_cb), loop); - gst_bus_enable_sync_message_emission (bus); - g_signal_connect (bus, "sync-message", G_CALLBACK (sync_bus_call), NULL); - gst_object_unref (bus); - - /* NULL to PAUSED state pipeline to make sure the gst opengl context is created and - * shared with the sdl one */ - gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED); - state = GST_STATE_PAUSED; - if (gst_element_get_state (GST_ELEMENT (pipeline), &state, NULL, - GST_CLOCK_TIME_NONE) != GST_STATE_CHANGE_SUCCESS) { - g_debug ("failed to pause pipeline\n"); - return -1; - } - - /* turn on back sdl opengl context */ -#ifdef WIN32 - wglMakeCurrent (sdl_dc, sdl_gl_context); -#else - glXMakeCurrent (sdl_display, sdl_win, sdl_gl_context); -#endif - - /* append a gst-gl texture to this queue when you do not need it no more */ - fakesink = gst_bin_get_by_name (GST_BIN (pipeline), "fakesink0"); - g_object_set (G_OBJECT (fakesink), "signal-handoffs", TRUE, NULL); - g_signal_connect (fakesink, "handoff", G_CALLBACK (on_gst_buffer), NULL); - queue_input_buf = g_async_queue_new (); - queue_output_buf = g_async_queue_new (); - g_object_set_data (G_OBJECT (fakesink), "queue_input_buf", queue_input_buf); - g_object_set_data (G_OBJECT (fakesink), "queue_output_buf", queue_output_buf); - g_object_set_data (G_OBJECT (fakesink), "loop", loop); - gst_object_unref (fakesink); - - gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); - - g_main_loop_run (loop); - - /* before to deinitialize the gst-gl-opengl context, - * no shared context (here the sdl one) must be current - */ -#ifdef WIN32 - wglMakeCurrent (0, 0); -#else - glXMakeCurrent (sdl_display, sdl_win, sdl_gl_context); -#endif - - gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); - gst_object_unref (pipeline); - - /* make sure there is no pending gst gl buffer in the communication queues - * between sdl and gst-gl - */ - while (g_async_queue_length (queue_input_buf) > 0) { - GstBuffer *buf = (GstBuffer *) g_async_queue_pop (queue_input_buf); - gst_buffer_unref (buf); - } - - while (g_async_queue_length (queue_output_buf) > 0) { - GstBuffer *buf = (GstBuffer *) g_async_queue_pop (queue_output_buf); - gst_buffer_unref (buf); - } - - /* turn on back sdl opengl context */ -#ifdef WIN32 - wglMakeCurrent (sdl_dc, sdl_gl_context); -#else - glXMakeCurrent (sdl_display, None, 0); -#endif - - SDL_Quit (); - - return 0; -} diff --git a/tests/examples/gl/sdl/sdlshare2.c b/tests/examples/gl/sdl/sdlshare2.c deleted file mode 100644 index b9ce10876..000000000 --- a/tests/examples/gl/sdl/sdlshare2.c +++ /dev/null @@ -1,411 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2015 Julien Isorce <julien.isorce@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 - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef WIN32 -#include <windows.h> -#endif - -#include <GL/gl.h> -#include "SDL/SDL.h" -#include "SDL/SDL_opengl.h" - -#ifndef WIN32 -#include <GL/glx.h> -#include "SDL/SDL_syswm.h" -#include <gst/gl/x11/gstgldisplay_x11.h> -#endif - -#include <gst/gst.h> -#include <gst/gl/gl.h> - -static GstGLContext *sdl_context; -static GstGLDisplay *sdl_gl_display; - -/* rotation angle for the triangle. */ -float rtri = 0.0f; - -/* rotation angle for the quadrilateral. */ -float rquad = 0.0f; - -/* A general OpenGL initialization function. Sets all of the initial parameters. */ -static void -InitGL (int Width, int Height) // We call this right after our OpenGL window is created. -{ - glViewport (0, 0, Width, Height); - glClearColor (0.0f, 0.0f, 0.0f, 0.0f); // This Will Clear The Background Color To Black - glClearDepth (1.0); // Enables Clearing Of The Depth Buffer - glDepthFunc (GL_LESS); // The Type Of Depth Test To Do - glEnable (GL_DEPTH_TEST); // Enables Depth Testing - glShadeModel (GL_SMOOTH); // Enables Smooth Color Shading - - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); // Reset The Projection Matrix - - glMatrixMode (GL_MODELVIEW); -} - -/* The main drawing function. */ -static void -DrawGLScene (GstVideoFrame * v_frame) -{ - guint texture = 0; - -#ifdef WIN32 - if (!wglGetCurrentContext ()) - return; -#else - if (!glXGetCurrentContext ()) - return; -#endif - - texture = *(guint *) v_frame->data[0]; - - glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer - glLoadIdentity (); // Reset The View - - glTranslatef (-0.4f, 0.0f, 0.0f); // Move Left 1.5 Units And Into The Screen 6.0 - - glRotatef (rtri, 0.0f, 1.0f, 0.0f); // Rotate The Triangle On The Y axis - // draw a triangle (in smooth coloring mode) - glBegin (GL_POLYGON); // start drawing a polygon - glColor3f (1.0f, 0.0f, 0.0f); // Set The Color To Red - glVertex3f (0.0f, 0.4f, 0.0f); // Top - glColor3f (0.0f, 1.0f, 0.0f); // Set The Color To Green - glVertex3f (0.4f, -0.4f, 0.0f); // Bottom Right - glColor3f (0.0f, 0.0f, 1.0f); // Set The Color To Blue - glVertex3f (-0.4f, -0.4f, 0.0f); // Bottom Left - glEnd (); // we're done with the polygon (smooth color interpolation) - - glEnable (GL_TEXTURE_2D); - glBindTexture (GL_TEXTURE_2D, texture); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - - glLoadIdentity (); // make sure we're no longer rotated. - glTranslatef (0.5f, 0.0f, 0.0f); // Move Right 3 Units, and back into the screen 6.0 - - glRotatef (rquad, 1.0f, 0.0f, 0.0f); // Rotate The Quad On The X axis - // draw a square (quadrilateral) - glColor3f (0.4f, 0.4f, 1.0f); // set color to a blue shade. - glBegin (GL_QUADS); // start drawing a polygon (4 sided) - glTexCoord3f (0.0f, 1.0f, 0.0f); - glVertex3f (-0.4f, 0.4f, 0.0f); // Top Left - glTexCoord3f (1.0f, 1.0f, 0.0f); - glVertex3f (0.4f, 0.4f, 0.0f); // Top Right - glTexCoord3f (1.0f, 0.0f, 0.0f); - glVertex3f (0.4f, -0.4f, 0.0f); // Bottom Right - glTexCoord3f (0.0f, 0.0f, 0.0f); - glVertex3f (-0.4f, -0.4f, 0.0f); // Bottom Left - glEnd (); // done with the polygon - - glBindTexture (GL_TEXTURE_2D, 0); - - rtri += 1.0f; // Increase The Rotation Variable For The Triangle - rquad -= 1.0f; // Decrease The Rotation Variable For The Quad - - // swap buffers to display, since we're double buffered. - SDL_GL_SwapBuffers (); -} - -static GMutex app_lock; -static GCond app_cond; -static gboolean app_rendered = FALSE; -static gboolean app_quit = FALSE; - -static void -stop_pipeline (GstElement * pipeline) -{ - g_mutex_lock (&app_lock); - app_quit = TRUE; - g_cond_signal (&app_cond); - g_mutex_unlock (&app_lock); - gst_element_send_event (pipeline, gst_event_new_eos ()); -} - -static gboolean -update_sdl_scene (gpointer data) -{ - GstElement *pipeline = (GstElement *) data; - SDL_Event event; - - while (SDL_PollEvent (&event)) { - if (event.type == SDL_QUIT) { - stop_pipeline (pipeline); - return FALSE; - } - if (event.type == SDL_KEYDOWN) { - if (event.key.keysym.sym == SDLK_ESCAPE) { - stop_pipeline (pipeline); - return FALSE; - } - } - } - - return TRUE; -} - -static gboolean -executeCallback (gpointer data) -{ - g_mutex_lock (&app_lock); - - if (!app_quit) - DrawGLScene (data); - - app_rendered = TRUE; - g_cond_signal (&app_cond); - g_mutex_unlock (&app_lock); - - return FALSE; -} - -static gboolean -on_client_draw (GstElement * glsink, GstGLContext * context, GstSample * sample, - gpointer data) -{ - GstBuffer *buf = gst_sample_get_buffer (sample); - GstCaps *caps = gst_sample_get_caps (sample); - GstVideoFrame v_frame; - GstVideoInfo v_info; - - /* FIXME don't do that every frame */ - gst_video_info_from_caps (&v_info, caps); - - if (!gst_video_frame_map (&v_frame, &v_info, buf, GST_MAP_READ | GST_MAP_GL)) { - g_warning ("Failed to map the video buffer"); - return TRUE; - } - - g_mutex_lock (&app_lock); - - app_rendered = FALSE; - g_idle_add_full (G_PRIORITY_HIGH, executeCallback, &v_frame, NULL); - - while (!app_rendered && !app_quit) - g_cond_wait (&app_cond, &app_lock); - - g_mutex_unlock (&app_lock); - - gst_video_frame_unmap (&v_frame); - - return TRUE; -} - -/* gst bus signal watch callback */ -static void -end_stream_cb (GstBus * bus, GstMessage * msg, GMainLoop * loop) -{ - switch (GST_MESSAGE_TYPE (msg)) { - - case GST_MESSAGE_EOS: - g_print ("End-of-stream\n"); - break; - - case GST_MESSAGE_ERROR: - { - gchar *debug = NULL; - GError *err = NULL; - - gst_message_parse_error (msg, &err, &debug); - - g_print ("Error: %s\n", err->message); - g_error_free (err); - - if (debug) { - g_print ("Debug deails: %s\n", debug); - g_free (debug); - } - - break; - } - - default: - break; - } - - g_main_loop_quit (loop); -} - -static gboolean -sync_bus_call (GstBus * bus, GstMessage * msg, gpointer data) -{ - switch (GST_MESSAGE_TYPE (msg)) { - case GST_MESSAGE_NEED_CONTEXT: - { - const gchar *context_type; - - gst_message_parse_context_type (msg, &context_type); - g_print ("got need context %s\n", context_type); - - if (g_strcmp0 (context_type, GST_GL_DISPLAY_CONTEXT_TYPE) == 0) { - GstContext *display_context = - gst_context_new (GST_GL_DISPLAY_CONTEXT_TYPE, TRUE); - gst_context_set_gl_display (display_context, sdl_gl_display); - gst_element_set_context (GST_ELEMENT (msg->src), display_context); - return TRUE; - } else if (g_strcmp0 (context_type, "gst.gl.app_context") == 0) { - GstContext *app_context = gst_context_new ("gst.gl.app_context", TRUE); - GstStructure *s = gst_context_writable_structure (app_context); - gst_structure_set (s, "context", GST_TYPE_GL_CONTEXT, sdl_context, - NULL); - gst_element_set_context (GST_ELEMENT (msg->src), app_context); - return TRUE; - } - break; - } - default: - break; - } - return FALSE; -} - -int -main (int argc, char **argv) -{ -#ifdef WIN32 - HGLRC sdl_gl_context = 0; - HDC sdl_dc = 0; -#else - SDL_SysWMinfo info; - Display *sdl_display = NULL; - Window sdl_win = 0; - GLXContext sdl_gl_context = NULL; -#endif - - GMainLoop *loop = NULL; - GstPipeline *pipeline = NULL; - GstBus *bus = NULL; - GstElement *glimagesink = NULL; - const gchar *platform; - - /* Initialize SDL for video output */ - if (SDL_Init (SDL_INIT_VIDEO) < 0) { - fprintf (stderr, "Unable to initialize SDL: %s\n", SDL_GetError ()); - return -1; - } - - /* Create a 640x480 OpenGL screen */ - if (SDL_SetVideoMode (640, 480, 0, SDL_OPENGL) == NULL) { - fprintf (stderr, "Unable to create OpenGL screen: %s\n", SDL_GetError ()); - SDL_Quit (); - return -1; - } - - /* Set the title bar in environments that support it */ - SDL_WM_SetCaption ("SDL and gst-plugins-gl", NULL); - - - /* Loop, drawing and checking events */ - InitGL (640, 480); - - gst_init (&argc, &argv); - loop = g_main_loop_new (NULL, FALSE); - - /* retrieve and turn off sdl opengl context */ -#ifdef WIN32 - sdl_gl_context = wglGetCurrentContext (); - sdl_dc = wglGetCurrentDC (); - wglMakeCurrent (0, 0); - platform = "wgl"; - sdl_gl_display = gst_gl_display_new (); -#else - SDL_VERSION (&info.version); - SDL_GetWMInfo (&info); - /* FIXME: This display is different to the one that SDL uses to create the - * GL context inside SDL_SetVideoMode() above which fails on Intel hardware - */ - sdl_display = info.info.x11.gfxdisplay; - sdl_win = info.info.x11.window; - sdl_gl_context = glXGetCurrentContext (); - glXMakeCurrent (sdl_display, None, 0); - platform = "glx"; - sdl_gl_display = - (GstGLDisplay *) gst_gl_display_x11_new_with_display (sdl_display); -#endif - - sdl_context = - gst_gl_context_new_wrapped (sdl_gl_display, (guintptr) sdl_gl_context, - gst_gl_platform_from_string (platform), GST_GL_API_OPENGL); - - pipeline = - GST_PIPELINE (gst_parse_launch - ("videotestsrc ! video/x-raw, width=320, height=240, framerate=(fraction)30/1 ! " - "glimagesink name=glimagesink0", NULL)); - - bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); - gst_bus_add_signal_watch (bus); - g_signal_connect (bus, "message::error", G_CALLBACK (end_stream_cb), loop); - g_signal_connect (bus, "message::warning", G_CALLBACK (end_stream_cb), loop); - g_signal_connect (bus, "message::eos", G_CALLBACK (end_stream_cb), loop); - gst_bus_enable_sync_message_emission (bus); - g_signal_connect (bus, "sync-message", G_CALLBACK (sync_bus_call), NULL); - gst_object_unref (bus); - - glimagesink = gst_bin_get_by_name (GST_BIN (pipeline), "glimagesink0"); - g_signal_connect (G_OBJECT (glimagesink), "client-draw", - G_CALLBACK (on_client_draw), NULL); - gst_object_unref (glimagesink); - - /* NULL to PAUSED state pipeline to make sure the gst opengl context is created and - * shared with the sdl one */ - gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED); - - /* turn on back sdl opengl context */ -#ifdef WIN32 - wglMakeCurrent (sdl_dc, sdl_gl_context); -#else - glXMakeCurrent (sdl_display, sdl_win, sdl_gl_context); -#endif - - gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); - - g_timeout_add (100, update_sdl_scene, pipeline); - - g_main_loop_run (loop); - - /* before to deinitialize the gst-gl-opengl context, - * no shared context (here the sdl one) must be current - */ -#ifdef WIN32 - wglMakeCurrent (0, 0); -#else - glXMakeCurrent (sdl_display, sdl_win, sdl_gl_context); -#endif - - gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); - gst_object_unref (pipeline); - - /* turn on back sdl opengl context */ -#ifdef WIN32 - wglMakeCurrent (sdl_dc, sdl_gl_context); -#else - glXMakeCurrent (sdl_display, None, 0); -#endif - - SDL_Quit (); - - return 0; -} diff --git a/tests/examples/meson.build b/tests/examples/meson.build index 838624807..6c3c4682e 100644 --- a/tests/examples/meson.build +++ b/tests/examples/meson.build @@ -5,7 +5,6 @@ #subdir('codecparsers') subdir('compositor') #subdir('directfb') -subdir('gl') #subdir('gtk') #subdir('ipcpipeline') subdir('mpegts') |