本文整理汇总了Java中com.jcraft.jogg.Page.serialno方法的典型用法代码示例。如果您正苦于以下问题:Java Page.serialno方法的具体用法?Java Page.serialno怎么用?Java Page.serialno使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jcraft.jogg.Page
的用法示例。
在下文中一共展示了Page.serialno方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bisectForwardSerialno
import com.jcraft.jogg.Page; //导入方法依赖的package包/类
/**
* Bisect forward serial number.
* @param begin beginning
* @param searched searched
* @param end end
* @param currentno current number
* @param m member
* @return success flag OV_*
*/
int bisectForwardSerialno(long begin, long searched, long end,
int currentno, int m) {
long endsearched = end;
long next = end;
Page page = new Page();
int ret;
while (searched < endsearched) {
long bisect;
if (endsearched - searched < CHUNKSIZE) {
bisect = searched;
} else {
bisect = (searched + endsearched) / 2;
}
seekHelper(bisect);
ret = getNextPage(page, -1);
if (ret == OV_EREAD) {
return OV_EREAD;
}
if (ret < 0 || page.serialno() != currentno) {
endsearched = bisect;
if (ret >= 0) {
next = ret;
}
} else {
searched = ret + page.headerLen + page.bodyLen;
}
}
seekHelper(next);
ret = getNextPage(page, -1);
if (ret == OV_EREAD) {
return OV_EREAD;
}
if (searched >= end || ret == -1) {
links = m + 1;
offsets = new long[m + 2];
offsets[m + 1] = searched;
} else {
ret = bisectForwardSerialno(next, offset, end, page.serialno(),
m + 1);
if (ret == OV_EREAD) {
return OV_EREAD;
}
}
offsets[m] = begin;
return 0;
}
示例2: fetchHeaders
import com.jcraft.jogg.Page; //导入方法依赖的package包/类
/**
* Uses the local ogg_stream storage in vf; this is important for
* non-streaming input sources.
* @param vi the info block
* @param vc comment block
* @param serialno serial numbers
* @param ogPtr ogg pointer page
* @return success codes OV_*
*/
int fetchHeaders(Info vi, Comment vc, int[] serialno, Page ogPtr) {
Page og = new Page();
Packet op = new Packet();
int ret;
if (ogPtr == null) {
ret = getNextPage(og, CHUNKSIZE);
if (ret == OV_EREAD) {
return OV_EREAD;
}
if (ret < 0) {
return OV_ENOTVORBIS;
}
ogPtr = og;
}
if (serialno != null) {
serialno[0] = ogPtr.serialno();
}
os.init(ogPtr.serialno());
// extract the initial header from the first page and verify that the
// Ogg bitstream is in fact Vorbis data
vi.init();
vc.init();
int i = 0;
while (i < 3) {
os.pagein(ogPtr);
while (i < 3) {
int result = os.packetout(op);
if (result == 0) {
break;
}
if (result == -1) {
vi.clear();
vc.clear();
os.clear();
return -1;
}
if (vi.synthesisHeaderin(vc, op) != 0) {
vi.clear();
vc.clear();
os.clear();
return -1;
}
i++;
}
if (i < 3) {
if (getNextPage(ogPtr, 1) < 0) {
vi.clear();
vc.clear();
os.clear();
return -1;
}
}
}
return 0;
}
示例3: prefetchAllHeaders
import com.jcraft.jogg.Page; //导入方法依赖的package包/类
/**
* Last step of the OggVorbis_File initialization; get all the
* vorbis_info structs and PCM positions. Only called by the seekable
* initialization (local stream storage is hacked slightly; pay
* attention to how that's done)
* @param firstInfo first info
* @param firstComment first comment
* @param dataoffset data offset
* @throws JOrbisException if an error occurs
*/
void prefetchAllHeaders(Info firstInfo, Comment firstComment, int dataoffset)
throws JOrbisException {
Page og = new Page();
int ret;
vi = new Info[links];
vc = new Comment[links];
dataoffsets = new long[links];
pcmlengths = new long[links];
serialnos = new int[links];
for (int i = 0; i < links; i++) {
if (firstInfo != null && firstComment != null && i == 0) {
// we already grabbed the initial header earlier. This just
// saves the waste of grabbing it again
vi[i] = firstInfo;
vc[i] = firstComment;
dataoffsets[i] = dataoffset;
} else {
// seek to the location of the initial header
seekHelper(offsets[i]); // !!!
vi[i] = new Info();
vc[i] = new Comment();
if (fetchHeaders(vi[i], vc[i], null, null) == -1) {
dataoffsets[i] = -1;
} else {
dataoffsets[i] = offset;
os.clear();
}
}
// get the serial number and PCM length of this link. To do this,
// get the last page of the stream
long end = offsets[i + 1]; // !!!
seekHelper(end);
while (true) {
ret = getPrevPage(og);
if (ret == -1) {
// this should not be possible
vi[i].clear();
vc[i].clear();
break;
}
if (og.granulepos() != -1) {
serialnos[i] = og.serialno();
pcmlengths[i] = og.granulepos();
break;
}
}
}
}
示例4: openSeekable
import com.jcraft.jogg.Page; //导入方法依赖的package包/类
/**
* Open seekable.
* @return success value
* @throws JOrbisException if an error occurs
*/
int openSeekable() throws JOrbisException {
Info initialInfo = new Info();
Comment initialComment = new Comment();
int serialno;
long end;
int ret;
int dataoffset;
Page og = new Page();
// is this even vorbis...?
int[] foo = new int[1];
ret = fetchHeaders(initialInfo, initialComment, foo, null);
serialno = foo[0];
dataoffset = (int) offset; // !!
os.clear();
if (ret == -1) {
return (-1);
}
if (ret < 0) {
return (ret);
}
// we can seek, so set out learning all about this file
seekable = true;
fseek(datasource, 0, SEEK_END);
offset = ftell(datasource);
end = offset;
// We get the offset for the last page of the physical bitstream.
// Most OggVorbis files will contain a single logical bitstream
end = getPrevPage(og);
// moer than one logical bitstream?
if (og.serialno() != serialno) {
// Chained bitstream. Bisect-search each logical bitstream
// section. Do so based on serial number only
if (bisectForwardSerialno(0, 0, end + 1, serialno, 0) < 0) {
clear();
return OV_EREAD;
}
} else {
// Only one logical bitstream
if (bisectForwardSerialno(0, end, end + 1, serialno, 0) < 0) {
clear();
return OV_EREAD;
}
}
prefetchAllHeaders(initialInfo, initialComment, dataoffset);
return 0;
}