static void OnMarshal(IntPtr closure, ref GLib.Value retval, uint argc, IntPtr argsPtr,
                              IntPtr ihint, IntPtr data)
        {
            object [] args = new object[argc - 1];
            object    o    = ((GLib.Value)Marshal.PtrToStructure(argsPtr, typeof(GLib.Value))).Val;

            for (int i = 1; i < argc; i++)
            {
                IntPtr     struct_ptr = (IntPtr)((long)argsPtr + (i * gvalue_struct_size));
                GLib.Value argument   = (GLib.Value)Marshal.PtrToStructure(struct_ptr, typeof(GLib.Value));
                args[i - 1] = argument.Val;
            }

            if (data == IntPtr.Zero)
            {
                Console.Error.WriteLine("No available data");
                return;
            }

            ObjectSignalKey k = (ObjectSignalKey)((GCHandle)data).Target;

            if (k != null)
            {
                SignalInfo      si  = (SignalInfo)SignalHandlers[k];
                GLib.SignalArgs arg = (GLib.SignalArgs)Activator.CreateInstance(si.ArgsType);
                arg.Args = args;
                si.RegisteredHandler.DynamicInvoke(new object[] { o, arg });
                if (arg.RetVal != null)
                {
                    retval.Val = arg.RetVal;
                }
            }
        }
Exemple #2
0
    private static void OnHaveType(object o, GLib.SignalArgs args)
    {
        Caps caps = args.Args[1] as Caps;

        caps.Refcount++;
        Console.WriteLine("MimeType: {0}", caps);
    }
        void TagsCb(object sender, GLib.SignalArgs args)
        {
            var playbin = sender as Element;
            // We are possibly in the Gstreamer working thread, so we notify the main thread of this event through a message in the bus
            var s = new Structure("tags-changed");

            playbin.PostMessage(Gst.Message.NewApplication(playbin, s));
        }
        void OnIceCandidate(object o, GLib.SignalArgs args)
        {
            var index  = (uint)args.Args[0];
            var cand   = (string)args.Args[1];
            var obj    = new { ice = new { sdpMLineIndex = index, candidate = cand } };
            var iceMsg = JsonConvert.SerializeObject(obj);

            _conn.SendAsync(iceMsg, (b) => { });
        }
Exemple #5
0
        /// <summary>
        /// This function is called when an error message is posted on the bus
        /// </summary>
        void ErrorCb(object o, GLib.SignalArgs args)
        {
            Gst.Message msg = (Gst.Message)args.Args[0];
            msg.ParseError(out GException err, out string debug);

            Console.WriteLine($"Error received from element {msg.Src.Name}: {err.Message}");
            Console.WriteLine("Debugging information: {0}", debug ?? "(none)");

            _playbin.SetState(State.Ready);
        }
        // This function is called when an error message is posted on the bus
        static void HandleError(object sender, GLib.SignalArgs args)
        {
            var msg = (Message)args.Args[0];

            // Print error details on the screen
            msg.ParseError(out GException err, out string debug);
            Console.WriteLine($"Error received from element {msg.Src.Name}: {err.Message}", msg.Src.Name, err.Message);
            Console.WriteLine("Debugging information: {0}", debug ?? "none");
            Data.MainLoop.Quit();
        }
        void OnNegotiationNeeded(object o, GLib.SignalArgs args)
        {
            var webRtc = o as Element;

            Assert(webRtc != null, "not a webrtc object");
            Promise   promise   = new Promise(OnOfferCreated, _webRtc.Handle, null); // webRtc.Handle, null);
            Structure structure = new Structure("struct");

            _webRtc.Emit("create-offer", structure, promise);
        }
        /// <summary>
        /// This function is called when an error message is posted on the bus
        /// </summary>
        static void ErrorCb(object o, GLib.SignalArgs args)
        {
            Bus     bus = o as Bus;
            Message msg = (Message)args.Args[0];

            msg.ParseError(out GException err, out string debug);

            $"Error received from element {msg.Src.Name}: {err.Message}".PrintErr();
            String.Format("Debugging information: {0}", debug ?? "(none)").PrintErr();

            Playbin.SetState(State.Ready);
        }
Exemple #9
0
        public static void InvokeProxySignalDelegate(Delegate raiseDelegate, Type type,
                                                     object o, GLib.SignalArgs args)
        {
            if (!type.IsSubclassOf(typeof(GLib.SignalArgs)))
            {
                throw new ArgumentException("Args type must derive SignalArgs");
            }

            if (raiseDelegate != null)
            {
                raiseDelegate.DynamicInvoke(new object [] { o,
                                                            Activator.CreateInstance(type, new object [] { args }) });
            }
        }
Exemple #10
0
        static void MarshalCallback(IntPtr raw_closure, IntPtr return_val, uint n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)
        {
            string message = String.Empty;

            try {
                SignalClosure closure = closures [raw_closure] as SignalClosure;
                message = "Marshaling " + closure.name + " signal";
                Value       objval = (Value)Marshal.PtrToStructure(param_values, typeof(Value));
                GLib.Object __obj  = objval.Val as GLib.Object;
                if (__obj == null)
                {
                    return;
                }

                if (closure.args_type == typeof(EventArgs))
                {
                    closure.Invoke(new ClosureInvokedArgs(__obj, EventArgs.Empty));
                    return;
                }

                SignalArgs args = Activator.CreateInstance(closure.args_type, new object [0]) as SignalArgs;
                args.Args = new object [n_param_vals - 1];
                GLib.Value[] vals = new GLib.Value [n_param_vals - 1];
                for (int i = 1; i < n_param_vals; i++)
                {
                    IntPtr ptr = new IntPtr(param_values.ToInt64() + i * Marshal.SizeOf(typeof(Value)));
                    vals [i - 1]      = (Value)Marshal.PtrToStructure(ptr, typeof(Value));
                    args.Args [i - 1] = vals [i - 1].Val;
                }
                ClosureInvokedArgs ci_args = new ClosureInvokedArgs(__obj, args);
                closure.Invoke(ci_args);
                for (int i = 1; i < n_param_vals; i++)
                {
                    vals [i - 1].Update(args.Args [i - 1]);
                    IntPtr ptr = new IntPtr(param_values.ToInt64() + i * Marshal.SizeOf(typeof(Value)));
                    Marshal.StructureToPtr(vals [i - 1], ptr, false);
                }
                if (return_val == IntPtr.Zero || args.RetVal == null)
                {
                    return;
                }

                Value ret = (Value)Marshal.PtrToStructure(return_val, typeof(Value));
                ret.Val = args.RetVal;
                Marshal.StructureToPtr(ret, return_val, false);
            } catch (Exception e) {
                Console.WriteLine(message);
                ExceptionManager.RaiseUnhandledException(e, false);
            }
        }
        void OnIncomingStream(object o, GLib.SignalArgs args)
        {
            var pad = args.Args[0] as Pad;

            if (pad.Direction != PadDirection.Src)
            {
                return;
            }
            var decodebin = ElementFactory.Make("decodebin");

            decodebin.Connect("pad-added", OnIncomingDecodebinStream);
            _pipe.Add(decodebin);
            decodebin.SyncStateWithParent();
            _webRtc.Link(decodebin);
        }
Exemple #12
0
        private bool propagating = false;   //Prevent reentry

        private void RaiseContextMenuEvent(GLib.SignalArgs signalArgs, Widget widget, double x, double y)
        {
            if (!propagating)
            {
                //Propagate the event
                Event evnt = Gtk.Global.CurrentEvent;
                propagating = true;
                Gtk.Global.PropagateEvent(widget, evnt);
                propagating       = false;
                signalArgs.RetVal = true;     //The widget already processed the event in the propagation
                //Raise the context menu event
                ContextMenuEventArgs args = new ContextMenuEventArgs(widget, x, y);
                if (ContextMenu != null)
                {
                    ContextMenu.Invoke(this, args);
                }
            }
        }
            unsafe static void MarshalCallback(IntPtr raw_closure, Value *return_val, uint n_param_vals, Value *param_values, IntPtr invocation_hint, IntPtr marshal_data)
            {
                SignalClosure closure = null;

                try {
                    closure = closures [raw_closure] as SignalClosure;
                    GLib.Object __obj = param_values [0].Val as GLib.Object;
                    if (__obj == null)
                    {
                        return;
                    }

                    if (closure.signal.args_type == typeof(EventArgs))
                    {
                        closure.Invoke(new ClosureInvokedArgs(__obj, EventArgs.Empty));
                        return;
                    }

                    SignalArgs args = FastActivator.CreateSignalArgs(closure.signal.args_type);
                    args.Args = new object [n_param_vals - 1];
                    for (int i = 1; i < n_param_vals; i++)
                    {
                        args.Args [i - 1] = param_values [i].Val;
                    }
                    ClosureInvokedArgs ci_args = new ClosureInvokedArgs(__obj, args);
                    closure.Invoke(ci_args);
                    for (int i = 1; i < n_param_vals; i++)
                    {
                        param_values [i].Update(args.Args [i - 1]);
                    }
                    if (return_val == null || args.RetVal == null)
                    {
                        return;
                    }

                    return_val->Val = args.RetVal;
                } catch (Exception e) {
                    if (closure != null)
                    {
                        Console.WriteLine("Marshaling {0} signal", closure.signal.name);
                    }
                    ExceptionManager.RaiseUnhandledException(e, false);
                }
            }
Exemple #14
0
        static void OnMarshal(IntPtr closure, ref GLib.Value retval, uint argc, IntPtr argsPtr, IntPtr ihint, IntPtr data)
        {
            object [] args = new object[argc - 1];
            object    o    = ((GLib.Value)Marshal.PtrToStructure(argsPtr, typeof(GLib.Value))).Val;

            for (int i = 1; i < argc; i++)
            {
                IntPtr struct_ptr   = (IntPtr)((long)argsPtr + (i * gvalue_struct_size));
                Type   detectedType = GLib.GType.LookupType(Marshal.ReadIntPtr(struct_ptr));

                if (detectedType.IsSubclassOf(typeof(Opaque)))
                {
                    args[i - 1] = (Opaque)Opaque.GetOpaque(g_value_peek_pointer(struct_ptr), detectedType, false);
                }
                else
                {
                    GLib.Value argument = (GLib.Value)Marshal.PtrToStructure(struct_ptr, typeof(GLib.Value));
                    args[i - 1] = argument.Val;
                }
            }

            if (data == IntPtr.Zero)
            {
                Console.Error.WriteLine("No available data");
            }

            Key k = (Key)((GCHandle)data).Target;

            if (k != null)
            {
                SignalArgs arg = new SignalArgs();
                arg.Args = args;
                SignalInfo           si      = (SignalInfo)SignalHandlers[k];
                DynamicSignalHandler handler = (DynamicSignalHandler)si.RegisteredHandler;
                handler(o, arg);

                if (arg.RetVal != null)
                {
                    retval.Val = arg.RetVal;
                }
            }
        }
 void OnDeleteEvent(object sender, SignalArgs a)
 {
     a.RetVal = true;
     Destroy();
 }
Exemple #16
0
 private void VideoSink_OnBeginDraw(object o, GLib.SignalArgs args)
 {
     OnDrawSignalReceived?.Invoke((Element)o, args);
 }
Exemple #17
0
        static void OnMarshal(IntPtr closure, ref GLib.Value retval, uint argc, IntPtr argsPtr, IntPtr ihint, IntPtr data)
        {
            object [] args = new object[argc - 1];
            object o = ((GLib.Value)Marshal.PtrToStructure (argsPtr, typeof (GLib.Value))).Val;

            for (int i=1; i < argc; i++)
            {
                IntPtr struct_ptr = (IntPtr)((long) argsPtr + (i * gvalue_struct_size));
                Type detectedType = GLib.GType.LookupType (Marshal.ReadIntPtr (struct_ptr));

                if (detectedType.IsSubclassOf (typeof (Opaque)))
                {
                    args[i - 1] = (Opaque)Opaque.GetOpaque (g_value_peek_pointer (struct_ptr), detectedType, false);
                }
                else
                {
                    GLib.Value argument = (GLib.Value)Marshal.PtrToStructure (struct_ptr, typeof (GLib.Value));
                    args[i - 1] = argument.Val;
                }
            }

            if (data == IntPtr.Zero)
                Console.Error.WriteLine("No available data");

            Key k = (Key)((GCHandle)data).Target;

            if (k != null)
            {
                SignalArgs arg = new SignalArgs ();
                arg.Args = args;
                SignalInfo si = (SignalInfo)SignalHandlers[k];
                DynamicSignalHandler handler = (DynamicSignalHandler)si.RegisteredHandler;
                handler (o, arg);

                if(arg.RetVal != null)
                    retval.Val = arg.RetVal;
            }
        }
 private void OnHandoff(object o, GLib.SignalArgs args)
 {
     Gst.Buffer buffer = args.Args[0] as Gst.Buffer;
     Console.WriteLine(buffer.Duration + "\t" + buffer.Timestamp);
 }