当前位置: 首页>>代码示例>>C#>>正文


C# IReader.read方法代码示例

本文整理汇总了C#中IReader.read方法的典型用法代码示例。如果您正苦于以下问题:C# IReader.read方法的具体用法?C# IReader.read怎么用?C# IReader.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IReader的用法示例。


在下文中一共展示了IReader.read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: init

        public ErrorCode init(IReader reader)
        {
            reader_ = reader;
            reader_.seek(0);
            ErrorCode res = ErrorCode.Success;

            do
            {
                if (reader_.size() < 44)
                {
                    res = ErrorCode.InvalidStream;
                }

                byte[] buff = new byte[1024];
                int size = 1024;
                reader_.read(buff, ref size);
                int offset = 0;
                UInt32 val = AVUtils.read32(buff, offset);
                if (val != 0x46464952)//RIFF
                {
                    res = ErrorCode.InvalidStream;
                    break;
                }
                offset += 4;
                length_ = 8 + AVUtils.read32(buff, offset);
                offset += 4;
                val = AVUtils.read32(buff, offset);
                if (val != 0x45564157) //WAVE
                {
                    res = ErrorCode.InvalidStream;
                    break;
                }
                offset += 12;
                val = AVUtils.read16(buff, offset);
                if (val != 1) //PCM
                {
                    res = ErrorCode.InvalidStream;
                    break;
                }

                offset += 2;
                channels_ = (UInt16)AVUtils.read16(buff, offset);
                offset += 2;
                frequency_ = AVUtils.read32(buff, offset);
                offset += 10;
                bps_ = (UInt16)AVUtils.read16(buff, offset);
                offset_ = 44;
                length_ = reader_.size() - offset_;
                reader.seek(44);
            }
            while (false);
            return res;
        }
开发者ID:da8eat,项目名称:AVSharp,代码行数:53,代码来源:WaveParser.cs

示例2: init

        public ErrorCode init(IReader reader)
        {
            reader_ = reader;
            reader_.seek(0);

            if (reader.size() < 4)
            {
                return ErrorCode.InvalidStream;
            }

            int size = Math.Min(64 * 1024, (int)reader.size());
            byte [] buff = new byte[size];
            int offset = 0;

            reader_.read(buff, ref size);

            while (offset + 4 < size)
            {
                MPAHeader hdr = MPAHeaderParser.parse(buff, offset);

                if (hdr.valid)
                {
                    UInt32 pckSize = MPAHeaderParser.mpaPacketSize(hdr);
                    MPAHeader hdr2 = MPAHeaderParser.parse(buff, offset + (int)pckSize);
                    if (hdr2.valid && hdr2.isEqual(hdr))
                    {
                        break;
                    }
                }
                ++offset;
            }

            if (offset + 4 < size)
            {
                MPAHeader hdr = MPAHeaderParser.parse(buff, offset);
                length_ = MPAHeaderParser.mpaPacketSize(hdr);
                offset_ = (UInt32)offset;

                UInt64 ln = reader.size() - (UInt64)offset;
                ln /= MPAHeaderParser.mpaPacketSize(hdr);

                packets_ = (UInt32)ln;
                duration_ = (UInt64)(100000 * (double)ln * (double)MPAHeaderParser.samples(hdr) / (double)MPAHeaderParser.samplingRate(hdr));
                info_ = new MPAInfo(hdr, duration_);
                samples_ = MPAHeaderParser.samples(hdr);
                seek(0);
                return ErrorCode.Success;
            }

            return ErrorCode.InvalidStream;
        }
开发者ID:da8eat,项目名称:AVSharp,代码行数:51,代码来源:MPAParser.cs


注:本文中的IReader.read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。