Saturday, 7 September 2013

No "message" signal from GstBus

No "message" signal from GstBus

I'm writting some converter with Gstreamer-1.0 and vala-0.20 I have
noticed that, I can't get any "message" from the bus of my pipeline
because my signal handler is never call. My code is like:
public void job_add_on_click(GLib.Object but, void *data)
{
Gtk.Window win = ((but as Widget).get_toplevel()) as Gtk.Window;
TreeView tree = (data as TreeView);
TreeModel model = tree.model;
stdout.printf ("trctrc\n");
ListStore store = (model as ListStore);
FileChooserDialog dialog = new FileChooserDialog("Selectionner un
fichier",
win,
Gtk.FileChooserAction.OPEN,
Gtk.Stock.CANCEL,
Gtk.ResponseType.CANCEL,
Gtk.Stock.OPEN,
Gtk.ResponseType.ACCEPT,
null);
dialog.select_multiple = true;
Dialog dial = dialog as Dialog;
if(dial.run() != Gtk.ResponseType.ACCEPT)return;
SList<File> lis = dialog.get_files();
dialog.close ();
Element decode = ElementFactory.make("decodebin","decode");
Element src = ElementFactory.make("filesrc","src");
Pipeline pipe = new Pipeline("pipe");
Element pix =
ElementFactory.make("autovideosink","pix");//gdkpixbufsink
pipe.add_many(src, decode, pix);
ForBus fb = new ForBus( store, tree, win, pipe);
Gst.Bus b = pipe.get_bus();
b.add_signal_watch();
b.message.connect(fb.pix_watch_on_bus);
src.link_pads("src", decode, "sink");
GLib.Signal.connect(decode , "pad-added", (GLib.Callback)pad_add,
(void *)pipe);
uint len = lis.length();
stdout.printf ("chacla\n");
uint i = 0;
int rm = 0;
File file;
string title, path;
for(i=0; i<len; i++)
{
file = lis.nth_data(i);
title = file.get_basename();
path = file.get_path();
fb.path = path;
fb.title = title;
string loc;
src.set("location", path);
src.get("location", out loc );
stdout.printf ("location: %s\n", loc);
stdout.printf ("path file: %s title: %s\n", fb.path, fb.title);
stdout.printf ("state of pipe14 %s\n",
pipe.current_state.to_string ());
pipe.set_state(Gst.State.PLAYING);
pipe.get_state (null, null, Gst.CLOCK_TIME_NONE);
stdout.printf ("change meme non\n");
while(pipe.current_state != Gst.State.PAUSED)
{
Thread.usleep (2000000);
stdout.printf ("state of pipe11 %s\n",
pipe.current_state.to_string ());
}
stdout.printf ("%d fois\n", (int)i);
pipe.set_state(Gst.State.NULL);
fb.end_int = pipe.numchildren;
for(rm = fb.start_int; rm < fb.end_int; rm++)
{
pipe.remove(pipe.get_by_name("sink".concat((rm).to_string())));
}
}
b.remove_signal_watch();
}
public class ForBus: GLib.Object
{
public TreeIter iter;
public ListStore store;
public TreeView tree;
public Gtk.Window win;
public string path;
public string title;
public Pipeline pipe;
public int start_int;
public int end_int;
public ForBus( ListStore store, TreeView tree, Gtk.Window win,
Pipeline pip)
{
this.store = store;
this.tree = tree;
this.win = win;
this.pipe = pip;
this.start_int = pipe.numchildren;
stdout.printf ("creation pipe childreen %d", this.start_int);
}
public void pix_watch_on_bus(Gst.Bus bus, Gst.Message msg)
{
stdout.printf ("name message originator\n");
}
}
all stdout.printf is for debugging purpose I use Gtk so there is mainloop
behind this code
please I need some help
Thanks

No comments:

Post a Comment