Наследование: Gst.Object
Пример #1
1
 void InsertReplayGain (Pad pad, bool blocked)
 {
     lock (pipeline_lock) {
         if (rgvolume == null) {
             rgvolume = ElementFactory.Make ("rgvolume", "rgvolume");
             Add (rgvolume);
             rgvolume.SyncStateWithParent ();
             visible_sink.SetTarget (rgvolume.GetStaticPad ("sink"));
             rgvolume.Link (first);
             first = rgvolume;
         }
     }
     visible_sink.SetBlocked (false, (_, __) => { });
 }
        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);
        }
        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);
        }
Пример #4
0
        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);
        }
Пример #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);
        }
Пример #6
0
        public bool HandleURI(Element playbin, string uri)
        {
            // Processes URIs like cdda://<track-number>#<device-node> and overrides
            // track transitioning through playbin if playback was already happening
            // from the device node by seeking directly to the track since the disc
            // is already spinning; playbin doesn't handle CDDA URIs with device nodes
            // so we have to handle setting the device property on GstCddaBaseSrc
            // through the notify::source signal on playbin

            string new_cdda_device;
            int p;

            if (playbin == null || String.IsNullOrEmpty (uri) || !uri.StartsWith ("cdda://")) {
                // Something is hosed or the URI isn't actually CDDA
                if (Device != null) {
                    Log.WarningFormat ("cdda: finished using device ({0})", Device);
                    Device = null;
                }
                return false;
            }

            p = uri.IndexOf ('#');
            if (p == -1 || p + 2 > uri.Length) {
                // Unset the cached device node if the URI doesn't
                // have its own valid device node
                Device = null;
                Log.WarningFormat ("cdda: invalid device node in URI ({0})", uri);
                return false;
            }

            new_cdda_device = uri.Substring (p + 1);

            if (Device == null) {
                // If we weren't already playing from a CD, cache the
                // device and allow playbin to begin playing it
                Device = new_cdda_device;
                Log.DebugFormat ("cdda: storing device node for fast seeks ({0})", Device);
                return false;
            }

            if (new_cdda_device == Device) {
                // Parse the track number from the URI and seek directly to it
                // since we are already playing from the device; prevent playbin
                // from stopping/starting the CD, which can take many many seconds
                string track_str = uri.Substring (7, p - 7);
                int track_num;
                int.TryParse (track_str, out track_num);
                Log.DebugFormat ("cdda: fast seeking to track on already playing device ({0})", Device);

                return SeekToTrack (playbin, track_num);
            }

            // We were already playing some CD, but switched to a different device node,
            // so unset and re-cache the new device node and allow playbin to do its thing
            Log.DebugFormat ("cdda: switching devices for CDDA playback (from {0}, to {1})", Device, new_cdda_device);
            Device = new_cdda_device;

            return false;
        }
Пример #7
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);
        }
Пример #8
0
 public void ActivateCurrentMenu(Element playbin)
 {
     if (Navigation == null) {
         FindNavigation (playbin);
     }
     if (Navigation != null) {
         Navigation.SendCommand (NavigationCommand.Activate);
     }
 }
Пример #9
0
        public static Delegate RemoveProxySignalDelegate(Element element, string signal, 
            GLib.DynamicSignalHandler baseHandler, Delegate existingHandler, Delegate removeHandler)
        {
            Delegate temp_delegate = Delegate.Remove(existingHandler, removeHandler);
            if(temp_delegate == null) {
                element.Disconnect(signal, baseHandler);
            }

            return temp_delegate;
        }
Пример #10
0
        private Element GetDvdSource (Element playbin)
        {
            Element source = null;

            if (playbin == null) {
                return null;
            }

            source = playbin ["source"] as Element;

            return source;
        }
Пример #11
0
        private CddaBaseSrc GetCddaSource (Element playbin)
        {
            CddaBaseSrc source = null;

            if (playbin == null) {
                return null;
            }

            source = playbin ["source"] as CddaBaseSrc;

            return source;
        }
Пример #12
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();
        }
Пример #13
0
        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);
        }
Пример #14
0
            public AudioSinkBin (string elementName) : base(elementName)
            {
                hw_audio_sink = SelectAudioSink ();
                Add (hw_audio_sink);
                first = hw_audio_sink;

                // Our audio sink is a tee, so plugins can attach their own pipelines
                audiotee = ElementFactory.Make ("tee", "audiotee") as Tee;
                if (audiotee == null) {
                    Log.Error ("Can not create audio tee!");
                } else {
                    Add (audiotee);
                }

                volume = FindVolumeProvider (hw_audio_sink);
                if (volume != null) {
                    // If the sink provides its own volume property we assume that it will
                    // also save that value across program runs.  Pulsesink has this behaviour.
                    VolumeNeedsSaving = false;
                } else {
                    volume = ElementFactory.Make ("volume", "volume");
                    VolumeNeedsSaving = true;
                    Add (volume);
                    volume.Link (hw_audio_sink);
                    first = volume;
                }

                equalizer = ElementFactory.Make ("equalizer-10bands", "equalizer-10bands");
                if (equalizer != null) {
                    Element eq_audioconvert = ElementFactory.Make ("audioconvert", "audioconvert");
                    Element eq_audioconvert2 = ElementFactory.Make ("audioconvert", "audioconvert2");
                    preamp = ElementFactory.Make ("volume", "preamp");

                    Add (eq_audioconvert, preamp, equalizer, eq_audioconvert2);
                    Element.Link (eq_audioconvert, preamp, equalizer, eq_audioconvert2, first);

                    first = eq_audioconvert;
                    Log.Debug ("Built and linked Equalizer");
                }

                // Link the first tee pad to the primary audio sink queue
                Pad sinkpad = first.GetStaticPad ("sink");
                Pad pad = audiotee.GetRequestPad ("src%d");
                audiotee.AllocPad = pad;
                pad.Link (sinkpad);
                first = audiotee;

                visible_sink = new GhostPad ("sink", first.GetStaticPad ("sink"));
                AddPad (visible_sink);
            }
Пример #15
0
	private void CameraScanWin()
	{

		Gst.Element e = Gst.ElementFactory.Make ("dshowvideosrc");
		Gst.Interfaces.PropertyProbeAdapter ppa = new Gst.Interfaces.PropertyProbeAdapter (e.Handle);

		object[] devices = ppa.ProbeAndGetValues ("device-name");

		FillCombo (cbxCamera);

		foreach (String dev in devices) {
			Gst.Caps caps = e.GetStaticPad ("src").Caps;

			foreach (Gst.Structure cap in caps) {
				if (cap.HasField ("width") && cap.HasField ("height")) {
					Gst.GLib.Value s;
					int height = 0, width = 0;

					s = cap.GetValue ("width");
					if (s.Val is int) {
						width = (int)s.Val;
					}
					s = cap.GetValue ("height");
					if (s.Val is int) {
						height = (int)s.Val;
					}

					if (width == 320 && height == 240) {
						s = cap.GetValue ("framerate");

						Gst.Fraction f;
						if (s.Val is Gst.FractionRange) {
							f = new Gst.FractionRange (s).Max;  // ? Min
						} else if (s.Val is Gst.Fraction) {
							f = new Gst.Fraction (s);
						} else if (s.Val is int) {
							f = new Gst.Fraction ((int)s.Val, 1);
						} else
							continue;

						cameras [dev] = new GstCapture.cameraDevice (dev, f, width, height);

						cbxCamera.AppendText (dev);	


					}
				}
			}
		}
	}
Пример #16
0
	private void MicScan(string source, string devprop )
	{
		Gst.Element e = Gst.ElementFactory.Make(source);
		Gst.Interfaces.PropertyProbeAdapter ppa = new Gst.Interfaces.PropertyProbeAdapter(e.Handle);

		object[] devices = ppa.ProbeAndGetValues(devprop);

		foreach (object dev in devices)
		{
			FillCombo (cbxMic);
			cbxMic.AppendText (String.Format ("{0}", dev.ToString ()));
		}


	}
Пример #17
0
        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);
        }
Пример #18
0
        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);
        }
Пример #19
0
        public BpmDetector()
        {
            try {
                pipeline = new Pipeline ("the pipeline");
                filesrc          = ElementFactory.Make ("filesrc", "the filesrc");
                var decodebin    = ElementFactory.Make ("decodebin", "the decodebin");
                var audioconvert = Make ("audioconvert");
                var bpmdetect    = Make ("bpmdetect");
                fakesink         = ElementFactory.Make ("fakesink", "the fakesink");

                pipeline.Add (filesrc, decodebin, audioconvert, bpmdetect, fakesink);

                if (!filesrc.Link (decodebin)) {
                    Log.Error ("Could not link pipeline elements");
                    throw new Exception ();
                }

                // decodebin and audioconvert are linked dynamically when the decodebin creates a new pad
                decodebin.PadAdded += (o,args) => {
                    var audiopad = audioconvert.GetStaticPad ("sink");
                    if (audiopad.IsLinked) {
                        return;
                    }

                    var caps = args.NewPad.QueryCaps ();
                    if (caps == null)
                        return;

                    var str = caps[0];
                    if (!str.Name.Contains ("audio"))
                        return;

                    args.NewPad.Link (audiopad);
                };

                if (!Element.Link (audioconvert, bpmdetect, fakesink)) {
                    Log.Error ("Could not link pipeline elements");
                    throw new Exception ();
                }
                pipeline.Bus.AddWatch (OnBusMessage);
            } catch (Exception e) {
                Log.Exception (e);
                throw new ApplicationException (Catalog.GetString ("Could not create BPM detection driver."), e);
            }
        }
Пример #20
0
        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);
        }
Пример #21
0
	private void CameraScanUnix ()
	{

		Gst.Element e = Gst.ElementFactory.Make ("v4l2src");
		Gst.Interfaces.PropertyProbeAdapter ppa = new Gst.Interfaces.PropertyProbeAdapter (e.Handle);

		object[] devices = ppa.ProbeAndGetValues ("device");

		FillCombo (cbxCamera);

		foreach (String dev in devices) {

			Gst.Fraction f = new Gst.Fraction(30,1);

			cameras [dev] = new GstCapture.cameraDevice (dev, f , 320 , 240);

			cbxCamera.AppendText (dev);	


		}
	}
 public PlayerEngine ()
 {
     Console.WriteLine ("Gst# PlayerEngine ctor - completely experimental, still a WIP");
     Gst.Application.Init ();
     
     //Making early-bound elements
     pipeline = new Pipeline ();
     playbin = new PlayBin2 ();
     audiobin = new MyBinType ("audiobin");
     filterbin = new BinList<Element> ("filterbin");
     
     //Making late-bound elements (not currently bound by gst-sharp)
     audiosink = ElementFactory.Make ("gconfaudiosink", "thesink");
     if (audiosink == null)
         audiosink = ElementFactory.Make ("autoaudiosink", "thesink");
     queue = ElementFactory.Make ("queue", "audioqueue");
     
     //Adding, linking, and padding
     filterbin.Add (queue);
     audiobin.Add (filterbin.GetBin (), audiosink);
     filterbin.GetSourceGhostPad ().Link (audiosink.GetStaticPad ("sink"));
     audiobinsink.SetTarget (filterbin.GetSinkGhostPad ());
     audiobin.AddPadHack (audiobinsink);
     
     playbin.AudioSink = audiobin;
     pipeline.Add (playbin);
     
     pipeline.Bus.AddWatch (OnBusMessage);
     
     Banshee.ServiceStack.Application.RunTimeout (200, delegate {
         OnEventChanged (PlayerEvent.Iterate);
         return true;
     });
     
     OnStateChanged (PlayerState.Ready);
 }
Пример #23
0
        void OnDeleteEvent(object sender, DeleteEventArgs args)
        {
            Gtk.Application.Quit ();

            if (_playbin != null) {
                _playbin.SetState (Gst.State.Null);
                _playbin.Dispose ();
                _playbin = null;
            }

            args.RetVal = true;
        }
Пример #24
0
 public CddaManager(Element playbin)
 {
     if (playbin != null) {
         playbin.AddNotification ("source", OnSourceChanged);
     }
 }
Пример #25
0
        void ButtonOpenClicked(object sender, EventArgs args)
        {
            FileChooserDialog dialog = new FileChooserDialog ("Open", this, FileChooserAction.Open, new object[] { "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept });
            dialog.SetCurrentFolder (Environment.GetFolderPath (Environment.SpecialFolder.Personal));

            if (dialog.Run () == (int) ResponseType.Accept) {
                _pipelineOK = false;

                if (_playbin != null) {
                    _playbin.SetState (Gst.State.Null);
                } else {
                    _playbin = ElementFactory.Make  ("playbin", "playbin");
                }

                _scale.Value = 0;

                if (_playbin == null)
                    Console.WriteLine ("Unable to create element 'playbin'");

                _playbin.Bus.EnableSyncMessageEmission ();
                _playbin.Bus.AddSignalWatch ();

                _playbin.Bus.SyncMessage += delegate (object bus, SyncMessageArgs sargs) {
                    Gst.Message msg = sargs.Message;

                    if (!Gst.Video.GlobalVideo.IsVideoOverlayPrepareWindowHandleMessage (msg))
                        return;

                    Element src = msg.Src as Element;
                    if (src == null)
                        return;

                    try {
                        src["force-aspect-ratio"] = true;
                    }
                    catch (PropertyNotFoundException) {}
                    Element overlay = null;
                    if(src is Gst.Bin)
                        overlay = ((Gst.Bin) src).GetByInterface (VideoOverlayAdapter.GType);

                    VideoOverlayAdapter adapter = new VideoOverlayAdapter (overlay.Handle);
                    adapter.WindowHandle = _xWindowId;
                    adapter.HandleEvents (true);
                };

                _playbin.Bus.Message += delegate (object bus, MessageArgs margs) {
                    Message message = margs.Message;

                    switch (message.Type) {
                        case Gst.MessageType.Error:
                        GLib.GException err;
                        string msg;

                        message.ParseError (out err, out msg);
                        Console.WriteLine (String.Format ("Error message: {0}", msg));
                        _pipelineOK = false;
                        break;
                        case Gst.MessageType.Eos:
                        Console.WriteLine ("EOS");
                        break;
                    }
                };

                switch (System.Environment.OSVersion.Platform) {
                    case PlatformID.Unix:
                    _playbin["uri"] = "file://" + dialog.Filename;
                    break;
                    case PlatformID.Win32NT:
                    case PlatformID.Win32S:
                    case PlatformID.Win32Windows:
                    case PlatformID.WinCE:
                    _playbin["uri"] = "file:///" + dialog.Filename.Replace("\\","/");
                    break;
                }

                StateChangeReturn sret = _playbin.SetState (Gst.State.Playing);

                if (sret == StateChangeReturn.Async) {
                    State state, pending;
                    sret = _playbin.GetState (out state, out pending, Constants.SECOND * 5L);
                }

                if (sret == StateChangeReturn.Success) {
                    Console.WriteLine ("State change successful");
                    _pipelineOK = true;
                } else {
                    Console.WriteLine ("State change failed for {0} ({1})\n", dialog.Filename, sret);
                }
            }

            dialog.Destroy ();
        }
Пример #26
0
        private AudioCdSrc GetCddaSource(Element playbin)
        {
            AudioCdSrc source = null;

            if (playbin == null) {
                return null;
            }

            source = playbin ["source"] as AudioCdSrc;

            return source;
        }
Пример #27
0
        bool SeekToTrack(Element playbin, int track)
        {
            Format format = Format.Undefined;
            Element cdda_src = null;
            State state, pending;

            format = Util.FormatGetByNick ("track");
            if (format == Format.Undefined) {
                return false;
            }

            playbin.GetState (out state, out pending, 0);
            if (state < State.Paused) {
                // We can only seek if the pipeline is playing or paused, otherwise
                // we just allow playbin to do its thing, which will re-start the
                // device and start at the desired track
                return false;
            }

            cdda_src = GetCddaSource (playbin);
            if (cdda_src == null) {
                return false;
            }

            if (playbin.Seek (1.0, format, SeekFlags.Flush,
                SeekType.Set, track - 1, SeekType.None, -1)) {
                Log.DebugFormat ("cdda: seeking to track {0}, avoiding playbin", track);
                return true;
            }

            return false;
        }
Пример #28
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;
            }
Пример #29
0
        private void SetupRecordingPipeline()
        {
            // set up pipeline and elements
            // gst-launch-0.10 autoaudiosrc ! audioconvert ! vorbisenc ! oggmux ! filesink location=dump.ogg
            // Create new pipeline.

            _pipeline = new Gst.Pipeline();

            //Pipeline pipeline = new Pipeline("pipeline");

            // Construct pipeline filesrc -> avidemux -> mpeg4 -> directdrawsink

            //_eleAudioSource = ElementFactory.Make("autoaudiosrc", "autoaudiosrc");
            _eleAudioSource  = ElementFactory.Make("pulsesrc");
            _eleAudioConvert = ElementFactory.Make("audioconvert");
            if (_recordOgg)
            {
                _eleVorbisEnc = ElementFactory.Make("vorbisenc");
                _eleOggMux    = ElementFactory.Make("oggmux");
            }
            else
            {
                _eleWavPack = ElementFactory.Make("wavpackenc");
            }
            _eleFileSink = new Gst.CorePlugins.FileSink();
            //_eleFileSink = ElementFactory.Make("filesink", "filesink");
            _eleFileSink ["location"] = _path;

            // Add and link pipeline.
            if (_recordOgg)
            {
                _pipeline.Add(_eleAudioSource, _eleAudioConvert, _eleVorbisEnc, _eleOggMux, _eleFileSink);
            }
            else
            {
                _pipeline.Add(_eleAudioSource, _eleAudioConvert, _eleWavPack, _eleFileSink);
            }

            // Play video.
            _pipeline.SetState(Gst.State.Ready);
            _pipeline.SetState(Gst.State.Paused);

            if (!_eleAudioSource.Link(_eleAudioConvert))
            {
                Console.WriteLine("link failed between source and converter");
            }
            if (_recordOgg)
            {
                if (!_eleAudioConvert.Link(_eleVorbisEnc))
                {
                    Console.WriteLine("link failed between converter and encoder");
                }

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

                if (!_eleOggMux.Link(_eleFileSink))
                {
                    Console.Error.WriteLine("link failed between parser and sink");
                }
            }
            else
            {
                if (!_eleAudioConvert.Link(_eleWavPack))
                {
                    Console.WriteLine("link failed between converter and encoder");
                }

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

            _recordInit = true;
        }
Пример #30
0
 PadProbeReturn InsertReplayGain(Pad pad, PadProbeInfo info)
 {
     lock (pipeline_lock) {
         if (rgvolume == null) {
             rgvolume = ElementFactory.Make ("rgvolume", "rgvolume");
             Add (rgvolume);
             rgvolume.SyncStateWithParent ();
             visible_sink.SetTarget (rgvolume.GetStaticPad ("sink"));
             rgvolume.Link (first);
             first = rgvolume;
         }
     }
     return PadProbeReturn.Remove;
 }
Пример #31
0
 PadProbeReturn RemoveReplayGain(Pad pad, PadProbeInfo info)
 {
     lock (pipeline_lock) {
         if (rgvolume != null) {
             first = rgvolume.GetStaticPad ("src").Peer.Parent as Element;
             rgvolume.Unlink (first);
             rgvolume.SetState (State.Null);
             Remove (rgvolume);
             rgvolume = null;
             visible_sink.SetTarget (first.GetStaticPad ("sink"));
         }
     }
     return PadProbeReturn.Remove;
 }
Пример #32
0
 void RemoveReplayGain (Pad pad, bool blocked)
 {
     lock (pipeline_lock) {
         if (rgvolume != null) {
             first = rgvolume.GetStaticPad ("src").Peer.Parent as Element;
             rgvolume.Unlink (first);
             rgvolume.SetState (State.Null);
             Remove (rgvolume);
             rgvolume = null;
             visible_sink.SetTarget (first.GetStaticPad ("sink"));
         }
     }
     visible_sink.SetBlocked (false, (_, __) => { });
 }
Пример #33
0
        protected override void Initialize()
        {
            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);

            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);

            InstallPreferences ();
            audio_sink.ReplayGainEnabled = ReplayGainEnabledSchema.Get ();
            GaplessEnabled = GaplessEnabledSchema.Get ();
        }
Пример #34
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;
            }