Ejemplo n.º 1
0
 public FilterStreams()
 {
   cStreams = 0;
   Streams = new FilterStreamInfos[MAX_STREAMS];
   cStreamsExternal = 0;
   StreamsExternal = new FilterStreamInfos[MAX_STREAMS];
 }
Ejemplo n.º 2
0
 private static FilterStreamInfos GetStreamInfos(StreamType type, int id, int streamsCount, FilterStreamInfos[] streams)
 {
   var empty = new FilterStreamInfos();
   for (int i = 0; i < streamsCount; i++)
   {
     if (type == streams[i].Type)
     {
       if (id == 0)
       {
         return streams[i];
       }
       id--;
     }
   }
   return empty;
 }
Ejemplo n.º 3
0
    public bool AnalyseStreams()
    {
      try
      {
        if (FStreams == null)
        {
          FStreams = new FilterStreams();
        }
        FStreams.DeleteAllStreams();
        //RETRIEVING THE CURRENT SPLITTER
        string filter;
        IBaseFilter[] foundfilter = new IBaseFilter[2];
        int fetched = 0;
        IEnumFilters enumFilters;
        graphBuilder.EnumFilters(out enumFilters);
        if (enumFilters != null)
        {
          enumFilters.Reset();
          while (enumFilters.Next(1, foundfilter, out fetched) == 0)
          {
            if (foundfilter[0] != null && fetched == 1)
            {
              if (chapters == null)
              {
                IAMExtendedSeeking pEs = foundfilter[0] as IAMExtendedSeeking;
                if (pEs != null)
                {
                  int markerCount = 0;
                  if (pEs.get_MarkerCount(out markerCount) == 0 && markerCount > 0)
                  {
                    chapters = new double[markerCount];
                    chaptersname = new string[markerCount];
                    for (int i = 1; i <= markerCount; i++)
                    {
                      double markerTime = 0;
                      pEs.GetMarkerTime(i, out markerTime);
                      chapters[i - 1] = markerTime;
                      //fill up chapter names
                      string name = null;
                      pEs.GetMarkerName(i, out name);
                      chaptersname[i - 1] = name;
                    }
                  }
                }
              }
              IAMStreamSelect pStrm = foundfilter[0] as IAMStreamSelect;
              if (pStrm != null)
              {
                FilterInfo foundfilterinfos = new FilterInfo();
                foundfilter[0].QueryFilterInfo(out foundfilterinfos);
                filter = foundfilterinfos.achName;
                int cStreams = 0;
                pStrm.Count(out cStreams);
                if (cStreams < 2)
                {
                  continue;
                }
                //GET STREAMS
                for (int istream = 0; istream < cStreams; istream++)
                {
                  AMMediaType sType;
                  AMStreamSelectInfoFlags sFlag;
                  int sPDWGroup, sPLCid;
                  string sName;
                  object pppunk, ppobject;
                  //STREAM INFO
                  pStrm.Info(istream, out sType, out sFlag, out sPLCid,
                             out sPDWGroup, out sName, out pppunk, out ppobject);
                  FilterStreamInfos FSInfos = new FilterStreamInfos();
                  FSInfos.Current = false;
                  FSInfos.Filter = filter;
                  FSInfos.Name = sName;
                  FSInfos.LCID = sPLCid;
                  FSInfos.Id = istream;
                  FSInfos.Type = StreamType.Unknown;
                  //Avoid listing ffdshow video filter's plugins amongst subtitle and audio streams and editions.
                  if ((FSInfos.Filter == "ffdshow DXVA Video Decoder" || FSInfos.Filter == "ffdshow Video Decoder" ||
                       FSInfos.Filter == "ffdshow raw video filter") &&
                      ((sPDWGroup == 1) || (sPDWGroup == 2) || (sPDWGroup == 18) || (sPDWGroup == 4)))
                  {
                    FSInfos.Type = StreamType.Unknown;
                  }
                  //VIDEO
                  else if (sPDWGroup == 0)
                  {
                    FSInfos.Type = StreamType.Video;
                  }
                  //AUDIO
                  else if (sPDWGroup == 1)
                  {
                    FSInfos.Type = StreamType.Audio;
                  }
                  //SUBTITLE
                  else if (sPDWGroup == 2 && sName.LastIndexOf("off") == -1 && sName.LastIndexOf("Hide ") == -1 &&
                           sName.LastIndexOf("No ") == -1 && sName.LastIndexOf("Miscellaneous ") == -1)
                  {
                    FSInfos.Type = StreamType.Subtitle;
                  }
                  //NO SUBTITILE TAG
                  else if ((sPDWGroup == 2 && (sName.LastIndexOf("off") != -1 || sName.LastIndexOf("No ") != -1)) ||
                           (sPDWGroup == 6590033 && sName.LastIndexOf("Hide ") != -1))
                  {
                    FSInfos.Type = StreamType.Subtitle_hidden;
                  }
                  //DirectVobSub SHOW SUBTITLE TAG
                  else if (sPDWGroup == 6590033 && sName.LastIndexOf("Show ") != -1)
                  {
                    FSInfos.Type = StreamType.Subtitle_shown;
                  }
                  //EDITION
                  else if (sPDWGroup == 18)
                  {
                    FSInfos.Type = StreamType.Edition;
                  }
                  else if (sPDWGroup == 4) //Subtitle file
                  {
                    FSInfos.Type = StreamType.Subtitle_file;
                  }
                  else if (sPDWGroup == 10) //Postprocessing filter
                  {
                    FSInfos.Type = StreamType.PostProcessing;
                  }
                  Log.Debug("VideoPlayer: FoundStreams: Type={0}; Name={1}, Filter={2}, Id={3}, PDWGroup={4}, LCID={5}",
                            FSInfos.Type.ToString(), FSInfos.Name, FSInfos.Filter, FSInfos.Id.ToString(),
                            sPDWGroup.ToString(), sPLCid.ToString());

                  switch (FSInfos.Type)
                  {
                    case StreamType.Unknown:
                    case StreamType.Subtitle:
                    case StreamType.Subtitle_file:
                      break;
                    case StreamType.Video:
                    case StreamType.Audio:
                    case StreamType.Edition:
                    case StreamType.PostProcessing:
                      if (FSInfos.Type == StreamType.Audio && FSInfos.Filter == MEDIAPORTAL_AUDIOSWITCHER_FILTER && FSInfos.Name == "Audio " && !AutoRenderingCheck && GetInterface)
                      {
                        FStreams.AddStreamInfosEx(FSInfos);
                        break;
                      }
                      if (FStreams.GetStreamCount(FSInfos.Type) == 0)
                      {
                        FSInfos.Current = true;
                        pStrm.Enable(FSInfos.Id, 0);
                        pStrm.Enable(FSInfos.Id, AMStreamSelectEnableFlags.Enable);
                        /*if (FSInfos.Type == StreamType.Audio && FSInfos.Filter != MEDIAPORTAL_AUDIOSWITCHER_FILTER && GetInterface && !AutoRenderingCheck)
                        {
                          iChangedMediaTypes = 1;
                          //DoGraphRebuild();
                        }*/
                      }
                      goto default;
                    default:
                      FStreams.AddStreamInfos(FSInfos);
                      break;
                  }
                }
              }
              DirectShowUtil.ReleaseComObject(foundfilter[0]);
            }
          }
          DirectShowUtil.ReleaseComObject(enumFilters);
        }
      }
      catch { }
      return true;
    }
Ejemplo n.º 4
0
 private static bool AddStreamInfos(FilterStreamInfos streamInfos, ref int streamsCount, FilterStreamInfos[] streams)
 {
   if (streamsCount == MAX_STREAMS)
   {
     return false;
   }
   streams[streamsCount] = streamInfos;
   streamsCount++;
   return true;
 }
Ejemplo n.º 5
0
 public bool AddStreamInfosEx(FilterStreamInfos streamInfos)
 {
   return AddStreamInfos(streamInfos, ref cStreamsExternal, StreamsExternal);
 }
Ejemplo n.º 6
0
 public bool AddStreamInfos(FilterStreamInfos streamInfos)
 {
   return AddStreamInfos(streamInfos, ref cStreams, Streams);
 }