private byte[] createSegmentTable(int newCommentLength,int setupHeaderLength,List<OggPageHeader.PacketStartAndLength> extraPackets){
  logger.finest("Create SegmentTable CommentLength:" + newCommentLength + ":SetupHeaderLength:"+ setupHeaderLength);
  ByteArrayOutputStream resultBaos=new ByteArrayOutputStream();
  byte[] newStart;
  byte[] restShouldBe;
  byte[] nextPacket;
  if (setupHeaderLength == 0) {
    newStart=createSegments(newCommentLength,false);
    return newStart;
  }
 else {
    newStart=createSegments(newCommentLength,true);
  }
  if (extraPackets.size() > 0) {
    restShouldBe=createSegments(setupHeaderLength,true);
  }
 else {
    restShouldBe=createSegments(setupHeaderLength,false);
  }
  logger.finest("Created " + newStart.length + " segments for header");
  logger.finest("Created " + restShouldBe.length + " segments for setup");
  try {
    resultBaos.write(newStart);
    resultBaos.write(restShouldBe);
    if (extraPackets.size() > 0) {
      logger.finer("Creating segments for " + extraPackets.size() + " packets");
      for (      OggPageHeader.PacketStartAndLength packet : extraPackets) {
        nextPacket=createSegments(packet.getLength(),false);
        resultBaos.write(nextPacket);
      }
    }
  }
 catch (  IOException ioe) {
    throw new RuntimeException("Unable to create segment table:" + ioe.getMessage());
  }
  return resultBaos.toByteArray();
}

private byte [ ] createSegmentTable ( int newCommentLength , int setupHeaderLength , List < OggPageHeader . PacketStartAndLength > extraPackets ) { logger . finest ( "Create SegmentTable CommentLength:" + newCommentLength + ":SetupHeaderLength:" + setupHeaderLength ) ; ByteArrayOutputStream resultBaos = new ByteArrayOutputStream ( ) ; byte [ ] newStart ; byte [ ] restShouldBe ; byte [ ] nextPacket ; if ( setupHeaderLength == 0 ) { newStart = createSegments ( newCommentLength , false ) ; return newStart ; } else { newStart = createSegments ( newCommentLength , true ) ; } if ( extraPackets . size ( ) > 0 ) { restShouldBe = createSegments ( setupHeaderLength , true ) ; } else { restShouldBe = createSegments ( setupHeaderLength , false ) ; } logger . finest ( "Created " + newStart . length + " segments for header" ) ; logger . finest ( "Created " + restShouldBe . length + " segments for setup" ) ; try { resultBaos . write ( newStart ) ; resultBaos . write ( restShouldBe ) ; if ( extraPackets . size ( ) > 0 ) { logger . finer ( "Creating segments for " + extraPackets . size ( ) + " packets" ) ; for ( OggPageHeader . PacketStartAndLength packet : extraPackets ) { nextPacket = createSegments ( packet . getLength ( ) , false ) ; resultBaos . write ( nextPacket ) ; } } } catch ( IOException ioe ) { throw new RuntimeException ( "Unable to create segment table:" + ioe . getMessage ( ) ) ; } return resultBaos . toByteArray ( ) ; }
this method creates a new segment table for the second page ( header ) .
