Skip to content

Commit

Permalink
Throw a ParserException instead of a NullPointerException if the samp…
Browse files Browse the repository at this point in the history
…le table (stbl) is missing a required sample description (stsd).

As per the javadoc for AtomParsers.parseTrack, ParserException should be "thrown if the trak atom can't be parsed."

PiperOrigin-RevId: 499522748
  • Loading branch information
Googler authored and christosts committed Jan 10, 2023
1 parent 2a77f1e commit bbe78b1
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.google.android.exoplayer2.drm.DrmInitData;
import com.google.android.exoplayer2.extractor.ExtractorUtil;
import com.google.android.exoplayer2.extractor.GaplessInfoHolder;
import com.google.android.exoplayer2.extractor.mp4.Atom.LeafAtom;
import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.metadata.mp4.SmtaMetadataEntry;
import com.google.android.exoplayer2.util.CodecSpecificDataUtil;
Expand Down Expand Up @@ -308,9 +309,14 @@ private static Track parseTrak(

Pair<Long, String> mdhdData =
parseMdhd(checkNotNull(mdia.getLeafAtomOfType(Atom.TYPE_mdhd)).data);
LeafAtom stsd = stbl.getLeafAtomOfType(Atom.TYPE_stsd);
if (stsd == null) {
throw ParserException.createForMalformedContainer(
"Malformed sample table (stbl) missing sample description (stsd)", /* cause= */ null);
}
StsdData stsdData =
parseStsd(
checkNotNull(stbl.getLeafAtomOfType(Atom.TYPE_stsd)).data,
stsd.data,
tkhdData.id,
tkhdData.rotationDegrees,
mdhdData.second,
Expand Down

0 comments on commit bbe78b1

Please sign in to comment.