Skip to content

Commit

Permalink
Fix naming to reflect that CEA-708 is supported too
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 312131816
  • Loading branch information
ojw28 committed May 18, 2020
1 parent be09840 commit 0de9c00
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public final class CeaUtil {
private static final int PROVIDER_CODE_DIRECTV = 0x2F;

/**
* Consumes the unescaped content of an SEI NAL unit, writing the content of any CEA-608 messages
* as samples to all of the provided outputs.
* Consumes the unescaped content of an SEI NAL unit, writing the content of any CEA-608/708
* messages as samples to all of the provided outputs.
*
* @param presentationTimeUs The presentation time in microseconds for any samples.
* @param seiBuffer The unescaped SEI NAL unit data, excluding the NAL unit start code and type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public class FragmentedMp4Extractor implements Extractor {
// Extractor output.
private @MonotonicNonNull ExtractorOutput extractorOutput;
private TrackOutput[] emsgTrackOutputs;
private TrackOutput[] cea608TrackOutputs;
private TrackOutput[] ceaTrackOutputs;

// Whether extractorOutput.seekMap has been called.
private boolean haveOutputSeekMap;
Expand Down Expand Up @@ -576,12 +576,12 @@ private void maybeInitExtraTracks() {
eventMessageTrackOutput.format(EMSG_FORMAT);
}
}
if (cea608TrackOutputs == null) {
cea608TrackOutputs = new TrackOutput[closedCaptionFormats.size()];
for (int i = 0; i < cea608TrackOutputs.length; i++) {
if (ceaTrackOutputs == null) {
ceaTrackOutputs = new TrackOutput[closedCaptionFormats.size()];
for (int i = 0; i < ceaTrackOutputs.length; i++) {
TrackOutput output = extractorOutput.track(trackBundles.size() + 1 + i, C.TRACK_TYPE_TEXT);
output.format(closedCaptionFormats.get(i));
cea608TrackOutputs[i] = output;
ceaTrackOutputs[i] = output;
}
}
}
Expand Down Expand Up @@ -1328,8 +1328,9 @@ private boolean readSample(ExtractorInput input) throws IOException {
output.sampleData(nalStartCode, 4);
// Write the NAL unit type byte.
output.sampleData(nalPrefix, 1);
processSeiNalUnitPayload = cea608TrackOutputs.length > 0
&& NalUnitUtil.isNalUnitSei(track.format.sampleMimeType, nalPrefixData[4]);
processSeiNalUnitPayload =
ceaTrackOutputs.length > 0
&& NalUnitUtil.isNalUnitSei(track.format.sampleMimeType, nalPrefixData[4]);
sampleBytesWritten += 5;
sampleSize += nalUnitLengthFieldLengthDiff;
} else {
Expand All @@ -1345,7 +1346,7 @@ private boolean readSample(ExtractorInput input) throws IOException {
// If the format is H.265/HEVC the NAL unit header has two bytes so skip one more byte.
nalBuffer.setPosition(MimeTypes.VIDEO_H265.equals(track.format.sampleMimeType) ? 1 : 0);
nalBuffer.setLimit(unescapedLength);
CeaUtil.consume(sampleTimeUs, nalBuffer, cea608TrackOutputs);
CeaUtil.consume(sampleTimeUs, nalBuffer, ceaTrackOutputs);
} else {
// Write the payload of the NAL unit.
writtenBytes = output.sampleData(input, sampleCurrentNalBytesRemaining, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.google.android.exoplayer2.util.ParsableByteArray;
import java.util.List;

/** Consumes SEI buffers, outputting contained CEA-608 messages to a {@link TrackOutput}. */
/** Consumes SEI buffers, outputting contained CEA-608/708 messages to a {@link TrackOutput}. */
public final class SeiReader {

private final List<Format> closedCaptionFormats;
Expand Down

0 comments on commit 0de9c00

Please sign in to comment.