mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 14:56:36 +00:00
gl/examples/generic: remove trailing whitespaces
This commit is contained in:
parent
ea7c8f9771
commit
f29a98cc5f
4 changed files with 84 additions and 93 deletions
|
@ -75,7 +75,6 @@ static void reshapeCallback (GLuint width, GLuint height, gpointer data)
|
|||
}
|
||||
|
||||
//client draw callback
|
||||
|
||||
static gboolean drawCallback (GLuint texture, GLuint width, GLuint height, gpointer data)
|
||||
{
|
||||
static GLfloat xrot = 0;
|
||||
|
@ -244,5 +243,4 @@ gint main (gint argc, gchar *argv[])
|
|||
gst_object_unref (pipeline);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
|
|
@ -33,13 +33,13 @@ static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
|
|||
{
|
||||
GMainLoop *loop = (GMainLoop*)data;
|
||||
|
||||
switch (GST_MESSAGE_TYPE (msg))
|
||||
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:
|
||||
case GST_MESSAGE_ERROR:
|
||||
{
|
||||
gchar *debug = 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_error_free (err);
|
||||
|
||||
if (debug)
|
||||
if (debug)
|
||||
{
|
||||
g_print ("Debug deails: %s\n", debug);
|
||||
g_free (debug);
|
||||
|
@ -57,7 +57,7 @@ static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
|
|||
|
||||
g_main_loop_quit (loop);
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ static void identityCallback (GstElement *src, GstBuffer *buffer, GstElement* t
|
|||
static GstClockTime last_timestamp = 0;
|
||||
static gint nbFrames = 0 ;
|
||||
|
||||
//display estimated video FPS
|
||||
//display estimated video FPS
|
||||
nbFrames++ ;
|
||||
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()) ;
|
||||
g_object_set(G_OBJECT(textoverlay), "text", s.c_str(), NULL);
|
||||
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);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(45, (gfloat)width/(gfloat)height, 0.1, 100);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
gluPerspective(45, (gfloat)width/(gfloat)height, 0.1, 100);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
|
||||
//client draw callback
|
||||
static gboolean drawCallback (GLuint texture, GLuint width, GLuint height)
|
||||
{
|
||||
|
||||
static GLfloat xrot = 0;
|
||||
static GLfloat yrot = 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;
|
||||
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);
|
||||
|
@ -131,7 +130,7 @@ static gboolean drawCallback (GLuint texture, GLuint width, GLuint height)
|
|||
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);
|
||||
|
@ -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, (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;
|
||||
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)
|
||||
{
|
||||
GstPad* identity_pad = gst_element_get_static_pad (identity, "sink");
|
||||
|
||||
//only link once
|
||||
if (GST_PAD_IS_LINKED (identity_pad))
|
||||
|
||||
//only link once
|
||||
if (GST_PAD_IS_LINKED (identity_pad))
|
||||
{
|
||||
gst_object_unref (identity_pad);
|
||||
return;
|
||||
|
@ -202,7 +201,7 @@ static void cb_new_pad (GstElement* decodebin, GstPad* pad, GstElement* identity
|
|||
|
||||
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"))
|
||||
if (!g_strrstr (gst_structure_get_name (str), "video"))
|
||||
{
|
||||
gst_caps_unref (caps);
|
||||
gst_object_unref (identity_pad);
|
||||
|
@ -211,8 +210,8 @@ static void cb_new_pad (GstElement* decodebin, GstPad* pad, GstElement* identity
|
|||
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");
|
||||
if (ret != GST_PAD_LINK_OK)
|
||||
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");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
std::string video_location(argv[1]);
|
||||
|
||||
|
||||
/* initialization */
|
||||
gst_init (&argc, &argv);
|
||||
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(glimagesink), "client-reshape-callback", reshapeCallback, NULL);
|
||||
g_object_set(G_OBJECT(glimagesink), "client-draw-callback", drawCallback, NULL);
|
||||
|
||||
|
||||
/* add elements */
|
||||
gst_bin_add_many (GST_BIN (pipeline), videosrc, decodebin, identity,
|
||||
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);
|
||||
|
||||
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");
|
||||
return -1;
|
||||
|
@ -292,16 +291,16 @@ gint main (gint argc, gchar *argv[])
|
|||
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)
|
||||
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)
|
||||
if (msg)
|
||||
{
|
||||
GError *err = NULL;
|
||||
|
||||
|
@ -320,6 +319,4 @@ gint main (gint argc, gchar *argv[])
|
|||
gst_object_unref (pipeline);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -33,13 +33,13 @@ static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
|
|||
{
|
||||
GMainLoop *loop = (GMainLoop*)data;
|
||||
|
||||
switch (GST_MESSAGE_TYPE (msg))
|
||||
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:
|
||||
case GST_MESSAGE_ERROR:
|
||||
{
|
||||
gchar *debug = 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_error_free (err);
|
||||
|
||||
if (debug)
|
||||
if (debug)
|
||||
{
|
||||
g_print ("Debug details: %s\n", debug);
|
||||
g_free (debug);
|
||||
|
@ -57,7 +57,7 @@ static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
|
|||
|
||||
g_main_loop_quit (loop);
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -72,16 +72,16 @@ static GstPadProbeReturn textoverlay_sink_pad_probe_cb (GstPad *pad, GstPadProbe
|
|||
static GstClockTime last_timestamp = 0;
|
||||
static gint nbFrames = 0 ;
|
||||
|
||||
//display estimated video FPS
|
||||
//display estimated video FPS
|
||||
nbFrames++ ;
|
||||
if (GST_BUFFER_TIMESTAMP(info->data) - last_timestamp >= 1000000000)
|
||||
{
|
||||
std::ostringstream oss ;
|
||||
std::ostringstream oss;
|
||||
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);
|
||||
last_timestamp = GST_BUFFER_TIMESTAMP(info->data) ;
|
||||
nbFrames = 0 ;
|
||||
nbFrames = 0;
|
||||
}
|
||||
|
||||
return GST_PAD_PROBE_OK;
|
||||
|
@ -94,8 +94,8 @@ static void reshapeCallback (GLuint width, GLuint height)
|
|||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(45, (gfloat)width/(gfloat)height, 0.1, 100);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
gluPerspective(45, (gfloat)width/(gfloat)height, 0.1, 100);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
|
||||
|
@ -103,15 +103,15 @@ static void reshapeCallback (GLuint width, GLuint height)
|
|||
static gboolean drawCallback (GLuint texture, GLuint width, GLuint height)
|
||||
{
|
||||
static GLfloat xrot = 0;
|
||||
static GLfloat yrot = 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;
|
||||
static gint nbFrames = 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;
|
||||
|
@ -132,7 +132,7 @@ static gboolean drawCallback (GLuint texture, GLuint width, GLuint height)
|
|||
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);
|
||||
|
@ -193,9 +193,9 @@ static gboolean drawCallback (GLuint texture, GLuint width, GLuint height)
|
|||
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))
|
||||
|
||||
//only link once
|
||||
if (!element_pad || GST_PAD_IS_LINKED (element_pad))
|
||||
{
|
||||
gst_object_unref (element_pad);
|
||||
return;
|
||||
|
@ -203,11 +203,11 @@ static void cb_new_pad (GstElement* decodebin, GstPad* pad, GstElement* element)
|
|||
|
||||
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"))
|
||||
|
||||
if (!g_strrstr (gst_structure_get_name (str), "video"))
|
||||
{
|
||||
gst_caps_unref (caps);
|
||||
gst_object_unref (element_pad);
|
||||
|
@ -216,7 +216,7 @@ static void cb_new_pad (GstElement* decodebin, GstPad* pad, GstElement* element)
|
|||
gst_caps_unref (caps);
|
||||
|
||||
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);
|
||||
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[])
|
||||
{
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
g_warning ("usage: doublecube.exe videolocation\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
std::string video_location(argv[1]);
|
||||
|
||||
/* initialization */
|
||||
|
@ -267,7 +266,7 @@ gint main (gint argc, gchar *argv[])
|
|||
if (!videosrc || !decodebin || !videoconvert || !textoverlay || !tee ||
|
||||
!queue0 || !glimagesink0 ||
|
||||
!queue1 || !glfiltercube || !glimagesink1 ||
|
||||
!queue2 || !glimagesink2)
|
||||
!queue2 || !glimagesink2)
|
||||
{
|
||||
g_warning ("one element could not be found \n");
|
||||
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(glimagesink0), "client-reshape-callback", reshapeCallback, NULL);
|
||||
g_object_set(G_OBJECT(glimagesink0), "client-draw-callback", drawCallback, NULL);
|
||||
|
||||
|
||||
/* add elements */
|
||||
gst_bin_add_many (GST_BIN (pipeline), videosrc, decodebin, videoconvert, textoverlay, tee,
|
||||
queue0, glimagesink0,
|
||||
queue1, glfiltercube, glimagesink1,
|
||||
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,
|
||||
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))
|
||||
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))
|
||||
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))
|
||||
|
||||
if (!gst_element_link_many(tee, queue0, NULL))
|
||||
{
|
||||
g_warning ("Failed to link one or more elements bettween tee and queue0!\n");
|
||||
return -1;
|
||||
|
@ -324,27 +323,27 @@ gint main (gint argc, gchar *argv[])
|
|||
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");
|
||||
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");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* run */
|
||||
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");
|
||||
|
||||
/* check if there is an error message with details on the bus */
|
||||
GstMessage* msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0);
|
||||
if (msg)
|
||||
if (msg)
|
||||
{
|
||||
GError *err = NULL;
|
||||
|
||||
|
@ -363,6 +362,4 @@ gint main (gint argc, gchar *argv[])
|
|||
gst_object_unref (pipeline);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -33,13 +33,13 @@ static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
|
|||
{
|
||||
GMainLoop *loop = (GMainLoop*)data;
|
||||
|
||||
switch (GST_MESSAGE_TYPE (msg))
|
||||
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:
|
||||
case GST_MESSAGE_ERROR:
|
||||
{
|
||||
gchar *debug = 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_error_free (err);
|
||||
|
||||
if (debug)
|
||||
if (debug)
|
||||
{
|
||||
g_print ("Debug details: %s\n", debug);
|
||||
g_free (debug);
|
||||
|
@ -57,7 +57,7 @@ static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
|
|||
|
||||
g_main_loop_quit (loop);
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -71,8 +71,8 @@ static void reshapeCallback (GLuint width, GLuint height)
|
|||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(45, (gfloat)width/(gfloat)height, 0.1, 100);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
gluPerspective(45, (gfloat)width/(gfloat)height, 0.1, 100);
|
||||
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 GLfloat xrot = 0;
|
||||
static GLfloat yrot = 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;
|
||||
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);
|
||||
|
@ -109,7 +109,7 @@ static gboolean drawCallback (GLuint width, GLuint height, GLuint texture, gpoin
|
|||
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);
|
||||
|
@ -159,8 +159,8 @@ static gboolean drawCallback (GLuint width, GLuint height, GLuint texture, gpoin
|
|||
}
|
||||
|
||||
|
||||
//equivalent command line:
|
||||
//gst-launch-1.0 videotestsrc num_buffers=400 ! gleffects effect=0 !
|
||||
//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" !
|
||||
|
@ -193,7 +193,7 @@ gint main (gint argc, gchar *argv[])
|
|||
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");
|
||||
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-data", NULL, NULL);
|
||||
g_object_set(G_OBJECT(filesink), "location", "record.avi", NULL);
|
||||
|
||||
|
||||
/* 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);
|
||||
|
||||
|
||||
/* link elements */
|
||||
gboolean link_ok = gst_element_link_filtered(videosrc, glfilterapp, 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") ;
|
||||
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");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* run */
|
||||
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");
|
||||
|
||||
/* check if there is an error message with details on the bus */
|
||||
GstMessage* msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0);
|
||||
if (msg)
|
||||
if (msg)
|
||||
{
|
||||
GError *err = NULL;
|
||||
|
||||
|
@ -274,5 +274,4 @@ gint main (gint argc, gchar *argv[])
|
|||
gst_object_unref (pipeline);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue