Пример #1
0
        public override Stream LoadTagData(Stream stream)
        {
            var MediaInfo = stream.ReadUInt8();                //#1

            this.Codec = (SoundFormat)(MediaInfo >> 4);        //ACC 10
            this.Rate  = (SoundRate)((MediaInfo & 0x0f) >> 2); //AAC: always 3
            this.Size  = (SoundSize)((MediaInfo & 0x02) >> 1); //AAC: always 1
            this.Type  = (SoundType)(MediaInfo & 0x01);        //AAC: always 1
            //=== Data ===
            var pos = stream.Position;
            var wtf = stream.ReadBytes(1);                                      //#1
            var buf = stream.ReadBytes((int)this.DataSize - 1 - 1);             //#n

            DataStream = new MemoryStream();
            DataStream.Write(buf, 0, buf.Length);
            return(DataStream);
        }
Пример #2
0
        protected override void Parse()
        {
            BinaryReader br = new BinaryReader(this._dataStream);
            BitStream bits = new BitStream(this._dataStream);

            ushort _reserved = (ushort)bits.GetBits(4);
            this._playbacksoundrate = DefineSound.getSoundRate(bits.GetBits(2));
            this._playbacksoundsize = (bits.GetBits(1) == 0) ? SoundSize.snd_8bit : SoundSize.snd_16bit;
            this._playbacksoundtype = (bits.GetBits(1) == 0) ? SoundType.mono : SoundType.stereo;

            this._streamsoundcompression = DefineSound.getFormat(bits.GetBits(4));
            this._streamsoundrate = DefineSound.getSoundRate(bits.GetBits(2));
            this._streamsoundsize = (bits.GetBits(1) == 0) ? SoundSize.snd_8bit : SoundSize.snd_16bit;
            this._streamsoundtype = (bits.GetBits(1) == 0) ? SoundType.mono : SoundType.stereo;

            this._streamsoundsamplecount = br.ReadUInt16();

            if (_streamsoundcompression == SoundEncoding.MP3)
                this._latencyseek = br.ReadInt16();

            if (_reserved != 0)
            {
                Exception e = new SwfFormatException("Reserved bits are set");
                Log.Warn(this, e);
            }
            String s1 = String.Format("0x{0:X08}: reading soundstreamhead. Avarage samples {1}", this.Tag.OffsetData, this.AvarageCount);
            Log.Debug(this, s1);

               String s2 = String.Format("0x{0:X08}:\tPlayback: {1} {2} {3}",
                this.Tag.OffsetData,
                this.PlaybackRate,
                this.PlaybackSize,
                this.PlaybackType);
               Log.Debug(this, s2);

               String s3 = String.Format("0x{0:X08}:\tStream:   {1} {2} {3} {4}",
                this.Tag.OffsetData,
                this.StreamCompression,
                this.StreamRate,
                this.StreamSize,
                this.StreamType);
               Log.Debug(this, s3);
        }
Пример #3
0
        /// <summary>
        /// 
        /// </summary>
        protected override void Parse()
        {
            BinaryReader br = new BinaryReader(this._dataStream);
            BitStream bits = new BitStream(this._dataStream);

            this._soundID = br.ReadUInt16();
            this._soundFormat = getFormat(bits.GetBits(4));
            this._soundRate = getSoundRate(bits.GetBits(2));
            this._soundSize = (bits.GetBits(1) == 0) ? SoundSize.snd_8bit : SoundSize.snd_16bit;
            this._soundType = (bits.GetBits(1) == 0) ? SoundType.mono : SoundType.stereo;
            this._soundSampleCount = br.ReadUInt32();

            this._requiredVersion = getRequiredVersion(this._soundFormat);

            // TODO: check buffersize
            // Casting from UInt32 to int !!!!
            this._soundData = br.ReadBytes((int)Tag.Length - 7);

            String s = String.Format("\t{0} {1}", Tag.Length, Length);
            //Log.Debug(this, s);
        }
Пример #4
0
        //
        /// <summary>
        /// Determines the number indicates the given soundrate
        /// </summary>
        /// <param name="sr">The sound rate</param>
        /// <returns>The sound rate ID</returns>
        public static uint getSoundRateID(SoundRate sr)
        {
            if (sr == SoundRate.snd_5kHz)
                return 0;

            else if (sr == SoundRate.snd_11kHz)
                return 1;

            else if (sr == SoundRate.snd_22kHz)
                return 2;

            else if (sr == SoundRate.snd_44kHz)
                return 3;

            else
                return 255;  //Invalid Value
        }