001/* JOrbis
002 * Copyright (C) 2000 ymnk, JCraft,Inc.
003 *  
004 * Written by: 2000 ymnk<ymnk@jcaft.com>
005 *   
006 * Many thanks to 
007 *   Monty <monty@xiph.org> and 
008 *   The XIPHOPHORUS Company http://www.xiph.org/ .
009 * JOrbis has been based on their awesome works, Vorbis codec.
010 *   
011 * This program is free software; you can redistribute it and/or
012 * modify it under the terms of the GNU Library General Public License
013 * as published by the Free Software Foundation; either version 2 of
014 * the License, or (at your option) any later version.
015   
016 * This program is distributed in the hope that it will be useful,
017 * but WITHOUT ANY WARRANTY; without even the implied warranty of
018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
019 * GNU Library General Public License for more details.
020 * 
021 * You should have received a copy of the GNU Library General Public
022 * License along with this program; if not, write to the Free Software
023 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
024 */
025
026package com.jcraft.jogg;
027
028public class Packet{
029  public byte[] packet_base;
030  public int packet;
031  public int bytes;
032  public int b_o_s;
033  public int e_o_s;
034
035  public long granulepos;
036
037  public long packetno; // sequence number for decode; the framing
038                       // knows where there's a hole in the data,
039                       // but we need coupling so that the codec
040                       // (which is in a seperate abstraction
041                       // layer) also knows about the gap
042
043  /*
044  // TEST
045  static int sequence=0;
046  static int lastno=0;
047  void checkpacket(int len, int no, int pos){
048    if(bytes!=len){
049      System.err.println("incorrect packet length!");
050      System.exit(1);
051    }
052    if(granulepos!=pos){
053      System.err.println("incorrect packet position!");
054      System.exit(1);
055    }
056
057    // packet number just follows sequence/gap; adjust the input number
058    // for that
059    if(no==0){
060      sequence=0;
061    }
062    else{
063      sequence++;
064      if(no>lastno+1)
065        sequence++;
066    }
067    lastno=no;
068    if(packetno!=sequence){
069     System.err.println("incorrect packet sequence "+packetno+" != "+sequence);
070      System.exit(1);
071    }
072
073    // Test data
074    for(int j=0;j<bytes;j++){
075      if((packet_base[packet+j]&0xff)!=((j+no)&0xff)){
076        System.err.println("body data mismatch at pos "+ j+": "+(packet_base[packet+j]&0xff)+"!="+((j+no)&0xff)+"!\n");
077        System.exit(1);
078      }
079    }
080  }
081  */
082}