sorry I was appying a controller to a wrong name property. Now it is fixed, the controller it's created.<br><br>GstController * ctrl = gst_object_control_properties(G_OBJECT(smpte), "position",NULL);<br><blockquote class="gmail_quote">
<br> if (ctrl == NULL)<br>
{<br> cout << "controller wasn't created.." << endl;<div class="im"><br> GST_WARNING ("No puede controlar el elemento fuente\n");<br> return 1;<br> }<br></div> else<br>
cout << "controller created..." << endl;<br>
<br> cout << "Controlando..." << endl;<div class="im"><br> // Todo valor GValue debe inicializarse en 0<br> GValue val_double = { 0, };<br> g_value_init (&val_double, G_TYPE_DOUBLE);<br><br>
// Creo la fuente al controlador y la asocio al controlador<br>
// Seteo modo de interpolacion<br><br> GstInterpolationControlSource * csource = gst_interpolation_control_source_new();<br><br></div><div class="im"> gst_interpolation_control_source_set_interpolation_mode(csource,GST_INTERPOLATE_LINEAR);<br>
<br> // Seteo primer valor<br> g_value_set_double(&val_double, 0.0);<br> gst_interpolation_control_source_set(csource,(0 * GST_MSECOND),&val_double);<br><br> // Seteo segundo valor <br> g_value_set_double (&val_double, 1.0);<br>
</div></blockquote><div> //duracion = 500 <br></div><blockquote class="gmail_quote"><div class="im">
gst_interpolation_control_source_set(csource,(duracion * GST_MSECOND),&val_double);<br><br></div> gst_controller_set_control_source (ctrl, "position", GST_CONTROL_SOURCE (csource));<br><br> g_object_unref (csource);<div>
<div class="h5"><br>
<br></div></div></blockquote><br><br><br><div class="gmail_quote">2011/10/25 Rossana Guerra <span dir="ltr"><<a href="mailto:guerra.rossana@gmail.com">guerra.rossana@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I change the code, the problems is still there, the controller is NULL.<br>I initialize the controller properly, after, gst_init.<br><br>Here's the code, I don't know what it's wrong, very clueles, and worse, I need a controller (thanks!):<br>
<br>GstController * ctrl = gst_object_control_properties(G_OBJECT(smpte), "property",NULL);<br> cout << "ctrl's value..." << ctrl << endl; // returns 0<br><br> if (ctrl == NULL)<br>
{<br> cout << "controller wasn't created.." << endl;<div class="im"><br> GST_WARNING ("No puede controlar el elemento fuente\n");<br> return 1;<br> }<br></div> else<br>
cout << "controller created..." << endl;<br>
<br> cout << "Controlando..." << endl;<div class="im"><br> // Todo valor GValue debe inicializarse en 0<br> GValue val_double = { 0, };<br> g_value_init (&val_double, G_TYPE_DOUBLE);<br><br>
// Creo la fuente al controlador y la asocio al controlador<br>
// Seteo modo de interpolacion<br><br> GstInterpolationControlSource * csource = gst_interpolation_control_source_new();<br><br></div><div class="im"> gst_interpolation_control_source_set_interpolation_mode(csource,GST_INTERPOLATE_LINEAR);<br>
<br> // Seteo primer valor<br> g_value_set_double(&val_double, 0.0);<br> gst_interpolation_control_source_set(csource,(0 * GST_MSECOND),&val_double);<br><br> // Seteo segundo valor<br> g_value_set_double (&val_double, duracion);<br>
gst_interpolation_control_source_set(csource,(1 * GST_MSECOND),&val_double);<br><br></div> gst_controller_set_control_source (ctrl, "property", GST_CONTROL_SOURCE (csource));<br><br> g_object_unref (csource);<div>
<div></div><div class="h5"><br>
<br><br><br><br><div class="gmail_quote">2011/10/25 Rossana Guerra <span dir="ltr"><<a href="mailto:guerra.rossana@gmail.com" target="_blank">guerra.rossana@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Well I did the following change and it doesn't work, with the right propery it couldn't create the controller either. I am clueless.<br><br>if (!(ctrl = gst_controller_new (G_OBJECT(smpte), "property",NULL)))<br>
{<br> cout << "ctrl vale..." << ctrl << endl;<br> cout << "no pudo crear controlador..." << endl;<div><br> GST_WARNING ("No puede controlar el elemento fuente\n");<br>
return 1;<br> }<br><br><br><br></div><div><div></div><div><div class="gmail_quote">2011/10/25 Rossana Guerra <span dir="ltr"><<a href="mailto:guerra.rossana@gmail.com" target="_blank">guerra.rossana@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks Stefan, as I understand, now I have to control the "position" property.<br><br>I run an the following example, where I control the "alpha" property, and it works fine. I don't know if it's due a different pipeline, but it doesn't concern about "alpha" property.<br>
Here's the code which runs (without sound): <br><div><br><br>#include <gst.h><br>#include <controller/gstcontroller.h><br><br>#include <iostream><br><br>using namespace std;<br><br><br>// Manejador de errores<br>
static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)<br>{<br>:::::::::::::::<br>}<br><br></div><div>static void on_pad_added (GstElement *element, GstPad *pad, gpointer data)<br>{<br> GstPad *sinkpad = NULL;<br>
</div> GstElement * queue = (GstElement *) data;<div><br>
<br> /* Ahora linkeo el pad de comp con sink pad */<br> g_print ("Dynamic pad created, linking queue\n");<br></div> sinkpad = gst_element_get_static_pad (queue, "sink");<div><br><br> gst_pad_link (pad, sinkpad);<br>
<br> gst_object_unref (sinkpad);<br><br>}<br><br></div>GstElement * getBin(const gchar * nomBin, GstElement * &alfa1, GstElement *&smpte, GstElement * &color, gint transicion = 1)<br>{<br><br> GstElement * bin = gst_bin_new(nomBin);<br>
<br> if (!bin)<br> {<br> g_printerr ("No se pudo crear el bin. Saliendo\n");<br> return NULL;<div><br> }<br><br> alfa1 = gst_element_factory_make ("alpha","alfa1");<br>
smpte = gst_element_factory_make ("smptealpha","smpte");<br>
color = gst_element_factory_make ("ffmpegcolorspace", "color");<br> GstElement * mixer = gst_element_factory_make("videomixer", "mixer");<br><br><br> if ((!alfa1) || (!smpte) || (!color) || (!mixer))<br>
{<br> g_printerr ("Alguno de los elementos del Bin no pudo ser creado. Saliendo\n");<br></div> return NULL;<br> }<br><br> // Anexamos al bin<br> gst_bin_add_many(GST_BIN (bin),alfa1,smpte,mixer,color,NULL);<br>
<br> // Enlazamos elementos<br> gst_element_link (alfa1, mixer);<br> gst_element_link (smpte, mixer);<br> gst_element_link (mixer,color);<div><br><br> g_object_set(smpte,"type", transicion, NULL);<br>
<br></div> return bin;<br>
}<br><br>void getAndSetController(GstElement * smpte, gdouble duracion)<div><br>{<br> GstController * ctrl = NULL;<br></div> if (!(ctrl = gst_controller_new (G_OBJECT (smpte), "alpha",NULL))) { // Here it works fine<div>
<br>
GST_WARNING ("No puede controlar el elemento fuente\n");<br></div> return;<div><br> }<br><br> // Todo valor GValue debe inicializarse en 0<br> GValue val_double = { 0, };<br> g_value_init (&val_double, G_TYPE_DOUBLE);<br>
<br><br> // Creo la fuente al controlador y la asocio al controlador<br> // Seteo modo de interpolacion<br><br> GstInterpolationControlSource * csource = gst_interpolation_control_source_new();<br> gst_controller_set_control_source (ctrl, "alpha", GST_CONTROL_SOURCE (csource));<br>
<br> gst_interpolation_control_source_set_interpolation_mode(csource,GST_INTERPOLATE_LINEAR);<br><br> // Seteo primer valor<br> g_value_set_double(&val_double, 0.0);<br> gst_interpolation_control_source_set(csource,(0 * GST_MSECOND),&val_double);<br>
<br> // Seteo segundo valor<br> g_value_set_double (&val_double, duracion);<br> gst_interpolation_control_source_set(csource,(1 * GST_MSECOND),&val_double);<br><br><br> g_object_unref (csource);<br><br>}<br><br>
</div>
void addGhostPadsToBin(GstElement *alfa1, GstElement * smpte, GstElement * color, GstElement* bin)<br>{<br> /* add ghostpad */<br> GstPad * pad1 = gst_element_get_static_pad (alfa1, "sink");<br> gst_element_add_pad(bin, gst_ghost_pad_new("alfasink1", pad1));<br>
gst_object_unref (GST_OBJECT (pad1));<br><br> GstPad * pad2 = gst_element_get_static_pad (smpte, "sink");<br> gst_element_add_pad(bin, gst_ghost_pad_new("alfasink2", pad2));<br> gst_object_unref(GST_OBJECT(pad2));<br>
<br> GstPad * pad3 = gst_element_get_static_pad (color, "src");<br> gst_element_add_pad(bin, gst_ghost_pad_new("colorsrc", pad3));<br> gst_object_unref(GST_OBJECT(pad3));<br><br>}<br><br>void crossTransicion(gdouble duracion, GstElement * & bin,gint transicion = 1)<br>
{<br> // devuelve el bin<br> GstElement * alfa1, *smpte, *color;<br> alfa1 = 0;<br> smpte = 0;<br> color = 0;<br><br> bin = getBin("bin",alfa1, smpte,color,transicion); // Crea el bin y los elementos<br>
<br> getAndSetController(smpte,duracion);<br><br> addGhostPadsToBin(alfa1, smpte, color, bin);<br><br>}<br><br>GstElement * getSetPipeline(gchar *argv[])<br>{<br> gint dur1 = 9000; // duration (in ms) to play of first clip<br>
gint dur2 = 8000; // duration (in ms) to play of second clip<br> gint dur_crossfade = 500; //number of milliseconds to crossfade for<br> GstElement *comp = 0;<br> GstElement *pipeline, *video1, *video2, *op, *bin, *queue, *sink;<br>
<br> // ejecuta 2 clips serialmente con un crosdfade entre ellos usando el elemento (GnlOlin) gnlcomposition<br> if ((comp = gst_element_factory_make("gnlcomposition", "micomposicion")) == NULL)<br>
{<br> printf ("\n Fallo al crear gnlcomposition \n");<br> return NULL;<br> }<br><br> op = gst_element_factory_make("gnloperation", "op");<br><br> crossTransicion(dur_crossfade, bin,1);<br>
<br> if (gst_bin_add (GST_BIN (op), bin) == FALSE)<br> {<br> printf ("\n No pudo agregar el bin a la gnloperacion op \n");<br> return NULL;<br> }<br><br> g_object_set (op,"start", (dur1-dur_crossfade) * GST_MSECOND,NULL);<br>
g_object_set (op,"duration", dur_crossfade * GST_MSECOND,NULL);<br> g_object_set (op,"media-start", 0 * GST_MSECOND,NULL);<br> g_object_set(op,"media-duration", dur_crossfade * GST_MSECOND,NULL);<br>
g_object_set(op,"priority",0,NULL);<br><br> if (gst_bin_add (GST_BIN (comp), op) == FALSE)<br> {<br> printf ("\n No pudo agregar la gnloperacion a la gnlcomposition \n");<br> return NULL;<br>
}<br><br><br> // configura primer clip<br><br> if ((video1 = gst_element_factory_make("gnlfilesource", "video1")) == NULL)<br> {<br> printf ("\n Falló la creacion del gnlfilesource \n");<br>
return NULL;<br> }<br> if (gst_bin_add (GST_BIN (comp), video1) == FALSE)<br> {<br> printf ("\n No pudo agregar video1 a comp \n");<br> return NULL;<br> }<br><br> g_object_set (video1, "location", argv[1], NULL);<br>
g_object_set(video1, "uri", argv[1],NULL);<br> g_object_set (video1, "start", 0 * GST_MSECOND, NULL);<br> g_object_set (video1, "duration", dur1 * GST_MSECOND, NULL);<br> g_object_set (video1, "media-start", 0* GST_MSECOND, NULL);<br>
g_object_set (video1, "media-duration", dur1 * GST_MSECOND, NULL);<br> g_object_set (video1, "priority", 1,NULL);<br><br> // crea 2º clip<br> if ((video2 = gst_element_factory_make("gnlfilesource", "video2")) == NULL)<br>
{<br> printf ("\n Falló la creacion del gnlfilesource \n");<br> return NULL;<br> }<br><br><br> if (gst_bin_add (GST_BIN (comp), video2) == FALSE)<br> {<br> printf ("\n No pudo agregar video2 a comp \n");<br>
return NULL;<br> }<br><br> g_object_set (video2, "location", argv[2], NULL);<br> g_object_set (video2,"uri",argv[2],NULL);<br> g_object_set (video2, "start", (dur1-dur_crossfade) * GST_MSECOND, NULL);<br>
g_object_set (video2, "duration", dur2 * GST_MSECOND, NULL);<br> g_object_set (video2, "media-start", 0 * GST_MSECOND, NULL);<br> g_object_set (video2, "media-duration", dur2 * GST_MSECOND, NULL);<br>
g_object_set (video2, "priority", 2,NULL);<br><br> // setup the backend viewer<div><br> queue = gst_element_factory_make("queue", "queue");<br> sink = gst_element_factory_make("autovideosink", "sink");<br>
<br></div><div> pipeline = gst_pipeline_new ("video-player");<br><br></div> /* Agrego elementos al pipeline */<br><br> gst_bin_add_many (GST_BIN (pipeline),comp, queue, sink, NULL);<br><br> g_signal_connect (comp, "pad-added", G_CALLBACK (on_pad_added),queue);<br>
<br> gst_element_link (queue, sink);<br><br> return pipeline;<br><br>}<br><br>void startPlay(GstElement * pip)<br>{<br> /* Set the pipeline to "playing" state*/<br> gst_element_set_state (pip, GST_STATE_PLAYING);<br>
<br>}<br><br><br>int main(gint argc, gchar *argv[])<br>{<br> GMainLoop *loop = NULL;<br><div><br> /* init GStreamer */<br> gst_init (&argc, &argv);<br> gst_controller_init (&argc, &argv);<br>
<br> loop = g_main_loop_new (NULL, FALSE);<br>
<br></div> /* chequeamos sintaxis */<br> if (argc != 3)<br> {<br> g_print ("Uso: %s <URI1> <URI2>\n", argv[0]);<br> return -1;<br> }<br><br> GstElement * play = getSetPipeline(argv);<br>
<br><br> GstBus *bus2 = gst_pipeline_get_bus (GST_PIPELINE (play));<br> gst_bus_add_watch (bus2, bus_call, loop);<br> gst_object_unref (bus2);<br><br> cout << "...PLAY" << endl;<br><br> startPlay(play);<br>
<br> /* now run */<div><br> g_main_loop_run (loop);<br><br> /* also clean up */<br></div> gst_element_set_state (play, GST_STATE_NULL);<br> gst_object_unref (GST_OBJECT (play));<br> return 0;<div>
<div></div><div><br>}<br><br><br><br><br>
<br><div class="gmail_quote">2011/10/25 Stefan Sauer <span dir="ltr"><<a href="mailto:ensonic@hora-obscura.de" target="_blank">ensonic@hora-obscura.de</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<u></u>
<div bgcolor="#ffffff" text="#000000"><div>
On 10/25/2011 08:06 AM, Rossana Guerra wrote:
<blockquote type="cite">Hello everyone, I am translating the following code to
C/C++: <a href="http://notes.brooks.nu/2011/01/python-gstreamer-controller/" target="_blank">http://notes.brooks.nu/2011/01/python-gstreamer-controller/</a><br>
It's a controller for controlling the alpha channel during
crossfade, I adapted it for transitions, using, smpte instead.<br>
</blockquote>
<br></div>
smptealpha does not have a property called "alpha". Only "border"
and "invert" are controllable right now.<br>
<br>
Stefan<div><div></div><div><br>
<blockquote type="cite">
<br>
The fact is it returns NULL and the programs stop running. The
code is below, I appreciate any suggestion.<br>
I am a bit clueless is an adaptation of a code I did before and it
works.<br>
<br>
Thanks and regards.<br>
<br>
Rossana<br>
<br>
//// the code<br>
<br>
#include <gst.h><br>
#include <controller/gstcontroller.h><br>
<br>
#include <iostream><br>
<br>
<br>
using namespace std;<br>
<br>
// Manejador de errores<br>
static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer
data)<br>
{<br>
::::::::::::::::::::::::................<br>
}<br>
<br>
static void on_pad_added (GstElement *element, GstPad *pad,
gpointer data)<br>
{<br>
GstPad *sinkpad = NULL;<br>
GstElement * elemento = (GstElement *) data;<br>
<br>
<br>
/* Ahora linkeo el pad de comp con sink pad */<br>
g_print ("Dynamic pad created, linking queue\n");<br>
sinkpad = gst_element_get_static_pad (elemento, "sink");<br>
<br>
<br>
gst_pad_link (pad, sinkpad);<br>
gst_object_unref(sinkpad);<br>
<br>
}<br>
<br>
<br>
int main(int argc, char *argv[])<br>
{<br>
<br>
GMainLoop *loop = NULL;<br>
<br>
GstElement *src1,
*src2,*dec1,*dec2,*alfa1,*color,*smpte,*queue,*sink;<br>
GstBus *bus;<br>
<br>
gdouble duracion = 500;<br>
gint transicion = 1;<br>
<br>
cout << "Inicio..." << endl;<br>
<br>
/* init GStreamer */<br>
gst_init (&argc, &argv);<br>
gst_controller_init (&argc, &argv);<br>
<br>
loop = g_main_loop_new (NULL, FALSE); <br>
<br>
/* make sure we have input */<br>
if (argc != 3) {<br>
g_print ("Usage: %s <filename1> <filename2>\n",
argv[0]);<br>
return -1;<br>
}<br>
<br>
src1 = gst_element_factory_make("filesrc", "src1");<br>
g_object_set(G_OBJECT(src1),"location",argv[1], NULL);<br>
<br>
src2 = gst_element_factory_make("filesrc", "src2");<br>
g_object_set(G_OBJECT(src1),"location",argv[2], NULL);<br>
<br>
GstElement *pipeline = gst_pipeline_new ("video-player");<br>
<br>
dec1 = gst_element_factory_make("decodebin2","dec1");<br>
<br>
dec2 = gst_element_factory_make("decodebin2","dec2");<br>
<br>
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));<br>
gst_bus_add_watch (bus, bus_call, loop);<br>
gst_object_unref (bus);<br>
<br>
alfa1 = gst_element_factory_make ("alpha","alfa1");<br>
smpte = gst_element_factory_make ("smptealpha","smpte");<br>
color = gst_element_factory_make ("ffmpegcolorspace", "color");<br>
GstElement * mixer = gst_element_factory_make("videomixer",
"mixer");<br>
<br>
if ((!alfa1) || (!smpte) || (!color) || (!mixer))<br>
{<br>
g_printerr ("Alguno de los elementos del Bin no pudo ser
creado. Saliendo\n");<br>
return 0;<br>
}<br>
<br>
queue = gst_element_factory_make("queue", "queue");<br>
sink = gst_element_factory_make("autovideosink", "sink");<br>
<br>
cout << "Creando 1..." << endl;<br>
<br>
// Agrego Controlador<br>
<br>
GstController * ctrl = NULL;<br>
if (!(ctrl = gst_controller_new (G_OBJECT(smpte),
"alpha",NULL))) /// Here's the error, always return NULL<br>
{<br>
cout << "ctrl value..." << ctrl <<
endl; <br>
GST_WARNING ("No puede controlar el elemento fuente\n");<br>
return 1;<br>
}<br>
</blockquote>
<br>
<br>
<br>
</div></div><blockquote type="cite"><div><div></div><div><br>
// Todo valor GValue debe inicializarse en 0<br>
GValue val_double = { 0, };<br>
g_value_init (&val_double, G_TYPE_DOUBLE);<br>
<br>
<br>
// Creo la fuente al controlador y la asocio al controlador<br>
// Seteo modo de interpolacion<br>
<br>
GstInterpolationControlSource * csource =
gst_interpolation_control_source_new();<br>
gst_controller_set_control_source (ctrl, "alpha",
GST_CONTROL_SOURCE (csource));<br>
<br>
gst_interpolation_control_source_set_interpolation_mode(csource,GST_INTERPOLATE_LINEAR);<br>
<br>
// Seteo primer valor<br>
g_value_set_double(&val_double, 0.0);<br>
gst_interpolation_control_source_set(csource,(0 *
GST_MSECOND),&val_double);<br>
<br>
// Seteo segundo valor<br>
g_value_set_double (&val_double, duracion);<br>
gst_interpolation_control_source_set(csource,(1 *
GST_MSECOND),&val_double);<br>
<br>
g_object_unref (csource);<br>
<br>
gst_bin_add_many (GST_BIN (pipeline),src1, src2, dec1, dec2,
alfa1, smpte, mixer, queue, color, sink, NULL);<br>
g_signal_connect (G_OBJECT (dec1), "pad-added", G_CALLBACK
(on_pad_added),alfa1);<br>
g_signal_connect (G_OBJECT (dec2), "pad-added", G_CALLBACK
(on_pad_added),smpte);<br>
<br>
gst_element_link (src1,dec1);<br>
gst_element_link (src2,dec2);<br>
gst_element_link (alfa1,mixer);<br>
gst_element_link (smpte,mixer);<br>
gst_element_link (mixer,queue);<br>
gst_element_link (queue,sink);<br>
g_object_set(smpte,"type", transicion, NULL);<br>
<br>
/* now run */<br>
gst_element_set_state (pipeline, GST_STATE_PLAYING);<br>
cout << "Playing..." << endl;<br>
g_main_loop_run (loop);<br>
<br>
/* also clean up */<br>
gst_element_set_state (pipeline, GST_STATE_NULL);<br>
gst_object_unref (GST_OBJECT (pipeline));<br>
<br>
return 0;<br>
}<br>
<br>
<br>
<br>
</div></div><pre><fieldset></fieldset>
_______________________________________________
gstreamer-devel mailing list
<a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank">gstreamer-devel@lists.freedesktop.org</a>
<a href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a>
</pre>
</blockquote>
<br>
</div>
<br>_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
<br></blockquote></div><br>
</div></div></blockquote></div><br>
</div></div></blockquote></div><br>
</div></div></blockquote></div><br>