Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
    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);
        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;
      }
      else
      {
        Enable = autoShow;
      }
      return true;
    }