/** * Decodes an audio track from a byte array. * @param trackInfo Track info for the track to decode * @param buffer Byte array containing the encoded track * @return Decoded audio track */ public AudioTrack decodeTrackDetails(AudioTrackInfo trackInfo, byte[] buffer) { try { DataInput input = new DataInputStream(new ByteArrayInputStream(buffer)); return decodeTrackDetails(trackInfo, input); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public DecodedTrackHolder decodeTrack(MessageInput stream) throws IOException { DataInput input = stream.nextMessage(); if (input == null) { return null; } int version = (stream.getMessageFlags() & TRACK_INFO_VERSIONED) != 0 ? (input.readByte() & 0xFF) : 1; AudioTrackInfo trackInfo = new AudioTrackInfo(input.readUTF(), input.readUTF(), input.readLong(), input.readUTF(), input.readBoolean(), version >= 2 ? DataFormatTools.readNullableText(input) : null); AudioTrack track = decodeTrackDetails(trackInfo, input); long position = input.readLong(); if (track != null) { track.setPosition(position); } stream.skipRemainingBytes(); return new DecodedTrackHolder(track); }