gl/examples/generic: remove trailing whitespaces

This commit is contained in:
Luis de Bethencourt 2014-05-03 21:05:19 -04:00 committed by Tim-Philipp Müller
parent ea7c8f9771
commit f29a98cc5f
4 changed files with 84 additions and 93 deletions

View file

@ -75,7 +75,6 @@ static void reshapeCallback (GLuint width, GLuint height, gpointer data)
} }
//client draw callback //client draw callback
static gboolean drawCallback (GLuint texture, GLuint width, GLuint height, gpointer data) static gboolean drawCallback (GLuint texture, GLuint width, GLuint height, gpointer data)
{ {
static GLfloat xrot = 0; static GLfloat xrot = 0;
@ -244,5 +243,4 @@ gint main (gint argc, gchar *argv[])
gst_object_unref (pipeline); gst_object_unref (pipeline);
return 0; return 0;
} }

View file

@ -33,13 +33,13 @@ static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
{ {
GMainLoop *loop = (GMainLoop*)data; GMainLoop *loop = (GMainLoop*)data;
switch (GST_MESSAGE_TYPE (msg)) switch (GST_MESSAGE_TYPE (msg))
{ {
case GST_MESSAGE_EOS: case GST_MESSAGE_EOS:
g_print ("End-of-stream\n"); g_print ("End-of-stream\n");
g_main_loop_quit (loop); g_main_loop_quit (loop);
break; break;
case GST_MESSAGE_ERROR: case GST_MESSAGE_ERROR:
{ {
gchar *debug = NULL; gchar *debug = NULL;
GError *err = NULL; GError *err = NULL;
@ -49,7 +49,7 @@ static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
g_print ("Error: %s\n", err->message); g_print ("Error: %s\n", err->message);
g_error_free (err); g_error_free (err);
if (debug) if (debug)
{ {
g_print ("Debug deails: %s\n", debug); g_print ("Debug deails: %s\n", debug);
g_free (debug); g_free (debug);
@ -57,7 +57,7 @@ static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
g_main_loop_quit (loop); g_main_loop_quit (loop);
break; break;
} }
default: default:
break; break;
} }
@ -72,7 +72,7 @@ static void identityCallback (GstElement *src, GstBuffer *buffer, GstElement* t
static GstClockTime last_timestamp = 0; static GstClockTime last_timestamp = 0;
static gint nbFrames = 0 ; static gint nbFrames = 0 ;
//display estimated video FPS //display estimated video FPS
nbFrames++ ; nbFrames++ ;
if (GST_BUFFER_TIMESTAMP(buffer) - last_timestamp >= 1000000000) if (GST_BUFFER_TIMESTAMP(buffer) - last_timestamp >= 1000000000)
{ {
@ -81,7 +81,7 @@ static void identityCallback (GstElement *src, GstBuffer *buffer, GstElement* t
std::string s(oss.str()) ; std::string s(oss.str()) ;
g_object_set(G_OBJECT(textoverlay), "text", s.c_str(), NULL); g_object_set(G_OBJECT(textoverlay), "text", s.c_str(), NULL);
last_timestamp = GST_BUFFER_TIMESTAMP(buffer) ; last_timestamp = GST_BUFFER_TIMESTAMP(buffer) ;
nbFrames = 0 ; nbFrames = 0 ;
} }
} }
@ -92,32 +92,31 @@ static void reshapeCallback (GLuint width, GLuint height)
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
gluPerspective(45, (gfloat)width/(gfloat)height, 0.1, 100); gluPerspective(45, (gfloat)width/(gfloat)height, 0.1, 100);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
} }
//client draw callback //client draw callback
static gboolean drawCallback (GLuint texture, GLuint width, GLuint height) static gboolean drawCallback (GLuint texture, GLuint width, GLuint height)
{ {
static GLfloat xrot = 0; static GLfloat xrot = 0;
static GLfloat yrot = 0; static GLfloat yrot = 0;
static GLfloat zrot = 0; static GLfloat zrot = 0;
static GTimeVal current_time; static GTimeVal current_time;
static glong last_sec = current_time.tv_sec; static glong last_sec = current_time.tv_sec;
static gint nbFrames = 0; static gint nbFrames = 0;
g_get_current_time (&current_time); g_get_current_time (&current_time);
nbFrames++ ; nbFrames++ ;
if ((current_time.tv_sec - last_sec) >= 1) if ((current_time.tv_sec - last_sec) >= 1)
{ {
std::cout << "GRPHIC FPS = " << nbFrames << std::endl; std::cout << "GRPHIC FPS = " << nbFrames << std::endl;
nbFrames = 0; nbFrames = 0;
last_sec = current_time.tv_sec; last_sec = current_time.tv_sec;
} }
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glEnable (GL_TEXTURE_2D); glEnable (GL_TEXTURE_2D);
@ -131,7 +130,7 @@ static gboolean drawCallback (GLuint texture, GLuint width, GLuint height)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
glTranslatef(0.0f,0.0f,-5.0f); glTranslatef(0.0f,0.0f,-5.0f);
glRotatef(xrot,1.0f,0.0f,0.0f); glRotatef(xrot,1.0f,0.0f,0.0f);
@ -169,7 +168,7 @@ static gboolean drawCallback (GLuint texture, GLuint width, GLuint height)
glTexCoord2f(0.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, (gfloat)height); glVertex3f(-1.0f, 1.0f, 1.0f); glTexCoord2f(0.0f, (gfloat)height); glVertex3f(-1.0f, 1.0f, 1.0f);
glTexCoord2f((gfloat)width, (gfloat)height); glVertex3f(-1.0f, 1.0f, -1.0f); glTexCoord2f((gfloat)width, (gfloat)height); glVertex3f(-1.0f, 1.0f, -1.0f);
glEnd(); glEnd();
xrot+=0.03f; xrot+=0.03f;
yrot+=0.02f; yrot+=0.02f;
@ -192,9 +191,9 @@ static gboolean drawCallback (GLuint texture, GLuint width, GLuint height)
static void cb_new_pad (GstElement* decodebin, GstPad* pad, GstElement* identity) static void cb_new_pad (GstElement* decodebin, GstPad* pad, GstElement* identity)
{ {
GstPad* identity_pad = gst_element_get_static_pad (identity, "sink"); GstPad* identity_pad = gst_element_get_static_pad (identity, "sink");
//only link once //only link once
if (GST_PAD_IS_LINKED (identity_pad)) if (GST_PAD_IS_LINKED (identity_pad))
{ {
gst_object_unref (identity_pad); gst_object_unref (identity_pad);
return; return;
@ -202,7 +201,7 @@ static void cb_new_pad (GstElement* decodebin, GstPad* pad, GstElement* identity
GstCaps* caps = gst_pad_get_current_caps (pad); GstCaps* caps = gst_pad_get_current_caps (pad);
GstStructure* str = gst_caps_get_structure (caps, 0); GstStructure* str = gst_caps_get_structure (caps, 0);
if (!g_strrstr (gst_structure_get_name (str), "video")) if (!g_strrstr (gst_structure_get_name (str), "video"))
{ {
gst_caps_unref (caps); gst_caps_unref (caps);
gst_object_unref (identity_pad); gst_object_unref (identity_pad);
@ -211,8 +210,8 @@ static void cb_new_pad (GstElement* decodebin, GstPad* pad, GstElement* identity
gst_caps_unref (caps); gst_caps_unref (caps);
GstPadLinkReturn ret = gst_pad_link (pad, identity_pad); GstPadLinkReturn ret = gst_pad_link (pad, identity_pad);
if (ret != GST_PAD_LINK_OK) if (ret != GST_PAD_LINK_OK)
g_warning ("Failed to link with decodebin!\n"); g_warning ("Failed to link with decodebin!\n");
} }
@ -223,9 +222,9 @@ gint main (gint argc, gchar *argv[])
g_warning ("usage: cubeyuv.exe videolocation\n"); g_warning ("usage: cubeyuv.exe videolocation\n");
return -1; return -1;
} }
std::string video_location(argv[1]); std::string video_location(argv[1]);
/* initialization */ /* initialization */
gst_init (&argc, &argv); gst_init (&argc, &argv);
GMainLoop* loop = g_main_loop_new (NULL, FALSE); GMainLoop* loop = g_main_loop_new (NULL, FALSE);
@ -267,7 +266,7 @@ gint main (gint argc, gchar *argv[])
g_object_set(G_OBJECT(textoverlay), "font_desc", "Ahafoni CLM Bold 30", NULL); g_object_set(G_OBJECT(textoverlay), "font_desc", "Ahafoni CLM Bold 30", NULL);
g_object_set(G_OBJECT(glimagesink), "client-reshape-callback", reshapeCallback, NULL); g_object_set(G_OBJECT(glimagesink), "client-reshape-callback", reshapeCallback, NULL);
g_object_set(G_OBJECT(glimagesink), "client-draw-callback", drawCallback, NULL); g_object_set(G_OBJECT(glimagesink), "client-draw-callback", drawCallback, NULL);
/* add elements */ /* add elements */
gst_bin_add_many (GST_BIN (pipeline), videosrc, decodebin, identity, gst_bin_add_many (GST_BIN (pipeline), videosrc, decodebin, identity,
textoverlay, glcolorscale, glimagesink, NULL); textoverlay, glcolorscale, glimagesink, NULL);
@ -277,7 +276,7 @@ gint main (gint argc, gchar *argv[])
g_signal_connect (decodebin, "pad-added", G_CALLBACK (cb_new_pad), identity); g_signal_connect (decodebin, "pad-added", G_CALLBACK (cb_new_pad), identity);
if (!gst_element_link_pads(identity, "src", textoverlay, "video_sink")) if (!gst_element_link_pads(identity, "src", textoverlay, "video_sink"))
{ {
g_print ("Failed to link identity to textoverlay!\n"); g_print ("Failed to link identity to textoverlay!\n");
return -1; return -1;
@ -292,16 +291,16 @@ gint main (gint argc, gchar *argv[])
g_warning("Failed to link textoverlay to glimagesink!\n") ; g_warning("Failed to link textoverlay to glimagesink!\n") ;
return -1 ; return -1 ;
} }
/* run */ /* run */
GstStateChangeReturn ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); GstStateChangeReturn ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (ret == GST_STATE_CHANGE_FAILURE) if (ret == GST_STATE_CHANGE_FAILURE)
{ {
g_print ("Failed to start up pipeline!\n"); g_print ("Failed to start up pipeline!\n");
/* check if there is an error message with details on the bus */ /* check if there is an error message with details on the bus */
GstMessage* msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0); GstMessage* msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0);
if (msg) if (msg)
{ {
GError *err = NULL; GError *err = NULL;
@ -320,6 +319,4 @@ gint main (gint argc, gchar *argv[])
gst_object_unref (pipeline); gst_object_unref (pipeline);
return 0; return 0;
} }

View file

@ -33,13 +33,13 @@ static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
{ {
GMainLoop *loop = (GMainLoop*)data; GMainLoop *loop = (GMainLoop*)data;
switch (GST_MESSAGE_TYPE (msg)) switch (GST_MESSAGE_TYPE (msg))
{ {
case GST_MESSAGE_EOS: case GST_MESSAGE_EOS:
g_print ("End-of-stream\n"); g_print ("End-of-stream\n");
g_main_loop_quit (loop); g_main_loop_quit (loop);
break; break;
case GST_MESSAGE_ERROR: case GST_MESSAGE_ERROR:
{ {
gchar *debug = NULL; gchar *debug = NULL;
GError *err = NULL; GError *err = NULL;
@ -49,7 +49,7 @@ static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
g_print ("Error: %s\n", err->message); g_print ("Error: %s\n", err->message);
g_error_free (err); g_error_free (err);
if (debug) if (debug)
{ {
g_print ("Debug details: %s\n", debug); g_print ("Debug details: %s\n", debug);
g_free (debug); g_free (debug);
@ -57,7 +57,7 @@ static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
g_main_loop_quit (loop); g_main_loop_quit (loop);
break; break;
} }
default: default:
break; break;
} }
@ -72,16 +72,16 @@ static GstPadProbeReturn textoverlay_sink_pad_probe_cb (GstPad *pad, GstPadProbe
static GstClockTime last_timestamp = 0; static GstClockTime last_timestamp = 0;
static gint nbFrames = 0 ; static gint nbFrames = 0 ;
//display estimated video FPS //display estimated video FPS
nbFrames++ ; nbFrames++ ;
if (GST_BUFFER_TIMESTAMP(info->data) - last_timestamp >= 1000000000) if (GST_BUFFER_TIMESTAMP(info->data) - last_timestamp >= 1000000000)
{ {
std::ostringstream oss ; std::ostringstream oss;
oss << "video framerate = " << nbFrames ; oss << "video framerate = " << nbFrames ;
std::string s(oss.str()) ; std::string s(oss.str());
g_object_set(G_OBJECT(textoverlay), "text", s.c_str(), NULL); g_object_set(G_OBJECT(textoverlay), "text", s.c_str(), NULL);
last_timestamp = GST_BUFFER_TIMESTAMP(info->data) ; last_timestamp = GST_BUFFER_TIMESTAMP(info->data) ;
nbFrames = 0 ; nbFrames = 0;
} }
return GST_PAD_PROBE_OK; return GST_PAD_PROBE_OK;
@ -94,8 +94,8 @@ static void reshapeCallback (GLuint width, GLuint height)
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
gluPerspective(45, (gfloat)width/(gfloat)height, 0.1, 100); gluPerspective(45, (gfloat)width/(gfloat)height, 0.1, 100);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
} }
@ -103,15 +103,15 @@ static void reshapeCallback (GLuint width, GLuint height)
static gboolean drawCallback (GLuint texture, GLuint width, GLuint height) static gboolean drawCallback (GLuint texture, GLuint width, GLuint height)
{ {
static GLfloat xrot = 0; static GLfloat xrot = 0;
static GLfloat yrot = 0; static GLfloat yrot = 0;
static GLfloat zrot = 0; static GLfloat zrot = 0;
static GTimeVal current_time; static GTimeVal current_time;
static glong last_sec = current_time.tv_sec; static glong last_sec = current_time.tv_sec;
static gint nbFrames = 0; static gint nbFrames = 0;
g_get_current_time (&current_time); g_get_current_time (&current_time);
nbFrames++ ; nbFrames++ ;
if ((current_time.tv_sec - last_sec) >= 1) if ((current_time.tv_sec - last_sec) >= 1)
{ {
std::cout << "GRAPHIC FPS of the scene which contains the custom cube) = " << nbFrames << std::endl; std::cout << "GRAPHIC FPS of the scene which contains the custom cube) = " << nbFrames << std::endl;
@ -132,7 +132,7 @@ static gboolean drawCallback (GLuint texture, GLuint width, GLuint height)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
glTranslatef(0.0f,0.0f,-5.0f); glTranslatef(0.0f,0.0f,-5.0f);
glRotatef(xrot,1.0f,0.0f,0.0f); glRotatef(xrot,1.0f,0.0f,0.0f);
@ -193,9 +193,9 @@ static gboolean drawCallback (GLuint texture, GLuint width, GLuint height)
static void cb_new_pad (GstElement* decodebin, GstPad* pad, GstElement* element) static void cb_new_pad (GstElement* decodebin, GstPad* pad, GstElement* element)
{ {
GstPad* element_pad = gst_element_get_static_pad (element, "sink"); GstPad* element_pad = gst_element_get_static_pad (element, "sink");
//only link once //only link once
if (!element_pad || GST_PAD_IS_LINKED (element_pad)) if (!element_pad || GST_PAD_IS_LINKED (element_pad))
{ {
gst_object_unref (element_pad); gst_object_unref (element_pad);
return; return;
@ -203,11 +203,11 @@ static void cb_new_pad (GstElement* decodebin, GstPad* pad, GstElement* element)
GstCaps* caps = gst_pad_get_current_caps (pad); GstCaps* caps = gst_pad_get_current_caps (pad);
GstStructure* str = gst_caps_get_structure (caps, 0); GstStructure* str = gst_caps_get_structure (caps, 0);
GstCaps* caps2 = gst_pad_query_caps (element_pad, NULL); GstCaps* caps2 = gst_pad_query_caps (element_pad, NULL);
gst_caps_unref (caps2); gst_caps_unref (caps2);
if (!g_strrstr (gst_structure_get_name (str), "video")) if (!g_strrstr (gst_structure_get_name (str), "video"))
{ {
gst_caps_unref (caps); gst_caps_unref (caps);
gst_object_unref (element_pad); gst_object_unref (element_pad);
@ -216,7 +216,7 @@ static void cb_new_pad (GstElement* decodebin, GstPad* pad, GstElement* element)
gst_caps_unref (caps); gst_caps_unref (caps);
GstPadLinkReturn ret = gst_pad_link (pad, element_pad); GstPadLinkReturn ret = gst_pad_link (pad, element_pad);
if (ret != GST_PAD_LINK_OK) if (ret != GST_PAD_LINK_OK)
g_warning ("Failed to link with decodebin %d!\n", ret); g_warning ("Failed to link with decodebin %d!\n", ret);
gst_object_unref (element_pad); gst_object_unref (element_pad);
} }
@ -224,13 +224,12 @@ static void cb_new_pad (GstElement* decodebin, GstPad* pad, GstElement* element)
gint main (gint argc, gchar *argv[]) gint main (gint argc, gchar *argv[])
{ {
if (argc != 2) if (argc != 2)
{ {
g_warning ("usage: doublecube.exe videolocation\n"); g_warning ("usage: doublecube.exe videolocation\n");
return -1; return -1;
} }
std::string video_location(argv[1]); std::string video_location(argv[1]);
/* initialization */ /* initialization */
@ -267,7 +266,7 @@ gint main (gint argc, gchar *argv[])
if (!videosrc || !decodebin || !videoconvert || !textoverlay || !tee || if (!videosrc || !decodebin || !videoconvert || !textoverlay || !tee ||
!queue0 || !glimagesink0 || !queue0 || !glimagesink0 ||
!queue1 || !glfiltercube || !glimagesink1 || !queue1 || !glfiltercube || !glimagesink1 ||
!queue2 || !glimagesink2) !queue2 || !glimagesink2)
{ {
g_warning ("one element could not be found \n"); g_warning ("one element could not be found \n");
return -1; return -1;
@ -284,33 +283,33 @@ gint main (gint argc, gchar *argv[])
g_object_set(G_OBJECT(textoverlay), "font_desc", "Ahafoni CLM Bold 30", NULL); g_object_set(G_OBJECT(textoverlay), "font_desc", "Ahafoni CLM Bold 30", NULL);
g_object_set(G_OBJECT(glimagesink0), "client-reshape-callback", reshapeCallback, NULL); g_object_set(G_OBJECT(glimagesink0), "client-reshape-callback", reshapeCallback, NULL);
g_object_set(G_OBJECT(glimagesink0), "client-draw-callback", drawCallback, NULL); g_object_set(G_OBJECT(glimagesink0), "client-draw-callback", drawCallback, NULL);
/* add elements */ /* add elements */
gst_bin_add_many (GST_BIN (pipeline), videosrc, decodebin, videoconvert, textoverlay, tee, gst_bin_add_many (GST_BIN (pipeline), videosrc, decodebin, videoconvert, textoverlay, tee,
queue0, glimagesink0, queue0, glimagesink0,
queue1, glfiltercube, glimagesink1, queue1, glfiltercube, glimagesink1,
queue2, glimagesink2, NULL); queue2, glimagesink2, NULL);
GstPad* textoverlay_sink_pad = gst_element_get_static_pad (textoverlay, "video_sink"); GstPad* textoverlay_sink_pad = gst_element_get_static_pad (textoverlay, "video_sink");
gst_pad_add_probe (textoverlay_sink_pad, GST_PAD_PROBE_TYPE_BUFFER, gst_pad_add_probe (textoverlay_sink_pad, GST_PAD_PROBE_TYPE_BUFFER,
(GstPadProbeCallback) textoverlay_sink_pad_probe_cb, (gpointer)textoverlay, NULL); (GstPadProbeCallback) textoverlay_sink_pad_probe_cb, (gpointer)textoverlay, NULL);
gst_object_unref (textoverlay_sink_pad); gst_object_unref (textoverlay_sink_pad);
if (!gst_element_link_many(videoconvert, textoverlay, tee, NULL)) if (!gst_element_link_many(videoconvert, textoverlay, tee, NULL))
{ {
g_print ("Failed to link videoconvert to tee!\n"); g_print ("Failed to link videoconvert to tee!\n");
return -1; return -1;
} }
if (!gst_element_link(videosrc, decodebin)) if (!gst_element_link(videosrc, decodebin))
{ {
g_print ("Failed to link videosrc to decodebin!\n"); g_print ("Failed to link videosrc to decodebin!\n");
return -1; return -1;
} }
g_signal_connect (decodebin, "pad-added", G_CALLBACK (cb_new_pad), videoconvert); g_signal_connect (decodebin, "pad-added", G_CALLBACK (cb_new_pad), videoconvert);
if (!gst_element_link_many(tee, queue0, NULL)) if (!gst_element_link_many(tee, queue0, NULL))
{ {
g_warning ("Failed to link one or more elements bettween tee and queue0!\n"); g_warning ("Failed to link one or more elements bettween tee and queue0!\n");
return -1; return -1;
@ -324,27 +323,27 @@ gint main (gint argc, gchar *argv[])
return -1 ; return -1 ;
} }
if (!gst_element_link_many(tee, queue1, glfiltercube, glimagesink1, NULL)) if (!gst_element_link_many(tee, queue1, glfiltercube, glimagesink1, NULL))
{ {
g_warning ("Failed to link one or more elements bettween tee and glimagesink1!\n"); g_warning ("Failed to link one or more elements bettween tee and glimagesink1!\n");
return -1; return -1;
} }
if (!gst_element_link_many(tee, queue2, glimagesink2, NULL)) if (!gst_element_link_many(tee, queue2, glimagesink2, NULL))
{ {
g_warning ("Failed to link one or more elements bettween tee and glimagesink2!\n"); g_warning ("Failed to link one or more elements bettween tee and glimagesink2!\n");
return -1; return -1;
} }
/* run */ /* run */
GstStateChangeReturn ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); GstStateChangeReturn ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (ret == GST_STATE_CHANGE_FAILURE) if (ret == GST_STATE_CHANGE_FAILURE)
{ {
g_print ("Failed to start up pipeline!\n"); g_print ("Failed to start up pipeline!\n");
/* check if there is an error message with details on the bus */ /* check if there is an error message with details on the bus */
GstMessage* msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0); GstMessage* msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0);
if (msg) if (msg)
{ {
GError *err = NULL; GError *err = NULL;
@ -363,6 +362,4 @@ gint main (gint argc, gchar *argv[])
gst_object_unref (pipeline); gst_object_unref (pipeline);
return 0; return 0;
} }

View file

@ -33,13 +33,13 @@ static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
{ {
GMainLoop *loop = (GMainLoop*)data; GMainLoop *loop = (GMainLoop*)data;
switch (GST_MESSAGE_TYPE (msg)) switch (GST_MESSAGE_TYPE (msg))
{ {
case GST_MESSAGE_EOS: case GST_MESSAGE_EOS:
g_print ("End-of-stream\n"); g_print ("End-of-stream\n");
g_main_loop_quit (loop); g_main_loop_quit (loop);
break; break;
case GST_MESSAGE_ERROR: case GST_MESSAGE_ERROR:
{ {
gchar *debug = NULL; gchar *debug = NULL;
GError *err = NULL; GError *err = NULL;
@ -49,7 +49,7 @@ static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
g_print ("Error: %s\n", err->message); g_print ("Error: %s\n", err->message);
g_error_free (err); g_error_free (err);
if (debug) if (debug)
{ {
g_print ("Debug details: %s\n", debug); g_print ("Debug details: %s\n", debug);
g_free (debug); g_free (debug);
@ -57,7 +57,7 @@ static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
g_main_loop_quit (loop); g_main_loop_quit (loop);
break; break;
} }
default: default:
break; break;
} }
@ -71,8 +71,8 @@ static void reshapeCallback (GLuint width, GLuint height)
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
gluPerspective(45, (gfloat)width/(gfloat)height, 0.1, 100); gluPerspective(45, (gfloat)width/(gfloat)height, 0.1, 100);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
} }
@ -80,22 +80,22 @@ static void reshapeCallback (GLuint width, GLuint height)
static gboolean drawCallback (GLuint width, GLuint height, GLuint texture, gpointer data) static gboolean drawCallback (GLuint width, GLuint height, GLuint texture, gpointer data)
{ {
static GLfloat xrot = 0; static GLfloat xrot = 0;
static GLfloat yrot = 0; static GLfloat yrot = 0;
static GLfloat zrot = 0; static GLfloat zrot = 0;
static GTimeVal current_time; static GTimeVal current_time;
static glong last_sec = current_time.tv_sec; static glong last_sec = current_time.tv_sec;
static gint nbFrames = 0; static gint nbFrames = 0;
g_get_current_time (&current_time); g_get_current_time (&current_time);
nbFrames++ ; nbFrames++ ;
if ((current_time.tv_sec - last_sec) >= 1) if ((current_time.tv_sec - last_sec) >= 1)
{ {
std::cout << "GRPHIC FPS = " << nbFrames << std::endl; std::cout << "GRPHIC FPS = " << nbFrames << std::endl;
nbFrames = 0; nbFrames = 0;
last_sec = current_time.tv_sec; last_sec = current_time.tv_sec;
} }
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glEnable (GL_TEXTURE_2D); glEnable (GL_TEXTURE_2D);
@ -109,7 +109,7 @@ static gboolean drawCallback (GLuint width, GLuint height, GLuint texture, gpoin
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
glTranslatef(0.0f,0.0f,-5.0f); glTranslatef(0.0f,0.0f,-5.0f);
glRotatef(xrot,1.0f,0.0f,0.0f); glRotatef(xrot,1.0f,0.0f,0.0f);
@ -159,8 +159,8 @@ static gboolean drawCallback (GLuint width, GLuint height, GLuint texture, gpoin
} }
//equivalent command line: //equivalent command line:
//gst-launch-1.0 videotestsrc num_buffers=400 ! gleffects effect=0 ! //gst-launch-1.0 videotestsrc num_buffers=400 ! gleffects effect=0 !
//avenc_mpeg4 ! avimux ! filesink location="record.avi" //avenc_mpeg4 ! avimux ! filesink location="record.avi"
// or // 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" ! //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" !
@ -193,7 +193,7 @@ gint main (gint argc, gchar *argv[])
filesink = gst_element_factory_make ("filesink", "filesink0"); filesink = gst_element_factory_make ("filesink", "filesink0");
if (!videosrc || !glfilterapp || !avenc_mpeg4 || !avimux || !filesink) if (!videosrc || !glfilterapp || !avenc_mpeg4 || !avimux || !filesink)
{ {
g_print ("one element could not be found \n"); g_print ("one element could not be found \n");
return -1; return -1;
@ -219,11 +219,11 @@ gint main (gint argc, gchar *argv[])
g_object_set(G_OBJECT(glfilterapp), "client-draw-callback", drawCallback, NULL); g_object_set(G_OBJECT(glfilterapp), "client-draw-callback", drawCallback, NULL);
g_object_set(G_OBJECT(glfilterapp), "client-data", NULL, NULL); g_object_set(G_OBJECT(glfilterapp), "client-data", NULL, NULL);
g_object_set(G_OBJECT(filesink), "location", "record.avi", NULL); g_object_set(G_OBJECT(filesink), "location", "record.avi", NULL);
/* add elements */ /* add elements */
gst_bin_add_many (GST_BIN (pipeline), videosrc, glfilterapp, gst_bin_add_many (GST_BIN (pipeline), videosrc, glfilterapp,
avenc_mpeg4, avimux, filesink, NULL); avenc_mpeg4, avimux, filesink, NULL);
/* link elements */ /* link elements */
gboolean link_ok = gst_element_link_filtered(videosrc, glfilterapp, caps) ; gboolean link_ok = gst_element_link_filtered(videosrc, glfilterapp, caps) ;
gst_caps_unref(caps) ; gst_caps_unref(caps) ;
@ -240,22 +240,22 @@ gint main (gint argc, gchar *argv[])
g_warning("Failed to link glfilterapp to avenc_mpeg4!\n") ; g_warning("Failed to link glfilterapp to avenc_mpeg4!\n") ;
return -1 ; return -1 ;
} }
if (!gst_element_link_many(avenc_mpeg4, avimux, filesink, NULL)) if (!gst_element_link_many(avenc_mpeg4, avimux, filesink, NULL))
{ {
g_print ("Failed to link one or more elements!\n"); g_print ("Failed to link one or more elements!\n");
return -1; return -1;
} }
/* run */ /* run */
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (ret == GST_STATE_CHANGE_FAILURE) if (ret == GST_STATE_CHANGE_FAILURE)
{ {
g_print ("Failed to start up pipeline!\n"); g_print ("Failed to start up pipeline!\n");
/* check if there is an error message with details on the bus */ /* check if there is an error message with details on the bus */
GstMessage* msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0); GstMessage* msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0);
if (msg) if (msg)
{ {
GError *err = NULL; GError *err = NULL;
@ -274,5 +274,4 @@ gint main (gint argc, gchar *argv[])
gst_object_unref (pipeline); gst_object_unref (pipeline);
return 0; return 0;
} }