diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/mp4/Atom.java b/library/src/main/java/com/google/android/exoplayer/extractor/mp4/Atom.java index 21632723e3..a8c9cb298e 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/mp4/Atom.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/mp4/Atom.java @@ -54,6 +54,8 @@ import java.util.List; public static final int TYPE_mdat = Util.getIntegerCodeForString("mdat"); public static final int TYPE_mp4a = Util.getIntegerCodeForString("mp4a"); public static final int TYPE_wave = Util.getIntegerCodeForString("wave"); + public static final int TYPE_lpcm = Util.getIntegerCodeForString("lpcm"); + public static final int TYPE_sowt = Util.getIntegerCodeForString("sowt"); public static final int TYPE_ac_3 = Util.getIntegerCodeForString("ac-3"); public static final int TYPE_dac3 = Util.getIntegerCodeForString("dac3"); public static final int TYPE_ec_3 = Util.getIntegerCodeForString("ec-3"); diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/mp4/AtomParsers.java b/library/src/main/java/com/google/android/exoplayer/extractor/mp4/AtomParsers.java index a4685c217e..1bbfd09f1f 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/mp4/AtomParsers.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/mp4/AtomParsers.java @@ -569,7 +569,8 @@ import java.util.List; || childAtomType == Atom.TYPE_ac_3 || childAtomType == Atom.TYPE_ec_3 || childAtomType == Atom.TYPE_dtsc || childAtomType == Atom.TYPE_dtse || childAtomType == Atom.TYPE_dtsh || childAtomType == Atom.TYPE_dtsl - || childAtomType == Atom.TYPE_samr || childAtomType == Atom.TYPE_sawb) { + || childAtomType == Atom.TYPE_samr || childAtomType == Atom.TYPE_sawb + || childAtomType == Atom.TYPE_lpcm || childAtomType == Atom.TYPE_sowt) { parseAudioSampleEntry(stsd, childAtomType, childStartPosition, childAtomSize, trackId, language, isQuickTime, out, i); } else if (childAtomType == Atom.TYPE_TTML) { @@ -827,16 +828,29 @@ import java.util.List; parent.skipBytes(16); } - int channelCount = parent.readUnsignedShort(); - int sampleSize = parent.readUnsignedShort(); - parent.skipBytes(4); - int sampleRate = parent.readUnsignedFixedPoint1616(); + int channelCount; + int sampleRate; - if (quickTimeSoundDescriptionVersion > 0) { - parent.skipBytes(16); - if (quickTimeSoundDescriptionVersion == 2) { - parent.skipBytes(20); + if (quickTimeSoundDescriptionVersion == 0 || quickTimeSoundDescriptionVersion == 1) { + channelCount = parent.readUnsignedShort(); + parent.skipBytes(6); // sampleSize, compressionId, packetSize. + sampleRate = parent.readUnsignedFixedPoint1616(); + + if (quickTimeSoundDescriptionVersion == 1) { + parent.skipBytes(16); } + } else if (quickTimeSoundDescriptionVersion == 2) { + parent.skipBytes(16); // always[3,16,Minus2,0,65536], sizeOfStructOnly + + sampleRate = (int) Math.round(parent.readDouble()); + channelCount = parent.readUnsignedIntToInt(); + + // Skip always7F000000, sampleSize, formatSpecificFlags, constBytesPerAudioPacket, + // constLPCMFramesPerAudioPacket. + parent.skipBytes(20); + } else { + // Unsupported version. + return; } // If the atom type determines a MIME type, set it immediately. @@ -855,6 +869,8 @@ import java.util.List; mimeType = MimeTypes.AUDIO_AMR_NB; } else if (atomType == Atom.TYPE_sawb) { mimeType = MimeTypes.AUDIO_AMR_WB; + } else if (atomType == Atom.TYPE_lpcm || atomType == Atom.TYPE_sowt) { + mimeType = MimeTypes.AUDIO_RAW; } byte[] initializationData = null; @@ -914,7 +930,7 @@ import java.util.List; } out.format = Format.createAudioSampleFormat(Integer.toString(trackId), mimeType, - Format.NO_VALUE, sampleSize, channelCount, sampleRate, + Format.NO_VALUE, Format.NO_VALUE, channelCount, sampleRate, initializationData == null ? null : Collections.singletonList(initializationData), language); } diff --git a/library/src/main/java/com/google/android/exoplayer/util/ParsableByteArray.java b/library/src/main/java/com/google/android/exoplayer/util/ParsableByteArray.java index 4aaf5d807e..c23ab140e5 100644 --- a/library/src/main/java/com/google/android/exoplayer/util/ParsableByteArray.java +++ b/library/src/main/java/com/google/android/exoplayer/util/ParsableByteArray.java @@ -328,6 +328,11 @@ public final class ParsableByteArray { return result; } + /** Reads the next eight bytes as a 64-bit floating point value. */ + public double readDouble() { + return Double.longBitsToDouble(readLong()); + } + /** * Reads the next {@code length} bytes as UTF-8 characters. *