com.google.android.exoplayer2.extractor.ts.DefaultTsPayloadReaderFactory Java Examples

The following examples show how to use com.google.android.exoplayer2.extractor.ts.DefaultTsPayloadReaderFactory. 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: DefaultHlsExtractorFactory.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
private static TsExtractor createTsExtractor(
    @DefaultTsPayloadReaderFactory.Flags int userProvidedPayloadReaderFactoryFlags,
    boolean exposeCea608WhenMissingDeclarations,
    Format format,
    @Nullable List<Format> muxedCaptionFormats,
    TimestampAdjuster timestampAdjuster) {
  @DefaultTsPayloadReaderFactory.Flags
  int payloadReaderFactoryFlags =
      DefaultTsPayloadReaderFactory.FLAG_IGNORE_SPLICE_INFO_STREAM
          | userProvidedPayloadReaderFactoryFlags;
  if (muxedCaptionFormats != null) {
    // The playlist declares closed caption renditions, we should ignore descriptors.
    payloadReaderFactoryFlags |= DefaultTsPayloadReaderFactory.FLAG_OVERRIDE_CAPTION_DESCRIPTORS;
  } else if (exposeCea608WhenMissingDeclarations) {
    // The playlist does not provide any closed caption information. We preemptively declare a
    // closed caption track on channel 0.
    muxedCaptionFormats =
        Collections.singletonList(
            Format.createTextSampleFormat(
                /* id= */ null,
                MimeTypes.APPLICATION_CEA608,
                /* selectionFlags= */ 0,
                /* language= */ null));
  } else {
    muxedCaptionFormats = Collections.emptyList();
  }
  String codecs = format.codecs;
  if (!TextUtils.isEmpty(codecs)) {
    // Sometimes AAC and H264 streams are declared in TS chunks even though they don't really
    // exist. If we know from the codec attribute that they don't exist, then we can
    // explicitly ignore them even if they're declared.
    if (!MimeTypes.AUDIO_AAC.equals(MimeTypes.getAudioMediaMimeType(codecs))) {
      payloadReaderFactoryFlags |= DefaultTsPayloadReaderFactory.FLAG_IGNORE_AAC_STREAM;
    }
    if (!MimeTypes.VIDEO_H264.equals(MimeTypes.getVideoMediaMimeType(codecs))) {
      payloadReaderFactoryFlags |= DefaultTsPayloadReaderFactory.FLAG_IGNORE_H264_STREAM;
    }
  }

  return new TsExtractor(
      TsExtractor.MODE_HLS,
      timestampAdjuster,
      new DefaultTsPayloadReaderFactory(payloadReaderFactoryFlags, muxedCaptionFormats));
}
 
Example #2
Source File: DefaultHlsExtractorFactory.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private static TsExtractor createTsExtractor(
    @DefaultTsPayloadReaderFactory.Flags int userProvidedPayloadReaderFactoryFlags,
    boolean exposeCea608WhenMissingDeclarations,
    Format format,
    List<Format> muxedCaptionFormats,
    TimestampAdjuster timestampAdjuster) {
  @DefaultTsPayloadReaderFactory.Flags
  int payloadReaderFactoryFlags =
      DefaultTsPayloadReaderFactory.FLAG_IGNORE_SPLICE_INFO_STREAM
          | userProvidedPayloadReaderFactoryFlags;
  if (muxedCaptionFormats != null) {
    // The playlist declares closed caption renditions, we should ignore descriptors.
    payloadReaderFactoryFlags |= DefaultTsPayloadReaderFactory.FLAG_OVERRIDE_CAPTION_DESCRIPTORS;
  } else if (exposeCea608WhenMissingDeclarations) {
    // The playlist does not provide any closed caption information. We preemptively declare a
    // closed caption track on channel 0.
    muxedCaptionFormats =
        Collections.singletonList(
            Format.createTextSampleFormat(
                /* id= */ null,
                MimeTypes.APPLICATION_CEA608,
                /* selectionFlags= */ 0,
                /* language= */ null));
  } else {
    muxedCaptionFormats = Collections.emptyList();
  }
  String codecs = format.codecs;
  if (!TextUtils.isEmpty(codecs)) {
    // Sometimes AAC and H264 streams are declared in TS chunks even though they don't really
    // exist. If we know from the codec attribute that they don't exist, then we can
    // explicitly ignore them even if they're declared.
    if (!MimeTypes.AUDIO_AAC.equals(MimeTypes.getAudioMediaMimeType(codecs))) {
      payloadReaderFactoryFlags |= DefaultTsPayloadReaderFactory.FLAG_IGNORE_AAC_STREAM;
    }
    if (!MimeTypes.VIDEO_H264.equals(MimeTypes.getVideoMediaMimeType(codecs))) {
      payloadReaderFactoryFlags |= DefaultTsPayloadReaderFactory.FLAG_IGNORE_H264_STREAM;
    }
  }

  return new TsExtractor(
      TsExtractor.MODE_HLS,
      timestampAdjuster,
      new DefaultTsPayloadReaderFactory(payloadReaderFactoryFlags, muxedCaptionFormats));
}
 
Example #3
Source File: DefaultHlsExtractorFactory.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private static TsExtractor createTsExtractor(
    @DefaultTsPayloadReaderFactory.Flags int userProvidedPayloadReaderFactoryFlags,
    boolean exposeCea608WhenMissingDeclarations,
    Format format,
    List<Format> muxedCaptionFormats,
    TimestampAdjuster timestampAdjuster) {
  @DefaultTsPayloadReaderFactory.Flags
  int payloadReaderFactoryFlags =
      DefaultTsPayloadReaderFactory.FLAG_IGNORE_SPLICE_INFO_STREAM
          | userProvidedPayloadReaderFactoryFlags;
  if (muxedCaptionFormats != null) {
    // The playlist declares closed caption renditions, we should ignore descriptors.
    payloadReaderFactoryFlags |= DefaultTsPayloadReaderFactory.FLAG_OVERRIDE_CAPTION_DESCRIPTORS;
  } else if (exposeCea608WhenMissingDeclarations) {
    // The playlist does not provide any closed caption information. We preemptively declare a
    // closed caption track on channel 0.
    muxedCaptionFormats =
        Collections.singletonList(
            Format.createTextSampleFormat(
                /* id= */ null,
                MimeTypes.APPLICATION_CEA608,
                /* selectionFlags= */ 0,
                /* language= */ null));
  } else {
    muxedCaptionFormats = Collections.emptyList();
  }
  String codecs = format.codecs;
  if (!TextUtils.isEmpty(codecs)) {
    // Sometimes AAC and H264 streams are declared in TS chunks even though they don't really
    // exist. If we know from the codec attribute that they don't exist, then we can
    // explicitly ignore them even if they're declared.
    if (!MimeTypes.AUDIO_AAC.equals(MimeTypes.getAudioMediaMimeType(codecs))) {
      payloadReaderFactoryFlags |= DefaultTsPayloadReaderFactory.FLAG_IGNORE_AAC_STREAM;
    }
    if (!MimeTypes.VIDEO_H264.equals(MimeTypes.getVideoMediaMimeType(codecs))) {
      payloadReaderFactoryFlags |= DefaultTsPayloadReaderFactory.FLAG_IGNORE_H264_STREAM;
    }
  }

  return new TsExtractor(
      TsExtractor.MODE_HLS,
      timestampAdjuster,
      new DefaultTsPayloadReaderFactory(payloadReaderFactoryFlags, muxedCaptionFormats));
}
 
Example #4
Source File: DefaultExtractorsFactory.java    From MediaSDK with Apache License 2.0 2 votes vote down vote up
/**
 * Sets flags for {@link DefaultTsPayloadReaderFactory}s used by {@link TsExtractor} instances
 * created by the factory.
 *
 * @see TsExtractor#TsExtractor(int)
 * @param flags The flags to use.
 * @return The factory, for convenience.
 */
public synchronized DefaultExtractorsFactory setTsExtractorFlags(
    @DefaultTsPayloadReaderFactory.Flags int flags) {
  tsFlags = flags;
  return this;
}
 
Example #5
Source File: DefaultExtractorsFactory.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets flags for {@link DefaultTsPayloadReaderFactory}s used by {@link TsExtractor} instances
 * created by the factory.
 *
 * @see TsExtractor#TsExtractor(int)
 * @param flags The flags to use.
 * @return The factory, for convenience.
 */
public synchronized DefaultExtractorsFactory setTsExtractorFlags(
    @DefaultTsPayloadReaderFactory.Flags int flags) {
  tsFlags = flags;
  return this;
}
 
Example #6
Source File: DefaultExtractorsFactory.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets flags for {@link DefaultTsPayloadReaderFactory}s used by {@link TsExtractor} instances
 * created by the factory.
 *
 * @see TsExtractor#TsExtractor(int)
 * @param flags The flags to use.
 * @return The factory, for convenience.
 */
public synchronized DefaultExtractorsFactory setTsExtractorFlags(
    @DefaultTsPayloadReaderFactory.Flags int flags) {
  tsFlags = flags;
  return this;
}
 
Example #7
Source File: DefaultExtractorsFactory.java    From Telegram-FOSS with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets flags for {@link DefaultTsPayloadReaderFactory}s used by {@link TsExtractor} instances
 * created by the factory.
 *
 * @see TsExtractor#TsExtractor(int)
 * @param flags The flags to use.
 * @return The factory, for convenience.
 */
public synchronized DefaultExtractorsFactory setTsExtractorFlags(
    @DefaultTsPayloadReaderFactory.Flags int flags) {
  tsFlags = flags;
  return this;
}
 
Example #8
Source File: DefaultExtractorsFactory.java    From Telegram with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets flags for {@link DefaultTsPayloadReaderFactory}s used by {@link TsExtractor} instances
 * created by the factory.
 *
 * @see TsExtractor#TsExtractor(int)
 * @param flags The flags to use.
 * @return The factory, for convenience.
 */
public synchronized DefaultExtractorsFactory setTsExtractorFlags(
    @DefaultTsPayloadReaderFactory.Flags int flags) {
  tsFlags = flags;
  return this;
}