Java Code Examples for com.google.android.exoplayer2.Format#OFFSET_SAMPLE_RELATIVE

The following examples show how to use com.google.android.exoplayer2.Format#OFFSET_SAMPLE_RELATIVE . 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: SampleQueue.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adjusts a {@link Format} to incorporate a sample offset into {@link Format#subsampleOffsetUs}.
 *
 * @param format The {@link Format} to adjust.
 * @param sampleOffsetUs The offset to apply.
 * @return The adjusted {@link Format}.
 */
private static Format getAdjustedSampleFormat(Format format, long sampleOffsetUs) {
  if (format == null) {
    return null;
  }
  if (sampleOffsetUs != 0 && format.subsampleOffsetUs != Format.OFFSET_SAMPLE_RELATIVE) {
    format = format.copyWithSubsampleOffsetUs(format.subsampleOffsetUs + sampleOffsetUs);
  }
  return format;
}
 
Example 2
Source File: SampleQueue.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adjusts a {@link Format} to incorporate a sample offset into {@link Format#subsampleOffsetUs}.
 *
 * @param format The {@link Format} to adjust.
 * @param sampleOffsetUs The offset to apply.
 * @return The adjusted {@link Format}.
 */
private static Format getAdjustedSampleFormat(Format format, long sampleOffsetUs) {
  if (format == null) {
    return null;
  }
  if (sampleOffsetUs != 0 && format.subsampleOffsetUs != Format.OFFSET_SAMPLE_RELATIVE) {
    format = format.copyWithSubsampleOffsetUs(format.subsampleOffsetUs + sampleOffsetUs);
  }
  return format;
}
 
Example 3
Source File: SampleQueue.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adjusts a {@link Format} to incorporate a sample offset into {@link Format#subsampleOffsetUs}.
 *
 * @param format The {@link Format} to adjust.
 * @param sampleOffsetUs The offset to apply.
 * @return The adjusted {@link Format}.
 */
private static Format getAdjustedSampleFormat(Format format, long sampleOffsetUs) {
  if (format == null) {
    return null;
  }
  if (sampleOffsetUs != 0 && format.subsampleOffsetUs != Format.OFFSET_SAMPLE_RELATIVE) {
    format = format.copyWithSubsampleOffsetUs(format.subsampleOffsetUs + sampleOffsetUs);
  }
  return format;
}
 
Example 4
Source File: DefaultTrackOutput.java    From K-Sonic with MIT License 5 votes vote down vote up
/**
 * Adjusts a {@link Format} to incorporate a sample offset into {@link Format#subsampleOffsetUs}.
 *
 * @param format The {@link Format} to adjust.
 * @param sampleOffsetUs The offset to apply.
 * @return The adjusted {@link Format}.
 */
private static Format getAdjustedSampleFormat(Format format, long sampleOffsetUs) {
  if (format == null) {
    return null;
  }
  if (sampleOffsetUs != 0 && format.subsampleOffsetUs != Format.OFFSET_SAMPLE_RELATIVE) {
    format = format.copyWithSubsampleOffsetUs(format.subsampleOffsetUs + sampleOffsetUs);
  }
  return format;
}
 
Example 5
Source File: SampleQueue.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adjusts a {@link Format} to incorporate a sample offset into {@link Format#subsampleOffsetUs}.
 *
 * @param format The {@link Format} to adjust.
 * @param sampleOffsetUs The offset to apply.
 * @return The adjusted {@link Format}.
 */
private static Format getAdjustedSampleFormat(Format format, long sampleOffsetUs) {
  if (format == null) {
    return null;
  }
  if (sampleOffsetUs != 0 && format.subsampleOffsetUs != Format.OFFSET_SAMPLE_RELATIVE) {
    format = format.copyWithSubsampleOffsetUs(format.subsampleOffsetUs + sampleOffsetUs);
  }
  return format;
}
 
Example 6
Source File: SampleQueue.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Adjusts a {@link Format} to incorporate a sample offset into {@link Format#subsampleOffsetUs}.
 *
 * @param format The {@link Format} to adjust.
 * @param sampleOffsetUs The offset to apply.
 * @return The adjusted {@link Format}.
 */
private static Format getAdjustedSampleFormat(Format format, long sampleOffsetUs) {
  if (format == null) {
    return null;
  }
  if (sampleOffsetUs != 0 && format.subsampleOffsetUs != Format.OFFSET_SAMPLE_RELATIVE) {
    format = format.copyWithSubsampleOffsetUs(format.subsampleOffsetUs + sampleOffsetUs);
  }
  return format;
}
 
Example 7
Source File: AtomParsers.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private static void parseTextSampleEntry(ParsableByteArray parent, int atomType, int position,
    int atomSize, int trackId, String language, StsdData out) throws ParserException {
  parent.setPosition(position + Atom.HEADER_SIZE + StsdData.STSD_HEADER_SIZE);

  // Default values.
  List<byte[]> initializationData = null;
  long subsampleOffsetUs = Format.OFFSET_SAMPLE_RELATIVE;

  String mimeType;
  if (atomType == Atom.TYPE_TTML) {
    mimeType = MimeTypes.APPLICATION_TTML;
  } else if (atomType == Atom.TYPE_tx3g) {
    mimeType = MimeTypes.APPLICATION_TX3G;
    int sampleDescriptionLength = atomSize - Atom.HEADER_SIZE - 8;
    byte[] sampleDescriptionData = new byte[sampleDescriptionLength];
    parent.readBytes(sampleDescriptionData, 0, sampleDescriptionLength);
    initializationData = Collections.singletonList(sampleDescriptionData);
  } else if (atomType == Atom.TYPE_wvtt) {
    mimeType = MimeTypes.APPLICATION_MP4VTT;
  } else if (atomType == Atom.TYPE_stpp) {
    mimeType = MimeTypes.APPLICATION_TTML;
    subsampleOffsetUs = 0; // Subsample timing is absolute.
  } else if (atomType == Atom.TYPE_c608) {
    // Defined by the QuickTime File Format specification.
    mimeType = MimeTypes.APPLICATION_MP4CEA608;
    out.requiredSampleTransformation = Track.TRANSFORMATION_CEA608_CDAT;
  } else {
    // Never happens.
    throw new IllegalStateException();
  }

  out.format =
      Format.createTextSampleFormat(
          Integer.toString(trackId),
          mimeType,
          /* codecs= */ null,
          /* bitrate= */ Format.NO_VALUE,
          /* selectionFlags= */ 0,
          language,
          /* accessibilityChannel= */ Format.NO_VALUE,
          /* drmInitData= */ null,
          subsampleOffsetUs,
          initializationData);
}
 
Example 8
Source File: AtomParsers.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
private static void parseTextSampleEntry(ParsableByteArray parent, int atomType, int position,
    int atomSize, int trackId, String language, StsdData out) throws ParserException {
  parent.setPosition(position + Atom.HEADER_SIZE + StsdData.STSD_HEADER_SIZE);

  // Default values.
  List<byte[]> initializationData = null;
  long subsampleOffsetUs = Format.OFFSET_SAMPLE_RELATIVE;

  String mimeType;
  if (atomType == Atom.TYPE_TTML) {
    mimeType = MimeTypes.APPLICATION_TTML;
  } else if (atomType == Atom.TYPE_tx3g) {
    mimeType = MimeTypes.APPLICATION_TX3G;
    int sampleDescriptionLength = atomSize - Atom.HEADER_SIZE - 8;
    byte[] sampleDescriptionData = new byte[sampleDescriptionLength];
    parent.readBytes(sampleDescriptionData, 0, sampleDescriptionLength);
    initializationData = Collections.singletonList(sampleDescriptionData);
  } else if (atomType == Atom.TYPE_wvtt) {
    mimeType = MimeTypes.APPLICATION_MP4VTT;
  } else if (atomType == Atom.TYPE_stpp) {
    mimeType = MimeTypes.APPLICATION_TTML;
    subsampleOffsetUs = 0; // Subsample timing is absolute.
  } else if (atomType == Atom.TYPE_c608) {
    // Defined by the QuickTime File Format specification.
    mimeType = MimeTypes.APPLICATION_MP4CEA608;
    out.requiredSampleTransformation = Track.TRANSFORMATION_CEA608_CDAT;
  } else {
    // Never happens.
    throw new IllegalStateException();
  }

  out.format =
      Format.createTextSampleFormat(
          Integer.toString(trackId),
          mimeType,
          /* codecs= */ null,
          /* bitrate= */ Format.NO_VALUE,
          /* selectionFlags= */ 0,
          language,
          /* accessibilityChannel= */ Format.NO_VALUE,
          /* drmInitData= */ null,
          subsampleOffsetUs,
          initializationData);
}
 
Example 9
Source File: AtomParsers.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private static void parseTextSampleEntry(ParsableByteArray parent, int atomType, int position,
    int atomSize, int trackId, String language, StsdData out) throws ParserException {
  parent.setPosition(position + Atom.HEADER_SIZE + StsdData.STSD_HEADER_SIZE);

  // Default values.
  List<byte[]> initializationData = null;
  long subsampleOffsetUs = Format.OFFSET_SAMPLE_RELATIVE;

  String mimeType;
  if (atomType == Atom.TYPE_TTML) {
    mimeType = MimeTypes.APPLICATION_TTML;
  } else if (atomType == Atom.TYPE_tx3g) {
    mimeType = MimeTypes.APPLICATION_TX3G;
    int sampleDescriptionLength = atomSize - Atom.HEADER_SIZE - 8;
    byte[] sampleDescriptionData = new byte[sampleDescriptionLength];
    parent.readBytes(sampleDescriptionData, 0, sampleDescriptionLength);
    initializationData = Collections.singletonList(sampleDescriptionData);
  } else if (atomType == Atom.TYPE_wvtt) {
    mimeType = MimeTypes.APPLICATION_MP4VTT;
  } else if (atomType == Atom.TYPE_stpp) {
    mimeType = MimeTypes.APPLICATION_TTML;
    subsampleOffsetUs = 0; // Subsample timing is absolute.
  } else if (atomType == Atom.TYPE_c608) {
    // Defined by the QuickTime File Format specification.
    mimeType = MimeTypes.APPLICATION_MP4CEA608;
    out.requiredSampleTransformation = Track.TRANSFORMATION_CEA608_CDAT;
  } else {
    // Never happens.
    throw new IllegalStateException();
  }

  out.format =
      Format.createTextSampleFormat(
          Integer.toString(trackId),
          mimeType,
          /* codecs= */ null,
          /* bitrate= */ Format.NO_VALUE,
          /* selectionFlags= */ 0,
          language,
          /* accessibilityChannel= */ Format.NO_VALUE,
          /* drmInitData= */ null,
          subsampleOffsetUs,
          initializationData);
}
 
Example 10
Source File: AtomParsers.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private static void parseTextSampleEntry(ParsableByteArray parent, int atomType, int position,
    int atomSize, int trackId, String language, StsdData out) throws ParserException {
  parent.setPosition(position + Atom.HEADER_SIZE + StsdData.STSD_HEADER_SIZE);

  // Default values.
  List<byte[]> initializationData = null;
  long subsampleOffsetUs = Format.OFFSET_SAMPLE_RELATIVE;

  String mimeType;
  if (atomType == Atom.TYPE_TTML) {
    mimeType = MimeTypes.APPLICATION_TTML;
  } else if (atomType == Atom.TYPE_tx3g) {
    mimeType = MimeTypes.APPLICATION_TX3G;
    int sampleDescriptionLength = atomSize - Atom.HEADER_SIZE - 8;
    byte[] sampleDescriptionData = new byte[sampleDescriptionLength];
    parent.readBytes(sampleDescriptionData, 0, sampleDescriptionLength);
    initializationData = Collections.singletonList(sampleDescriptionData);
  } else if (atomType == Atom.TYPE_wvtt) {
    mimeType = MimeTypes.APPLICATION_MP4VTT;
  } else if (atomType == Atom.TYPE_stpp) {
    mimeType = MimeTypes.APPLICATION_TTML;
    subsampleOffsetUs = 0; // Subsample timing is absolute.
  } else if (atomType == Atom.TYPE_c608) {
    // Defined by the QuickTime File Format specification.
    mimeType = MimeTypes.APPLICATION_MP4CEA608;
    out.requiredSampleTransformation = Track.TRANSFORMATION_CEA608_CDAT;
  } else {
    // Never happens.
    throw new IllegalStateException();
  }

  out.format =
      Format.createTextSampleFormat(
          Integer.toString(trackId),
          mimeType,
          /* codecs= */ null,
          /* bitrate= */ Format.NO_VALUE,
          /* selectionFlags= */ 0,
          language,
          /* accessibilityChannel= */ Format.NO_VALUE,
          /* drmInitData= */ null,
          subsampleOffsetUs,
          initializationData);
}
 
Example 11
Source File: AtomParsers.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private static void parseTextSampleEntry(ParsableByteArray parent, int atomType, int position,
    int atomSize, int trackId, String language, StsdData out) throws ParserException {
  parent.setPosition(position + Atom.HEADER_SIZE + StsdData.STSD_HEADER_SIZE);

  // Default values.
  List<byte[]> initializationData = null;
  long subsampleOffsetUs = Format.OFFSET_SAMPLE_RELATIVE;

  String mimeType;
  if (atomType == Atom.TYPE_TTML) {
    mimeType = MimeTypes.APPLICATION_TTML;
  } else if (atomType == Atom.TYPE_tx3g) {
    mimeType = MimeTypes.APPLICATION_TX3G;
    int sampleDescriptionLength = atomSize - Atom.HEADER_SIZE - 8;
    byte[] sampleDescriptionData = new byte[sampleDescriptionLength];
    parent.readBytes(sampleDescriptionData, 0, sampleDescriptionLength);
    initializationData = Collections.singletonList(sampleDescriptionData);
  } else if (atomType == Atom.TYPE_wvtt) {
    mimeType = MimeTypes.APPLICATION_MP4VTT;
  } else if (atomType == Atom.TYPE_stpp) {
    mimeType = MimeTypes.APPLICATION_TTML;
    subsampleOffsetUs = 0; // Subsample timing is absolute.
  } else if (atomType == Atom.TYPE_c608) {
    // Defined by the QuickTime File Format specification.
    mimeType = MimeTypes.APPLICATION_MP4CEA608;
    out.requiredSampleTransformation = Track.TRANSFORMATION_CEA608_CDAT;
  } else {
    // Never happens.
    throw new IllegalStateException();
  }

  out.format =
      Format.createTextSampleFormat(
          Integer.toString(trackId),
          mimeType,
          /* codecs= */ null,
          /* bitrate= */ Format.NO_VALUE,
          /* selectionFlags= */ 0,
          language,
          /* accessibilityChannel= */ Format.NO_VALUE,
          /* drmInitData= */ null,
          subsampleOffsetUs,
          initializationData);
}
 
Example 12
Source File: SubtitleOutputBuffer.java    From TelePlus-Android with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Sets the content of the output buffer, consisting of a {@link Subtitle} and associated
 * metadata.
 *
 * @param timeUs The time of the start of the subtitle in microseconds.
 * @param subtitle The subtitle.
 * @param subsampleOffsetUs An offset that must be added to the subtitle's event times, or
 *     {@link Format#OFFSET_SAMPLE_RELATIVE} if {@code timeUs} should be added.
 */
public void setContent(long timeUs, Subtitle subtitle, long subsampleOffsetUs) {
  this.timeUs = timeUs;
  this.subtitle = subtitle;
  this.subsampleOffsetUs = subsampleOffsetUs == Format.OFFSET_SAMPLE_RELATIVE ? this.timeUs
      : subsampleOffsetUs;
}
 
Example 13
Source File: SubtitleOutputBuffer.java    From TelePlus-Android with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Sets the content of the output buffer, consisting of a {@link Subtitle} and associated
 * metadata.
 *
 * @param timeUs The time of the start of the subtitle in microseconds.
 * @param subtitle The subtitle.
 * @param subsampleOffsetUs An offset that must be added to the subtitle's event times, or
 *     {@link Format#OFFSET_SAMPLE_RELATIVE} if {@code timeUs} should be added.
 */
public void setContent(long timeUs, Subtitle subtitle, long subsampleOffsetUs) {
  this.timeUs = timeUs;
  this.subtitle = subtitle;
  this.subsampleOffsetUs = subsampleOffsetUs == Format.OFFSET_SAMPLE_RELATIVE ? this.timeUs
      : subsampleOffsetUs;
}
 
Example 14
Source File: SubtitleOutputBuffer.java    From K-Sonic with MIT License 3 votes vote down vote up
/**
 * Sets the content of the output buffer, consisting of a {@link Subtitle} and associated
 * metadata.
 *
 * @param timeUs The time of the start of the subtitle in microseconds.
 * @param subtitle The subtitle.
 * @param subsampleOffsetUs An offset that must be added to the subtitle's event times, or
 *     {@link Format#OFFSET_SAMPLE_RELATIVE} if {@code timeUs} should be added.
 */
public void setContent(long timeUs, Subtitle subtitle, long subsampleOffsetUs) {
  this.timeUs = timeUs;
  this.subtitle = subtitle;
  this.subsampleOffsetUs = subsampleOffsetUs == Format.OFFSET_SAMPLE_RELATIVE ? this.timeUs
      : subsampleOffsetUs;
}
 
Example 15
Source File: SubtitleOutputBuffer.java    From Telegram-FOSS with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Sets the content of the output buffer, consisting of a {@link Subtitle} and associated
 * metadata.
 *
 * @param timeUs The time of the start of the subtitle in microseconds.
 * @param subtitle The subtitle.
 * @param subsampleOffsetUs An offset that must be added to the subtitle's event times, or
 *     {@link Format#OFFSET_SAMPLE_RELATIVE} if {@code timeUs} should be added.
 */
public void setContent(long timeUs, Subtitle subtitle, long subsampleOffsetUs) {
  this.timeUs = timeUs;
  this.subtitle = subtitle;
  this.subsampleOffsetUs = subsampleOffsetUs == Format.OFFSET_SAMPLE_RELATIVE ? this.timeUs
      : subsampleOffsetUs;
}
 
Example 16
Source File: SubtitleOutputBuffer.java    From Telegram with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Sets the content of the output buffer, consisting of a {@link Subtitle} and associated
 * metadata.
 *
 * @param timeUs The time of the start of the subtitle in microseconds.
 * @param subtitle The subtitle.
 * @param subsampleOffsetUs An offset that must be added to the subtitle's event times, or
 *     {@link Format#OFFSET_SAMPLE_RELATIVE} if {@code timeUs} should be added.
 */
public void setContent(long timeUs, Subtitle subtitle, long subsampleOffsetUs) {
  this.timeUs = timeUs;
  this.subtitle = subtitle;
  this.subsampleOffsetUs = subsampleOffsetUs == Format.OFFSET_SAMPLE_RELATIVE ? this.timeUs
      : subsampleOffsetUs;
}
 
Example 17
Source File: SubtitleOutputBuffer.java    From MediaSDK with Apache License 2.0 3 votes vote down vote up
/**
 * Sets the content of the output buffer, consisting of a {@link Subtitle} and associated
 * metadata.
 *
 * @param timeUs The time of the start of the subtitle in microseconds.
 * @param subtitle The subtitle.
 * @param subsampleOffsetUs An offset that must be added to the subtitle's event times, or
 *     {@link Format#OFFSET_SAMPLE_RELATIVE} if {@code timeUs} should be added.
 */
public void setContent(long timeUs, Subtitle subtitle, long subsampleOffsetUs) {
  this.timeUs = timeUs;
  this.subtitle = subtitle;
  this.subsampleOffsetUs = subsampleOffsetUs == Format.OFFSET_SAMPLE_RELATIVE ? this.timeUs
      : subsampleOffsetUs;
}