mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 17:50:36 +00:00
gl/examples: fix recordgraphic example
Not ported to proper modern OpenGL though but that is the case for a lot of the GL examples. Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/issues/859 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1016>
This commit is contained in:
parent
abb026ec6a
commit
4caab55109
1 changed files with 34 additions and 15 deletions
|
@ -65,7 +65,7 @@ static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
|
||||||
}
|
}
|
||||||
|
|
||||||
//client draw callback
|
//client draw callback
|
||||||
static gboolean drawCallback (void *filter, void *context, GLuint texture, GLuint width, GLuint height, gpointer data)
|
static gboolean drawCallback (void *filter, GLuint texture, GLuint width, GLuint height, gpointer data)
|
||||||
{
|
{
|
||||||
static GLfloat xrot = 0;
|
static GLfloat xrot = 0;
|
||||||
static GLfloat yrot = 0;
|
static GLfloat yrot = 0;
|
||||||
|
@ -98,7 +98,7 @@ static gboolean drawCallback (void *filter, void *context, GLuint texture, GLuin
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
glTranslatef(0.0f,0.0f,-5.0f);
|
glScalef (0.5f, 0.5f, 0.5f);
|
||||||
|
|
||||||
glRotatef(xrot,1.0f,0.0f,0.0f);
|
glRotatef(xrot,1.0f,0.0f,0.0f);
|
||||||
glRotatef(yrot,0.0f,1.0f,0.0f);
|
glRotatef(yrot,0.0f,1.0f,0.0f);
|
||||||
|
@ -138,6 +138,9 @@ static gboolean drawCallback (void *filter, void *context, GLuint texture, GLuin
|
||||||
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
|
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
|
glDisable (GL_DEPTH_TEST);
|
||||||
|
glDisable (GL_TEXTURE_2D);
|
||||||
|
|
||||||
xrot+=0.3f;
|
xrot+=0.3f;
|
||||||
yrot+=0.2f;
|
yrot+=0.2f;
|
||||||
zrot+=0.4f;
|
zrot+=0.4f;
|
||||||
|
@ -156,10 +159,13 @@ static gboolean drawCallback (void *filter, void *context, GLuint texture, GLuin
|
||||||
gint main (gint argc, gchar *argv[])
|
gint main (gint argc, gchar *argv[])
|
||||||
{
|
{
|
||||||
GstStateChangeReturn ret;
|
GstStateChangeReturn ret;
|
||||||
GstElement *pipeline, *videosrc, *glfilterapp, *avenc_mpeg4, *avimux, *filesink;
|
GstElement *pipeline, *videosrc, *glupload, *glfilterapp, *glcolorconvert, *gldownload, *avenc_mpeg4, *avimux, *filesink;
|
||||||
GMainLoop *loop;
|
GMainLoop *loop;
|
||||||
GstBus *bus;
|
GstBus *bus;
|
||||||
|
|
||||||
|
/* FIXME: remove once the example supports gl3 and/or gles2 */
|
||||||
|
g_setenv ("GST_GL_API", "opengl", FALSE);
|
||||||
|
|
||||||
/* initialization */
|
/* initialization */
|
||||||
gst_init (&argc, &argv);
|
gst_init (&argc, &argv);
|
||||||
loop = g_main_loop_new (NULL, FALSE);
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
|
@ -175,13 +181,15 @@ gint main (gint argc, gchar *argv[])
|
||||||
|
|
||||||
/* create elements */
|
/* create elements */
|
||||||
videosrc = gst_element_factory_make ("videotestsrc", "videotestsrc0");
|
videosrc = gst_element_factory_make ("videotestsrc", "videotestsrc0");
|
||||||
|
glupload = gst_element_factory_make("glupload", "glupload0");
|
||||||
glfilterapp = gst_element_factory_make ("glfilterapp", "glfilterapp0");
|
glfilterapp = gst_element_factory_make ("glfilterapp", "glfilterapp0");
|
||||||
|
glcolorconvert = gst_element_factory_make ("glcolorconvert", "glcolorconvert0");
|
||||||
|
gldownload = gst_element_factory_make("gldownload", "gldownload0");
|
||||||
avenc_mpeg4 = gst_element_factory_make ("avenc_mpeg4", "avenc_mpeg40");
|
avenc_mpeg4 = gst_element_factory_make ("avenc_mpeg4", "avenc_mpeg40");
|
||||||
avimux = gst_element_factory_make ("avimux", "avimux0");
|
avimux = gst_element_factory_make ("avimux", "avimux0");
|
||||||
filesink = gst_element_factory_make ("filesink", "filesink0");
|
filesink = gst_element_factory_make ("filesink", "filesink0");
|
||||||
|
|
||||||
|
if (!videosrc || !glupload || !glfilterapp || !glcolorconvert || !gldownload || !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;
|
||||||
|
@ -189,7 +197,6 @@ gint main (gint argc, gchar *argv[])
|
||||||
|
|
||||||
/* change video source caps */
|
/* change video source caps */
|
||||||
GstCaps *caps = gst_caps_new_simple("video/x-raw",
|
GstCaps *caps = gst_caps_new_simple("video/x-raw",
|
||||||
"format", G_TYPE_STRING, "UYVY",
|
|
||||||
"width", G_TYPE_INT, 320,
|
"width", G_TYPE_INT, 320,
|
||||||
"height", G_TYPE_INT, 240,
|
"height", G_TYPE_INT, 240,
|
||||||
"framerate", GST_TYPE_FRACTION, 25, 1,
|
"framerate", GST_TYPE_FRACTION, 25, 1,
|
||||||
|
@ -207,32 +214,44 @@ gint main (gint argc, gchar *argv[])
|
||||||
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, glupload, glfilterapp,
|
||||||
avenc_mpeg4, avimux, filesink, NULL);
|
glcolorconvert, gldownload, 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, glupload, caps) ;
|
||||||
gst_caps_unref(caps) ;
|
gst_caps_unref(caps) ;
|
||||||
if(!link_ok)
|
if(!link_ok)
|
||||||
{
|
{
|
||||||
g_warning("Failed to link videosrc to glfilterapp!\n") ;
|
g_warning("Failed to link videosrc to glfilterapp!") ;
|
||||||
return -1 ;
|
return -1 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
link_ok = gst_element_link_filtered(glfilterapp, avenc_mpeg4, outcaps) ;
|
if (!gst_element_link (glupload, glfilterapp)) {
|
||||||
|
g_warning("Failed to link glupload to glfilterapp!") ;
|
||||||
|
return -1 ;
|
||||||
|
}
|
||||||
|
if (!gst_element_link (glfilterapp, glcolorconvert)) {
|
||||||
|
g_warning("Failed to link glfilterapp to glcolorconvert!") ;
|
||||||
|
return -1 ;
|
||||||
|
}
|
||||||
|
if (!gst_element_link (glcolorconvert, gldownload)) {
|
||||||
|
g_warning("Failed to link glfilterapp to glcolorconvert!") ;
|
||||||
|
return -1 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
link_ok = gst_element_link_filtered(gldownload, avenc_mpeg4, outcaps);
|
||||||
gst_caps_unref(outcaps) ;
|
gst_caps_unref(outcaps) ;
|
||||||
if(!link_ok)
|
if(!link_ok)
|
||||||
{
|
{
|
||||||
g_warning("Failed to link glfilterapp to avenc_mpeg4!\n") ;
|
g_warning("Failed to link glfilterapp to avenc_mpeg4!") ;
|
||||||
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_warning ("Failed to link one or more elements!");
|
||||||
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)
|
||||||
|
@ -246,7 +265,7 @@ gint main (gint argc, gchar *argv[])
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
|
|
||||||
gst_message_parse_error (msg, &err, NULL);
|
gst_message_parse_error (msg, &err, NULL);
|
||||||
g_print ("ERROR: %s\n", err->message);
|
g_warning ("ERROR: %s", err->message);
|
||||||
g_error_free (err);
|
g_error_free (err);
|
||||||
gst_message_unref (msg);
|
gst_message_unref (msg);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue