Exemple #1
0
        /// <summary>
        /// Gets the chunk attributes for the given <paramref name="chunkName"/>
        /// using the information from the given <paramref name="attribute"/>.
        /// This adds the chunk to the list of container chunks if-and-only-if the
        /// chunk is a container chunk.
        /// </summary>
        /// <param name="chunkName">the chunk name</param>
        /// <param name="attribute">the attribute for the given chunk name</param>
        /// <param name="allContainerChunks">the list of all container chunks</param>
        /// <returns>the chunk attributes</returns>
        private static ChunkAttributes GetChunkAttributes(AviChunkName chunkName, AviAttribute attribute, ICollection <AviChunkName> allContainerChunks)
        {
            // Retrieve list of chunk types (4CC)
            List <uint> chunkTypes = new List <uint>();

            if (attribute.ChunkType != null)
            {
                foreach (string chunkType in attribute.ChunkType.Split("|".ToCharArray()))
                {
                    chunkTypes.Add(chunkType.To4CC());
                }
            }

            // Retrieve suitable parents, all container chunks if empty list
            ICollection <AviChunkName> suitableParents = attribute.SuitableParents;

            if (suitableParents.Count == 0)
            {
                suitableParents = allContainerChunks;
            }

            //// Update list of all container chunks
            if ((attribute.ChunkFlags & ChunkFlags.ContainerChunk) == ChunkFlags.ContainerChunk)
            {
                allContainerChunks.Add(chunkName);
            }
            return(new ChunkAttributes(chunkTypes.AsReadOnly(), attribute.ChunkFlags, suitableParents));
        }
Exemple #2
0
 /// <summary>
 /// Gets the chunk type flags for the given <paramref name="chunkName"/>.
 /// </summary>
 /// <param name="chunkName">the chunk name</param>
 /// <returns>the chunk flags</returns>
 public static ChunkFlags GetChunkFlags(this AviChunkName chunkName)
 {
     return(ChunkAttributesForChunkName[chunkName].ChunkFlags);
 }
Exemple #3
0
 /// <summary>
 /// Returns whether the given <paramref name="chunkFlag"/> is set for
 /// the given <paramref name="chunkName"/>.
 /// </summary>
 /// <param name="chunkName">the chunk name</param>
 /// <param name="chunkFlag">the flag to test</param>
 /// <returns>true if the flag is set, false otherwise</returns>
 public static bool IsFlagSet(this AviChunkName chunkName, ChunkFlags chunkFlag)
 {
     return((chunkName.GetChunkFlags() & chunkFlag) == chunkFlag);
 }
Exemple #4
0
 /// <summary>
 /// Gets the suitable parents for the given <paramref name="chunkName"/>.
 /// </summary>
 /// <param name="chunkName">the chunk name</param>
 /// <returns>the suitable parents</returns>
 public static ICollection <AviChunkName> GetSuitableParents(this AviChunkName chunkName)
 {
     return(ChunkAttributesForChunkName[chunkName].SuitableParents);
 }
Exemple #5
0
        /// <summary>
        /// Returns whether the given <paramref name="chunkName"/> is a top-level chunk type.
        /// Top-level chunks are only allowed in the root. For example, the Movie chunk.
        /// </summary>
        /// <param name="chunkName">the chunk name</param>
        /// <returns>true if it is a top-level chunk type, false otherwise</returns>
        public static bool IsTopLevel(this AviChunkName chunkName)
        {
            ICollection <AviChunkName> suitableParents = chunkName.GetSuitableParents();

            return(suitableParents.Count == 1 && suitableParents.Contains(AviChunkName.Root));
        }