com.google.android.exoplayer2.extractor.ExtractorOutput Java Examples

The following examples show how to use com.google.android.exoplayer2.extractor.ExtractorOutput. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SeiReader.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void createTracks(ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) {
  for (int i = 0; i < outputs.length; i++) {
    idGenerator.generateNewId();
    TrackOutput output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_TEXT);
    Format channelFormat = closedCaptionFormats.get(i);
    String channelMimeType = channelFormat.sampleMimeType;
    Assertions.checkArgument(MimeTypes.APPLICATION_CEA608.equals(channelMimeType)
        || MimeTypes.APPLICATION_CEA708.equals(channelMimeType),
        "Invalid closed caption mime type provided: " + channelMimeType);
    String formatId = channelFormat.id != null ? channelFormat.id : idGenerator.getFormatId();
    output.format(
        Format.createTextSampleFormat(
            formatId,
            channelMimeType,
            /* codecs= */ null,
            /* bitrate= */ Format.NO_VALUE,
            channelFormat.selectionFlags,
            channelFormat.language,
            channelFormat.accessibilityChannel,
            /* drmInitData= */ null,
            Format.OFFSET_SAMPLE_RELATIVE,
            channelFormat.initializationData));
    outputs[i] = output;
  }
}
 
Example #2
Source File: UserDataReader.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void createTracks(
    ExtractorOutput extractorOutput, TsPayloadReader.TrackIdGenerator idGenerator) {
  for (int i = 0; i < outputs.length; i++) {
    idGenerator.generateNewId();
    TrackOutput output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_TEXT);
    Format channelFormat = closedCaptionFormats.get(i);
    String channelMimeType = channelFormat.sampleMimeType;
    Assertions.checkArgument(
        MimeTypes.APPLICATION_CEA608.equals(channelMimeType)
            || MimeTypes.APPLICATION_CEA708.equals(channelMimeType),
        "Invalid closed caption mime type provided: " + channelMimeType);
    output.format(
        Format.createTextSampleFormat(
            idGenerator.getFormatId(),
            channelMimeType,
            /* codecs= */ null,
            /* bitrate= */ Format.NO_VALUE,
            channelFormat.selectionFlags,
            channelFormat.language,
            channelFormat.accessibilityChannel,
            /* drmInitData= */ null,
            Format.OFFSET_SAMPLE_RELATIVE,
            channelFormat.initializationData));
    outputs[i] = output;
  }
}
 
Example #3
Source File: UserDataReader.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void createTracks(
    ExtractorOutput extractorOutput, TsPayloadReader.TrackIdGenerator idGenerator) {
  for (int i = 0; i < outputs.length; i++) {
    idGenerator.generateNewId();
    TrackOutput output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_TEXT);
    Format channelFormat = closedCaptionFormats.get(i);
    String channelMimeType = channelFormat.sampleMimeType;
    Assertions.checkArgument(
        MimeTypes.APPLICATION_CEA608.equals(channelMimeType)
            || MimeTypes.APPLICATION_CEA708.equals(channelMimeType),
        "Invalid closed caption mime type provided: " + channelMimeType);
    output.format(
        Format.createTextSampleFormat(
            idGenerator.getFormatId(),
            channelMimeType,
            /* codecs= */ null,
            /* bitrate= */ Format.NO_VALUE,
            channelFormat.selectionFlags,
            channelFormat.language,
            channelFormat.accessibilityChannel,
            /* drmInitData= */ null,
            Format.OFFSET_SAMPLE_RELATIVE,
            channelFormat.initializationData));
    outputs[i] = output;
  }
}
 
Example #4
Source File: AdtsExtractor.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void maybeOutputSeekMap(
    long inputLength, boolean canUseConstantBitrateSeeking, boolean readEndOfStream) {
  if (hasOutputSeekMap) {
    return;
  }
  boolean useConstantBitrateSeeking = canUseConstantBitrateSeeking && averageFrameSize > 0;
  if (useConstantBitrateSeeking
      && reader.getSampleDurationUs() == C.TIME_UNSET
      && !readEndOfStream) {
    // Wait for the sampleDurationUs to be available, or for the end of the stream to be reached,
    // before creating seek map.
    return;
  }

  ExtractorOutput extractorOutput = Assertions.checkNotNull(this.extractorOutput);
  if (useConstantBitrateSeeking && reader.getSampleDurationUs() != C.TIME_UNSET) {
    extractorOutput.seekMap(getConstantBitrateSeekMap(inputLength));
  } else {
    extractorOutput.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
  }
  hasOutputSeekMap = true;
}
 
Example #5
Source File: DvbSubtitleReader.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void createTracks(ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) {
  for (int i = 0; i < outputs.length; i++) {
    DvbSubtitleInfo subtitleInfo = subtitleInfos.get(i);
    idGenerator.generateNewId();
    TrackOutput output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_TEXT);
    output.format(
        Format.createImageSampleFormat(
            idGenerator.getFormatId(),
            MimeTypes.APPLICATION_DVBSUBS,
            null,
            Format.NO_VALUE,
            0,
            Collections.singletonList(subtitleInfo.initializationData),
            subtitleInfo.language,
            null));
    outputs[i] = output;
  }
}
 
Example #6
Source File: FlacExtractor.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Outputs a {@link SeekMap} and returns a {@link FlacBinarySearchSeeker} if one is required to
 * handle seeks.
 */
@Nullable
private static FlacBinarySearchSeeker outputSeekMap(
    FlacDecoderJni decoderJni,
    FlacStreamMetadata streamMetadata,
    long streamLength,
    ExtractorOutput output) {
  boolean haveSeekTable = decoderJni.getSeekPoints(/* timeUs= */ 0) != null;
  FlacBinarySearchSeeker binarySearchSeeker = null;
  SeekMap seekMap;
  if (haveSeekTable) {
    seekMap = new FlacSeekMap(streamMetadata.durationUs(), decoderJni);
  } else if (streamLength != C.LENGTH_UNSET) {
    long firstFramePosition = decoderJni.getDecodePosition();
    binarySearchSeeker =
        new FlacBinarySearchSeeker(streamMetadata, firstFramePosition, streamLength, decoderJni);
    seekMap = binarySearchSeeker.getSeekMap();
  } else {
    seekMap = new SeekMap.Unseekable(streamMetadata.durationUs());
  }
  output.seekMap(seekMap);
  return binarySearchSeeker;
}
 
Example #7
Source File: AdtsExtractor.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
private void maybeOutputSeekMap(
    long inputLength, boolean canUseConstantBitrateSeeking, boolean readEndOfStream) {
  if (hasOutputSeekMap) {
    return;
  }
  boolean useConstantBitrateSeeking = canUseConstantBitrateSeeking && averageFrameSize > 0;
  if (useConstantBitrateSeeking
      && reader.getSampleDurationUs() == C.TIME_UNSET
      && !readEndOfStream) {
    // Wait for the sampleDurationUs to be available, or for the end of the stream to be reached,
    // before creating seek map.
    return;
  }

  ExtractorOutput extractorOutput = Assertions.checkNotNull(this.extractorOutput);
  if (useConstantBitrateSeeking && reader.getSampleDurationUs() != C.TIME_UNSET) {
    extractorOutput.seekMap(getConstantBitrateSeekMap(inputLength));
  } else {
    extractorOutput.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
  }
  hasOutputSeekMap = true;
}
 
Example #8
Source File: H262Reader.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public void createTracks(ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) {
  idGenerator.generateNewId();
  formatId = idGenerator.getFormatId();
  output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_VIDEO);
  if (userDataReader != null) {
    userDataReader.createTracks(extractorOutput, idGenerator);
  }
}
 
Example #9
Source File: Id3Reader.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void createTracks(ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) {
  idGenerator.generateNewId();
  output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_METADATA);
  output.format(Format.createSampleFormat(idGenerator.getFormatId(), MimeTypes.APPLICATION_ID3,
      null, Format.NO_VALUE, null));
}
 
Example #10
Source File: SeiReader.java    From K-Sonic with MIT License 5 votes vote down vote up
public void createTracks(ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) {
  for (int i = 0; i < outputs.length; i++) {
    idGenerator.generateNewId();
    TrackOutput output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_TEXT);
    Format channelFormat = closedCaptionFormats.get(i);
    String channelMimeType = channelFormat.sampleMimeType;
    Assertions.checkArgument(MimeTypes.APPLICATION_CEA608.equals(channelMimeType)
        || MimeTypes.APPLICATION_CEA708.equals(channelMimeType),
        "Invalid closed caption mime type provided: " + channelMimeType);
    output.format(Format.createTextSampleFormat(idGenerator.getFormatId(), channelMimeType, null,
        Format.NO_VALUE, channelFormat.selectionFlags, channelFormat.language,
        channelFormat.accessibilityChannel, null));
    outputs[i] = output;
  }
}
 
Example #11
Source File: H262Reader.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void createTracks(ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) {
  idGenerator.generateNewId();
  formatId = idGenerator.getFormatId();
  output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_VIDEO);
  if (userDataReader != null) {
    userDataReader.createTracks(extractorOutput, idGenerator);
  }
}
 
Example #12
Source File: H264Reader.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void createTracks(ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) {
  idGenerator.generateNewId();
  formatId = idGenerator.getFormatId();
  output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_VIDEO);
  sampleReader = new SampleReader(output, allowNonIdrKeyframes, detectAccessUnits);
  seiReader.createTracks(extractorOutput, idGenerator);
}
 
Example #13
Source File: FlacExtractor.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void init(ExtractorOutput output) {
  extractorOutput = output;
  trackOutput = extractorOutput.track(0, C.TRACK_TYPE_AUDIO);
  extractorOutput.endTracks();
  try {
    decoderJni = new FlacDecoderJni();
  } catch (FlacDecoderException e) {
    throw new RuntimeException(e);
  }
}
 
Example #14
Source File: Id3Reader.java    From K-Sonic with MIT License 5 votes vote down vote up
@Override
public void createTracks(ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) {
  idGenerator.generateNewId();
  output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_METADATA);
  output.format(Format.createSampleFormat(idGenerator.getFormatId(), MimeTypes.APPLICATION_ID3,
      null, Format.NO_VALUE, null));
}
 
Example #15
Source File: H264Reader.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public void createTracks(ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) {
  idGenerator.generateNewId();
  formatId = idGenerator.getFormatId();
  output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_VIDEO);
  sampleReader = new SampleReader(output, allowNonIdrKeyframes, detectAccessUnits);
  seiReader.createTracks(extractorOutput, idGenerator);
}
 
Example #16
Source File: SpliceInfoSectionReader.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public void init(TimestampAdjuster timestampAdjuster, ExtractorOutput extractorOutput,
    TsPayloadReader.TrackIdGenerator idGenerator) {
  this.timestampAdjuster = timestampAdjuster;
  idGenerator.generateNewId();
  output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_METADATA);
  output.format(Format.createSampleFormat(idGenerator.getFormatId(), MimeTypes.APPLICATION_SCTE35,
      null, Format.NO_VALUE, null));
}
 
Example #17
Source File: AdtsExtractor.java    From K-Sonic with MIT License 5 votes vote down vote up
@Override
public void init(ExtractorOutput output) {
  reader = new AdtsReader(true);
  reader.createTracks(output, new TrackIdGenerator(0, 1));
  output.endTracks();
  output.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
}
 
Example #18
Source File: H265Reader.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public void createTracks(ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) {
  idGenerator.generateNewId();
  formatId = idGenerator.getFormatId();
  output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_VIDEO);
  sampleReader = new SampleReader(output);
  seiReader.createTracks(extractorOutput, idGenerator);
}
 
Example #19
Source File: RawCcExtractor.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void init(ExtractorOutput output) {
  output.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
  trackOutput = output.track(0, C.TRACK_TYPE_TEXT);
  output.endTracks();
  trackOutput.format(format);
}
 
Example #20
Source File: SpliceInfoSectionReader.java    From K-Sonic with MIT License 5 votes vote down vote up
@Override
public void init(TimestampAdjuster timestampAdjuster, ExtractorOutput extractorOutput,
    TsPayloadReader.TrackIdGenerator idGenerator) {
  this.timestampAdjuster = timestampAdjuster;
  idGenerator.generateNewId();
  output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_METADATA);
  output.format(Format.createSampleFormat(idGenerator.getFormatId(), MimeTypes.APPLICATION_SCTE35,
      null, Format.NO_VALUE, null));
}
 
Example #21
Source File: WavExtractor.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void init(ExtractorOutput output) {
  extractorOutput = output;
  trackOutput = output.track(0, C.TRACK_TYPE_AUDIO);
  wavHeader = null;
  output.endTracks();
}
 
Example #22
Source File: WavExtractor.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void init(ExtractorOutput output) {
  extractorOutput = output;
  trackOutput = output.track(0, C.TRACK_TYPE_AUDIO);
  wavHeader = null;
  output.endTracks();
}
 
Example #23
Source File: FlacExtractor.java    From Jockey with Apache License 2.0 5 votes vote down vote up
@Override
public void init(ExtractorOutput output) {
  extractorOutput = output;
  trackOutput = extractorOutput.track(0, C.TRACK_TYPE_AUDIO);
  extractorOutput.endTracks();
  try {
    decoderJni = new FlacDecoderJni();
  } catch (FlacDecoderException e) {
    throw new RuntimeException(e);
  }
}
 
Example #24
Source File: StreamReader.java    From K-Sonic with MIT License 5 votes vote down vote up
void init(ExtractorOutput output, TrackOutput trackOutput) {
  this.extractorOutput = output;
  this.trackOutput = trackOutput;
  this.oggPacket = new OggPacket();

  reset(true);
}
 
Example #25
Source File: FlacExtractor.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void init(ExtractorOutput output) {
  extractorOutput = output;
  trackOutput = extractorOutput.track(0, C.TRACK_TYPE_AUDIO);
  extractorOutput.endTracks();
  try {
    decoderJni = new FlacDecoderJni();
  } catch (FlacDecoderException e) {
    throw new RuntimeException(e);
  }
}
 
Example #26
Source File: H265Reader.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void createTracks(ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) {
  idGenerator.generateNewId();
  formatId = idGenerator.getFormatId();
  output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_VIDEO);
  sampleReader = new SampleReader(output);
  seiReader.createTracks(extractorOutput, idGenerator);
}
 
Example #27
Source File: FragmentedMp4Extractor.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void init(ExtractorOutput output) {
  extractorOutput = output;
  if (sideloadedTrack != null) {
    TrackBundle bundle = new TrackBundle(output.track(0, sideloadedTrack.type));
    bundle.init(sideloadedTrack, new DefaultSampleValues(0, 0, 0, 0));
    trackBundles.put(0, bundle);
    maybeInitExtraTracks();
    extractorOutput.endTracks();
  }
}
 
Example #28
Source File: H262Reader.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void createTracks(ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) {
  idGenerator.generateNewId();
  formatId = idGenerator.getFormatId();
  output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_VIDEO);
  if (userDataReader != null) {
    userDataReader.createTracks(extractorOutput, idGenerator);
  }
}
 
Example #29
Source File: H264Reader.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void createTracks(ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) {
  idGenerator.generateNewId();
  formatId = idGenerator.getFormatId();
  output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_VIDEO);
  sampleReader = new SampleReader(output, allowNonIdrKeyframes, detectAccessUnits);
  seiReader.createTracks(extractorOutput, idGenerator);
}
 
Example #30
Source File: FragmentedMp4Extractor.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void init(ExtractorOutput output) {
  extractorOutput = output;
  if (sideloadedTrack != null) {
    TrackBundle bundle = new TrackBundle(output.track(0, sideloadedTrack.type));
    bundle.init(sideloadedTrack, new DefaultSampleValues(0, 0, 0, 0));
    trackBundles.put(0, bundle);
    maybeInitExtraTracks();
    extractorOutput.endTracks();
  }
}