public int fetchHeaders(final Info info, final Comment comment, final int[] serialno, Page page) { if (page == null) { page = new Page(); final int retValue = this.getNextPage(page, this.m_chunkSize); if (retValue == -128) { return -128; } if (retValue < 0) { return -130; } } if (serialno != null) { serialno[0] = page.serialno(); } this.m_oggStreamState.init(page.serialno()); info.init(); comment.init(); final Packet packet = new Packet(); int i = 0; while (i < 3) { this.m_oggStreamState.pagein(page); while (i < 3) { final int result = this.m_oggStreamState.packetout(packet); if (result == 0) { break; } if (result == -1) { info.clear(); this.m_oggStreamState.clear(); return -1; } if (info.synthesis_headerin(comment, packet) != 0) { info.clear(); this.m_oggStreamState.clear(); return -1; } ++i; } if (i < 3 && this.getNextPage(page, 1L) < 0) { info.clear(); this.m_oggStreamState.clear(); return -1; } } return 0; }
/** * Creates a new comment. Comments must be part of an article. * * @param text The comment text. * @param article The article. * @return The new comment. */ public Comment createComment(String text, Article article) { Comment c = new Comment(text); c.init(ontology, article); return c; }
/** * 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; }