gst_controller_new returns NULL

Stefan Sauer ensonic at hora-obscura.de
Tue Oct 25 01:28:50 PDT 2011


On 10/25/2011 08:06 AM, Rossana Guerra wrote:
> Hello everyone, I am translating the following code to C/C++:
> http://notes.brooks.nu/2011/01/python-gstreamer-controller/
> It's a controller for controlling the alpha channel during crossfade,
> I adapted it for transitions, using, smpte instead.

smptealpha does not have a property called "alpha". Only "border" and
"invert" are controllable right now.

Stefan
>
> The fact is it returns NULL and the programs stop running. The code is
> below, I appreciate any suggestion.
> I am a bit clueless is an adaptation of a code I did before and it works.
>
> Thanks and regards.
>
> Rossana
>
> //// the code
>
> #include <gst.h>
> #include <controller/gstcontroller.h>
>
> #include <iostream>
>
>
> using namespace std;
>
> // Manejador de errores
> static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
> {
> ::::::::::::::::::::::::................
> }
>
> 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;
>   gint transicion = 1;
>
>   cout << "Inicio..." << endl;
>
>     /* init GStreamer */
>   gst_init (&argc, &argv);
>   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");
>
>   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");
>   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;
>   }
>
>   queue = gst_element_factory_make("queue", "queue");
>   sink  = gst_element_factory_make("autovideosink", "sink");
>
>   cout << "Creando 1..." << endl;
>
>   // Agrego Controlador
>
>   GstController * ctrl = NULL;
>   if (!(ctrl = gst_controller_new (G_OBJECT(smpte), "alpha",NULL))) 
> /// Here's the error, always return NULL
>   {
>         cout << "ctrl value..." << ctrl << endl;        
>         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_controller_set_control_source (ctrl, "alpha", GST_CONTROL_SOURCE
> (csource));
>
>  
> 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, duracion);
>   gst_interpolation_control_source_set(csource,(1 *
> GST_MSECOND),&val_double);
>
>   g_object_unref (csource);
>
>   gst_bin_add_many (GST_BIN (pipeline),src1, src2, dec1, dec2, alfa1,
> smpte, mixer, queue, color, sink, NULL);
>   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);
>
>   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);
>   g_object_set(smpte,"type", transicion, NULL);
>
>   /* 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;
> }
>
>
>
>
> _______________________________________________
> 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/20111025/b447c393/attachment.html>


More information about the gstreamer-devel mailing list