JarrettVance.ChapterTools.Extractors.XplExtractor.GetStreams C# (CSharp) Method

GetStreams() public method

public GetStreams ( string location ) : List
location string
return List
        public override List<ChapterInfo> GetStreams(string location)
        {
            List<ChapterInfo> pgcs = new List<ChapterInfo>();
              XDocument doc = XDocument.Load(location);
              XNamespace ns = "http://www.dvdforum.org/2005/HDDVDVideo/Playlist";
              foreach (XElement ts in doc.Element(ns + "Playlist").Elements(ns + "TitleSet"))
              {
            float timeBase = GetFps((string)ts.Attribute("timeBase"));
            float tickBase = GetFps((string)ts.Attribute("tickBase"));
            foreach (XElement title in ts.Elements(ns + "Title").Where(t => t.Element(ns + "ChapterList") != null))
            {
              ChapterInfo pgc = new ChapterInfo();
              List<ChapterEntry> chapters = new List<ChapterEntry>();
              pgc.SourceName = location;
              pgc.SourceHash = ChapterExtractor.ComputeMD5Sum(location);
              pgc.SourceType = "HD-DVD";
              pgc.FramesPerSecond = 24D;
              pgc.Extractor = Application.ProductName + " " + Application.ProductVersion;
              OnStreamDetected(pgc);

              int tickBaseDivisor = (int?)title.Attribute("tickBaseDivisor") ?? 1;
              pgc.Duration = GetTimeSpan((string)title.Attribute("titleDuration"), timeBase, tickBase, tickBaseDivisor);
              string titleName = Path.GetFileNameWithoutExtension(location);
              if (title.Attribute("id") != null) titleName = (string)title.Attribute("id");
              if (title.Attribute("displayName") != null) titleName = (string)title.Attribute("displayName");
              pgc.Title = titleName;
              foreach (XElement chapter in title.Element(ns + "ChapterList").Elements(ns + "Chapter"))
              {
            chapters.Add(new ChapterEntry()
            {
              Name = (string)chapter.Attribute("displayName"),
              Time = GetTimeSpan((string)chapter.Attribute("titleTimeBegin"), timeBase, tickBase, tickBaseDivisor)
            });
              }
              pgc.Chapters = chapters;
              OnChaptersLoaded(pgc);
              //pgc.ChangeFps(24D / 1.001D);
              pgcs.Add(pgc);
            }
              }
              pgcs = pgcs.OrderByDescending(p => p.Duration).ToList();
              OnExtractionComplete();
              return pgcs;
        }

Usage Example

Example #1
0
        public override List <ChapterInfo> GetStreams(string location)
        {
            List <ChapterInfo> pgcs = new List <ChapterInfo>();
            string             path = Path.Combine(location, "ADV_OBJ");

            if (!Directory.Exists(path))
            {
                throw new FileNotFoundException("Could not find ADV_OBJ folder on HD-DVD disc.");
            }

            ChapterExtractor ex = new XplExtractor();

            ex.StreamDetected += (sender, args) => OnStreamDetected(args.ProgramChain);
            ex.ChaptersLoaded += (sender, args) => OnChaptersLoaded(args.ProgramChain);

            string vol = Pathing.VolumeInfo.GetVolumeLabel(new DirectoryInfo(location));

            foreach (string file in Directory.GetFiles(path, "*.xpl"))
            {
                var pgc = ex.GetStreams(file)[0];
                if (!string.IsNullOrEmpty(vol))
                {
                    pgc.VolumeName = vol;
                }
                pgcs.Add(pgc);
            }

            pgcs = pgcs.OrderByDescending(p => p.Duration).ToList();
            OnExtractionComplete();
            return(pgcs);
        }
All Usage Examples Of JarrettVance.ChapterTools.Extractors.XplExtractor::GetStreams