Exemple #1
0
        /// <summary>
        /// Tries to add an entry created from the frame.
        /// </summary>
        /// <param name="managedFrame">The managed frame.</param>
        /// <returns>
        /// True if the index entry was created from the frame.
        /// False if the frame is of wrong picture type or if it already existed.
        /// </returns>
        internal bool TryAdd(VideoFrame managedFrame)
        {
            // Update the Seek index
            if (managedFrame.PictureType != AVPictureType.AV_PICTURE_TYPE_I)
            {
                return(false);
            }

            // Create the seek entry
            var seekEntry = new VideoSeekIndexEntry(managedFrame);

            // Check if the entry already exists.
            if (Entries.BinarySearch(seekEntry, LookupComparer) >= 0)
            {
                return(false);
            }

            // Add the seek entry and ensure they are sorted.
            Entries.Add(seekEntry);
            Entries.Sort(LookupComparer);
            return(true);
        }