Example #1
0
        public bool LoadSubtitles(IGraphBuilder graphBuilder, string filename)
        {
            LoadSettings();
            MpcSubtitles.SetDefaultStyle(ref this.defStyle, this.overrideASSStyle);
            if (selectionOff)
            {
                MpcSubtitles.SetShowForcedOnly(false);
            }
            else
            {
                MpcSubtitles.SetShowForcedOnly(!this.autoShow);
            }
            //remove DirectVobSub
            DirectVobSubUtil.RemoveFromGraph(graphBuilder);
            {
                //remove InternalScriptRenderer as it takes subtitle pin
                IBaseFilter isr = null;
                DirectShowUtil.FindFilterByClassID(graphBuilder, ClassId.InternalScriptRenderer, out isr);
                if (isr != null)
                {
                    graphBuilder.RemoveFilter(isr);
                    DirectShowUtil.ReleaseComObject(isr);
                }
            }

            FFDShowEngine.DisableFFDShowSubtitles(graphBuilder);

            Size size = new Size(GUIGraphicsContext.Width, GUIGraphicsContext.Height);

            return(MpcSubtitles.LoadSubtitles(
                       DirectShowUtil.GetUnmanagedDevice(GUIGraphicsContext.DX9Device),
                       size, filename, graphBuilder, subPaths));
        }
Example #2
0
        public bool LoadSubtitles(IGraphBuilder graphBuilder, string filename)
        {
            LoadSettings();

            //remove DirectVobSub
            DirectVobSubUtil.RemoveFromGraph(graphBuilder);
            {
                //remove InternalScriptRenderer as it takes subtitle pin
                IBaseFilter isr = null;
                DirectShowUtil.FindFilterByClassID(graphBuilder, ClassId.InternalScriptRenderer, out isr);
                if (isr != null)
                {
                    graphBuilder.RemoveFilter(isr);
                    DirectShowUtil.ReleaseComObject(isr);
                }
            }
            // Window size
            //Size size = new Size(GUIGraphicsContext.Width, GUIGraphicsContext.Height);

            /*List<FFDShowAPI.FFDShowInstance> ffdshowInstance = FFDShowAPI.getFFDShowInstances();
             * FFDShowAPI.FFDShowAPI api = new FFDShowAPI();*/


            IBaseFilter baseFilter = null;

            DirectShowUtil.FindFilterByClassID(graphBuilder, FFDShowAPI.FFDShowVideoGuid, out baseFilter);
            if (baseFilter == null)
            {
                DirectShowUtil.FindFilterByClassID(graphBuilder, FFDShowAPI.FFDShowVideoDXVAGuid, out baseFilter);
            }
            if (baseFilter == null)
            {
                DirectShowUtil.FindFilterByClassID(graphBuilder, FFDShowAPI.FFDShowVideoRawGuid, out baseFilter);
            }
            if (baseFilter == null)
            {
                return(false);
            }

            ffdshowAPI = new FFDShowAPI((object)baseFilter);

            IffdshowDec ffdshowDec = baseFilter as IffdshowDec;

            if (ffdshowDec == null)
            {
                Log.Error("FFdshow interfaces not found. Try to update FFDShow");
            }
            else
            {
                Log.Info("FFdshow interfaces found");
            }
            if (selectionOff)
            {
                Enable = false;
            }
            else
            {
                Enable = autoShow;
            }
            return(true);
        }
        public bool LoadSubtitles(IGraphBuilder graphBuilder, string filename)
        {
            FreeSubtitles();
            LoadSettings();

            {
                //remove InternalScriptRenderer as it takes subtitle pin
                IBaseFilter isr = null;
                DirectShowUtil.FindFilterByClassID(graphBuilder, ClassId.InternalScriptRenderer, out isr);
                if (isr != null)
                {
                    graphBuilder.RemoveFilter(isr);
                    DirectShowUtil.ReleaseComObject(isr);
                }
            }

            vobSub = (IDirectVobSub)DirectVobSubUtil.AddToGraph(graphBuilder);
            if (vobSub == null)
            {
                return(false);
            }

            {
                //set style
                Log.Debug("VideoPlayerVMR9: Setting DirectVobsub parameters");
                LOGFONT logFont = new LOGFONT();
                int     txtcolor;
                bool    fShadow, fOutLine, fAdvancedRenderer = false;
                int     size = Marshal.SizeOf(typeof(LOGFONT));
                vobSub.get_TextSettings(logFont, size, out txtcolor, out fShadow, out fOutLine, out fAdvancedRenderer);
                FontStyle fontStyle = defStyle.fontIsBold ? FontStyle.Regular : FontStyle.Bold;
                Font      Subfont   = new Font(defStyle.fontName, defStyle.fontSize, fontStyle, GraphicsUnit.Point,
                                               (byte)defStyle.fontCharset);
                Subfont.ToLogFont(logFont);
                fShadow  = defStyle.shadow > 0;
                fOutLine = defStyle.isBorderOutline;
                vobSub.put_TextSettings(logFont, size, defStyle.fontColor, fShadow, fOutLine, fAdvancedRenderer);
                vobSub.put_FileName(filename);

                bool fBuffer, fOnlyForced, fPolygonize;
                vobSub.get_VobSubSettings(out fBuffer, out fOnlyForced, out fPolygonize);
                if (selectionOff)
                {
                    vobSub.put_VobSubSettings(fBuffer, false, fPolygonize);
                }
                else
                {
                    vobSub.put_VobSubSettings(fBuffer, !this.autoShow, fPolygonize);
                }
            }

            {
                //load sub streams
                IBaseFilter hms = null;
                DirectShowUtil.FindFilterByClassID(graphBuilder, ClassId.HaaliGuid, out hms);
                if (hms == null)
                {
                    DirectShowUtil.FindFilterByClassID(graphBuilder, ClassId.LAVFilterSource, out hms);
                }
                if (hms == null)
                {
                    DirectShowUtil.FindFilterByClassID(graphBuilder, ClassId.LAVFilter, out hms);
                }
                embeddedSelector = hms as IAMStreamSelect;
                if (embeddedSelector != null)
                {
                    AddStreams(embeddedSelector);
                }

                vobSub.get_LanguageCount(out extCount);
                if (intSubs.Count > 0)
                {
                    //if there are embedded subtitles,
                    //last stream of directvobsub is currently selected embedded subtitle
                    extCount--;
                }
            }

            FFDShowEngine.DisableFFDShowSubtitles(graphBuilder);

            Current = 0;
            if (selectionOff)
            {
                Enable = false;
            }
            return(true);
        }
        public bool LoadSubtitles(IGraphBuilder graphBuilder, string filename)
        {
            LoadSettings();
            MpcSubtitles.SetDefaultStyle(ref this.defStyle, this.overrideASSStyle);
            if (selectionOff)
            {
                MpcSubtitles.SetShowForcedOnly(false);
            }
            else
            {
                MpcSubtitles.SetShowForcedOnly(!this.autoShow);
            }
            //remove DirectVobSub
            DirectVobSubUtil.RemoveFromGraph(graphBuilder);
            {
                //remove InternalScriptRenderer as it takes subtitle pin
                IBaseFilter isr = null;
                DirectShowUtil.FindFilterByClassID(graphBuilder, ClassId.InternalScriptRenderer, out isr);
                if (isr != null)
                {
                    graphBuilder.RemoveFilter(isr);
                    DirectShowUtil.ReleaseComObject(isr);
                }
            }

            FFDShowEngine.DisableFFDShowSubtitles(graphBuilder);

            Size size = new Size(GUIGraphicsContext.Width, GUIGraphicsContext.Height);

            // Get Default Language from MP Setting and parse it to MPC-HC Engine (needed for forced track)
            string defaultLanguageCulture = "EN";
            string localizedCINameSub     = "EN";
            int    lcidCI = 0;

            using (Settings xmlreader = new MPSettings())
            {
                try
                {
                    if (g_Player.IsVideo && (g_Player.CurrentFile.ToUpperInvariant().Contains(@"\BDMV\INDEX.BDMV")))
                    {
                        localizedCINameSub = (xmlreader.GetValueAsString("bdplayer", "subtitlelanguage", "English"));
                        foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.NeutralCultures))
                        {
                            if (ci.EnglishName == localizedCINameSub)
                            {
                                lcidCI = ci.TextInfo.LCID;;
                            }
                        }
                        Log.Info("MpcEngine: Subtitle Blu-ray Player CultureInfo {0}", localizedCINameSub);
                    }
                    else
                    {
                        CultureInfo ci = new CultureInfo(xmlreader.GetValueAsString("subtitles", "language", defaultLanguageCulture));
                        lcidCI = ci.TextInfo.LCID;
                        Log.Info("MpcEngine: Subtitle VideoPlayer CultureInfo {0}", ci);
                    }
                }
                catch (Exception ex)
                {
                    CultureInfo ci = new CultureInfo(defaultLanguageCulture);
                    lcidCI = ci.TextInfo.LCID;
                    Log.Error(
                        "MpcEngine: SelectSubtitleLanguage - unable to build CultureInfo, make sure MediaPortal.xml is not corrupted! - {0}",
                        ex);
                }
            }

            return(MpcSubtitles.LoadSubtitles(
                       DirectShowUtil.GetUnmanagedDevice(GUIGraphicsContext.DX9Device),
                       size, filename, graphBuilder, subPaths, lcidCI));
        }
 public bool LoadSubtitles(IGraphBuilder graphBuilder, string filename)
 {
     DirectVobSubUtil.RemoveFromGraph(graphBuilder);
     return(false);
 }