@Override public SubtitleDecoder createDecoder(Format format) { switch (format.sampleMimeType) { case MimeTypes.TEXT_VTT: return new WebvttDecoder(); case MimeTypes.APPLICATION_MP4VTT: return new Mp4WebvttDecoder(); case MimeTypes.APPLICATION_TTML: return new TtmlDecoder(); case MimeTypes.APPLICATION_SUBRIP: return new SubripDecoder(); case MimeTypes.APPLICATION_TX3G: return new Tx3gDecoder(format.initializationData); case MimeTypes.APPLICATION_CEA608: case MimeTypes.APPLICATION_MP4CEA608: return new Cea608Decoder(format.sampleMimeType, format.accessibilityChannel); case MimeTypes.APPLICATION_CEA708: return new Cea708Decoder(format.accessibilityChannel); case MimeTypes.APPLICATION_DVBSUBS: return new DvbDecoder(format.initializationData); default: throw new IllegalArgumentException("Attempted to create decoder for unsupported format"); } }
@Override public SubtitleDecoder createDecoder(Format format) { switch (format.sampleMimeType) { case MimeTypes.TEXT_VTT: return new WebvttDecoder(); case MimeTypes.TEXT_SSA: return new SsaDecoder(format.initializationData); case MimeTypes.APPLICATION_MP4VTT: return new Mp4WebvttDecoder(); case MimeTypes.APPLICATION_TTML: return new TtmlDecoder(); case MimeTypes.APPLICATION_SUBRIP: return new SubripDecoder(); case MimeTypes.APPLICATION_TX3G: return new Tx3gDecoder(format.initializationData); case MimeTypes.APPLICATION_CEA608: case MimeTypes.APPLICATION_MP4CEA608: return new Cea608Decoder(format.sampleMimeType, format.accessibilityChannel); case MimeTypes.APPLICATION_CEA708: return new Cea708Decoder(format.accessibilityChannel); case MimeTypes.APPLICATION_DVBSUBS: return new DvbDecoder(format.initializationData); default: throw new IllegalArgumentException("Attempted to create decoder for unsupported format"); } }
public void consume(long pesTimeUs, ParsableByteArray seiBuffer) { int b; while (seiBuffer.bytesLeft() > 1 /* last byte will be rbsp_trailing_bits */) { // Parse payload type. int payloadType = 0; do { b = seiBuffer.readUnsignedByte(); payloadType += b; } while (b == 0xFF); // Parse payload size. int payloadSize = 0; do { b = seiBuffer.readUnsignedByte(); payloadSize += b; } while (b == 0xFF); // Process the payload. if (Cea608Decoder.isSeiMessageCea608(payloadType, payloadSize, seiBuffer)) { // Ignore country_code (1) + provider_code (2) + user_identifier (4) // + user_data_type_code (1). seiBuffer.skipBytes(8); // Ignore first three bits: reserved (1) + process_cc_data_flag (1) + zero_bit (1). int ccCount = seiBuffer.readUnsignedByte() & 0x1F; seiBuffer.skipBytes(1); int sampleBytes = 0; for (int i = 0; i < ccCount; i++) { int ccValidityAndType = seiBuffer.peekUnsignedByte() & 0x07; // Check that validity == 1 and type == 0 (i.e. NTSC_CC_FIELD_1). if (ccValidityAndType != 0x04) { seiBuffer.skipBytes(3); } else { sampleBytes += 3; output.sampleData(seiBuffer, 3); } } output.sampleMetadata(pesTimeUs, C.BUFFER_FLAG_KEY_FRAME, sampleBytes, 0, null); // Ignore trailing information in SEI, if any. seiBuffer.skipBytes(payloadSize - (10 + ccCount * 3)); } else { seiBuffer.skipBytes(payloadSize); } } }