Search in sources :

Example 1 with DefaultAudioSink

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

the class LibflacAudioRenderer method supportsFormatInternal.

@Override
@C.FormatSupport
protected int supportsFormatInternal(Format format) {
    if (!FlacLibrary.isAvailable() || !MimeTypes.AUDIO_FLAC.equalsIgnoreCase(format.sampleMimeType)) {
        return C.FORMAT_UNSUPPORTED_TYPE;
    }
    // Compute the format that the FLAC decoder will output.
    Format outputFormat;
    if (format.initializationData.isEmpty()) {
        // The initialization data might not be set if the format was obtained from a manifest (e.g.
        // for DASH playbacks) rather than directly from the media. In this case we assume
        // ENCODING_PCM_16BIT. If the actual encoding is different then playback will still succeed as
        // long as the AudioSink supports it, which will always be true when using DefaultAudioSink.
        outputFormat = Util.getPcmFormat(C.ENCODING_PCM_16BIT, format.channelCount, format.sampleRate);
    } else {
        int streamMetadataOffset = STREAM_MARKER_SIZE + METADATA_BLOCK_HEADER_SIZE;
        FlacStreamMetadata streamMetadata = new FlacStreamMetadata(format.initializationData.get(0), streamMetadataOffset);
        outputFormat = getOutputFormat(streamMetadata);
    }
    if (!sinkSupportsFormat(outputFormat)) {
        return C.FORMAT_UNSUPPORTED_SUBTYPE;
    } else if (format.cryptoType != C.CRYPTO_TYPE_NONE) {
        return C.FORMAT_UNSUPPORTED_DRM;
    } else {
        return C.FORMAT_HANDLED;
    }
}
Also used : Format(com.google.android.exoplayer2.Format) FlacStreamMetadata(com.google.android.exoplayer2.extractor.FlacStreamMetadata)

Example 2 with DefaultAudioSink

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

the class DefaultAudioSinkTest method floatOutputSupportedIfFloatOutputEnabledFromApi21.

@Config(minSdk = 21)
@Test
public void floatOutputSupportedIfFloatOutputEnabledFromApi21() {
    defaultAudioSink = new DefaultAudioSink.Builder().setEnableFloatOutput(true).build();
    Format floatFormat = STEREO_44_1_FORMAT.buildUpon().setSampleMimeType(MimeTypes.AUDIO_RAW).setPcmEncoding(C.ENCODING_PCM_FLOAT).build();
    assertThat(defaultAudioSink.getFormatSupport(floatFormat)).isEqualTo(SINK_FORMAT_SUPPORTED_DIRECTLY);
}
Also used : Format(com.google.android.exoplayer2.Format) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 3 with DefaultAudioSink

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

the class DefaultAudioSinkTest method audioSinkWithAacAudioCapabilitiesWithoutOffload_doesNotSupportAac.

@Test
public void audioSinkWithAacAudioCapabilitiesWithoutOffload_doesNotSupportAac() {
    DefaultAudioSink defaultAudioSink = new DefaultAudioSink.Builder().setAudioCapabilities(new AudioCapabilities(new int[] { C.ENCODING_AAC_LC }, 2)).build();
    Format aacLcFormat = STEREO_44_1_FORMAT.buildUpon().setSampleMimeType(MimeTypes.AUDIO_AAC).setPcmEncoding(C.ENCODING_AAC_LC).build();
    assertThat(defaultAudioSink.supportsFormat(aacLcFormat)).isFalse();
}
Also used : Format(com.google.android.exoplayer2.Format) Test(org.junit.Test)

Example 4 with DefaultAudioSink

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

the class DefaultAudioSinkTest method floatPcmNeedsTranscodingIfFloatOutputDisabled.

@Test
public void floatPcmNeedsTranscodingIfFloatOutputDisabled() {
    defaultAudioSink = new DefaultAudioSink.Builder().build();
    Format floatFormat = STEREO_44_1_FORMAT.buildUpon().setSampleMimeType(MimeTypes.AUDIO_RAW).setPcmEncoding(C.ENCODING_PCM_FLOAT).build();
    assertThat(defaultAudioSink.getFormatSupport(floatFormat)).isEqualTo(SINK_FORMAT_SUPPORTED_WITH_TRANSCODING);
}
Also used : Format(com.google.android.exoplayer2.Format) Test(org.junit.Test)

Example 5 with DefaultAudioSink

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

the class DefaultAudioSinkTest method floatPcmNeedsTranscodingIfFloatOutputEnabledBeforeApi21.

@Config(maxSdk = 20)
@Test
public void floatPcmNeedsTranscodingIfFloatOutputEnabledBeforeApi21() {
    defaultAudioSink = new DefaultAudioSink.Builder().setEnableFloatOutput(true).build();
    Format floatFormat = STEREO_44_1_FORMAT.buildUpon().setSampleMimeType(MimeTypes.AUDIO_RAW).setPcmEncoding(C.ENCODING_PCM_FLOAT).build();
    assertThat(defaultAudioSink.getFormatSupport(floatFormat)).isEqualTo(SINK_FORMAT_SUPPORTED_WITH_TRANSCODING);
}
Also used : Format(com.google.android.exoplayer2.Format) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Aggregations

Format (com.google.android.exoplayer2.Format)5 Test (org.junit.Test)4 Config (org.robolectric.annotation.Config)2 FlacStreamMetadata (com.google.android.exoplayer2.extractor.FlacStreamMetadata)1