Commit 05bfd277 authored by Matthew Waters's avatar Matthew Waters 🐨 Committed by Tim-Philipp Müller

gl/examples: move to -bad

- fix all the compiler errors
- give them their own gl directory
parent d3124725
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
clutteractor
clutteractortee
cluttershare
noinst_PROGRAMS = ##
#works on win32 and X
if HAVE_CLUTTER
noinst_PROGRAMS += cluttershare
cluttershare_SOURCES = cluttershare.c
cluttershare_CFLAGS=$(GST_PLUGINS_GL_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=$(GST_PLUGINS_GL_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_GL_LIBS) $(GST_PLUGINS_BASE_LIBS) $(GST_LIBS) \
$(GL_LIBS) $(XCOMPOSITE_LIBS) -lgstvideo-$(GST_API_VERSION)
clutteractortee_SOURCES = clutteractortee.c
clutteractortee_CFLAGS=$(GST_PLUGINS_GL_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_GL_LIBS) $(GST_PLUGINS_BASE_LIBS) $(GST_LIBS) \
$(GL_LIBS) $(XCOMPOSITE_LIBS) -lgstvideo-$(GST_API_VERSION)
endif
endif
endif
/*
* 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_GLX_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_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;
}
/*
* 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_GLX_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_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;
}
This diff is collapsed.
<?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>
if HAVE_WINDOW_COCOA
SUBDIRS = videooverlay
endif
--- Description of the Cocoa examples ---
- videooverlay:
Show how to use the videooverlay interface through Cocoa.
For now, the source is videotestsrc. (not yet a video file)
--- How to build the Cocoa examples on GNUstep environnements ---
make clean all -f GNUmakefile.gnustep
if HAVE_WINDOW_COCOA
noinst_PROGRAMS = videooverlay
videooverlay_SOURCES = main.m
videooverlay_OBJCFLAGS=$(GST_PLUGINS_GL_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) \
$(GL_CFLAGS) -I/usr/local/include/gstreamer-${GST_API_VERSION} ${GL_OBJCFLAGS}
videooverlay_LDADD=$(GST_PLUGINS_GL_LIBS) $(GST_PLUGINS_BASE_LIBS) $(GST_LIBS) \
$(GL_LIBS) -lgstvideo-$(GST_API_VERSION)
videooverlay_LIBTOOLFLAGS = --tag=OBJC
endif
#include <Cocoa/Cocoa.h>
#include <gst/gst.h>
#include <gst/video/videooverlay.h>
/* ============================================================= */
/* */
/* MainWindow */
/* */
/* ============================================================= */
@interface MainWindow: NSWindow {
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: (NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask | NSMiniaturizableWindowMask)
backing: NSBackingStoreBuffered defer: NO screen: nil];
[self setReleasedWhenClosed:NO];
[NSApp 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;
}