Search in sources :

Example 1 with SyncFrameInfo

use of com.google.android.exoplayer2.audio.Ac3Util.SyncFrameInfo in project ExoPlayer by google.

the class Ac3Reader method parseHeader.

/**
 * Parses the sample header.
 */
@RequiresNonNull("output")
private void parseHeader() {
    headerScratchBits.setPosition(0);
    SyncFrameInfo frameInfo = Ac3Util.parseAc3SyncframeInfo(headerScratchBits);
    if (format == null || frameInfo.channelCount != format.channelCount || frameInfo.sampleRate != format.sampleRate || !Util.areEqual(frameInfo.mimeType, format.sampleMimeType)) {
        format = new Format.Builder().setId(formatId).setSampleMimeType(frameInfo.mimeType).setChannelCount(frameInfo.channelCount).setSampleRate(frameInfo.sampleRate).setLanguage(language).build();
        output.format(format);
    }
    sampleSize = frameInfo.frameSize;
    // In this class a sample is an access unit (syncframe in AC-3), but Format#sampleRate
    // specifies the number of PCM audio samples per second.
    sampleDurationUs = C.MICROS_PER_SECOND * frameInfo.sampleCount / format.sampleRate;
}
Also used : Format(com.google.android.exoplayer2.Format) SyncFrameInfo(com.google.android.exoplayer2.audio.Ac3Util.SyncFrameInfo) RequiresNonNull(org.checkerframework.checker.nullness.qual.RequiresNonNull)

Example 2 with SyncFrameInfo

use of com.google.android.exoplayer2.audio.Ac3Util.SyncFrameInfo in project ExoPlayer by google.

the class Ac4Reader method parseHeader.

/**
 * Parses the sample header.
 */
@RequiresNonNull("output")
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 = new Format.Builder().setId(formatId).setSampleMimeType(MimeTypes.AUDIO_AC4).setChannelCount(frameInfo.channelCount).setSampleRate(frameInfo.sampleRate).setLanguage(language).build();
        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;
}
Also used : Format(com.google.android.exoplayer2.Format) SyncFrameInfo(com.google.android.exoplayer2.audio.Ac4Util.SyncFrameInfo) RequiresNonNull(org.checkerframework.checker.nullness.qual.RequiresNonNull)

Aggregations

Format (com.google.android.exoplayer2.Format)2 RequiresNonNull (org.checkerframework.checker.nullness.qual.RequiresNonNull)2 SyncFrameInfo (com.google.android.exoplayer2.audio.Ac3Util.SyncFrameInfo)1 SyncFrameInfo (com.google.android.exoplayer2.audio.Ac4Util.SyncFrameInfo)1