/// <summary> /// Gets the header attributes for the given <paramref name="headerName"/> /// using the information from the given <paramref name="attribute"/>. /// This adds the header to the list of container headers if-and-only-if the /// header is a container header. /// </summary> /// <param name="headerName">the header name</param> /// <param name="attribute">the attribute for the given header name</param> /// <param name="allContainerHeaders">the list of all container headers</param> /// <returns>the header attributes</returns> private static HeaderAttributes GetHeaderAttributes(Mpeg4HeaderName headerName, Mpeg4Attribute attribute, ICollection <Mpeg4HeaderName> allContainerHeaders) { // Retrieve list of header start codes List <uint> headerStartCodes = new List <uint>(); if (attribute.HeaderStartCode != null) { const string SeparatorCharacter = "-"; if (attribute.HeaderStartCode.Contains(SeparatorCharacter)) { Debug.Assert(attribute.HeaderStartCode.Length == 5); // Example: "40-5F" string[] startCodes = attribute.HeaderStartCode.Split(SeparatorCharacter.ToCharArray()); uint firstStartCode = uint.Parse(startCodes[0], System.Globalization.NumberStyles.HexNumber, CultureInfo.InvariantCulture); uint lastStartCode = uint.Parse(startCodes[1], System.Globalization.NumberStyles.HexNumber, CultureInfo.InvariantCulture); Debug.Assert(firstStartCode < lastStartCode); for (uint startCode = firstStartCode; startCode <= lastStartCode; startCode++) { headerStartCodes.Add(0x100 + startCode); } } else { headerStartCodes.Add(0x100 + uint.Parse(attribute.HeaderStartCode, System.Globalization.NumberStyles.HexNumber, CultureInfo.InvariantCulture)); } } // Retrieve suitable parents, all container headers if empty list ICollection <Mpeg4HeaderName> suitableParents = attribute.SuitableParents; if (suitableParents.Count == 0) { suitableParents = allContainerHeaders; } // Update list of all container headers if ((attribute.HeaderFlags & HeaderFlags.MasterHeader) == HeaderFlags.MasterHeader) { allContainerHeaders.Add(headerName); } return(new HeaderAttributes(headerStartCodes.AsReadOnly(), attribute.HeaderFlags, suitableParents)); }
/// <summary> /// Gets the suitable parents for the given <paramref name="headerName"/>. /// </summary> /// <param name="headerName">the header name</param> /// <returns>the suitable parents</returns> public static ICollection <Mpeg4HeaderName> GetSuitableParents(this Mpeg4HeaderName headerName) { return(_headerAttributes[headerName].SuitableParents); }
/// <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 Mpeg4HeaderName chunkName) { ICollection <Mpeg4HeaderName> suitableParents = chunkName.GetSuitableParents(); return(suitableParents.Count == 1 && suitableParents.Contains(Mpeg4HeaderName.Root)); }
/// <summary> /// Gets the header flags for the given <paramref name="headerName"/>. /// </summary> /// <param name="headerName">the header name</param> /// <returns>the header flags</returns> public static HeaderFlags GetHeaderFlags(this Mpeg4HeaderName headerName) { return(_headerAttributes[headerName].HeaderFlags); }
/// <summary> /// Returns whether the given <paramref name="headerFlag"/> is set for /// the given <paramref name="headerName"/>. /// </summary> /// <param name="headerName">the header name</param> /// <param name="headerFlag">the flag to test</param> /// <returns>true if the flag is set, false otherwise</returns> public static bool IsFlagSet(this Mpeg4HeaderName headerName, HeaderFlags headerFlag) { return((headerName.GetHeaderFlags() & headerFlag) == headerFlag); }