Commit 294da02a authored by Matthew Waters's avatar Matthew Waters 🐨

gl/examples: move to -bad

- fix all the compiler errors
- give them their own gl directory
parent 967982a0
......@@ -235,6 +235,65 @@ fi
AM_CONDITIONAL(HAVE_GTK, test "x$HAVE_GTK" = "xyes")
dnl GTK is optional and used in examples
HAVE_GTK3=NO
if test "x$BUILD_EXAMPLES" = "xyes"; then
PKG_CHECK_MODULES(GTK3, gtk+-3.0 >= 3.4, HAVE_GTK3=yes, HAVE_GTK3=no)
if test "x$HAVE_GTK3" = "xyes"; then
HAVE_GTK=yes
GTK_VERSION=`$PKG_CONFIG --variable=gtk_binary_version gtk+-3.0`
AC_SUBST(GTK_VERSION)
GTK_PREFIX=`$PKG_CONFIG --variable=prefix gdk-pixbuf-2.0`
AC_SUBST(GTK_BASE_DIR)
fi
fi
AC_SUBST(GTK3_LIBS)
AC_SUBST(GTK3_CFLAGS)
AC_SUBST(HAVE_GTK3)
AM_CONDITIONAL(HAVE_GTK3, test "x$HAVE_GTK3" = "xyes")
dnl clutter is optional and used in examples
HAVE_CLUTTER=no
HAVE_CLUTTER_X11=no
HAVE_CLUTTER_GLX=no
if test "x$BUILD_EXAMPLES" = "xyes"; then
PKG_CHECK_MODULES(CLUTTER, clutter-1.0 >= 1.8, HAVE_CLUTTER=yes, HAVE_CLUTTER=no)
AC_SUBST(CLUTTER_LIBS)
AC_SUBST(CLUTTER_CFLAGS)
AC_SUBST(HAVE_CLUTTER)
PKG_CHECK_MODULES(CLUTTER_GLX, clutter-glx-1.0 >= 1.8, HAVE_CLUTTER_GLX=yes, HAVE_CLUTTER_GLX=no)
AC_SUBST(CLUTTER_GLX_LIBS)
AC_SUBST(CLUTTER_GLX_CFLAGS)
AC_SUBST(HAVE_CLUTTER_GLX)
PKG_CHECK_MODULES(CLUTTER_X11, clutter-x11-1.0 >= 1.8, HAVE_CLUTTER_X11=yes, HAVE_CLUTTER_X11=no)
AC_SUBST(CLUTTER_X11_LIBS)
AC_SUBST(CLUTTER_X11_CFLAGS)
AC_SUBST(HAVE_CLUTTER_X11)
fi
AM_CONDITIONAL(HAVE_CLUTTER, test "x$HAVE_CLUTTER" = "xyes")
AM_CONDITIONAL(HAVE_CLUTTER_GLX, test "x$HAVE_CLUTTER_GLX" = "xyes")
AM_CONDITIONAL(HAVE_CLUTTER_X11, test "x$HAVE_CLUTTER_X11" = "xyes")
dnl used in the gl/clutteractor example
if test "x$BUILD_EXAMPLES" = "xyes"; then
PKG_CHECK_MODULES(XCOMPOSITE, xcomposite, HAVE_XCOMPOSITE=yes, HAVE_XCOMPOSITE=no)
AC_SUBST(XCOMPOSITE_CFLAGS)
AC_SUBST(XCOMPOSITE_LIBS)
fi
AM_CONDITIONAL(HAVE_XCOMPOSITE, test "x$HAVE_XCOMPOSITE" = "xyes")
dnl sdl is optional and used in examples
HAVE_SDL=NO
if test "x$BUILD_EXAMPLES" = "xyes"; then
PKG_CHECK_MODULES(SDL, sdl >= 1.2.0, HAVE_SDL=yes, HAVE_SDL=no)
AC_SUBST(SDL_LIBS)
AC_SUBST(SDL_CFLAGS)
AC_SUBST(SDL_CLUTTER)
fi
AM_CONDITIONAL(HAVE_SDL, test "x$HAVE_SDL" = "xyes")
dnl Needed for GtkBuilder to autoconnect signals
PKG_CHECK_MODULES(GMODULE_EXPORT, gmodule-export-2.0, HAVE_GMODULE_EXPORT=yes, HAVE_GMODULE_EXPORT=no)
......@@ -3161,6 +3220,23 @@ tests/files/Makefile
tests/examples/Makefile
tests/examples/camerabin2/Makefile
tests/examples/directfb/Makefile
tests/examples/gl/Makefile
tests/examples/gl/cocoa/Makefile
tests/examples/gl/cocoa/videooverlay/Makefile
tests/examples/gl/clutter/Makefile
tests/examples/gl/generic/Makefile
tests/examples/gl/generic/cube/Makefile
tests/examples/gl/generic/cubeyuv/Makefile
tests/examples/gl/generic/doublecube/Makefile
tests/examples/gl/generic/recordgraphic/Makefile
tests/examples/gl/gtk/Makefile
tests/examples/gl/gtk/gtkvideooverlay/Makefile
tests/examples/gl/gtk/filternovideooverlay/Makefile
tests/examples/gl/gtk/filtervideooverlay/Makefile
tests/examples/gl/gtk/fxtest/Makefile
tests/examples/gl/gtk/switchvideooverlay/Makefile
tests/examples/gl/qt/Makefile
tests/examples/gl/sdl/Makefile
tests/examples/mpegts/Makefile
tests/examples/mxf/Makefile
tests/examples/opencv/Makefile
......
......@@ -18,7 +18,13 @@ endif
OPENCV_EXAMPLES=opencv
SUBDIRS= mpegts $(DIRECTFB_DIR) $(GTK_EXAMPLES) $(OPENCV_EXAMPLES)
DIST_SUBDIRS= mpegts camerabin2 directfb mxf opencv uvch264
if USE_OPENGL
GL_DIR=gl
else
GL_DIR=
endif
SUBDIRS= mpegts $(DIRECTFB_DIR) $(GTK_EXAMPLES) $(OPENCV_EXAMPLES) $(GL_DIR)
DIST_SUBDIRS= mpegts camerabin2 directfb mxf opencv uvch264 gl
include $(top_srcdir)/common/parallel-subdirs.mak
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
......@@ -24,6 +24,9 @@
#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_1_16
#define COGL_VERSION_MAX_ALLOWED COGL_VERSION_1_18
#include <clutter/clutter.h>
#ifndef WIN32
#include <clutter/x11/clutter-x11.h>
......@@ -41,7 +44,7 @@
*/
/* rotation */
void
static void
on_new_frame (ClutterTimeline * timeline, gint msecs, gpointer data)
{
ClutterActor *rect_actor = CLUTTER_ACTOR (data);
......@@ -60,7 +63,7 @@ on_new_frame (ClutterTimeline * timeline, gint msecs, gpointer data)
/* clutter scene */
ClutterActor *
static ClutterActor *
setup_stage (ClutterStage * stage)
{
ClutterTimeline *timeline = NULL;
......@@ -98,7 +101,7 @@ setup_stage (ClutterStage * stage)
}
/* put a gst gl buffer in the texture actor */
gboolean
static gboolean
update_texture_actor (gpointer data)
{
ClutterTexture *texture_actor = (ClutterTexture *) data;
......@@ -167,7 +170,7 @@ update_texture_actor (gpointer data)
/* fakesink handoff callback */
void
static void
on_gst_buffer (GstElement * element, GstBuffer * buf, GstPad * pad,
ClutterActor * texture_actor)
{
......@@ -193,7 +196,7 @@ on_gst_buffer (GstElement * element, GstBuffer * buf, GstPad * pad,
}
/* gst bus signal watch callback */
void
static void
end_stream_cb (GstBus * bus, GstMessage * msg, gpointer data)
{
switch (GST_MESSAGE_TYPE (msg)) {
......
<?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;
}
- (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);
gst_message_unref (message);
return GST_BUS_DROP;
}
static void end_stream_cb(GstBus* bus, GstMessage* message, MainWindow* window)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
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];
[pool release];
}
static gpointer thread_func (MainWindow* window)
{
#ifdef GNUSTEP
GSRegisterCurrentThread();
#endif
g_main_loop_run ([window loop]);
#ifdef GNUSTEP
GSUnregisterCurrentThread();
#endif
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;
NSAutoreleasePool *pool=nil;
NSRect rect;
MainWindow *window=nil;
#ifdef GNUSTEP
GstState state;
#endif
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");
#ifdef GNUSTEP
gst_element_set_state (pipeline, GST_STATE_PAUSED);
state = GST_STATE_PAUSED;
gst_element_get_state (pipeline, &state, &state, GST_CLOCK_TIME_NONE);
g_print("pipeline paused\n");
GSRegisterCurrentThread();
#endif
pool = [[NSAutoreleasePool alloc] init];
#ifndef GNUSTEP
[NSApplication sharedApplication];
#endif
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);
g_signal_connect(bus, "message::error", G_CALLBACK(end_stream_cb), window);
g_signal_connect(bus, "message::warning", G_CALLBACK(end_stream_cb), window);
g_signal_connect(bus, "message::eos", G_CALLBACK(end_stream_cb), window);
gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, window, NULL);
gst_object_unref (bus);
loop_thread = g_thread_new (NULL,
(GThreadFunc) thread_func, window);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
[window orderFront:window];
#ifndef GNUSTEP
while (![window isClosed]) {
NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask
untilDate:[NSDate dateWithTimeIntervalSinceNow:1]
inMode:NSDefaultRunLoopMode dequeue:YES];
if (event)
[NSApp sendEvent:event];
}
#endif
g_thread_join (loop_thread);
[window release];
[pool release];
#ifdef GNUSTEP
GSUnregisterCurrentThread();
#endif
return 0;
}
SUBDIRS = cube cubeyuv doublecube recordgraphic
--- 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.
noinst_PROGRAMS = cube
cube_SOURCES = main.cpp
cube_CXXFLAGS=$(GST_PLUGINS_GL_CFLAGS) $(GST_CXXFLAGS) $(GL_CFLAGS)
cube_LDADD=$(GST_PLUGINS_GL_LIBS) $(GST_LIBS) $(GL_LIBS)
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="cube"
ProjectGUID="{DA41FBFF-E1DE-4DA1-BB96-C56C63D5CDBE}"
RootNamespace="cube"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;C:\gstreamer\include\glib-2.0&quot;;&quot;C:\gstreamer\lib\glib-2.0\include&quot;;&quot;C:\gstreamer\include\gstreamer-1.0&quot;;C:\gstreamer\include\libxml2;C:\gstreamer\include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool