parse(mediaSegment) {
    const Mp4Parser = shaka.util.Mp4Parser;
    const BitstreamFormat = shaka.cea.Mp4CeaParser.BitstreamFormat;

    if (this.bitstreamFormat_ == BitstreamFormat.UNKNOWN) {
      // We don't know how to extract SEI from this.
      return [];
    }

    /** @type {!Array<!shaka.extern.ICeaParser.CaptionPacket>} **/
    const captionPackets = [];

    let moofOffset = 0;

    /** @type {!Array<!shaka.cea.Mp4CeaParser.ParsedTRAF>} */
    let parsedTRAFs = [];

    new Mp4Parser()
        .box('moof', (box) => {
          moofOffset = box.start;
          // traf box parsing is reset on each moof.
          parsedTRAFs = [];
          Mp4Parser.children(box);
        })
        .box('traf', (box) => {
          parsedTRAFs.push({
            baseMediaDecodeTime: null,
            defaultSampleDuration: this.defaultSampleDuration_,
            defaultSampleSize: this.defaultSampleSize_,
            parsedTRUNs: [],
            timescale: shaka.cea.CeaUtils.DEFAULT_TIMESCALE_VALUE,
          });
          Mp4Parser.children(box);
        })
        .fullBox('trun', (box) => {
          goog.asserts.assert(
              box.version != null && box.flags != null,
              'TRUN is a full box and should have a valid version & flags.');

          const lastTRAF = parsedTRAFs[parsedTRAFs.length - 1];

          const parsedTRUN = shaka.util.Mp4BoxParsers.parseTRUN(
              box.reader, box.version, box.flags);
          lastTRAF.parsedTRUNs.push(parsedTRUN);
        })
        .fullBox('tfhd', (box) => {
          goog.asserts.assert(
              box.flags != null,
              'TFHD is a full box and should have valid flags.');

          const lastTRAF = parsedTRAFs[parsedTRAFs.length - 1];

          const parsedTFHD = shaka.util.Mp4BoxParsers.parseTFHD(
              box.reader, box.flags);

          // If specified, defaultSampleDuration and defaultSampleSize
          // override the ones specified in the TREX box
          lastTRAF.defaultSampleDuration = parsedTFHD.defaultSampleDuration ||
              this.defaultSampleDuration_;

          lastTRAF.defaultSampleSize = parsedTFHD.defaultSampleSize ||
              this.defaultSampleSize_;

          const trackId = parsedTFHD.trackId;

          // Get the timescale from the track Id
          if (this.trackIdToTimescale_.has(trackId)) {
            lastTRAF.timescale = this.trackIdToTimescale_.get(trackId);
          }
        })
        .fullBox('tfdt', (box) => {
          goog.asserts.assert(
              box.version != null,
              'TFDT is a full box and should have a valid version.');

          const lastTRAF = parsedTRAFs[parsedTRAFs.length - 1];

          const parsedTFDT = shaka.util.Mp4BoxParsers.parseTFDTInaccurate(
              box.reader, box.version);

          lastTRAF.baseMediaDecodeTime = parsedTFDT.baseMediaDecodeTime;
        })
        .box('mdat', (box) => {
          const offset = moofOffset - box.start - 8;
          const initialPosition = box.reader.getPosition();
          for (const parsedTRAF of parsedTRAFs) {
            if (parsedTRAF.baseMediaDecodeTime === null) {
              // This field should have been populated by the Base Media Decode
              // Time in the tfdt box.
              shaka.log.alwaysWarn(
                  'Unable to find base media decode time for CEA captions!');
              throw new shaka.util.Error(
                  shaka.util.Error.Severity.CRITICAL,
                  shaka.util.Error.Category.TEXT,
                  shaka.util.Error.Code.INVALID_MP4_CEA);
            }
            box.reader.seek(initialPosition);
            this.parseMdat_(box.reader,
                parsedTRAF.baseMediaDecodeTime,
                parsedTRAF.timescale,
                parsedTRAF.defaultSampleDuration,
                parsedTRAF.defaultSampleSize,
                offset,
                parsedTRAF.parsedTRUNs,
                captionPackets);
          }
        })
        .parse(mediaSegment, /* partialOkay= */ false);

    return captionPackets;
  }
Parses each video segment. In fragmented MP4s, MOOF and MDAT come in
pairs. The following logic gets the necessary info from MOOFs to parse
MDATs (base media decode time, sample sizes/offsets/durations, etc),
and then parses the MDAT boxes for CEA-708 packets using this information.
CEA-708 packets are returned in the callback.
@override