com.google.android.exoplayer2.audio.Ac4Util.SyncFrameInfo Java Examples

The following examples show how to use com.google.android.exoplayer2.audio.Ac4Util.SyncFrameInfo. 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: Ac4Reader.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/** Parses the sample header. */
@SuppressWarnings("ReferenceEquality")
private void parseHeader() {
  headerScratchBits.setPosition(0);
  SyncFrameInfo frameInfo = Ac4Util.parseAc4SyncframeInfo(headerScratchBits);
  if (format == null
      || frameInfo.channelCount != format.channelCount
      || frameInfo.sampleRate != format.sampleRate
      || !MimeTypes.AUDIO_AC4.equals(format.sampleMimeType)) {
    format =
        Format.createAudioSampleFormat(
            trackFormatId,
            MimeTypes.AUDIO_AC4,
            /* codecs= */ null,
            /* bitrate= */ Format.NO_VALUE,
            /* maxInputSize= */ Format.NO_VALUE,
            frameInfo.channelCount,
            frameInfo.sampleRate,
            /* initializationData= */ null,
            /* drmInitData= */ null,
            /* selectionFlags= */ 0,
            language);
    output.format(format);
  }
  sampleSize = frameInfo.frameSize;
  // In this class a sample is an AC-4 sync frame, but Format#sampleRate specifies the number of
  // PCM audio samples per second.
  sampleDurationUs = C.MICROS_PER_SECOND * frameInfo.sampleCount / format.sampleRate;
}
 
Example #2
Source File: Ac4Reader.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/** Parses the sample header. */
@SuppressWarnings("ReferenceEquality")
private void parseHeader() {
  headerScratchBits.setPosition(0);
  SyncFrameInfo frameInfo = Ac4Util.parseAc4SyncframeInfo(headerScratchBits);
  if (format == null
      || frameInfo.channelCount != format.channelCount
      || frameInfo.sampleRate != format.sampleRate
      || !MimeTypes.AUDIO_AC4.equals(format.sampleMimeType)) {
    format =
        Format.createAudioSampleFormat(
            trackFormatId,
            MimeTypes.AUDIO_AC4,
            /* codecs= */ null,
            /* bitrate= */ Format.NO_VALUE,
            /* maxInputSize= */ Format.NO_VALUE,
            frameInfo.channelCount,
            frameInfo.sampleRate,
            /* initializationData= */ null,
            /* drmInitData= */ null,
            /* selectionFlags= */ 0,
            language);
    output.format(format);
  }
  sampleSize = frameInfo.frameSize;
  // In this class a sample is an AC-4 sync frame, but Format#sampleRate specifies the number of
  // PCM audio samples per second.
  sampleDurationUs = C.MICROS_PER_SECOND * frameInfo.sampleCount / format.sampleRate;
}
 
Example #3
Source File: Ac4Reader.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/** Parses the sample header. */
@SuppressWarnings("ReferenceEquality")
private void parseHeader() {
  headerScratchBits.setPosition(0);
  SyncFrameInfo frameInfo = Ac4Util.parseAc4SyncframeInfo(headerScratchBits);
  if (format == null
      || frameInfo.channelCount != format.channelCount
      || frameInfo.sampleRate != format.sampleRate
      || !MimeTypes.AUDIO_AC4.equals(format.sampleMimeType)) {
    format =
        Format.createAudioSampleFormat(
            trackFormatId,
            MimeTypes.AUDIO_AC4,
            /* codecs= */ null,
            /* bitrate= */ Format.NO_VALUE,
            /* maxInputSize= */ Format.NO_VALUE,
            frameInfo.channelCount,
            frameInfo.sampleRate,
            /* initializationData= */ null,
            /* drmInitData= */ null,
            /* selectionFlags= */ 0,
            language);
    output.format(format);
  }
  sampleSize = frameInfo.frameSize;
  // In this class a sample is an AC-4 sync frame, but Format#sampleRate specifies the number of
  // PCM audio samples per second.
  sampleDurationUs = C.MICROS_PER_SECOND * frameInfo.sampleCount / format.sampleRate;
}