public static void Main(string[] args)
        {
            // Initialize GStreamer
            Application.Init (ref args);

            // Build the pipeline
            Pipeline = Parse.Launch ("playbin uri=http://download.blender.org/durian/trailer/sintel_trailer-1080p.mp4");
            var bus = Pipeline.Bus;

            // Start playing
            var ret = Pipeline.SetState (State.Playing);
            if (ret == StateChangeReturn.Failure) {
                Console.WriteLine ("Unable to set the pipeline to the playing state.");
                return;
            } else if (ret == StateChangeReturn.NoPreroll) {
                IsLive = true;
            }

            MainLoop = new GLib.MainLoop ();

            bus.AddSignalWatch ();
            bus.Message += HandleMessage;

            MainLoop.Run ();

            // Free resources
            Pipeline.SetState (State.Null);
        }
        public static void Main(string[] args)
        {
            ElementFactory selectedFactory = null;

            // Initialize GStreamer
            Application.Init (ref args);

            // Get a list of all visualization plugins
            var list = Registry.Get().FeatureFilter (FilterVisFeatures, false);

            // Print their names
            Console.WriteLine ("Available visualization plugins:");
            foreach (var walk in list) {
                var factory = (ElementFactory)walk;
                var name = factory.Name;
                Console.WriteLine("  {0}", name);

                if (selectedFactory == null && name.StartsWith ("goom")) {
                    selectedFactory = factory;
                }
            }

            // Don't use the factory if it's still empty
            // e.g. no visualization plugins found
            if (selectedFactory == null) {
                Console.WriteLine ("No visualization plugins found!");
                return;
            }

            // We have now selected a factory for the visualization element
            Console.WriteLine ("Selected '{0}'", selectedFactory.Name);
            var visPlugin = selectedFactory.Create ();
            if (visPlugin == null)
                return;

            // Build the pipeline
            Pipeline = Parse.Launch ("playbin uri=http://1live.akacast.akamaistream.net/7/706/119434/v1/gnl.akacast.akamaistream.net/1live");

            // Set the visualization flag
            var flags = (uint)Pipeline ["flags"];
            flags |= PlayFlagsVis;
            Pipeline ["flags"] = flags;

            // set vis plugin for playbin
            Pipeline ["vis-plugin"] = visPlugin;

            // Start playing
            var ret = Pipeline.SetState (State.Playing);
            if (ret == StateChangeReturn.Failure) {
                Console.WriteLine ("Unable to set the pipeline to the playing state.");
                return;
            }

            // Wait until error or EOS
            var bus = Pipeline.Bus;
            var msg = bus.TimedPopFiltered (Constants.CLOCK_TIME_NONE, MessageType.Error | MessageType.Eos);

            // Free resources
            Pipeline.SetState (State.Null);
        }
        public static void Main(string[] args)
        {
            // Initialize GStreamer
            Application.Init (ref args);
            GtkSharp.GstreamerSharp.ObjectManager.Initialize ();

            // Print usage map
            Console.WriteLine ("USAGE: Choose one of the following options, then press enter:");
            Console.WriteLine (" 'C' to increase contrast, 'c' to decrease contrast");
            Console.WriteLine (" 'B' to increase brightness, 'b' to decrease brightness");
            Console.WriteLine (" 'H' to increase hue, 'h' to decrease hue");
            Console.WriteLine (" 'S' to increase saturation, 's' to decrease saturation");
            Console.WriteLine (" 'Q' to quit");

            // Build the pipeline
            Pipeline = Parse.Launch ("playbin uri=http://docs.gstreamer.com/media/sintel_trailer-480p.webm");

            // Add a keyboard watch so we get notified of keystrokes

            // Start playing
            var ret = Pipeline.SetState (State.Playing);
            if (ret == StateChangeReturn.Failure) {
                Console.WriteLine ("Unable to set the pipeline to the playing state.");
                return;
            }
            PrintCurrentValues ();

            // Create a GLib Main Loop and set it to run
            MainLoop = new GLib.MainLoop ();
            GLib.Timeout.Add (50, HandleKeyboard);
            MainLoop.Run ();

            // Free resources
            Pipeline.SetState (State.Null);
        }
        static double Rate; //Current playback rate (can be negative)

        #endregion Fields

        #region Methods

        public static void Main(string[] args)
        {
            // Initialize GStreamer
            Application.Init (ref args);

            // Print usage map
            Console.WriteLine ("USAGE: Choose one of the following options, then press enter:");
            Console.WriteLine (" 'P' to toggle between PAUSE and PLAY");
            Console.WriteLine (" 'S' to increase playback speed, 's' to decrease playback speed");
            Console.WriteLine (" 'D' to toggle playback direction");
            Console.WriteLine (" 'N' to move to next frame (in the current direction, better in PAUSE)");
            Console.WriteLine (" 'Q' to quit");

            // Build the pipeline
            //Pipeline = Parse.Launch ("playbin uri=http://download.blender.org/durian/trailer/sintel_trailer-1080p.mp4");
            Pipeline = Parse.Launch ("playbin uri=file:///home/stephan/Downloads/sintel_trailer-1080p.mp4");

            // Start playing
            var ret = Pipeline.SetState (State.Playing);
            if (ret == StateChangeReturn.Failure) {
                Console.WriteLine ("Unable to set the pipeline to the playing state.");
                return;
            }
            Playing = true;
            Rate = 1.0;

            // Process input
            HandleKeyboard ();

            // Free resources
            Pipeline.SetState (State.Null);
        }
Beispiel #5
0
    public HelloWorld(string [] args)
    {
        Application.Init();

        loop = new MainLoop();
        pipeline = new Pipeline ("audio-player");

        if ( (source = ElementFactory.Make ("filesrc", "file-source")) == null) {
          Console.WriteLine ("Could not create file-source");
        }

        parser = ElementFactory.Make ("oggdemux", "ogg-parser");
        decoder = ElementFactory.Make ("vorbisdec", "vorbis-decoder");
        conv = ElementFactory.Make ("audioconvert", "converter");
        identity = ElementFactory.Make ("identity", "identitye");
        sink = ElementFactory.Make ("alsasink", "alsa-output");

        source["location"] = args[0];

        Bin bin = (Bin) pipeline;
        bin.Bus.AddWatch (new BusFunc (BusCall));

        bin.Add (source, parser, decoder, conv, identity, sink);

        if (!source.Link (parser)) {
          Console.WriteLine ("link failed between source and parser");
        }

        if (!decoder.Link (conv)) {
          Console.WriteLine ("link failed between decoder and converter");
        }

        if (!conv.Link (identity)) {
          Console.WriteLine ("link failed between converter and identity");
        }

        if (!identity.Link (sink)) {
          Console.Error.WriteLine ("link failed between identity and sink");
        }

        parser.PadAdded += new PadAddedHandler (OnPadAdded);
        identity.Connect ("handoff", OnHandoff);

        pipeline.SetState (State.Playing);

        Console.WriteLine ("Playing [" + args[0] + "]");

        loop.Run();

        pipeline.SetState (State.Null);
        pipeline.Dispose();
    }
        public static void Main(string[] args)
        {
            // Initialize GTK
            Gtk.Application.Init ();

            // Initialize Gstreamer
            Gst.Application.Init(ref args);

            // Create the elements
            Playbin = ElementFactory.Make ("playbin", "playbin");

            if (Playbin == null) {
                Console.WriteLine ("Not all elements could be created");
                return;
            }

            // Set the URI to play.
            Playbin ["uri"] = "http://download.blender.org/durian/trailer/sintel_trailer-1080p.mp4";

            // Connect to interesting signals in playbin
            Playbin.Connect ("video-tags-changed", HandleTags);
            Playbin.Connect ("audio-tags-changed", HandleTags);
            Playbin.Connect ("text-tags-changed", HandleTags);

            // Create the GUI
            CreateUI ();

            // Instruct the bus to emit signals for each received message, and connect to the interesting signals
            var bus = Playbin.Bus;
            bus.AddSignalWatch ();
            bus.Connect ("message::error", HandleError);
            bus.Connect ("message::eos", HandleEos);
            bus.Connect ("message::state-changed", HandleStateChanged);
            bus.Connect ("message::application", HandleApplication);

            // Start playing
            var ret = Playbin.SetState (State.Playing);
            if (ret == StateChangeReturn.Failure) {
                Console.WriteLine ("Unable to set the pipeline to the playing state.");
                return;
            }

            // Register a function that GLib will call every second
            GLib.Timeout.Add (1, RefreshUI);

            // Start the GTK main loop- We will not regain control until gtk_main_quit is called
            Gtk.Application.Run ();

            // Free resources
            Playbin.SetState (State.Null);
        }
        static uint Video = (1 << 0); // We want video output

        #endregion Fields

        #region Methods

        public static void Main(string[] args)
        {
            // Initialize GStreamer
            Application.Init (ref args);

            // Create the elements
            Playbin = ElementFactory.Make ("playbin", "playbin");

            if (Playbin == null) {
                Console.WriteLine ("Not all elements could be created.");
                return;
            }

            // Set the URI to play
            Playbin ["uri"] = "http://docs.gstreamer.com/media/sintel_trailer-480p.ogv";

            // Set the subtitle URI to play and some font description
            Playbin ["suburi"] = "http://docs.gstreamer.com/media/sintel_trailer_gr.srt";
            Playbin ["subtitle-font-desc"] = "Sans, 18";

            // Set flags to show Audio and Video and Subtitles
            var flags = (uint)Playbin ["flags"];
            flags |= Audio | Video | Text;
            Playbin ["flags"] = flags;

            // Add a bus watch, so we get notified when a message arrives
            var bus = Playbin.Bus;
            bus.AddSignalWatch ();
            bus.Message += HandleMessage;

            // Start playing
            var ret = Playbin.SetState (State.Playing);
            if (ret == StateChangeReturn.Failure) {
                Console.WriteLine ("Unable to set the pipeline to the playing state.");
                return;
            }

            // Add a keyboard watch so we get notified of keystrokes
            GLib.Idle.Add (HandleKeyboard);
            MainLoop = new GLib.MainLoop ();
            MainLoop.Run ();

            // Free resources
            Playbin.SetState (State.Null);
        }
        static uint Video = (1 << 0); // We want video output

        #endregion Fields

        #region Methods

        public static void Main(string[] args)
        {
            // Initialize GStreamer
            Application.Init (ref args);

            // Create the elements
            Playbin = ElementFactory.Make ("playbin", "playbin");

            if (Playbin == null) {
                Console.WriteLine ("Not all elements could be created.");
                return;
            }

            // Set the URI to play
            Playbin ["uri"] = "http://docs.gstreamer.com/media/sintel_cropped_multilingual.webm";

            // Set flags to show Audio and Video but ignore Subtitles
            var flags = (uint)Playbin ["flags"];
            flags |= Audio | Video;
            flags &= ~Text;
            Playbin ["flags"] = flags;

            // Set connection speed. This will affect some internal decisions of playbin2
            Playbin ["connection-speed"] = 56;

            // Add a bus watch, so we get notified when a message arrives
            var bus = Playbin.Bus;
            bus.AddSignalWatch ();
            bus.Message += HandleMessage;

            // Start playing
            var ret = Playbin.SetState (State.Playing);
            if (ret == StateChangeReturn.Failure) {
                Console.WriteLine ("Unable to set the pipeline to the playing state.");
                return;
            }

            // Add a keyboard watch so we get notified of keystrokes
            GLib.Idle.Add (HandleKeyboard);
            MainLoop = new GLib.MainLoop ();
            MainLoop.Run ();

            // Free resources
            Playbin.SetState (State.Null);
        }
        static uint PlayFlagDownload = (1 << 7); // Enable progressive download (on selected formats)

        #endregion Fields

        #region Methods

        public static void Main(string[] args)
        {
            // Initialize GStreamer
            Application.Init (ref args);
            BufferingLevel = 100;

            // Build the pipeline
            Pipeline = Parse.Launch ("playbin uri=http://docs.gstreamer.com/media/sintel_trailer-480p.webm");
            var bus = Pipeline.Bus;

            // Set the download flag
            var flags = (uint)Pipeline ["flags"];
            flags |= PlayFlagDownload;
            Pipeline ["flags"] = flags;

            // Uncomment this line to limit the amount of downloaded data
            // g_object_set (pipeline, "ring-buffer-max-size", (guint64)4000000, NULL);

            // Start playing
            var ret = Pipeline.SetState (State.Playing);
            if (ret == StateChangeReturn.Failure) {
                Console.WriteLine ("Unable to set the pipeline to the playing state.");
                return;
            } else if (ret == StateChangeReturn.NoPreroll) {
                IsLive = true;
            }

            MainLoop = new GLib.MainLoop ();

            bus.AddSignalWatch ();
            bus.Message += HandleMessage;
            Pipeline.Connect ("deep-notify::temp-location", GotLocation);

            // Register a function that GLib will call every second
            GLib.Timeout.AddSeconds (1, RefreshUI);

            MainLoop.Run ();

            // Free resources
            Pipeline.SetState (State.Null);
        }
Beispiel #10
0
        public static void Main(string[] args)
        {
            Loop = new GLib.MainLoop();

            Application.Init(ref args);
            element = Gst.Parse.ParseLaunch("playbin uri=http://ftp.nluug.nl/ftp/graphics/blender/apricot/trailer/Sintel_Trailer1.1080p.DivX_Plus_HD.mkv");

            element.Bus.AddSignalWatch();
            element.Bus.Message += Handle;
            element.SetState(State.Playing);
            Loop.Run();
        }
Beispiel #11
0
            static Element FindVolumeProvider (Element sink)
            {
                Element volumeProvider = null;
                // Sinks which automatically select between a number of possibilities
                // (such as autoaudiosink and gconfaudiosink) need to be at least in
                // the Ready state before they'll contain an actual sink.
                sink.SetState (State.Ready);

                if (sink.HasProperty ("volume")) {
                    volumeProvider = sink;
                    Log.DebugFormat ("Sink {0} has native volume.", volumeProvider.Name);
                } else {
                    var sinkBin = sink as Bin;
                    if (sinkBin != null) {
                        foreach (Element e in sinkBin.ElementsRecurse) {
                            if (e.HasProperty ("volume")) {
                                volumeProvider = e;
                                Log.DebugFormat ("Found volume provider {0} in {1}.",
                                    volumeProvider.Name, sink.Name);
                            }
                        }
                    }
                }
                return volumeProvider;
            }
Beispiel #12
0
            static Element FindVolumeProvider(Element sink)
            {
                Element volumeProvider = null;
                // Sinks which automatically select between a number of possibilities
                // (such as autoaudiosink and gconfaudiosink) need to be at least in
                // the Ready state before they'll contain an actual sink.
                sink.SetState (State.Ready);

                try {
                    var volume = sink ["volume"];
                    volumeProvider = sink;
                    Log.DebugFormat ("Sink {0} has native volume: {1}", volumeProvider.Name, volume);
                } catch (Gst.PropertyNotFoundException) {
                    var sinkBin = sink as Bin;
                    if (sinkBin != null) {
                        foreach (Element e in sinkBin.IterateRecurse ()) {
                            try {
                                var volume = e ["volume"];
                                volumeProvider = e;
                                Log.DebugFormat ("Found volume provider {0} in {1}: {2}",
                                    volumeProvider.Name, sink.Name, volume);
                                break;
                            } catch (Gst.PropertyNotFoundException) { }
                        }
                    }
                }
                return volumeProvider;
            }
Beispiel #13
0
    public void TestBusCallback(bool use_AddWatch)
    {
        pipeline = new Pipeline();
        Assert.IsNotNull (pipeline, "Could not create pipeline");

        Element src = ElementFactory.Make ("fakesrc");
        Assert.IsNotNull (src, "Could not create fakesrc");
        Element sink = ElementFactory.Make ("fakesink");
        Assert.IsNotNull (sink, "Could not create fakesink");

        Bin bin = (Bin) pipeline;
        bin.Add (src, sink);
        Assert.IsTrue (src.Link (sink), "Could not link between src and sink");

        if (use_AddWatch)
          pipeline.Bus.AddWatch (new BusFunc (MessageReceived));
        else {
          pipeline.Bus.AddSignalWatch();
          pipeline.Bus.Message += delegate (object o, MessageArgs args) {
        MessageReceived (null, args.Message);
          };
        }
        Assert.AreEqual (pipeline.SetState (State.Playing), StateChangeReturn.Async);

        loop = new GLib.MainLoop();
        loop.Run();

        Assert.AreEqual (pipeline.SetState (State.Null), StateChangeReturn.Success);
        State current, pending;
        Assert.AreEqual (pipeline.GetState (out current, out pending, Clock.TimeNone), StateChangeReturn.Success);
        Assert.AreEqual (current, State.Null, "state is not NULL but " + current);
    }
        public static void Main(string[] args)
        {
            // Initialize Gstreamer
            Application.Init(ref args);

            // Create the elements
            playbin = ElementFactory.Make ("playbin", "playbin");

            if (playbin == null) {
                Console.WriteLine ("Not all elements could be created");
                return;
            }

            // Set the URI to play.
            playbin ["uri"] = "http://download.blender.org/durian/trailer/sintel_trailer-1080p.mp4";

            // Start playing
            var ret = playbin.SetState (State.Playing);
            if (ret == StateChangeReturn.Failure) {
                Console.WriteLine ("Unable to set the pipeline to the playing state.");
                return;
            }

            // Listen to the bus
            var bus = playbin.Bus;
            do {
                var msg = bus.TimedPopFiltered (100 * Constants.MSECOND, MessageType.StateChanged | MessageType.Error |  MessageType.DurationChanged);

                // Parse message
                if (msg != null) {
                    HandleMessage (msg);
                }
                else {
                    // We got no message, this means the timeout expired
                    if (playing) {
                        var fmt = Format.Time;
                        var current = -1L;

                        // Query the current position of the stream
                        if (!playbin.QueryPosition (fmt, out current)) {
                            Console.WriteLine ("Could not query current position.");
                        }

                        // if we didn't know it yet, query the stream position
                        if (duration <= 0) {
                            if (!playbin.QueryDuration (fmt, out duration)) {
                                Console.WriteLine ("Could not query current duration.");
                            }
                        }

                        // Print current position and total duration
                        Console.WriteLine ("Position {0} / {1}", new TimeSpan (current), new TimeSpan (duration));

                        if (seekEnabled && seekDone && current > 10L * Constants.SECOND) {
                            Console.WriteLine ("Readed 10s, performing seek...");
                            playbin.SeekSimple (fmt, SeekFlags.KeyUnit, 30L * Constants.SECOND);
                            seekDone = true;
                        }
                    }
                }
            } while (!terminate);
        }