Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gtk 否";讯息;来自GstBus的信号_Gtk_Gstreamer_Vala - Fatal编程技术网

Gtk 否";讯息;来自GstBus的信号

Gtk 否";讯息;来自GstBus的信号,gtk,gstreamer,vala,Gtk,Gstreamer,Vala,我正在用Gstreamer-1.0、vala-0.20和Gtk+-3.0编写一些转换器 我注意到我无法从我的管道总线上得到任何“信息”, 因为我的信号处理器从未被调用: public void job_add_on_click(GLib.Object but, void *data) { Gtk.Window win = ((but as Widget).get_toplevel()) as Gtk.Window; TreeView tree = (dat

我正在用Gstreamer-1.0、vala-0.20和Gtk+-3.0编写一些转换器

我注意到我无法从我的管道总线上得到任何“信息”, 因为我的信号处理器从未被调用:

 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");
          }
    }

  public void pad_add(Element decode1, Pad new_pad, void* data)
    {
        stdout.printf ("not good I suppose hein\n");
        Gst.Pipeline pipe = data as Gst.Pipeline;
        stdout.printf ("it is good here\n");
        Caps actual_caps = new_pad.query_caps (null);
        if(actual_caps == null)stdout.printf ("this caaps is null\n");
        unowned Structure stru = actual_caps.get_structure(0);
                stdout.printf ("tictidddddddvvvvvc\n");
        stdout.printf ("name of pad %s\n", stru.get_name ());
        if(stru.get_name().has_prefix ("video/x-raw"))
        {
            stdout.printf ("video\n");
            Element pix = pipe.get_by_name("pix");
            if(pix == null)stdout.printf ("pix is null\n");
            Pad pad = pix.get_static_pad("sink");
            stdout.printf ("danger\n");
            if(pad.is_linked() == true)
            {
                stdout.printf ("audio\n");
                Element tmp = ElementFactory.make("alsa","sink".concat((pipe.numchildren).to_string()));
                Pad p = tmp.get_static_pad("sink");
                stdout.printf ("%d\n", pipe.numchildren);
                pipe.add(tmp);
                new_pad.link(p);
                tmp.sync_state_with_parent();
                return;
            }
            stdout.printf ("calcuta\n");
            new_pad.link(pad);
            stdout.printf ("do it ffff\n");
        stdout.printf ("state of pipe %s\n", pipe.current_state.to_string ());
            return;
        }
        Element tmp1 = ElementFactory.make("autoaudiosink","sink".concat((pipe.numchildren).to_string()));
        pipe.add(tmp1);
        stdout.printf ("%d\n", pipe.numchildren);
        Pad p1 = tmp1.get_static_pad("sink");
        new_pad.link(p1);
        stdout.printf ("sa data rek\n");
        stdout.printf ("end of\n");
        tmp1.sync_state_with_parent();
        stdout.printf ("with its parent\n");
        if(pipe.current_state==Gst.State.PLAYING)stdout.printf ("pipe is playing\n");
    }
public void job\u单击添加(GLib.Object but,void*数据)
{
Window win=((但作为Widget.get_toplevel())作为Gtk.Window;
TreeView树=(数据为TreeView);
TreeModel model=tree.model;
stdout.printf(“trctrc\n”);
ListStore=(模型为ListStore);
FileChooserDialog=新建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)返回;
SList lis=dialog.get_files();
dialog.close();
Element decode=ElementFactory.make(“decodebin”、“decode”);
Element src=ElementFactory.make(“filesrc”、“src”);
管道=新管道(“管道”);
Element pix=ElementFactory.make(“自动视频接收器”、“pix”);//gdkpixbufsink
pipe.add_many(src、decode、pix);
ForBus fb=新ForBus(商店、树、win、管道);
Gst.Bus b=管道。获取_总线();
b、 添加_信号_手表();
b、 消息连接(fb.pix\U总线上的观察);
src.link_焊盘(“src”,解码,“sink”);
GLib.Signal.connect(解码,“pad added”,(GLib.Callback)pad_add,(void*)管道);
uint len=lis.length();
stdout.printf(“chacla\n”);
uint i=0;
int rm=0;
文件;
字符串标题、路径;

对于(i=0;i您的变量
pipe
可能超出范围。请尝试使用
object.signal.connect(…)
而不是
GLib.signal.connect
,如下所示:


如果您必须在Vala中使用
void*
,您可能做的工作比您应该做的要多,因为Vala应该使用更安全的类型来抽象它。

您的变量
管道
可能超出范围。请尝试使用
对象.signal.connect(…)
而不是
GLib.Signal.连接
,按照:


如果你必须在Vala中使用一个
void*
,你可能做了比你应该做的更多的工作,因为Vala应该用更安全的类型来抽象它。

你好,apmasell,我不明白你的答案,因为我想我的问题在这两个语句之间:b.添加信号\u watch();b.message.connect(fb.pix_watch_on_bus);那么与我的管道的链接是什么呢?thanksI指的是“添加的pad”。无论如何,管道应该在什么时候运行?GStreamer不会调用您的信号,除非您返回主循环。您需要让管道位于此函数之外的作用域中。它位于此函数之外,因为我可以用它播放一些电影,但我无法从其总线获取任何信号。管道应该在之后运行通过job_add_on_click函数将其设置为播放状态…你好,阿普马斯尔,我不明白你的答案,因为我想我的问题在于这两个语句之间:b.添加信号(watch();b.消息.连接(fb.pix_watch_on_bus);那么与我的管道的链接是什么?谢谢,我指的是“添加的pad”。无论如何,管道应该在什么时候运行?GStreamer不会调用您的信号,除非您返回主循环。您需要让管道位于此函数之外的作用域中。它位于此函数之外,因为我可以用它播放一些电影,但我无法从其总线获取任何信号。管道应该在之后运行从作业添加点击功能将其设置为播放状态。。。