コード例 #1
0
ファイル: MP3Stream.java プロジェクト: Red5/red5-io
 /**
  * Searches for the next MPEG frame header from the current stream position on. This method
  * advances the underlying input stream until it finds a valid frame header or the end of the
  * stream is reached. In the former case a corresponding {@code AudioFrame} object is created. In
  * the latter case there are no more headers, so the end of the stream is probably reached.
  *
  * @return the next {@code AudioFrame} or <b>null</b>
  * @throws IOException if an IO error occurs
  */
 public AudioFrame nextFrame() throws IOException {
   AudioFrame frame = null;
   while (!endOfStream && frame == null) {
     findFrameSyncByte();
     if (!endOfStream) {
       HeaderBitField headerField = createHeaderField();
       if (!endOfStream) {
         frame = createHeader(headerField);
         if (frame == null) {
           pushBack(headerField);
         } else {
           System.arraycopy(headerField.toArray(), 0, header, 0, 3);
         }
       }
     }
   }
   currentHeader = frame;
   return frame;
 }
コード例 #2
0
ファイル: MP3Stream.java プロジェクト: Red5/red5-io
 /**
  * Pushes the given header field back in the stream so that the bytes are read again. This method
  * is called if an invalid header was detected. Then search has to continue at the next byte after
  * the frame sync byte.
  *
  * @param field the header bit field with the invalid frame header
  * @throws IOException if an error occurs
  */
 private void pushBack(HeaderBitField field) throws IOException {
   unread(field.toArray());
 }