示例#1
0
        // Functions below print the capabilities in a human-friendly format
        static void PrintCaps(Caps caps, string pfx)
        {
            if (caps == null)
            {
                return;
            }

            if (caps.IsAny)
            {
                Console.WriteLine("{0}ANY", pfx);
                return;
            }

            if (caps.IsEmpty)
            {
                Console.WriteLine("{0}EMPTY", pfx);
                return;
            }

            for (uint i = 0; i < caps.Size; i++)
            {
                var structure = caps.GetStructure(i);

                Console.WriteLine("{0}{1}", pfx, structure.Name);
                structure.Foreach((field_id, value) => {
                    var ptr   = g_quark_to_string(field_id);
                    var quark = GLib.Marshaller.Utf8PtrToString(ptr);
                    Console.WriteLine("{0}   {1}: {2}", pfx, quark, value.Val);
                    return(true);
                });
            }
        }
示例#2
0
        private void OnCapsSet(object o, GLib.NotifyArgs args)
        {
            Structure s = null;
            int       width, height, fps_n, fps_d, par_n, par_d;
            Caps      caps = ((Pad)o).CurrentCaps;

            width = height = fps_n = fps_d = 0;
            if (caps == null)
            {
                return;
            }

            /* Get video decoder caps */
            s = caps.GetStructure(0);
            if (s != null)
            {
                /* We need at least width/height and framerate */
                if (!(s.HasField("framerate") && s.HasField("width") && s.HasField("height")))
                {
                    return;
                }
                Fraction f = new Fraction(s.GetValue("framerate"));
                fps_n = f.Numerator;
                fps_d = f.Denominator;
                GLib.Value val;
                width  = (int)s.GetValue("width");
                height = (int)s.GetValue("height");
                /* Get the PAR if available */
                val = s.GetValue("pixel-aspect-ratio");
                if (!val.Equals(GLib.Value.Empty))
                {
                    Fraction par = new Fraction(val);
                    par_n = par.Numerator;
                    par_d = par.Denominator;
                }
                else   /* Square pixels */
                {
                    par_n = 1;
                    par_d = 1;
                }

                /* Notify PlayerEngine if a callback was set */
                RaiseVideoGeometry(width, height, fps_n, fps_d, par_n, par_d);
            }
        }