Ejemplo n.º 1
0
        /// <summary>
        /// <see cref="BinarySubstr"/> から FrameHeader を読み取ります。
        /// </summary>
        /// <param name="image">FrameHeader の情報を持つ BinarySubstr を指定します。</param>
        public unsafe FrameHeader(BinarySubstr image)
        {
            fixed(byte *fix = image.array)
            {
                byte *           pB = image.CurrentPtr;
                FrameHeaderInfo *fh = (FrameHeaderInfo *)pB;

                this.frameId = (string)fh->frameID;

                this.discardOnAlteringTag  = fh->DiscardsIfTagAlter;
                this.discardOnAlteringFile = fh->DiscardsIfFileAlter;
                this.readOnly    = fh->IsReadOnly;
                this.compression = fh->IsCompressed;
                this.encryption  = fh->IsEncrypted;
                this.grouping    = fh->IsGrouped;

                if (this.compression)
                {
                    this.trueSize = fh->TrueSize;
                }
                if (this.encryption)
                {
                    this.trueSize = fh->EncryptionMethod;
                }
                if (this.grouping)
                {
                    this.groupId = fh->GroupId;
                }

                image.index += fh->HeaderSize;
                this.content = image.ReadRange((int)(uint)fh->size - fh->ExtraHeaderSize);
            }

            // this.content の内容を解凍・復号
        }
Ejemplo n.º 2
0
        public unsafe TagHeader(byte[] image, int offset)
        {
            this.fromfile = true;

            fixed(byte *pImgB = &image[0])
            {
                TagHeaderInfo *p = (TagHeaderInfo *)(pImgB + offset);

                if (!p->IsID3v2)
                {
                    throw new System.ApplicationException("有効な ID3v2.3.0 tag header ではありません。");
                }
                this.unsynchronization = p->Unsynchronization;
                this.hasExtHeader      = p->HasExtendedHeader;
                this.experimental      = p->IsExperimental;
                this.size = (int)p->size;

                this.content = new BinarySubstr(image, offset + (int)sizeof(TagHeaderInfo), (int)p->size);
            }

            if (this.unsynchronization)
            {
                this.content = this.content.ResolveUnsync();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 新しい TagHeader を生成します。
        /// </summary>
        public TagHeader()
        {
            this.unsynchronization = false;
            this.hasExtHeader      = false;
            this.experimental      = false;
            this.content           = null;

            this.fromfile = false;
        }
Ejemplo n.º 4
0
        public Tag(byte[] image, int offset)
        {
            this.header = new TagHeader(image, offset);
            BinarySubstr data = this.header.content;

#if DEBUG
            __dll__.log.Lock();
            __dll__.log.WriteLine("[ID3v2.3.0 Tag]");
            __dll__.log.AddIndent();
            __dll__.log.WriteVar("IsExperimentalTag", this.header.experimental.ToString());
            __dll__.log.WriteVar("Unsynchronization", this.header.unsynchronization.ToString());
            __dll__.log.WriteVar("HasExtendedHeader", this.header.hasExtHeader.ToString());
#endif
            if (this.header.hasExtHeader)
            {
                this.extheader = new ExtendedHeader(data);
#if DEBUG
                __dll__.log.WriteVar("PaddingSize", this.extheader.paddingSize.ToString());
                __dll__.log.WriteVar("HasCRC32", this.extheader.hasCrc32.ToString());
#endif
                if (this.extheader.hasCrc32)
                {
                    uint crc32 = data.CalculateCRC32();
                    __dll__.log.WriteLine("    CRC32 Check: 実 {0:X8} --><-- {1:X8} 理", crc32, this.extheader.crc32);
                    if (crc32 != this.extheader.crc32)
                    {
                        throw new System.ApplicationException("Crc 値が一致しません。");
                    }
                }
            }
            afh.Collections.DictionaryP <string, FrameHeader> headers = FrameHeader.GetFrameHeaders(data);
            this.frames = headers.Map <Frame>(Frame.CreateFrame);
#if DEBUG
            __dll__.log.RemoveIndent();
            foreach (Gen::KeyValuePair <string, Frame> pair in this.frames)
            {
                __dll__.log.WriteLine("Frame---");
                __dll__.log.AddIndent();
                __dll__.log.WriteVar("FrameID", pair.Key);
                __dll__.log.WriteVar("FrameType", pair.Value.GetType().FullName);
                //__dll__.log.WriteVar("Discards on TagChange",pair.Value.discardOnAlteringTag.ToString());
                //__dll__.log.WriteVar("Discards on FileChange",pair.Value.discardOnAlteringFile.ToString());
                //__dll__.log.WriteVar("ReadOnly",pair.Value.readOnly.ToString());
                //__dll__.log.WriteVar("Compressed",pair.Value.compression.ToString());
                //__dll__.log.WriteVar("Encrypted",pair.Value.encryption.ToString());
                //__dll__.log.WriteVar("Grouping",pair.Value.grouping.ToString());
                if (pair.Value is ID3v2_3_.TextInformationFrame)
                {
                    __dll__.log.WriteVar("TextContent", ((ID3v2_3_.TextInformationFrame)pair.Value).Text);
                }
                __dll__.log.RemoveIndent();
            }
            __dll__.log.Unlock();
#endif
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 新しい FrameHeader を作成します。
        /// </summary>
        /// <param name="frameId">新しい FrameHeader の FrameId を指定します。</param>
        internal FrameHeader(string frameId)
        {
            this.frameId = frameId;

            this.discardOnAlteringTag  = false;
            this.discardOnAlteringFile = Frame.FramesData[frameId].DiscardOnAlteringFile;
            this.readOnly    = false;
            this.compression = false;
            this.encryption  = false;
            this.grouping    = false;

            //this.trueSize=0;
            //this.encryptionMethod=0;
            //this.groupId=0;

            this.content = null;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// ExtendedHeader を初期化します。
        /// ExtendedHeader を読み取った後、読み取り位置は読み取った分だけ先に進められます。
        /// </summary>
        /// <param name="data">ExtendedHeader の情報を指定します。</param>
        public unsafe ExtendedHeader(BinarySubstr data)
        {
            fixed(byte *fix = data.array)
            {
                ExtendedHeaderInfo *xh = (ExtendedHeaderInfo *)data.CurrentPtr;

                this.hasCrc32 = xh->HasCrc32;
                if (this.hasCrc32)
                {
                    this.crc32 = (uint)xh->Crc32;
                }
                this.paddingSize = (uint)xh->paddingSize;

                data.index += (int)this.Size;
                data.end   -= (int)this.paddingSize;
            }
        }
Ejemplo n.º 7
0
        private unsafe static FrameHeader ReadFrameHeader(BinarySubstr data)
        {
            string frameID;

            fixed(byte *fix = data.array)
            {
                byte *p  = data.CurrentPtr;
                byte *pM = data.ptrEnd - 11;

                while (*p == 0)
                {
                    if (pM <= p++)
                    {
                        return(null);
                    }
                }
                frameID = (string)*(CharCode4 *)p;
            }

            return(new FrameHeader(data));
        }
Ejemplo n.º 8
0
 public Frame(FrameHeader header)
 {
     this.header = header;
     this.data   = header.content;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Frame 情報が並んだデータを持つ BinarySubstr から FrameHeader の集合を読み取ります。
        /// </summary>
        /// <param name="data">Frame 情報が並んだデータを参照する BinarySubstr を指定します。</param>
        /// <returns>読み取った FrameHeader の集合を返します。</returns>
        public static afh.Collections.DictionaryP <string, FrameHeader> GetFrameHeaders(BinarySubstr data)
        {
            FrameHeader fheader;

            afh.Collections.DictionaryP <string, FrameHeader> dic = new afh.Collections.DictionaryP <string, FrameHeader>();
            while (null != (fheader = ReadFrameHeader(data)))
            {
                dic.Add(fheader.frameId, fheader);
            }
            return(dic);
        }