Ejemplo n.º 1
0
 private void InitializeMainloop()
 {
     mMainLoop       = new GLib.MainLoop();
     mMainGlibThread = new System.Threading.Thread(mMainLoop.Run);
     mMainGlibThread.IsBackground = true;
     mMainGlibThread.Start();
 }
Ejemplo n.º 2
0
		public TestVolumes ()
		{
			Gnome.Vfs.Vfs.Initialize ();
			
			VolumeMonitor monitor = VolumeMonitor.Get ();
			monitor.DriveConnected += new DriveConnectedHandler (OnDriveConnected);
			monitor.DriveDisconnected += new DriveDisconnectedHandler (OnDriveDisconnected);
			monitor.VolumeMounted += new VolumeMountedHandler (OnVolumeMounted);
			monitor.VolumeUnmounted += new VolumeUnmountedHandler (OnVolumeUnmounted);
			
			Volume[] vols = monitor.MountedVolumes;
			Console.WriteLine ("Mounted volumes:");
			foreach (Volume v in vols)
				PrintVolume (v);
			
			Drive[] drives = monitor.ConnectedDrives;
			Console.WriteLine ("\nConnected drives:");
			foreach (Drive d in drives)
				PrintDrive (d);
			
			Console.WriteLine ("\nWaiting for volume events...");
			GLib.MainLoop loop = new GLib.MainLoop ();
			loop.Run ();
			
			Gnome.Vfs.Vfs.Shutdown ();
		}
Ejemplo n.º 3
0
        void InitGStreamerPipeline()
        {
            _mainLoop       = new GLib.MainLoop();
            _mainGlibThread = new System.Threading.Thread(_mainLoop.Run);
            _mainGlibThread.Start();

            _pipeline = CreatePipeline("camera-pipeline");
            Assert(_pipeline != null, "Pipeline could not be created");

            _pipeline.Bus.EnableSyncMessageEmission();
            _pipeline.Bus.SyncMessage += OnBusSyncMessage;
            _pipeline.Bus.AddWatch(OnBusMessage);

            _devMon = new DeviceMonitor();
            var caps   = new Caps("video/x-raw");
            var filtId = _devMon.AddFilter("Video/Source", caps);

            foreach (var d in _devMon.Devices.Select(d => d.DisplayName))
            {
                _devices.Add(d);
            }

            var cam = _devMon.Devices.FirstOrDefault(d => d.DeviceClass == "Video/Source");

            if (cam != null)
            {
                ShowCamera(cam.DisplayName);
            }

            Assert(_devMon.Start(), "Device monitor cannot start");
            _devMon.Bus.AddWatch(OnBusMessage);
        }
Ejemplo n.º 4
0
        public static void Run(ref string[] args, string source, string sourceOptions = "")
        {
            Console.WriteLine($"Playing video and audio from {source}");
            Application.Init(ref args);
            Pipeline = Gst.Parse.Launch($"playbin uri=\"{source}\" {sourceOptions}");

            MainLoop = new GLib.MainLoop();

            Pipeline.Bus.AddSignalWatch();
            Pipeline.Bus.EnableSyncMessageEmission();
            Pipeline.Bus.Message     += OnMessage;
            Pipeline.Bus.SyncMessage += OnSync;
            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;
                Console.WriteLine("Playing a live stream.");
            }

            MainLoop.Run();

            Pipeline.SetState(State.Null);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        public TestVolumes()
        {
            Gnome.Vfs.Vfs.Initialize();

            VolumeMonitor monitor = VolumeMonitor.Get();

            monitor.DriveConnected    += new DriveConnectedHandler(OnDriveConnected);
            monitor.DriveDisconnected += new DriveDisconnectedHandler(OnDriveDisconnected);
            monitor.VolumeMounted     += new VolumeMountedHandler(OnVolumeMounted);
            monitor.VolumeUnmounted   += new VolumeUnmountedHandler(OnVolumeUnmounted);

            Volume[] vols = monitor.MountedVolumes;
            Console.WriteLine("Mounted volumes:");
            foreach (Volume v in vols)
            {
                PrintVolume(v);
            }

            Drive[] drives = monitor.ConnectedDrives;
            Console.WriteLine("\nConnected drives:");
            foreach (Drive d in drives)
            {
                PrintDrive(d);
            }

            Console.WriteLine("\nWaiting for volume events...");
            GLib.MainLoop loop = new GLib.MainLoop();
            loop.Run();

            Gnome.Vfs.Vfs.Shutdown();
        }
        public static void Run(string[] args)
        {
            // Initialize GStreamer
            Gst.Application.Init(ref args);
            GtkSharp.GstreamerSharp.ObjectManager.Initialize();

            string fileName = @"U:/Video/test.avi";

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

            _effects.AddRange(list.Select(pf => pf.Name));
            foreach (var ef in _effects)
            {
                Console.WriteLine(ef);
            }

            _pipeline = new Pipeline();
            _src      = ElementFactory.Make("filesrc");
            _dbin     = ElementFactory.Make("decodebin");
            _conv     = ElementFactory.Make("videoconvert");
            _scale    = ElementFactory.Make("videoscale");
            _navseek  = ElementFactory.Make("navseek");
            _queue    = ElementFactory.Make("queue");
            _sink     = ElementFactory.Make("autovideosink");

            if (new[] { _pipeline, _src, _dbin, _conv, _scale, _navseek, _queue, _sink }.Any(e => e == null))
            {
                "Failed to create elements".PrintErr();
                return;
            }
            _src["location"] = fileName;

            _pipeline.Add(_src, _dbin, _conv, _scale, _navseek, _queue, _sink);
            if (!Element.Link(_src, _dbin) || !Element.Link(_conv, _scale, _navseek, _queue, _sink))
            {
                "Failed to link elements".PrintErr();
                return;
            }

            _dbin.PadAdded += PadAddedCb;

            _loop = new GLib.MainLoop();
            var bus = _pipeline.Bus;

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

            if (_pipeline.SetState(State.Playing) == StateChangeReturn.Failure)
            {
                "Failed to go into PLAYING state".PrintErr();
                return;
            }

            _loop.Run();
            _pipeline.SetState(State.Null);
            _dbinSrcpad?.Dispose();
            _pipeline.Dispose();
        }
        public static void Run(string[] args)
        {
            Application.Init(ref args);
            GtkSharp.GstreamerSharp.ObjectManager.Initialize();

            var devmon = new DeviceMonitor();
//            var caps = new Caps("video/x-raw");
//            var filtId = devmon.AddFilter("Video/Source", caps);

            var bus = devmon.Bus;

            bus.AddWatch(OnBusMessage);
            if (!devmon.Start())
            {
                "Device monitor cannot start".PrintErr();
                return;
            }

            Console.WriteLine("Video devices count = " + devmon.Devices.Length);
            foreach (var dev in devmon.Devices)
            {
                DumpDevice(dev);
            }

            var loop = new GLib.MainLoop();

            loop.Run();
        }
Ejemplo n.º 9
0
        public static void Main(string[] args)
        {
            b = 1;
            d = 1;

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

            // Create the playbin element
            Pipeline = Parse.Launch("playbin uri=appsrc://");
            Pipeline.Connect("source-setup", SourceSetup);

            // Instruct the bus to emit signals for each received message, and connect to the interesting signals
            var bus = Pipeline.Bus;

            bus.AddSignalWatch();
            bus.Connect("message::error", HandleError);

            // Start playing the pipeline
            Pipeline.SetState(State.Playing);

            // Create a GLib Main Loop and set it to run
            MainLoop = new GLib.MainLoop();
            MainLoop.Run();

            // Free resources
            Pipeline.SetState(State.Null);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Initializes the Gstreamer pipeline and Glib loop.
        /// </summary>
        /// <returns></returns>
        public bool Connect()
        {
            GstUtilities.DetectGstPath();
            bool r = false;

            glibLoop   = new GLib.MainLoop();
            glibThread = new sysThread.Thread(glibLoop.Run)
            {
                IsBackground = true
            };

            if (pipeline == null)
            {
                pipelineCreated = this.SetupPipeline();
            }
            if (!pipelineCreated)
            {
                sysDbg.WriteLine("Error creating pipeline.");
            }
            StateChangeReturn ret = pipeline.SetState(State.Ready);

            r = pipelineCreated && (ret != StateChangeReturn.Failure);

            return(r);
        }
Ejemplo n.º 11
0
        public static void Run(string[] args)
        {
            Application.Init(ref args);
            GtkSharp.GstreamerSharp.ObjectManager.Initialize();

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

            using (_pipeline = Parse.Launch("playbin uri=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm"))
            {
                GLib.Idle.Add(HandleKeyboard);

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

                PrintCurrentValues();

                // Create a GLib Main Loop and set it to run
                _loop = new GLib.MainLoop();
                _loop.Run();

                // Free resources
                _pipeline.SetState(State.Null);
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Create a new gstreamer pipeline rendering the stream at URL into the provided window handle 
 /// </summary>
 /// <param name="WindowHandle">The handle of the window to render to </param>
 /// <param name="Url">The url of the video stream</param>
 public gstPipeline2(string Url, IntPtr WindowHandle)
 {
     windowHandle = WindowHandle;    // get the handle and save it locally
     // initialise the gstreamer library and associated threads (for diagnostics)
     Gst.Application.Init();
     mainLoop = new GLib.MainLoop();
     mainGLibThread = new System.Threading.Thread(mainLoop.Run);
     mainGLibThread.Start();
     // create each element now for the pipeline
     uriDecodeBin = ElementFactory.Make("uridecodebin", "uriDecodeBin0");  // create an uridecodebin (which handles most of the work for us!!)
     uriDecodeBin["uri"] = Url;   // and set its location (the source of the data)
     videoSink = ElementFactory.Make("autovideosink", "sink0");  // and finally the sink to render the video (redirected to the required window handle below in Bus_SyncMessage() ) 
     // create our pipeline which links all the elements together into a valid data flow
     currentPipeline = new Pipeline("pipeline");
     currentPipeline.Add(uriDecodeBin, videoSink); // add the required elements into it
     uriDecodeBin.PadAdded += uriDecodeBin_PadAdded; // subscribe to the PadAdded event so we can link new pads (sources of data?) to the depayloader when they arrive
     uriDecodeBin.Connect("source-setup", SourceSetup);  // subscribe to the "source-setup" signal, not quite done in the usual C# eventing way but treat it as essentially the same
     // subscribe to the messaging system of the bus and pipeline so we can monitor status as we go
     Bus bus = currentPipeline.Bus;
     bus.AddSignalWatch();
     bus.Message += Bus_Message;
     bus.EnableSyncMessageEmission();
     bus.SyncMessage += Bus_SyncMessage;
     // finally set the state of the pipeline running so we can get data
     var setStateReturn = currentPipeline.SetState(State.Null);
     System.Diagnostics.Debug.WriteLine("SetStateNULL returned: " + setStateReturn.ToString());
     setStateReturn = currentPipeline.SetState(State.Ready);
     System.Diagnostics.Debug.WriteLine("SetStateReady returned: " + setStateReturn.ToString());
     setStateReturn = currentPipeline.SetState(State.Playing);
     System.Diagnostics.Debug.WriteLine("SetStatePlaying returned: " + setStateReturn.ToString());
 }
Ejemplo n.º 13
0
        public static void Main(string[] args)
        {
            Loop = new GLib.MainLoop();

            Application.Init(ref args);
            element = Gst.Parse.Launch("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();
        }
Ejemplo n.º 14
0
        public static void RunMainLoop()
        {
            if (mainloop == null)
            {
                mainloop = new GLib.MainLoop();
            }

            if (!mainloop.IsRunning)
            {
                mainloop.Run();
            }
        }
Ejemplo n.º 15
0
        public VideoOverlay()
        {
            InitializeComponent();

            //Init Gstreamer
            Gst.Application.Init();
            GtkSharp.GstreamerSharp.ObjectManager.Initialize();
            _mainLoop       = new GLib.MainLoop();
            _mainGlibThread = new System.Threading.Thread(_mainLoop.Run);
            _mainGlibThread.Start();

            _videoPanelHandle = videoPanel.Handle;
            GLib.Timeout.Add(1000, new GLib.TimeoutHandler(UpdatePos));
        }
        public static void Main(string[] argv)
        {
            if (argv.Length < 1)
            {
                Console.WriteLine("Usage: ChromaPrintTest.exe <audio file>");
                return;
            }

            Application.Init();
            Loop = new GLib.MainLoop();

            var reader = new AcoustIDReader("TP95csTg");

            reader.GetID(argv [0], (id, list) => {
                Console.WriteLine("Track ID: " + id);
                foreach (Recording rec in list)
                {
                    Console.WriteLine("=========================");
                    Console.WriteLine("Recording ID: " + rec.ID);
                    Console.WriteLine("Title: " + rec.Title);
                    Console.WriteLine("Artists: ");
                    foreach (Artist artist in rec.Artists)
                    {
                        Console.WriteLine("\t * {0} (ID: {1})", artist.Name, artist.ID);
                    }
                    Console.WriteLine("Release Groups: ");
                    foreach (ReleaseGroup release_group in rec.ReleaseGroups)
                    {
                        string sec_types = "";
                        if (release_group.SecondaryTypes.Count == 0)
                        {
                            sec_types = "no secondary types";
                        }
                        else
                        {
                            foreach (string t in release_group.SecondaryTypes)
                            {
                                sec_types += t + ", ";
                            }
                            sec_types = sec_types.Remove(sec_types.Length - 2);
                        }
                        Console.WriteLine("\t * {0} (Type: {1} /{3}/, ID: {2})", release_group.Title, release_group.Type, release_group.ID, sec_types);
                    }
                }

                Loop.Quit();
            });

            Loop.Run();
        }
        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://freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.ogv";

            // Set the subtitle URI to play and some font description
            Playbin ["suburi"]             = "http://freedesktop.org/software/gstreamer-sdk/data/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);
        }
Ejemplo n.º 18
0
        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);
        }
Ejemplo n.º 19
0
        public void ChangedEvent()
        {
            GLib.MainLoop loop = new GLib.MainLoop ();

            bool changed = false;
            test_entry.Changed += delegate {
                changed = true;
                loop.Quit ();
            };
            test_entry.Value = 100;
            loop.Run ();

            Assert.IsTrue (changed);
        }
Ejemplo n.º 20
0
        public static void Run(string[] args)
        {
            Application.Init(ref args);
            GtkSharp.GstreamerSharp.ObjectManager.Initialize();

            _pipeline = CreatePipeline("cam_pipeline");

            var bus = _pipeline.Bus;

            bus.AddWatch(OnBusMessage);

            _devMon = new DeviceMonitor();
            var caps   = new Caps("video/x-raw");
            var filtId = _devMon.AddFilter("Video/Source", caps);

            if (!_devMon.Start())
            {
                "Device monitor cannot start".PrintErr();
                return;
            }

            if (_devMon.Devices.Length == 0)
            {
                Console.WriteLine("No video sources");
            }
            else
            {
                Console.WriteLine($"Video devices count = {_devMon.Devices.Length}");
                foreach (var dev in _devMon.Devices)
                {
                    DumpDevice(dev);
                }
                var cam = _devMon.Devices.FirstOrDefault(d => d.DeviceClass == "Video/Source");
                if (cam != null)
                {
                    Console.WriteLine("Cam found");
                    ShowCamera(cam.DisplayName);
                }
            }

            var devMonBus = _devMon.Bus;

            devMonBus.AddWatch(OnBusMessage);

            var loop = new GLib.MainLoop();

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

            // Build the pipeline
            Pipeline = Parse.Launch("playbin uri=http://freedesktop.org/software/gstreamer-sdk/data/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);
        }
        public static void Run(string[] args)
        {
            GLib.ExceptionManager.UnhandledException += ExceptionManager_UnhandledException;

            string uri = "http://download.blender.org/durian/trailer/sintel_trailer-1080p.mp4";

// Missing GError ?
            uri = "https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm";
            if (args.Length > 1)
            {
                uri = args[0];
            }

            Gst.Application.Init(ref args);
            Console.WriteLine($"Discovering {uri}");

            Discoverer = new Discoverer(5 * Gst.Constants.SECOND);
            if (Discoverer == null)
            {
                Console.WriteLine("Error creating discoverer ");
                return;
            }

            // Connect to the interesting signals
            Discoverer.Discovered += OnDiscoveredCb;
            Discoverer.Finished   += OnFinishedCb;

            // Start the discoverer process (nothing to do yet)
            Discoverer.Start();

            //Add a request to process asynchronously the URI passed through the command line
            if (!Discoverer.DiscoverUriAsync(uri))
            {
                $"Failed to start discovering {uri}".PrintErr();
                return;
            }

            // Create a GLib Main Loop and set it to run, so we can wait for the signals
            MainLoop = new GLib.MainLoop();
            MainLoop.Run();

            Discoverer.Stop();
            Console.ReadLine();
        }
Ejemplo n.º 23
0
        public static void Run(string[] args)
        {
            // Initialize GStreamer
            Gst.Application.Init(ref args);
            GtkSharp.GstreamerSharp.ObjectManager.Initialize();

            string fileName = @"U:/Video/test.avi";

            _pipeline = new Pipeline();
            _src      = ElementFactory.Make("filesrc");
            _dbin     = ElementFactory.Make("decodebin");
            _conv     = ElementFactory.Make("videoconvert");
            _tee      = ElementFactory.Make("tee");

            if (new[] { _pipeline, _src, _dbin, _conv, _tee }.Any(e => e == null))
            {
                "Failed to create elements".PrintErr();
                return;
            }
            _src["location"] = fileName;

            _pipeline.Add(_src, _dbin, _conv, _tee);
            if (!Element.Link(_src, _dbin) || !Element.Link(_conv, _tee))
            {
                "Failed to link elements".PrintErr();
                return;
            }

            _dbin.PadAdded += PadAddedCb;
            _loop           = new GLib.MainLoop();
            var bus = _pipeline.Bus;

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

            if (_pipeline.SetState(State.Playing) == StateChangeReturn.Failure)
            {
                "Failed to go into PLAYING state".PrintErr();
                return;
            }
            _loop.Run();
            _pipeline.SetState(State.Null);
            _pipeline.Dispose();
        }
Ejemplo n.º 24
0
        public static void Run(ref string[] args, string source, string sourceOptions = "")
        {
            Console.WriteLine($"Playing video and audio from {source}");
            Application.Init(ref args);

            Pipeline  = new Gst.Pipeline("simplepipeline");
            VideoSink = new AppSink("videoSink");
            Playbin   = ElementFactory.Make("playbin", "playbin");

            Playbin["uri"]        = source;
            Playbin["video-sink"] = VideoSink;

            VideoSink["caps"]     = Caps.FromString("video/x-raw,format=RGBA");
            VideoSink.EmitSignals = true;
            VideoSink.NewSample  += NewVideoSample;
            VideoSink.Drop        = true;
            VideoSink.Sync        = true;
            VideoSink.Qos         = true;

            Pipeline.Add(Playbin);

            MainLoop = new GLib.MainLoop();

            Pipeline.Bus.AddSignalWatch();
            Pipeline.Bus.Message += OnMessage;

            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;
                Console.WriteLine("Playing a live stream.");
            }

            MainLoop.Run();

            Pipeline.SetState(State.Null);
        }
Ejemplo n.º 25
0
        public static void Main(string[] args)
        {
            var uri = "http://download.blender.org/durian/trailer/sintel_trailer-1080p.mp4";

            // if a URI was provided, use it instead of the default one
            if (args.Length > 1)
            {
                uri = args[0];
            }

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

            Console.WriteLine("Discovering '{0}'", uri);

            // Instantiate the Discoverer
            Discoverer = new Discoverer(5L * Gst.Constants.SECOND);

            // Connect to the interesting signals
            Discoverer.Discovered += HandleDiscovered;
            Discoverer.Finished   += (sender, e) => {
                Console.WriteLine("Finished discovering");
                MainLoop.Quit();
            };

            // Start the discoverer process (nothing to do yet)
            Discoverer.Start();

            // Add a request to process asynchronously the URI passed through the command line
            if (!Discoverer.DiscoverUriAsync(uri))
            {
                Console.WriteLine("Failed to start discovering URI '{0}'", uri);
                return;
            }

            // Create a GLib Main Loop and set it to run, so we can wait for the signals
            MainLoop = new GLib.MainLoop();
            MainLoop.Run();

            // Stop the discoverer process
            Discoverer.Stop();
        }
Ejemplo n.º 26
0
    public void TestBufferOwnershipNIp()
    {
        MyTransformNIp.Register ();

        Pipeline pipeline = new Pipeline ();
        Element src = ElementFactory.Make ("fakesrc");
        src["sizetype"] = 2;
        Element capsfilter = ElementFactory.Make ("capsfilter");
        capsfilter["caps"] = Caps.FromString ("foo/bar");
        src["num-buffers"] = 10;
        MyTransformNIp transform = new MyTransformNIp ();
        Element sink = ElementFactory.Make ("fakesink");

        pipeline.Add (src, capsfilter, transform, sink);
        Element.Link (src, capsfilter, transform, sink);

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

        pipeline.Bus.AddWatch (delegate (Bus bus, Message message) {
                             switch (message.Type) {
                             case MessageType.Error:
                                 Enum err;
                                 string msg;

                                 message.ParseError (out err, out msg);
                                 Assert.Fail (String.Format ("Error message: {0}", msg));
                                 loop.Quit ();
                                 break;
                               case MessageType.Eos:
                                   loop.Quit ();
                                   break;
                                 }
                                 return true;
                               });

        pipeline.SetState (State.Playing);
        loop.Run ();
        Assert.IsTrue (transform.transformed);
        pipeline.SetState (State.Null);
    }
Ejemplo n.º 27
0
        private void RunMainLoop()
        {
            ThreadAssist.InitializeMainThread();
            ThreadAssist.ProxyToMainHandler = Banshee.ServiceStack.Application.Invoke;

            service = new PlayerEngineService();

            service.PlayWhenIdleRequest += delegate { play_when_idles++; };
            service.TrackIntercept      += delegate { track_intercepts++; return(false); };

            // TODO call each test w/ permutations of Gapless enabled/disabled, RG enabled/disabled

            try {
                ServiceManager.RegisterService(service);
            } catch {}

            ((IInitializeService)service).Initialize();
            ((IDelayedInitializeService)service).DelayedInitialize();

            main_loop = new GLib.MainLoop();
            started   = true;
            main_loop.Run();
        }
Ejemplo n.º 28
0
        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);
        }
Ejemplo n.º 29
0
		static void Main (string [] args)
		{
			args = CommandLine.Process (typeof (BludgeonMain), args);

			// BU.CommandLine.Process returns null if --help was passed
			if (args == null)
				return;

			if (list_hammers) {
				foreach (string hammer in Toolbox.HammerNames)
					Console.WriteLine ("  - {0}", hammer);
				return;
			}

			ArrayList hammers_to_use;
			hammers_to_use = new ArrayList ();
			foreach (string name in args) {
				IHammer hammer;
				hammer = Toolbox.GetHammer (name);
				if (hammer != null)
					hammers_to_use.Add (hammer);
				else
					Log.Failure ("Unknown hammer '{0}'", name);
			}

			root = CreateTestRoot ();
			TreeBuilder.Build (root,
					   30,    // number of directories
					   100,   // number of files
					   0, //0.1,   // no archives
					   0, //0.5,   // archive decay, which does nothing here
					   false, // build all directories first, not in random order
					   null); // no need to track events
			if (! root.VerifyOnDisk ())
				throw new Exception ("VerifyOnDisk failed for " + root.FullName);
			
			EventTracker tracker;
			tracker = new EventTracker ();

			abuse = new Abuse (root, tracker, hammers_to_use);

			abuse.TotalCount = total_count;
			abuse.TotalTime = total_time;

			abuse.Cycles = cycles;
			abuse.MinCycles = min_cycles;
			abuse.MaxCycles = max_cycles;

			abuse.Pause = pause;
			abuse.MinPause = min_pause;
			abuse.MaxPause = max_pause;

			GLib.Idle.Add (new GLib.IdleHandler (Startup));
			main_loop = new GLib.MainLoop ();
			main_loop.Run ();
		}
Ejemplo n.º 30
0
  public static void Main (string [] args) {
    if (args.Length < 2) {
      Console.WriteLine ("Usage: mono decodebin-transcoder.exe <input-file> <output-file>");
      return;
    }

    Gst.Application.Init();
    loop = new GLib.MainLoop();

    DecodeBinTranscoder transcoder = new DecodeBinTranscoder();

    transcoder.Error += delegate (object o, ErrorArgs eargs) {
      Console.WriteLine ("Error: {0}", eargs.Error);
      transcoder.Dispose();
      loop.Quit();
    };

    transcoder.Finished += delegate {
      Console.WriteLine ("\nFinished");
      transcoder.Dispose();
      loop.Quit();
    };

    transcoder.Progress += delegate (object o, ProgressArgs pargs) {
      Console.Write ("\rEncoding: {0} / {1} ({2:00.00}%) ",
                     new TimeSpan ( (pargs.Position / (long) Clock.Second) * TimeSpan.TicksPerSecond),
                     new TimeSpan ( (pargs.Duration / (long) Clock.Second) * TimeSpan.TicksPerSecond),
                     ( (double) pargs.Position / (double) pargs.Duration) * 100.0);
    };

    transcoder.Transcode (args[0], args[1]);

    loop.Run();
  }
Ejemplo n.º 31
0
 public static void RegisterMainLoop(GLib.MainLoop loop)
 {
     main_loop = loop;
 }
Ejemplo n.º 32
0
        public static void Run(ref string[] args, string source, string sourceOptions = "",
                               bool withVideoPlayback = true, bool withAudioPlayback = true)
        {
            Console.WriteLine($"Getting raw video and audio samples and playing {source}");
            Application.Init(ref args);
            GtkSharp.GstreamerSharp.ObjectManager.Initialize(); // for AppSink, including finding exisitng app sinks

            bool validUri = false;

            if (Gst.Uri.IsValid(source))
            {
                var protocol = Gst.Uri.GetProtocol(source);
                if (Gst.Uri.ProtocolIsValid(protocol) && Gst.Uri.ProtocolIsSupported(URIType.Src, protocol))
                {
                    validUri = true;
                }
            }
            if (!validUri)
            {
                // still trying as a file path
                source = "file://" + source.Replace('\\', '/');
            }

            // if needed to force TCP with rtps source and uridecodebin,
            // use rtspt:// as source scheme. Also see http://gstreamer-devel.966125.n4.nabble.com/setting-protocols-for-rtsp-when-using-uridecodebin-tp4669327p4669328.html

            // We create a pipeline with 4 target sinks:
            //                                                                             ==> autoaudiosink (audio playback)
            //                                                                           //
            //                                               ==> audio (tee 'audioTee')=||
            //                                             //                            \\ 
            //                                            //                               ==> appsink 'audioSink' (raw audio samples)
            // =>>> source stream =>>> urlcodebin demux =||
            //                                            \\                               ==> autovideosink (video playback)
            //                                             \\                            //
            //                                               ==> video (tee 'videoTee')=||
            //                                                                           \\
            //                                                                             ==> appsink 'videoSink' (raw video samples)
            //
            // We can initialize a pipeline declaratively using Gst.Parse.Launch as if we were doing that in command line.
            // Then access pipeline elements by their names (audioSink and videoSink)

            Pipeline = Gst.Parse.Launch(
                $"uridecodebin uri=\"{source}\" {sourceOptions} name=dmux " +           // using uridecodebin as a demuxer
                                                                                        // you can also use replace it with:
                                                                                        // for HTTP(S) - "souphttpsrc location=\"{source}\" {sourceOptions} ! decodebin name=dmux"
                                                                                        // for RTSP - "rtspsrc location=\"{source}\" {sourceOptions} ! decodebin name=dmux"

                "dmux. ! queue ! audioconvert ! audio/x-raw,format=F32LE " +            // audio flow: raw PCM, 32bit float, little-endian
                "! tee name=audioTee " +                                                // create a tee for audio split
                (!withAudioPlayback ? " " :
                 "audioTee. ! queue ! autoaudiosink ") +                                // first [optional] audio branch - an automatic sink for playback
                "audioTee. ! queue ! appsink name=audioSink " +                         // second audio branch - an appsink 'audioSink' for raw audio samples

                "dmux. ! queue ! videoconvert " +                                       // video flow: raw RGBA, 32bpp
                                                                                        // color conversion to RGBA on GPU
                "! glupload ! glcolorconvert ! video/x-raw(memory:GLMemory),texture-target=2D,format=(string)RGBA ! gldownload " +

                "! tee name=videoTee " +                                                        // create second tee - for video split
                (!withVideoPlayback ? " " :
                 "videoTee. ! queue! autovideosink ") +                                         // first [optional] video branch - an automatic sink for playback
                "videoTee. ! queue ! appsink name=videoSink");                                  // second video branch - an appsink 'videoSink' for raw video samples

            MainLoop = new GLib.MainLoop();

            Pipeline.Bus.AddSignalWatch();
            Pipeline.Bus.EnableSyncMessageEmission();
            Pipeline.Bus.Message     += OnMessage;
            Pipeline.Bus.SyncMessage += OnSync;

            AppSink videoSink        = null;
            var     videoSinkElement = (Pipeline as Gst.Pipeline).GetChildByName("videoSink");

            if (videoSinkElement != null)
            {
                videoSink = videoSinkElement as AppSink;
                if (videoSink != null)
                {
                    videoSink.EmitSignals = true;
                    videoSink.NewSample  += NewVideoSample;

                    videoSink.Drop = true;
                    videoSink.Sync = true;
                    videoSink.Qos  = true;
                }
            }

            AppSink audioSink        = null;
            var     audioSinkElement = (Pipeline as Gst.Pipeline).GetChildByName("audioSink");

            if (audioSinkElement != null)
            {
                audioSink = audioSinkElement as AppSink;
                if (audioSink != null)
                {
                    audioSink.EmitSignals = true;
                    audioSink.NewSample  += NewAudioSample;

                    audioSink.Drop = true;
                    audioSink.Sync = true;
                    audioSink.Qos  = true;
                }
            }

            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;
                Console.WriteLine("Playing a live stream.");
            }

            MainLoop.Run();

            Pipeline.SetState(State.Null);
        }
Ejemplo n.º 33
0
        static void GstRun()
        {
            _MainLoop = new GLib.MainLoop();

            _MainLoop.Run();
            _MainLoop = null;
        }
Ejemplo n.º 34
0
 void Run(object o)
 {
     GLib.MainContext context = new GLib.MainContext();
     mainLoop = new GLib.MainLoop(context);
 }
Ejemplo n.º 35
0
        public static void Main(string[] args)
        {
            b = 1;
            d = 1;
            Gst.Audio.AudioInfo info = new Gst.Audio.AudioInfo();

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

            // Create the elements
            AppSource     = new Gst.App.AppSrc("app_src");
            Tee           = ElementFactory.Make("tee", "tee");
            AudioQueue    = ElementFactory.Make("queue", "audio_queue");
            AudioConvert1 = ElementFactory.Make("audioconvert", "audio_convert1");
            AudioResample = ElementFactory.Make("audioresample", "audio_resample");
            AudioSink     = ElementFactory.Make("autoaudiosink", "audio_sink");
            VideoQueue    = ElementFactory.Make("queue", "video_queue");
            AudioConvert2 = ElementFactory.Make("audioconvert", "audio_convert2");
            Visual        = ElementFactory.Make("wavescope", "visual");
            VideoConvert  = ElementFactory.Make("videoconvert", "video_convert");
            VideoSink     = ElementFactory.Make("autovideosink", "video_sink");
            AppQueue      = ElementFactory.Make("queue", "app_queue");
            AppSink       = new Gst.App.AppSink("app_sink");

            // Create the empty pipeline
            var pipeline = new Pipeline("test-pipeline");

            if (AppSource == null || Tee == null || AudioQueue == null || AudioConvert1 == null || AudioResample == null ||
                AudioSink == null || VideoQueue == null || AudioConvert2 == null || Visual == null || VideoConvert == null ||
                AppQueue == null || AppSink == null || pipeline == null)
            {
                Console.WriteLine("Not all elements could be created.");
                return;
            }

            // Configure wavescope
            Visual ["shader"] = 0;
            Visual ["style"]  = 0;

            // Configure appsrc
            info.SetFormat(Gst.Audio.AudioFormat.S16, SampleRate, 1, (Gst.Audio.AudioChannelPosition) 0);
            var audioCaps = info.ToCaps();

            AppSource ["caps"]   = audioCaps;
            AppSource ["format"] = Format.Time;

            AppSource.NeedData   += StartFeed;
            AppSource.EnoughData += StopFeed;

            // Configure appsink
            AppSink ["emit-signals"] = true;
            AppSink ["caps"]         = audioCaps;
            AppSink.NewSample       += NewSample;

            // Link all elements that can be automatically linked because they have "Always" pads
            pipeline.Add(AppSource, Tee, AudioQueue, AudioConvert1, AudioResample,
                         AudioSink, VideoQueue, AudioConvert2, Visual, VideoConvert, VideoSink, AppQueue, AppSink);
            if (!Element.Link(AppSource, Tee) ||
                !Element.Link(AudioQueue, AudioConvert1, AudioResample, AudioSink) ||
                !Element.Link(VideoQueue, AudioConvert2, Visual, VideoConvert, VideoSink) ||
                !Element.Link(AppQueue, AppSink))
            {
                Console.WriteLine("Elements could not be linked.");
                return;
            }

            // Manually link the Tee, which has "Request" pads
            var teeSrcPadTemplate = Tee.GetPadTemplate("src_%u");
            var teeAudioPad       = Tee.RequestPad(teeSrcPadTemplate);

            Console.WriteLine("Obtained request pad {0} for audio branch.", teeAudioPad.Name);
            var queueAudioPad = AudioQueue.GetStaticPad("sink");
            var teeVideoPad   = Tee.RequestPad(teeSrcPadTemplate);

            Console.WriteLine("Obtained request pad {0} for video branch.", teeVideoPad.Name);
            var queueVideoPad = VideoQueue.GetStaticPad("sink");
            var teeAppPad     = Tee.RequestPad(teeSrcPadTemplate);

            Console.WriteLine("Obtained request pad {0} for app branch.", teeAppPad.Name);
            var queueAppPad = AppQueue.GetStaticPad("sink");

            if (teeAudioPad.Link(queueAudioPad) != PadLinkReturn.Ok ||
                teeVideoPad.Link(queueVideoPad) != PadLinkReturn.Ok ||
                teeAppPad.Link(queueAppPad) != PadLinkReturn.Ok)
            {
                Console.WriteLine("Tee could not be linked");
                return;
            }

            // Instruct the bus to emit signals for each received message, and connect to the interesting signals
            var bus = pipeline.Bus;

            bus.AddSignalWatch();
            bus.Connect("message::error", HandleError);

            // Start playing the pipeline
            pipeline.SetState(State.Playing);

            // Create a GLib Main Loop and set it to run
            MainLoop = new GLib.MainLoop();
            MainLoop.Run();

            // Release the request pads from the Tee, and unref them
            Tee.ReleaseRequestPad(teeAudioPad);
            Tee.ReleaseRequestPad(teeVideoPad);
            Tee.ReleaseRequestPad(teeAppPad);

            // Free resources
            pipeline.SetState(State.Null);

            Gst.Global.Deinit();
        }
        public static void RunMainLoop ()
        {
            if (mainloop == null) {
                mainloop = new GLib.MainLoop ();
            }

            if (!mainloop.IsRunning) {
                mainloop.Run ();
            }
        }
Ejemplo n.º 37
0
        private void RunMainLoop ()
        {
            ThreadAssist.InitializeMainThread ();
            ThreadAssist.ProxyToMainHandler = Banshee.ServiceStack.Application.Invoke;

            service = new PlayerEngineService ();

            service.PlayWhenIdleRequest += delegate { play_when_idles++; };
            service.TrackIntercept += delegate { track_intercepts++; return false; };

            // TODO call each test w/ permutations of Gapless enabled/disabled, RG enabled/disabled

            try {
                ServiceManager.RegisterService (service);
            } catch {}

            ((IInitializeService)service).Initialize ();
            ((IDelayedInitializeService)service).DelayedInitialize ();

            main_loop = new GLib.MainLoop ();
            started = true;
            main_loop.Run ();
        }
Ejemplo n.º 38
0
		public static void RegisterMainLoop (GLib.MainLoop loop)
		{
			main_loop = loop;
		}
Ejemplo n.º 39
0
		private void GLibMainLoopThread ()
		{
			mainLoop = new GLib.MainLoop ();
			mainLoop.Run ();
		}
Ejemplo n.º 40
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);
    }
Ejemplo n.º 41
0
    static void Main(string[] args)
    {
        Gst.Application.Init ();
        TransformSample.Register ();

        Pipeline pipeline = new Pipeline ();
        Element videotestsrc = ElementFactory.Make ("videotestsrc");
        Element transform = new TransformSample ();
        Element ffmpegcolorspace = ElementFactory.Make ("ffmpegcolorspace");
        Element videosink = ElementFactory.Make ("autovideosink");

        pipeline.Add (videotestsrc, transform, ffmpegcolorspace, videosink);
        Element.Link (videotestsrc, transform, ffmpegcolorspace, videosink);

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

        pipeline.Bus.AddSignalWatch();
        pipeline.Bus.Message += delegate (object sender, MessageArgs margs) {
          Message message = margs.Message;

          switch (message.Type) {
        case MessageType.Error:
          Enum err;
          string msg;

          message.ParseError (out err, out msg);
          System.Console.WriteLine (String.Format ("Error message: {0}", msg));
          loop.Quit ();
          break;
        case MessageType.Eos:
          loop.Quit ();
          break;
          }
        };

        pipeline.SetState (State.Playing);
        loop.Run ();
        pipeline.SetState (State.Null);
    }
Ejemplo n.º 42
0
 private void GLibMainLoopThread()
 {
     mainLoop = new GLib.MainLoop();
     mainLoop.Run();
 }