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);
        }
Beispiel #2
0
        public static Delegate AddProxySignalDelegate(Element element, string signal, 
            GLib.DynamicSignalHandler baseHandler, Delegate existingHandler, Delegate addHandler)
        {
            if(existingHandler == null) {
                element.Connect(signal, baseHandler);
            }

            return Delegate.Combine(existingHandler, addHandler);
        }
Beispiel #3
0
        public static Delegate AddProxySignalDelegate(Element element, string signal,
                                                      GLib.DynamicSignalHandler baseHandler, Delegate existingHandler, Delegate addHandler)
        {
            if (existingHandler == null)
            {
                element.Connect(signal, baseHandler);
            }

            return(Delegate.Combine(existingHandler, addHandler));
        }
        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);
        }
        private void ReInitPipeline()
        {
            if (pipeline != null) {
                pipeline.SetState (Gst.State.Null);
                pipeline = null;
            }

            pipeline = new Gst.Pipeline ();
            drawSink = Gst.ElementFactory.Make ("xvimagesink");
            camerabin = Gst.ElementFactory.Make ("camerabin");
            camerabin.Connect ("image-done", new Gst.SignalHandler (OnImageDone));
            pipeline.SetState (Gst.State.Null);

            overlayAdapter = new Gst.Interfaces.XOverlayAdapter (drawSink.Handle);
            overlayAdapter.XwindowId = gdk_x11_drawable_get_xid (drawingArea.GdkWindow.Handle);
            pipeline.Add (camerabin);

            if (camerabin.HasProperty ("viewfinder-sink")) {
                camerabin ["viewfinder-sink"] = drawSink;
            }

            if (camerabin.HasProperty ("filename")) {
                camerabin ["filename"] = "snapshot.png";
            }

            pipeline.SetState (Gst.State.Playing);
            needReInit = false;
        }
Beispiel #6
0
        public PlayerEngine()
        {
            Log.InformationFormat ("GStreamer# {0} Initializing; {1}.{2}",
                typeof (Gst.Version).Assembly.GetName ().Version, Gst.Version.Description, Gst.Version.Nano);

            // Setup the gst plugins/registry paths if running Windows
            if (PlatformDetection.IsWindows) {
                var gst_paths = new string [] { Hyena.Paths.Combine (Hyena.Paths.InstalledApplicationPrefix, "gst-plugins") };
                Environment.SetEnvironmentVariable ("GST_PLUGIN_PATH", String.Join (";", gst_paths));
                Environment.SetEnvironmentVariable ("GST_PLUGIN_SYSTEM_PATH", "");
                Environment.SetEnvironmentVariable ("GST_DEBUG", "1");

                string registry = Hyena.Paths.Combine (Hyena.Paths.ApplicationData, "registry.bin");
                if (!System.IO.File.Exists (registry)) {
                    System.IO.File.Create (registry).Close ();
                }

                Environment.SetEnvironmentVariable ("GST_REGISTRY", registry);

                //System.Environment.SetEnvironmentVariable ("GST_REGISTRY_FORK", "no");
                Log.DebugFormat ("GST_PLUGIN_PATH = {0}", Environment.GetEnvironmentVariable ("GST_PLUGIN_PATH"));
            }

            Gst.Application.Init ();
            playbin = ElementFactory.Make ("playbin", "the playbin");

            next_track_set = new ManualResetEvent (false);

            audio_sink = new AudioSinkBin ("audiobin");

            playbin["audio-sink"] = audio_sink;

            if (audio_sink.VolumeNeedsSaving) {
                // Remember the volume from last time
                Volume = (ushort)PlayerEngineService.VolumeSchema.Get ();
            }

            visualization = new Visualization (audio_sink);

            playbin.AddNotification ("volume", OnVolumeChanged);
            playbin.Bus.AddWatch (OnBusMessage);
            playbin.Connect ("about-to-finish", OnAboutToFinish);

            cdda_manager = new CddaManager (playbin);
            dvd_manager = new DvdManager (playbin);

            video_manager = new VideoManager (playbin);
            video_manager.PrepareWindow += OnVideoPrepareWindow;
            video_manager.Initialize ();

            dvd_manager.FindNavigation (playbin);
            OnStateChanged (PlayerState.Ready);
        }