Esempio n. 1
0
        private bool OnBusMessage(Bus bus, Message msg)
        {
            switch (msg.Type)
            {
            case MessageType.Eos:
                StopIterating();
                Close(false);
                OnEventChanged(PlayerEvent.EndOfStream);
                OnEventChanged(PlayerEvent.RequestNextTrack);
                break;

            case MessageType.StateChanged:
                if (msg.Src == playbin)
                {
                    State old_state, new_state, pending_state;
                    msg.ParseStateChanged(out old_state, out new_state, out pending_state);
                    HandleStateChange(old_state, new_state, pending_state);
                }
                break;

            case MessageType.Buffering:
                int buffer_percent;
                msg.ParseBuffering(out buffer_percent);
                HandleBuffering(buffer_percent);
                break;

            case MessageType.Tag:
                Pad     pad;
                TagList tag_list;
                msg.ParseTag(out pad, out tag_list);

                HandleTag(pad, tag_list);
                break;

            case MessageType.Error:
                Enum   error_type;
                string err_msg, debug;
                msg.ParseError(out error_type, out err_msg, out debug);

                HandleError(error_type, err_msg, debug);
                break;

            case MessageType.Element:
                if (MissingPluginMessage.IsMissingPluginMessage(msg))
                {
                    string detail = MissingPluginMessage.GetInstallerDetail(msg);

                    if (detail == null)
                    {
                        return(false);
                    }

                    if (missing_details.Contains(detail))
                    {
                        Log.DebugFormat("Ignoring missing element details, already prompted ('{0}')", detail);
                        return(false);
                    }

                    Log.DebugFormat("Saving missing element details ('{0}')", detail);
                    missing_details.Add(detail);

                    Log.Error("Missing GStreamer Plugin", MissingPluginMessage.GetDescription(msg), true);

                    InstallPluginsContext install_context = new InstallPluginsContext();
                    Install.InstallPlugins(missing_details.ToArray(), install_context, OnInstallPluginsReturn);
                }
                else if (msg.Src == playbin && msg.Structure.Name == "playbin2-stream-changed")
                {
                    HandleStreamChanged();
                }
                else if (NavigationMessage.MessageGetType(msg) == NavigationMessageType.CommandsChanged)
                {
                    dvd_manager.HandleCommandsChanged(playbin);
                }
                break;

            case MessageType.Application:
                string    name;
                Structure s = msg.Structure;
                name = s.Name;
                if (String.IsNullOrEmpty(name) && name == "stream-changed")
                {
                    video_manager.ParseStreamInfo();
                }
                break;
            }

            return(true);
        }
Esempio n. 2
0
        private bool OnBusMessage(Bus bus, Message msg)
        {
            switch (msg.Type)
            {
            case MessageType.Eos:
                StopIterating();
                Close(false);
                OnEventChanged(PlayerEvent.EndOfStream);

                OnEos();
                break;

            case MessageType.StateChanged:
                if (msg.Src == playbin)
                {
                    State old_state, new_state, pending_state;
                    msg.ParseStateChanged(out old_state, out new_state, out pending_state);
                    HandleStateChange(old_state, new_state, pending_state);
                }
                break;

            case MessageType.Buffering:
                int buffer_percent = msg.ParseBuffering();
                HandleBuffering(buffer_percent);
                break;

            case MessageType.Tag:
                TagList tag_list = msg.ParseTag();
                tag_list.Foreach(HandleTag);
                break;

            case MessageType.Error:
                GLib.GException err;
                string          debug;
                msg.ParseError(out err, out debug);

                HandleError(err);
                break;

            case MessageType.Element:

                if (Gst.PbUtils.Global.IsMissingPluginMessage(msg))
                {
                    string detail = Gst.PbUtils.Global.MissingPluginMessageGetInstallerDetail(msg);

                    if (detail == null)
                    {
                        return(false);
                    }

                    if (missing_details.Contains(detail))
                    {
                        Log.DebugFormat("Ignoring missing element details, already prompted ('{0}')", detail);
                        return(false);
                    }

                    Log.DebugFormat("Saving missing element details ('{0}')", detail);
                    missing_details.Add(detail);

                    Log.Error("Missing GStreamer Plugin", Gst.PbUtils.Global.MissingPluginMessageGetDescription(msg), true);

                    InstallPluginsContext install_context = new InstallPluginsContext();
                    Gst.PbUtils.Global.InstallPluginsAsync(missing_details.ToArray(), install_context, OnInstallPluginsReturn);
                }
                else if (NavigationAdapter.MessageGetType(msg) == NavigationMessageType.CommandsChanged)
                {
                    dvd_manager.HandleCommandsChanged(playbin);
                }
                break;

            case MessageType.StreamStart:
                HandleStreamStart();
                break;

            case MessageType.Application:
                string    name;
                Structure s = msg.Structure;
                name = s.Name;
                if (String.IsNullOrEmpty(name) && name == "stream-changed")
                {
                    video_manager.ParseStreamInfo();
                }
                break;
            }

            return(true);
        }