Beispiel #1
0
        static public MMChunk FromStream(Stream st)
        {
            if (!st.CanRead)
            {
                return(null);
            }
            if (st.Position > st.Length - 4)
            {
                return(null);
            }
            byte[] data = new byte[4];
            st.Read(data, 0, 4);
            FourCC fourCC = BitConverter.ToInt32(data, 0);

            if (fourCC == FourCC.Riff)
            {
                RiffChunk ck = new RiffChunk(st);
                ck.LoadFromStream(st);
                return(ck);
            }
            else if (fourCC == FourCC.Fmt)
            {
                FmtChunk ck = new FmtChunk(st, null);
                ck.LoadFromStream(st);
                return(ck);
            }
            else if (fourCC == FourCC.Data)
            {
                DataChunk ck = new DataChunk(st);
                ck.LoadFromStream(st);
                return(ck);
            }
            else
            {
                _RiffChunk ck = new _RiffChunk(fourCC, st);
                ck.LoadFromStream(st);
                return(ck);
            }
        }
Beispiel #2
0
        virtual public MMChunk CreateSubChunk(FourCC fourCC, Stream st)
        {
            if (fourCC == FourCC.Riff)
            {
                MMChunk ck = new RiffChunk(st);
                m_chunkList.Add(ck);
                return(ck);
            }
            else if (fourCC == FourCC.Fmt)
            {
                MMChunk ck = new FmtChunk(st, null);
                m_chunkList.Add(ck);
                return(ck);
            }
            else if (fourCC == FourCC.Data)
            {
                MMChunk ck = new DataChunk(st);
                m_chunkList.Add(ck);
                return(ck);
            }

            return(null);
        }