Esempio n. 1
0
 public override string ToTextualConvention(Container.Node node)
 {
     if (node.Master.Equals(this))
     {
         return(RiffReader.ToFourCharacterCode(node.Identifier));
     }
     return(base.ToTextualConvention(node));
 }
Esempio n. 2
0
        public Node ReadNext()
        {
            if (Remaining <= MinimumSize)
            {
                throw new System.IO.EndOfStreamException();
            }

            byte[] identifier = new byte[IdentifierSize];

            byte[] lengthBytes = new byte[LengthSize];

            int read = Read(identifier, 0, IdentifierSize);

            read += Read(lengthBytes, 0, LengthSize);

            ulong length = (ulong)Common.Binary.Read32(lengthBytes, 0, Media.Common.Binary.IsBigEndian);

            int identifierSize = IdentifierSize;

            //Get the fourCC of the node
            FourCharacterCode fourCC = (FourCharacterCode)Common.Binary.Read32(identifier, 0, Media.Common.Binary.IsBigEndian);

            //Store the first
            if (false == m_Type.HasValue)
            {
                m_Type = fourCC;
            }

            //Determine if 64 bit support is needed by inspecting the first node encountered.
            if (false == m_Needs64BitInfo.HasValue)
            {
                //There may be other nodes to account for also...
                m_Needs64BitInfo = fourCC == FourCharacterCode.RF64;
            }

            //Determine if an identifier follows
            if (RiffReader.HasSubType(fourCC))
            {
                //Resize the identifier to make room for the sub type
                Array.Resize(ref identifier, MinimumSize);

                //Read the sub type
                read += Read(identifier, IdentifierSize, IdentifierSize);

                //Not usually supposed to read the identifier
                length -= IdentifierSize;

                //Adjust for the bytes read.
                identifierSize += IdentifierSize;

                //Store the SubType if needed.
                if (false == m_SubType.HasValue)
                {
                    m_SubType = GetSubType(identifier);
                }
            }

            //If this is a 64 bit entry
            if (length == uint.MaxValue)
            {
                //use the dataSize (0 for the first node, otherwise whatever was found)
                length = m_DataSize;

                //There are so may ways to handle this it's not funny, this seems to the most documented but probably one of the ugliest.
                //Not to mention this doesn't really give you compatiblity and doesn't contain a failsafe.

                //If files can be found which still don't work I will adjust this logic as necessary.
            }

            //return a new node,                                             Calculate length as padded size (to word boundary)
            return(new Node(this, new Common.MemorySegment(identifier), identifierSize, LengthSize, Position, (long)(0 != (length & 1) ? ++length : length),
                            read >= MinimumSize && length <= (ulong)Remaining)); //determine Complete
        }