protected bool Equals(ProjectionSourceDefinition other)
 {
     return(AllEvents.Equals(other.AllEvents) && AllStreams.Equals(other.AllStreams) &&
            ByStream.Equals(other.ByStream) && ByCustomPartitions.Equals(other.ByCustomPartitions) &&
            Equals(Categories, other.Categories) && Equals(Events, other.Events) &&
            Equals(Streams, other.Streams) && string.Equals(CatalogStream, other.CatalogStream) &&
            LimitingCommitPosition == other.LimitingCommitPosition && Equals(Options, other.Options));
 }
Exemple #2
0
 public override int GetHashCode()
 {
     unchecked {
         int hashCode = AllEvents.GetHashCode();
         hashCode = (hashCode * 397) ^ AllStreams.GetHashCode();
         hashCode = (hashCode * 397) ^ ByStream.GetHashCode();
         hashCode = (hashCode * 397) ^ ByCustomPartitions.GetHashCode();
         hashCode = (hashCode * 397) ^ LimitingCommitPosition.GetHashCode();
         hashCode = (hashCode * 397) ^ (Options != null ? Options.GetHashCode() : 0);
         return(hashCode);
     }
 }
        private void PrepareMediaInfo(bool appendInfo)
        {
            if (this.IsMediaInfoAvailable)
            {
                return;
            }

            if (System.IO.File.Exists(this.File) == false)
            {
                return;
            }

            using (var objMediaInfo = new MediaInfo())
            {
                objMediaInfo.Open(this.File);

                try
                {
                    this.MediaInfoText = objMediaInfo.Inform().Trim();

                    var generalStream = new Streams.GeneralStream();
                    var allStreams    = new List <Streams.IStreamBase>();

                    IEnumerable <string> streams = null;
                    string[]             lines   = null;

                    streams = this.MediaInfoText.Split(Environment.NewLine + Environment.NewLine);

                    var streamIndex = -1;

                    foreach (var stream in streams)
                    {
                        Streams.StreamBase currentStream = null;
                        lines = stream.Split(Environment.NewLine);
                        var firstLine = lines[0];

                        if (!string.IsNullOrEmpty(firstLine))
                        {
                            if (firstLine.Contains("General"))
                            {
                                currentStream = generalStream = new Streams.GeneralStream();
                                //MediaInfo cannot read Avisynth files, so add format manually
                                if (Extension == ".avs")
                                {
                                    currentStream.Properties.Add("Format", "Avisynth Script");
                                }
                            }
                            else if (firstLine.Contains("Audio"))
                            {
                                currentStream = new Streams.AudioStream();
                                allStreams.Add(currentStream);
                                currentStream.StreamIndex = ++streamIndex;
                            }
                            else if (firstLine.Contains("Video"))
                            {
                                currentStream = new Streams.VideoStream();
                                allStreams.Add(currentStream);
                                currentStream.StreamIndex = ++streamIndex;
                            }
                            else if (firstLine.Contains("Text"))
                            {
                                currentStream = new Streams.TextStream();
                                allStreams.Add(currentStream);
                                currentStream.StreamIndex = ++streamIndex;
                            }
                            else if (firstLine.Contains("Image"))
                            {
                                currentStream = new Streams.ImageStream();
                                allStreams.Add(currentStream);
                                currentStream.StreamIndex = ++streamIndex;
                            }
                            else if (firstLine.Contains("Menu"))
                            {
                                currentStream = new Streams.MenuStream();
                                allStreams.Add(currentStream);
                                currentStream.StreamIndex = ++streamIndex;
                            }
                            else if (firstLine.Contains("Chapters"))
                            {
                                currentStream = new Streams.ChaptersStream();
                                allStreams.Add(currentStream);
                                currentStream.StreamIndex = ++streamIndex;
                            }
                        }

                        if (currentStream != null)
                        {
                            //get properties
                            foreach (var line in lines)
                            {
                                var property = line.Split(" : ");
                                if (property.Length > 1)
                                {
                                    var propertyName  = property[0].Trim();
                                    var propertyValue = property[1].Trim();
                                    if (!currentStream.Properties.ContainsKey(propertyName))
                                    {
                                        currentStream.Properties.Add(propertyName, propertyValue);
                                    }
                                }
                            }
                        }
                    }

                    foreach (var stream in allStreams)
                    {
                        stream.SourceFile = this;
                    }

                    //fix stream order using ID property ------------------------------------

                    var flag = true;
                    Streams.IStreamBase tempStream;

                    //bubble-sort the streams using the ID number

                    for (var pass = 1; (pass <= allStreams.Count) && flag; pass++) // N passes
                    {
                        flag = false;

                        for (var comp = 0; comp <= allStreams.Count - 2; comp++) // N-1 comparisons
                        {
                            if (allStreams[comp].Id != -1 & allStreams[comp + 1].Id != -1)
                            {
                                if (allStreams[comp].Id > allStreams[comp + 1].Id)
                                {
                                    tempStream           = allStreams[comp];
                                    allStreams[comp]     = allStreams[comp + 1];
                                    allStreams[comp + 1] = tempStream;
                                    flag = true;
                                }
                            }
                        }
                    }

                    foreach (var stream in allStreams)
                    {
                        stream.StreamIndex = AllStreams.IndexOf(stream);
                    }

                    SetStreamTypeIndices(allStreams);

                    //--finished fixing stream order ---------------------------------------

                    this.IsMediaInfoAvailable = true;
                    this.MediaInfoHtml        = GetInfoHtml(generalStream, allStreams);

                    if (appendInfo)
                    {
                        AddProperties(generalStream, allStreams, true);
                    }
                }
                finally
                {
                    objMediaInfo.Close();
                }
            }
        }