Invalid property's type for a controller at runtime: `G_VALUE_TYPE (value) == self->priv->type' failed
Rossana Guerra
guerra.rossana at gmail.com
Wed Oct 26 16:37:02 PDT 2011
Well the error type disappeared, it was due where the place the
gst_controller_set_control_source (ctrl, "position", GST_CONTROL_SOURCE
(csource)) sentence was.
The first time I did it according the documentation, at the end of the value
sets of the control source. It seems it isn't the right place, I changed the
sentences right after creating the controller, it seems it works. Hope it
helps someone else.
In this way:
GstInterpolationControlSource * csource =
gst_interpolation_control_source_new();
gst_interpolation_control_source_set_interpolation_mode(csource,GST_INTERPOLATE_LINEAR);
gst_controller_set_control_source (ctrl, "position", GST_CONTROL_SOURCE
(csource));
(Now the runtime is another! but one less at least)
Specially thanks to Stefan!
Here is the complete code:
#include <gst.h>
#include <controller/gstcontroller.h>
#include <iostream>
#include <string.h>
using namespace std;
// Manejador de errores
static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;
switch (GST_MESSAGE_TYPE (msg))
{
case GST_MESSAGE_EOS:
g_print ("Final de stream\n");
g_main_loop_quit (loop);
break;
case GST_MESSAGE_ERROR:
{
gchar *debug;
GError *error;
gst_message_parse_error (msg, &error, &debug);
g_free (debug);
g_printerr ("Error: %s\n", error->message);
g_error_free (error);
g_main_loop_quit (loop);
break;
}
default:
break;
}
return TRUE;
}
static void on_pad_added (GstElement *element, GstPad *pad, gpointer data)
{
GstPad *sinkpad = NULL;
GstElement * elemento = (GstElement *) data;
/* Ahora linkeo el pad de comp con sink pad */
g_print ("Dynamic pad created, linking queue\n");
sinkpad = gst_element_get_static_pad (elemento, "sink");
gst_pad_link (pad, sinkpad);
gst_object_unref(sinkpad);
}
int main(int argc, char *argv[])
{
GMainLoop *loop = NULL;
GstElement *src1, *src2,*dec1,*dec2,*alfa1,*color,*smpte,*queue,*sink;
GstBus *bus;
gdouble duracion = 500.0;
gint transicion = 1;
cout << "Inicio..." << endl;
/* init GStreamer */
gst_init (&argc, &argv);
bool iniciado = gst_controller_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
//gint transicion = 1;
/* make sure we have input */
if (argc != 3) {
g_print ("Usage: %s <filename1> <filename2>\n", argv[0]);
return -1;
}
cout << "Creando..." << endl;
src1 = gst_element_factory_make("filesrc", "src1");
g_object_set(G_OBJECT(src1),"location",argv[1], NULL);
src2 = gst_element_factory_make("filesrc", "src2");
g_object_set(G_OBJECT(src1),"location",argv[2], NULL);
GstElement *pipeline = gst_pipeline_new ("video-player");
dec1 = gst_element_factory_make("decodebin2","dec1");
dec2 = gst_element_factory_make("decodebin2","dec2");
cout << "Creando pipeline..." << endl;
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
alfa1 = gst_element_factory_make ("alpha","alfa1");
smpte = gst_element_factory_make ("smptealpha","smpte");
g_object_set(smpte,"type", transicion, NULL);
color = gst_element_factory_make ("ffmpegcolorspace", "color");
GstElement * mixer = gst_element_factory_make("videomixer", "mixer");
if ((!alfa1) || (!smpte) || (!color) || (!mixer))
{
g_printerr ("Alguno de los elementos del Bin no pudo ser creado.
Saliendo\n");
return 0;
}
cout << "Creando 1..." << endl;
// Agrego Controlador
GstController * ctrl = gst_object_control_properties(G_OBJECT(smpte),
"position",NULL);
if (ctrl == NULL)
{
GST_WARNING ("No puede controlar el elemento fuente\n");
return 1;
}
// Todo valor GValue debe inicializarse en 0
GValue val_double = { 0, };
g_value_init (&val_double, G_TYPE_DOUBLE);
// Creo la fuente al controlador y la asocio al controlador
// Seteo modo de interpolacion
GstInterpolationControlSource * csource =
gst_interpolation_control_source_new();
gst_interpolation_control_source_set_interpolation_mode(csource,GST_INTERPOLATE_LINEAR);
gst_controller_set_control_source (ctrl, "position", GST_CONTROL_SOURCE
(csource));
// Seteo primer valor
g_value_set_double(&val_double, 0.0);
gst_interpolation_control_source_set(csource,(0 *
GST_MSECOND),&val_double);
// Seteo segundo valor
g_value_set_double(&val_double, 1.0);
gst_interpolation_control_source_set(csource,(duracion*GST_MSECOND),&val_double);
//gst_controller_set_control_source (ctrl, "position", GST_CONTROL_SOURCE
(csource));
g_object_unref (csource);
g_value_unset (&val_double);
g_signal_connect (G_OBJECT (dec1), "pad-added", G_CALLBACK
(on_pad_added),alfa1);
g_signal_connect (G_OBJECT (dec2), "pad-added", G_CALLBACK
(on_pad_added),smpte);
queue = gst_element_factory_make("queue", "queue");
sink = gst_element_factory_make("autovideosink", "sink");
gst_bin_add_many (GST_BIN (pipeline),src1, src2, dec1, dec2, alfa1, smpte,
mixer, queue, color, sink, NULL);
gst_element_link (src1,dec1);
gst_element_link (src2,dec2);
gst_element_link (alfa1,mixer);
gst_element_link (smpte,mixer);
gst_element_link (mixer,queue);
gst_element_link (queue,sink);
/* now run */
gst_element_set_state (pipeline, GST_STATE_PLAYING);
cout << "Playing..." << endl;
g_main_loop_run (loop);
/* also clean up */
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (GST_OBJECT (pipeline));
return 0;
}
2011/10/26 Rossana Guerra <guerra.rossana at gmail.com>
> Sorry, I had some copy/paste errors. Here's the code, the runtime error is:
>
> CRITICAL **: gst_interpolation_control_source_set: assertion `G_VALUE_TYPE
> (value) == self->priv->type' failed.
>
> I changed the duracion value variable unit to second (replacing 500 with
> 5), and I tryed with GST_SECOND insted, but it didn't work.
> So I wrote it back to GST_MSECOND.
>
> The code ΅without" typing errors:
>
>
> #include <gst.h>
> #include <controller/gstcontroller.h>
>
> #include <iostream>
> #include <string.h>
>
>
> using namespace std;
>
> // Manejador de errores
>
> static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
> {
> GMainLoop *loop = (GMainLoop *) data;
>
> switch (GST_MESSAGE_TYPE (msg))
> {
> case GST_MESSAGE_EOS:
> g_print ("Final de stream\n");
> g_main_loop_quit (loop);
> break;
> case GST_MESSAGE_ERROR:
> {
> gchar *debug;
> GError *error;
> gst_message_parse_error (msg, &error, &debug);
> g_free (debug);
> g_printerr ("Error: %s\n", error->message);
> g_error_free (error);
> g_main_loop_quit (loop);
> break;
> }
> default:
> break;
> }
> return TRUE;
> }
>
> static void on_pad_added (GstElement *element, GstPad *pad, gpointer data)
> {
> GstPad *sinkpad = NULL;
> GstElement * elemento = (GstElement *) data;
>
>
> /* Ahora linkeo el pad de comp con sink pad */
> g_print ("Dynamic pad created, linking queue\n");
> sinkpad = gst_element_get_static_pad (elemento, "sink");
>
>
> gst_pad_link (pad, sinkpad);
> gst_object_unref(sinkpad);
>
> }
>
>
> int main(int argc, char *argv[])
> {
>
> GMainLoop *loop = NULL;
>
> GstElement *src1, *src2,*dec1,*dec2,*alfa1,*color,*smpte,*queue,*sink;
> GstBus *bus;
>
> guint duracion = 500;
> gint transicion = 1;
>
> cout << "Inicio..." << endl;
>
>
> /* init GStreamer */
> gst_init (&argc, &argv);
> bool iniciado = gst_controller_init (&argc, &argv);
>
> loop = g_main_loop_new (NULL, FALSE);
>
> if (argc != 3) {
> g_print ("Usage: %s <filename1> <filename2>\n", argv[0]);
> return -1;
> }
>
> cout << "Creando..." << endl;
>
> src1 = gst_element_factory_make("filesrc", "src1");
> g_object_set(G_OBJECT(src1),"location",argv[1], NULL);
>
> src2 = gst_element_factory_make("filesrc", "src2");
> g_object_set(G_OBJECT(src1),"location",argv[2], NULL);
>
> GstElement *pipeline = gst_pipeline_new ("video-player");
>
> dec1 = gst_element_factory_make("decodebin2","dec1");
>
> dec2 = gst_element_factory_make("decodebin2","dec2");
>
> cout << "Creando pipeline..." << endl;
>
> bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
> gst_bus_add_watch (bus, bus_call, loop);
> gst_object_unref (bus);
>
> alfa1 = gst_element_factory_make ("alpha","alfa1");
> smpte = gst_element_factory_make ("smptealpha","smpte");
> g_object_set(smpte,"type", transicion, NULL);
> color = gst_element_factory_make ("ffmpegcolorspace", "color");
> GstElement * mixer = gst_element_factory_make("videomixer", "mixer");
>
> if ((!alfa1) || (!smpte) || (!color) || (!mixer))
> {
> g_printerr ("Alguno de los elementos del Bin no pudo ser creado.
> Saliendo\n");
> return 0;
> }
>
>
> // Agrego Controlador
>
>
> GstController * ctrl = gst_object_control_properties(G_OBJECT(smpte),
> "position",NULL);
>
> if (ctrl == NULL)
> {
> GST_WARNING ("No puede controlar el elemento fuente\n");
> return 1;
> }
>
> // Todo valor GValue debe inicializarse en 0
> GValue val_int = { 0, };
> g_value_init (&val_int, G_TYPE_INT);
>
>
> // Set interpolation mode
>
> GstInterpolationControlSource * csource =
> gst_interpolation_control_source_new();
>
>
> gst_interpolation_control_source_set_interpolation_mode(csource,GST_INTERPOLATE_LINEAR);
>
> // Seteo primer valor
> g_value_set_int(&val_int, 0);
> gst_interpolation_control_source_set(csource,(0 * GST_MSECOND),&val_int);
>
> // Seteo segundo valor
> g_value_set_int (&val_int, 1);
>
> gst_interpolation_control_source_set(csource,(duracion*GST_MSECOND),&val_int);
>
>
> gst_controller_set_control_source (ctrl, "position", GST_CONTROL_SOURCE
> (csource));
>
> g_object_unref (csource);
> g_value_unset (&val_int);
>
>
> g_signal_connect (G_OBJECT (dec1), "pad-added", G_CALLBACK
> (on_pad_added),alfa1);
> g_signal_connect (G_OBJECT (dec2), "pad-added", G_CALLBACK
> (on_pad_added),smpte);
>
> queue = gst_element_factory_make("queue", "queue");
> sink = gst_element_factory_make("autovideosink", "sink");
>
> gst_bin_add_many (GST_BIN (pipeline),src1, src2, dec1, dec2, alfa1,
> smpte, mixer, queue, color, sink, NULL);
>
> gst_element_link (src1,dec1);
> gst_element_link (src2,dec2);
> gst_element_link (alfa1,mixer);
> gst_element_link (smpte,mixer);
> gst_element_link (mixer,queue);
> gst_element_link (queue,sink);
>
>
> /* now run */
> gst_element_set_state (pipeline, GST_STATE_PLAYING);
> cout << "Playing..." << endl;
> g_main_loop_run (loop);
>
> /* also clean up */
> gst_element_set_state (pipeline, GST_STATE_NULL);
> gst_object_unref (GST_OBJECT (pipeline));
>
> return 0;
> }
>
>
>
>
>
>
>
>
> 2011/10/26 Rossana Guerra <guerra.rossana at gmail.com>
>
>> Where it says guint duration = 500.0 it should say guint duration = 500.
>> Nonetheless, the error persists.
>>
>>
>> 2011/10/26 Rossana Guerra <guerra.rossana at gmail.com>
>>
>>> HI Stefan, thanks for your help, I changed the variable type from gdouble
>>> to guint, same error.
>>>
>>> Here's the whole code example:
>>>
>>>
>>> #include <gst.h>
>>> #include <controller/gstcontroller.h>
>>> #include <iostream>
>>>
>>>
>>> using namespace std;
>>>
>>> // Error handler
>>> static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
>>> {
>>> GMainLoop *loop = (GMainLoop *) data;
>>>
>>> switch (GST_MESSAGE_TYPE (msg))
>>> {
>>> case GST_MESSAGE_EOS:
>>> g_print ("Final de stream\n");
>>> g_main_loop_quit (loop);
>>> break;
>>> case GST_MESSAGE_ERROR:
>>> {
>>> gchar *debug;
>>> GError *error;
>>> gst_message_parse_error (msg, &error, &debug);
>>> g_free (debug);
>>> g_printerr ("Error: %s\n", error->message);
>>> g_error_free (error);
>>> g_main_loop_quit (loop);
>>> break;
>>> }
>>> default:
>>> break;
>>> }
>>> return TRUE;
>>> }
>>>
>>> static void on_pad_added (GstElement *element, GstPad *pad, gpointer
>>> data)
>>> {
>>> GstPad *sinkpad = NULL;
>>> GstElement * elemento = (GstElement *) data;
>>>
>>>
>>> /* Ahora linkeo el pad de comp con sink pad */
>>> g_print ("Dynamic pad created, linking queue\n");
>>> sinkpad = gst_element_get_static_pad (elemento, "sink");
>>>
>>>
>>> gst_pad_link (pad, sinkpad);
>>> gst_object_unref(sinkpad);
>>>
>>> }
>>>
>>>
>>> int main(int argc, char *argv[])
>>> {
>>>
>>> GMainLoop *loop = NULL;
>>>
>>> GstElement *src1, *src2,*dec1,*dec2,*alfa1,*color,*smpte,*queue,*sink;
>>> GstBus *bus;
>>>
>>> guint duracion = 500.0;
>>> guint transicion = 1;
>>>
>>>
>>> /* init GStreamer */
>>> gst_init (&argc, &argv);
>>> bool iniciado = gst_controller_init (&argc, &argv);
>>>
>>>
>>>
>>> loop = g_main_loop_new (NULL, FALSE);
>>>
>>> /* make sure we have input */
>>> if (argc != 3) {
>>> g_print ("Usage: %s <filename1> <filename2>\n", argv[0]);
>>> return -1;
>>> }
>>>
>>> src1 = gst_element_factory_make("filesrc", "src1");
>>> g_object_set(G_OBJECT(src1),"location",argv[1], NULL);
>>>
>>> src2 = gst_element_factory_make("filesrc", "src2");
>>> g_object_set(G_OBJECT(src1),"location",argv[2], NULL);
>>>
>>> GstElement *pipeline = gst_pipeline_new ("video-player");
>>>
>>> dec1 = gst_element_factory_make("decodebin2","dec1");
>>>
>>> dec2 = gst_element_factory_make("decodebin2","dec2");
>>>
>>> cout << "Creando pipeline..." << endl;
>>>
>>> bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
>>> gst_bus_add_watch (bus, bus_call, loop);
>>> gst_object_unref (bus);
>>>
>>> alfa1 = gst_element_factory_make ("alpha","alfa1");
>>> smpte = gst_element_factory_make ("smptealpha","smpte");
>>> g_object_set(smpte,"type", transicion, NULL);
>>> color = gst_element_factory_make ("ffmpegcolorspace", "color");
>>> GstElement * mixer = gst_element_factory_make("videomixer", "mixer");
>>>
>>> if ((!alfa1) || (!smpte) || (!color) || (!mixer))
>>> {
>>> g_printerr ("Alguno de los elementos del Bin no pudo ser creado.
>>> Saliendo\n");
>>> return 0;
>>> }
>>>
>>>
>>> // Controller creation
>>>
>>>
>>> GstController * ctrl = gst_object_control_properties(G_OBJECT(smpte),
>>> "position",NULL);
>>>
>>> if (ctrl == NULL)
>>> {
>>> GST_WARNING ("No puede controlar el elemento fuente\n");
>>> return 1;
>>> }
>>>
>>> // Todo valor GValue debe inicializarse en 0
>>> GValue val_double = { 0, };
>>> g_value_init (&val_double, G_TYPE_DOUBLE);
>>>
>>> // Set interpolation mode
>>>
>>>
>>> GstInterpolationControlSource * csource =
>>> gst_interpolation_control_source_new();
>>>
>>>
>>> gst_interpolation_control_source_set_interpolation_mode(csource,GST_INTERPOLATE_LINEAR);
>>>
>>> // Seteo primer valor
>>> g_value_set_double(&val_double, 0.0);
>>> gst_interpolation_control_source_set(csource,(0 *
>>> GST_MSECOND),&val_double);
>>>
>>> // Seteo segundo valor
>>> g_value_set_double (&val_double, 1.0);
>>>
>>> gst_interpolation_control_source_set(csource,(duracion*GST_MSECOND),&val_double);
>>>
>>> gst_controller_set_control_source (ctrl, "position", GST_CONTROL_SOURCE
>>> (csource));
>>>
>>> g_object_unref (csource);
>>> g_value_unset (&val_double);
>>>
>>> g_signal_connect (G_OBJECT (dec1), "pad-added", G_CALLBACK
>>> (on_pad_added),alfa1);
>>> g_signal_connect (G_OBJECT (dec2), "pad-added", G_CALLBACK
>>> (on_pad_added),smpte);
>>>
>>> queue = gst_element_factory_make("queue", "queue");
>>> sink = gst_element_factory_make("autovideosink", "sink");
>>>
>>> gst_bin_add_many (GST_BIN (pipeline),src1, src2, dec1, dec2, alfa1,
>>> smpte, mixer, queue, color, sink, NULL);
>>>
>>> gst_element_link (src1,dec1);
>>> gst_element_link (src2,dec2);
>>> gst_element_link (alfa1,mixer);
>>> gst_element_link (smpte,mixer);
>>> gst_element_link (mixer,queue);
>>> gst_element_link (queue,sink);
>>>
>>>
>>> /* now run */
>>> gst_element_set_state (pipeline, GST_STATE_PLAYING);
>>> cout << "Playing..." << endl;
>>> g_main_loop_run (loop);
>>>
>>> /* also clean up */
>>> gst_element_set_state (pipeline, GST_STATE_NULL);
>>> gst_object_unref (GST_OBJECT (pipeline));
>>>
>>> return 0;
>>>
>>> }
>>>
>>>
>>>
>>>
>>>
>>>
>>> 2011/10/26 Stefan Sauer <ensonic at hora-obscura.de>
>>>
>>>> **
>>>> On 10/26/2011 03:12 AM, Rossana Guerra wrote:
>>>>
>>>> Hi I trying to control the position property of a smptealpha element. It
>>>> controls the opacity of the alpha channel,
>>>>
>>>> no, position controls the transition of the fade. 0.0:input1,
>>>> 1.0:input2.
>>>>
>>>> it varies from 0.0 to 1.0.
>>>> The duration of this setting is 500ms.
>>>>
>>>> I am working around this problem, it happens at runtime, I can't figure out
>>>> what it's wrong.
>>>>
>>>>
>>>> What is not working? The code snippet looks more of less okay. Maybe you
>>>> can post a full standalone example.
>>>>
>>>> Stefan
>>>>
>>>> Thanks and regards,
>>>>
>>>> Rossana
>>>>
>>>>
>>>> Here's the code;
>>>> _____________
>>>>
>>>>
>>>> gst_interpolation_control_source_set: assertion `G_VALUE_TYPE (value) ==
>>>> self->priv->type' failed
>>>>
>>>> // Agrego Controlador
>>>>
>>>> gdouble duracion = 500;
>>>>
>>>> guint64 duracion = 500;
>>>>
>>>> GstController * ctrl = gst_object_control_properties(G_OBJECT(smpte),
>>>> "position",NULL);
>>>>
>>>> if (ctrl == NULL)
>>>> {
>>>> GST_WARNING ("No puede controlar el elemento fuente\n");
>>>> return 0;
>>>> }
>>>>
>>>>
>>>> // Todo valor GValue debe inicializarse en 0
>>>> GValue val_double = { 0, };
>>>> g_value_init (&val_double, G_TYPE_DOUBLE);
>>>>
>>>>
>>>> // Seteo modo de interpolacion
>>>>
>>>> GstInterpolationControlSource * csource =
>>>> gst_interpolation_control_source_new();
>>>>
>>>>
>>>> gst_interpolation_control_source_set_interpolation_mode(csource,GST_INTERPOLATE_LINEAR);
>>>>
>>>> // Seteo primer valor
>>>> g_value_set_double(&val_double, 0.0);
>>>> gst_interpolation_control_source_set(csource,(0 *
>>>> GST_MSECOND),&val_double);
>>>>
>>>> // Seteo segundo valor
>>>> g_value_set_double (&val_double, 1.0);
>>>>
>>>> gst_interpolation_control_source_set(csource,(duracion*GST_MSECOND),&val_double);
>>>>
>>>> gst_controller_set_control_source (ctrl, "position", GST_CONTROL_SOURCE
>>>> (csource));
>>>>
>>>> g_object_unref (csource);
>>>> g_value_unset (&val_double);
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> gstreamer-devel mailing listgstreamer-devel at lists.freedesktop.orghttp://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> gstreamer-devel mailing list
>>>> gstreamer-devel at lists.freedesktop.org
>>>> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20111026/4bfad3a4/attachment-0001.html>
More information about the gstreamer-devel
mailing list