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