Ejemplo n.º 1
0
        /// <summary>Initializes a new instance of the <see cref="ID3v2Frame" /> class.</summary>
        /// <param name="header">The header.</param>
        /// <param name="reader">The reader.</param>
        /// <exception cref="ArgumentNullException">Header.</exception>
        /// <exception cref="NotSupportedException"></exception>
        public ID3v2Frame(ID3v2Header header, DataFrameReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("Reader");
            }

            m_Header = new ID3v2FrameHeader(header, reader);

            // prepare content (has to be decoded, decrypted, decompressed, ...
            m_Content = reader.Read(m_Header.HeaderSize, m_Header.ContentSize);

            switch (header.Version)
            {
            case 2: /*nothing to do, raw plain content data*/ break;

            case 3: ParseVersion3(reader); break;

            case 4: ParseVersion4(reader); break;

            default: throw new NotSupportedException(string.Format("ID3v2.{0} is not supported!", header.Version));
            }

            // copy raw data and remove from reader
            m_Data = reader.GetBuffer(m_Header.HeaderSize + m_Header.ContentSize);
        }
Ejemplo n.º 2
0
        /// <summary>Initializes a new instance of the <see cref="ID3v2Frame"/> class.</summary>
        /// <param name="frame">The frame.</param>
        /// <exception cref="ArgumentNullException">Frame.</exception>
        public ID3v2Frame(ID3v2Frame frame)
        {
            if (frame == null)
            {
                throw new ArgumentNullException("Frame");
            }

            m_Data    = frame.m_Data;
            m_Content = frame.m_Content;
            m_Header  = frame.m_Header;
        }
Ejemplo n.º 3
0
        /// <summary>Initializes a new instance of the <see cref="ID3v2Frame" /> class.</summary>
        /// <param name="header">The header.</param>
        /// <param name="data">The data.</param>
        public ID3v2Frame(ID3v2Header header, byte[] data)
        {
            m_Header = new ID3v2FrameHeader(header, data);
            if (m_Header.ContentSize + m_Header.HeaderSize != data.Length)
            {
                throw new ArgumentOutOfRangeException("data", $"Invalid size of data! Expected {m_Header.ContentSize + m_Header.HeaderSize} bytes, got {data.Length}!");
            }

            m_Data    = data;
            m_Content = new byte[m_Header.ContentSize];
            Array.Copy(m_Data, m_Header.HeaderSize, m_Content, 0, m_Header.ContentSize);
        }