public void parse(
         InputStream stream, ContentHandler handler,
         Metadata metadata, ParseContext context)
         throws IOException, TikaException, SAXException {
      // Process the file straight through once
      OggFile ogg = new OggFile(stream);
      
      // To track the streams we find
      Map<OggStreamType, Integer> streams = 
              new HashMap<OggStreamType, Integer>();
      Map<OggStreamType.Kind, Integer> streamKinds =
              new HashMap<OggStreamType.Kind, Integer>();
      List<Integer> sids = new ArrayList<Integer>();
      int totalStreams = 0;
      
      // Start
      XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
      xhtml.startDocument();

      // Check the streams in turn
      OggPacketReader r = ogg.getPacketReader();
      OggPacket p;
      while( (p = r.getNextPacket()) != null ) {
         if (p.isBeginningOfStream()) {
            totalStreams++;
            sids.add(p.getSid());

            OggStreamType type = OggStreamIdentifier.identifyType(p);
            Integer prevValue = streams.get(type);
            if (prevValue == null) {
                prevValue = 0;
            }
            streams.put(type, (prevValue+1));

            prevValue = streamKinds.get(type.kind);
            if (prevValue == null) {
                prevValue = 0;
            }
            streamKinds.put(type.kind, (prevValue+1));
         }
      }

      // Report about the streams, which is all we really can do
      metadata.add("streams-total", Integer.toString(totalStreams));
      for (OggStreamType type : streams.keySet()) {
          String key = type.mimetype.substring(type.mimetype.indexOf('/')+1);
          if (key.startsWith("x-")) {
              key = key.substring(2);
          }
          if (type == OggStreamIdentifier.UNKNOWN) {
              key = "unknown";
          }
          metadata.add("streams-" + key, Integer.toString(streams.get(type)));
      }
      for (OggStreamType.Kind kind : streamKinds.keySet()) {
          String key = kind.name().toLowerCase();
          metadata.add("streams-" + key, Integer.toString(streamKinds.get(kind)));
      }

      // If we found a skeleton stream, report the relations between the streams
      // TODO

      // Finish
      xhtml.endDocument();
      ogg.close();
   }