Remove CEA-6/708 support from DefaultSubtitleParserFactory
`Cea608Parser` and `Cea708Parser` don't currently work correctly on their own without the re-ordering of input buffers implemented in `CeaDecoder`, and it's not clear how we can properly do this re-ordering during extraction. This change ensures that if 'parse subtitles during extraction' is enabled, CEA-6/708 subs will be passed through without transcoding and can then be decoded during rendering by `Cea6/708Decoder`. PiperOrigin-RevId: 595658628
This commit is contained in:
parent
8eda9f2ed2
commit
1cb6865884
@ -20,8 +20,6 @@ import androidx.media3.common.Format;
|
|||||||
import androidx.media3.common.Format.CueReplacementBehavior;
|
import androidx.media3.common.Format.CueReplacementBehavior;
|
||||||
import androidx.media3.common.MimeTypes;
|
import androidx.media3.common.MimeTypes;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import androidx.media3.extractor.text.cea.Cea608Parser;
|
|
||||||
import androidx.media3.extractor.text.cea.Cea708Parser;
|
|
||||||
import androidx.media3.extractor.text.dvb.DvbParser;
|
import androidx.media3.extractor.text.dvb.DvbParser;
|
||||||
import androidx.media3.extractor.text.pgs.PgsParser;
|
import androidx.media3.extractor.text.pgs.PgsParser;
|
||||||
import androidx.media3.extractor.text.ssa.SsaParser;
|
import androidx.media3.extractor.text.ssa.SsaParser;
|
||||||
@ -46,8 +44,6 @@ import java.util.Objects;
|
|||||||
* <li>PGS ({@link PgsParser})
|
* <li>PGS ({@link PgsParser})
|
||||||
* <li>DVB ({@link DvbParser})
|
* <li>DVB ({@link DvbParser})
|
||||||
* <li>TTML ({@link TtmlParser})
|
* <li>TTML ({@link TtmlParser})
|
||||||
* <li>CEA-608 ({@link Cea608Parser})
|
|
||||||
* <li>CEA-708 ({@link Cea708Parser})
|
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
@ -63,10 +59,7 @@ public final class DefaultSubtitleParserFactory implements SubtitleParser.Factor
|
|||||||
|| Objects.equals(mimeType, MimeTypes.APPLICATION_TX3G)
|
|| Objects.equals(mimeType, MimeTypes.APPLICATION_TX3G)
|
||||||
|| Objects.equals(mimeType, MimeTypes.APPLICATION_PGS)
|
|| Objects.equals(mimeType, MimeTypes.APPLICATION_PGS)
|
||||||
|| Objects.equals(mimeType, MimeTypes.APPLICATION_DVBSUBS)
|
|| Objects.equals(mimeType, MimeTypes.APPLICATION_DVBSUBS)
|
||||||
|| Objects.equals(mimeType, MimeTypes.APPLICATION_TTML)
|
|| Objects.equals(mimeType, MimeTypes.APPLICATION_TTML);
|
||||||
|| Objects.equals(mimeType, MimeTypes.APPLICATION_MP4CEA608)
|
|
||||||
|| Objects.equals(mimeType, MimeTypes.APPLICATION_CEA608)
|
|
||||||
|| Objects.equals(mimeType, MimeTypes.APPLICATION_CEA708);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -90,11 +83,6 @@ public final class DefaultSubtitleParserFactory implements SubtitleParser.Factor
|
|||||||
return DvbParser.CUE_REPLACEMENT_BEHAVIOR;
|
return DvbParser.CUE_REPLACEMENT_BEHAVIOR;
|
||||||
case MimeTypes.APPLICATION_TTML:
|
case MimeTypes.APPLICATION_TTML:
|
||||||
return TtmlParser.CUE_REPLACEMENT_BEHAVIOR;
|
return TtmlParser.CUE_REPLACEMENT_BEHAVIOR;
|
||||||
case MimeTypes.APPLICATION_MP4CEA608:
|
|
||||||
case MimeTypes.APPLICATION_CEA608:
|
|
||||||
return Cea608Parser.CUE_REPLACEMENT_BEHAVIOR;
|
|
||||||
case MimeTypes.APPLICATION_CEA708:
|
|
||||||
return Cea708Parser.CUE_REPLACEMENT_BEHAVIOR;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -123,17 +111,6 @@ public final class DefaultSubtitleParserFactory implements SubtitleParser.Factor
|
|||||||
return new DvbParser(format.initializationData);
|
return new DvbParser(format.initializationData);
|
||||||
case MimeTypes.APPLICATION_TTML:
|
case MimeTypes.APPLICATION_TTML:
|
||||||
return new TtmlParser();
|
return new TtmlParser();
|
||||||
case MimeTypes.APPLICATION_MP4CEA608:
|
|
||||||
case MimeTypes.APPLICATION_CEA608:
|
|
||||||
// Deliberately pass a timeout longer than Cea608Parser.MIN_DATA_CHANNEL_TIMEOUT_MS
|
|
||||||
// because Cea608Parser erases 'stuck' cues starting from their start time, rather than
|
|
||||||
// the last piece of CEA data received.
|
|
||||||
return new Cea608Parser(
|
|
||||||
mimeType,
|
|
||||||
format.accessibilityChannel,
|
|
||||||
/* validDataChannelTimeoutMs= */ 2 * Cea608Parser.MIN_DATA_CHANNEL_TIMEOUT_MS);
|
|
||||||
case MimeTypes.APPLICATION_CEA708:
|
|
||||||
return new Cea708Parser(format.accessibilityChannel, format.initializationData);
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,9 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/** A {@link SubtitleParser} for CEA-608 (also known as "line 21 captions" and "EIA-608"). */
|
/** A {@link SubtitleParser} for CEA-608 (also known as "line 21 captions" and "EIA-608"). */
|
||||||
|
// TODO: b/317488646 - Either re-combine this with Cea608Decoder (if we decide that decoding this
|
||||||
|
// format must happen during rendering), or re-add it to DefaultSubtitleParserFactory (if we're
|
||||||
|
// able to solve the re-ordering issue during extraction).
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
public final class Cea608Parser implements SubtitleParser {
|
public final class Cea608Parser implements SubtitleParser {
|
||||||
|
|
||||||
|
@ -48,6 +48,9 @@ import java.util.List;
|
|||||||
import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||||
|
|
||||||
/** A {@link SubtitleParser} for CEA-708 (also known as "EIA-708"). */
|
/** A {@link SubtitleParser} for CEA-708 (also known as "EIA-708"). */
|
||||||
|
// TODO: b/317488646 - Either re-combine this with Cea708Decoder (if we decide that decoding this
|
||||||
|
// format must happen during rendering), or re-add it to DefaultSubtitleParserFactory (if we're
|
||||||
|
// able to solve the re-ordering issue during extraction).
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
public final class Cea708Parser implements SubtitleParser {
|
public final class Cea708Parser implements SubtitleParser {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user