diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BundledChunkExtractor.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BundledChunkExtractor.java index 5b2362f3e1..4f0b674135 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BundledChunkExtractor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BundledChunkExtractor.java @@ -31,7 +31,6 @@ import com.google.android.exoplayer2.extractor.SeekMap; import com.google.android.exoplayer2.extractor.TrackOutput; import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor; import com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor; -import com.google.android.exoplayer2.extractor.rawcc.RawCcExtractor; import com.google.android.exoplayer2.upstream.DataReader; import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.MimeTypes; @@ -56,13 +55,8 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac @Nullable String containerMimeType = format.containerMimeType; Extractor extractor; if (MimeTypes.isText(containerMimeType)) { - if (MimeTypes.APPLICATION_RAWCC.equals(containerMimeType)) { - // RawCC is special because it's a text specific container format. - extractor = new RawCcExtractor(format); - } else { - // All other text types are raw formats that do not need an extractor. - return null; - } + // Text types do not need an extractor. + return null; } else if (MimeTypes.isMatroska(containerMimeType)) { extractor = new MatroskaExtractor(MatroskaExtractor.FLAG_DISABLE_SEEK_FOR_CUES); } else { diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java index 80a69e0f8c..5bf2a6e4e7 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java @@ -1673,11 +1673,7 @@ public class DashManifestParser extends DefaultHandler } else if (MimeTypes.isVideo(containerMimeType)) { return MimeTypes.getVideoMediaMimeType(codecs); } else if (MimeTypes.isText(containerMimeType)) { - if (MimeTypes.APPLICATION_RAWCC.equals(containerMimeType)) { - // RawCC is special because it's a text specific container format. - return MimeTypes.getTextMediaMimeType(codecs); - } - // All other text types are raw formats. + // Text types are raw formats. return containerMimeType; } else if (MimeTypes.isImage(containerMimeType)) { // Image types are raw formats. diff --git a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParserTest.java b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParserTest.java index 3038ceedd3..39aa4467a2 100644 --- a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParserTest.java +++ b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParserTest.java @@ -274,14 +274,6 @@ public class DashManifestParserTest { List adaptationSets = manifest.getPeriod(0).adaptationSets; Format format = adaptationSets.get(0).representations.get(0).format; - assertThat(format.containerMimeType).isEqualTo(MimeTypes.APPLICATION_RAWCC); - assertThat(format.sampleMimeType).isEqualTo(MimeTypes.APPLICATION_CEA608); - assertThat(format.codecs).isEqualTo("cea608"); - assertThat(format.roleFlags).isEqualTo(C.ROLE_FLAG_SUBTITLE | C.ROLE_FLAG_MAIN); - assertThat(format.selectionFlags).isEqualTo(0); - assertThat(adaptationSets.get(0).type).isEqualTo(C.TRACK_TYPE_TEXT); - - format = adaptationSets.get(1).representations.get(0).format; assertThat(format.containerMimeType).isEqualTo(MimeTypes.APPLICATION_MP4); assertThat(format.sampleMimeType).isEqualTo(MimeTypes.APPLICATION_TTML); assertThat(format.codecs).isEqualTo("stpp.ttml.im1t"); @@ -291,11 +283,11 @@ public class DashManifestParserTest { // Ensure that forced-subtitle and forced_subtitle are both parsed as a 'forced' text track. // https://github.com/google/ExoPlayer/issues/9727 - format = adaptationSets.get(2).representations.get(0).format; + format = adaptationSets.get(1).representations.get(0).format; assertThat(format.roleFlags).isEqualTo(C.ROLE_FLAG_SUBTITLE); assertThat(format.selectionFlags).isEqualTo(C.SELECTION_FLAG_FORCED); - format = adaptationSets.get(3).representations.get(0).format; + format = adaptationSets.get(2).representations.get(0).format; assertThat(format.containerMimeType).isEqualTo(MimeTypes.APPLICATION_TTML); assertThat(format.sampleMimeType).isEqualTo(MimeTypes.APPLICATION_TTML); assertThat(format.codecs).isNull(); @@ -627,11 +619,10 @@ public class DashManifestParserTest { assertThat(manifest.getPeriodCount()).isEqualTo(1); List adaptationSets = manifest.getPeriod(0).adaptationSets; - assertThat(adaptationSets).hasSize(4); + assertThat(adaptationSets).hasSize(3); assertThat(getAvailabilityTimeOffsetUs(adaptationSets.get(0))).isEqualTo(C.TIME_UNSET); assertThat(getAvailabilityTimeOffsetUs(adaptationSets.get(1))).isEqualTo(C.TIME_UNSET); assertThat(getAvailabilityTimeOffsetUs(adaptationSets.get(2))).isEqualTo(C.TIME_UNSET); - assertThat(getAvailabilityTimeOffsetUs(adaptationSets.get(3))).isEqualTo(C.TIME_UNSET); } @Test diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/rawcc/RawCcExtractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/rawcc/RawCcExtractor.java deleted file mode 100644 index a1c4977745..0000000000 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/rawcc/RawCcExtractor.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.android.exoplayer2.extractor.rawcc; - -import com.google.android.exoplayer2.C; -import com.google.android.exoplayer2.Format; -import com.google.android.exoplayer2.ParserException; -import com.google.android.exoplayer2.extractor.Extractor; -import com.google.android.exoplayer2.extractor.ExtractorInput; -import com.google.android.exoplayer2.extractor.ExtractorOutput; -import com.google.android.exoplayer2.extractor.PositionHolder; -import com.google.android.exoplayer2.extractor.SeekMap; -import com.google.android.exoplayer2.extractor.TrackOutput; -import com.google.android.exoplayer2.util.Assertions; -import com.google.android.exoplayer2.util.ParsableByteArray; -import java.io.IOException; -import org.checkerframework.checker.nullness.qual.MonotonicNonNull; -import org.checkerframework.checker.nullness.qual.RequiresNonNull; - -/** Extracts data from the RawCC container format. */ -public final class RawCcExtractor implements Extractor { - - private static final int SCRATCH_SIZE = 9; - private static final int HEADER_SIZE = 8; - private static final int HEADER_ID = 0x52434301; - private static final int TIMESTAMP_SIZE_V0 = 4; - private static final int TIMESTAMP_SIZE_V1 = 8; - - // Parser states. - private static final int STATE_READING_HEADER = 0; - private static final int STATE_READING_TIMESTAMP_AND_COUNT = 1; - private static final int STATE_READING_SAMPLES = 2; - - private final Format format; - private final ParsableByteArray dataScratch; - - private @MonotonicNonNull TrackOutput trackOutput; - private int parserState; - private int version; - private long timestampUs; - private int remainingSampleCount; - private int sampleBytesWritten; - - public RawCcExtractor(Format format) { - this.format = format; - dataScratch = new ParsableByteArray(SCRATCH_SIZE); - parserState = STATE_READING_HEADER; - } - - @Override - public void init(ExtractorOutput output) { - output.seekMap(new SeekMap.Unseekable(C.TIME_UNSET)); - trackOutput = output.track(0, C.TRACK_TYPE_TEXT); - trackOutput.format(format); - output.endTracks(); - } - - @Override - public boolean sniff(ExtractorInput input) throws IOException { - dataScratch.reset(/* limit= */ HEADER_SIZE); - input.peekFully(dataScratch.getData(), 0, HEADER_SIZE); - return dataScratch.readInt() == HEADER_ID; - } - - @Override - public int read(ExtractorInput input, PositionHolder seekPosition) throws IOException { - Assertions.checkStateNotNull(trackOutput); // Asserts that init has been called. - while (true) { - switch (parserState) { - case STATE_READING_HEADER: - if (parseHeader(input)) { - parserState = STATE_READING_TIMESTAMP_AND_COUNT; - } else { - return RESULT_END_OF_INPUT; - } - break; - case STATE_READING_TIMESTAMP_AND_COUNT: - if (parseTimestampAndSampleCount(input)) { - parserState = STATE_READING_SAMPLES; - } else { - parserState = STATE_READING_HEADER; - return RESULT_END_OF_INPUT; - } - break; - case STATE_READING_SAMPLES: - parseSamples(input); - parserState = STATE_READING_TIMESTAMP_AND_COUNT; - return RESULT_CONTINUE; - default: - throw new IllegalStateException(); - } - } - } - - @Override - public void seek(long position, long timeUs) { - parserState = STATE_READING_HEADER; - } - - @Override - public void release() { - // Do nothing - } - - private boolean parseHeader(ExtractorInput input) throws IOException { - dataScratch.reset(/* limit= */ HEADER_SIZE); - if (input.readFully(dataScratch.getData(), 0, HEADER_SIZE, true)) { - if (dataScratch.readInt() != HEADER_ID) { - throw new IOException("Input not RawCC"); - } - version = dataScratch.readUnsignedByte(); - // no versions use the flag fields yet - return true; - } else { - return false; - } - } - - private boolean parseTimestampAndSampleCount(ExtractorInput input) throws IOException { - if (version == 0) { - dataScratch.reset(/* limit= */ TIMESTAMP_SIZE_V0 + 1); - if (!input.readFully(dataScratch.getData(), 0, TIMESTAMP_SIZE_V0 + 1, true)) { - return false; - } - // version 0 timestamps are 45kHz, so we need to convert them into us - timestampUs = dataScratch.readUnsignedInt() * 1000 / 45; - } else if (version == 1) { - dataScratch.reset(/* limit= */ TIMESTAMP_SIZE_V1 + 1); - if (!input.readFully(dataScratch.getData(), 0, TIMESTAMP_SIZE_V1 + 1, true)) { - return false; - } - timestampUs = dataScratch.readLong(); - } else { - throw ParserException.createForMalformedContainer( - "Unsupported version number: " + version, /* cause= */ null); - } - - remainingSampleCount = dataScratch.readUnsignedByte(); - sampleBytesWritten = 0; - return true; - } - - @RequiresNonNull("trackOutput") - private void parseSamples(ExtractorInput input) throws IOException { - for (; remainingSampleCount > 0; remainingSampleCount--) { - dataScratch.reset(/* limit= */ 3); - input.readFully(dataScratch.getData(), 0, 3); - - trackOutput.sampleData(dataScratch, 3); - sampleBytesWritten += 3; - } - - if (sampleBytesWritten > 0) { - trackOutput.sampleMetadata(timestampUs, C.BUFFER_FLAG_KEY_FRAME, sampleBytesWritten, 0, null); - } - } -} diff --git a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/rawcc/RawCcExtractorTest.java b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/rawcc/RawCcExtractorTest.java deleted file mode 100644 index 3856f2b573..0000000000 --- a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/rawcc/RawCcExtractorTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.android.exoplayer2.extractor.rawcc; - -import com.google.android.exoplayer2.Format; -import com.google.android.exoplayer2.testutil.ExtractorAsserts; -import com.google.android.exoplayer2.util.MimeTypes; -import com.google.common.collect.ImmutableList; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.ParameterizedRobolectricTestRunner; - -/** Tests for {@link RawCcExtractor}. */ -@RunWith(ParameterizedRobolectricTestRunner.class) -public final class RawCcExtractorTest { - - @ParameterizedRobolectricTestRunner.Parameters(name = "{0}") - public static ImmutableList params() { - return ExtractorAsserts.configs(); - } - - @ParameterizedRobolectricTestRunner.Parameter(0) - public ExtractorAsserts.SimulationConfig simulationConfig; - - @Test - public void rawCcSample() throws Exception { - Format format = - new Format.Builder() - .setSampleMimeType(MimeTypes.APPLICATION_CEA608) - .setCodecs("cea608") - .setAccessibilityChannel(1) - .build(); - ExtractorAsserts.assertBehavior( - () -> new RawCcExtractor(format), "media/rawcc/sample.rawcc", simulationConfig); - } -} diff --git a/testdata/src/test/assets/media/mpd/sample_mpd_text b/testdata/src/test/assets/media/mpd/sample_mpd_text index 9af9e24915..adadafaef5 100644 --- a/testdata/src/test/assets/media/mpd/sample_mpd_text +++ b/testdata/src/test/assets/media/mpd/sample_mpd_text @@ -6,13 +6,6 @@ - - - - - https://test.com/0 - -