Commit d9a8622b by ibaker Committed by Ian Baker

Eagerly set the format in PassthroughSectionPayloadReader.init

This reverts https://github.com/google/ExoPlayer/commit/94315ab757505f98d0b907fa2f7d2c516356ecae

This fixes issue:#7177

PiperOrigin-RevId: 305674114
parent e250900a
...@@ -36,7 +36,7 @@ public final class PassthroughSectionPayloadReader implements SectionPayloadRead ...@@ -36,7 +36,7 @@ public final class PassthroughSectionPayloadReader implements SectionPayloadRead
private final String mimeType; private final String mimeType;
private @MonotonicNonNull TimestampAdjuster timestampAdjuster; private @MonotonicNonNull TimestampAdjuster timestampAdjuster;
private @MonotonicNonNull TrackOutput output; private @MonotonicNonNull TrackOutput output;
private boolean formatDeclared; private boolean formatOutputWithTimestampAdjustment;
/** /**
* Create a new PassthroughSectionPayloadReader. * Create a new PassthroughSectionPayloadReader.
...@@ -55,12 +55,15 @@ public final class PassthroughSectionPayloadReader implements SectionPayloadRead ...@@ -55,12 +55,15 @@ public final class PassthroughSectionPayloadReader implements SectionPayloadRead
this.timestampAdjuster = timestampAdjuster; this.timestampAdjuster = timestampAdjuster;
idGenerator.generateNewId(); idGenerator.generateNewId();
output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_METADATA); output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_METADATA);
// Eagerly output an incomplete format (missing timestamp offset) to ensure source preparation
// is not blocked waiting for potentially sparse metadata.
output.format(new Format.Builder().setSampleMimeType(mimeType).build());
} }
@Override @Override
public void consume(ParsableByteArray sectionData) { public void consume(ParsableByteArray sectionData) {
assertInitialized(); assertInitialized();
if (!formatDeclared) { if (!formatOutputWithTimestampAdjustment) {
if (timestampAdjuster.getTimestampOffsetUs() == C.TIME_UNSET) { if (timestampAdjuster.getTimestampOffsetUs() == C.TIME_UNSET) {
// There is not enough information to initialize the timestamp adjuster. // There is not enough information to initialize the timestamp adjuster.
return; return;
...@@ -70,7 +73,7 @@ public final class PassthroughSectionPayloadReader implements SectionPayloadRead ...@@ -70,7 +73,7 @@ public final class PassthroughSectionPayloadReader implements SectionPayloadRead
.setSampleMimeType(mimeType) .setSampleMimeType(mimeType)
.setSubsampleOffsetUs(timestampAdjuster.getTimestampOffsetUs()) .setSubsampleOffsetUs(timestampAdjuster.getTimestampOffsetUs())
.build()); .build());
formatDeclared = true; formatOutputWithTimestampAdjustment = true;
} }
int sampleSize = sectionData.bytesLeft(); int sampleSize = sectionData.bytesLeft();
output.sampleData(sectionData, sampleSize); output.sampleData(sectionData, sampleSize);
......
...@@ -36,6 +36,7 @@ import com.google.android.exoplayer2.testutil.FakeTrackOutput; ...@@ -36,6 +36,7 @@ import com.google.android.exoplayer2.testutil.FakeTrackOutput;
import com.google.android.exoplayer2.testutil.TestUtil; import com.google.android.exoplayer2.testutil.TestUtil;
import com.google.android.exoplayer2.util.ParsableByteArray; import com.google.android.exoplayer2.util.ParsableByteArray;
import com.google.android.exoplayer2.util.TimestampAdjuster; import com.google.android.exoplayer2.util.TimestampAdjuster;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -54,11 +55,17 @@ public final class TsExtractorTest { ...@@ -54,11 +55,17 @@ public final class TsExtractorTest {
} }
@Test @Test
@Ignore
// TODO(internal: b/153539929) Re-enable when ExtractorAsserts is less strict around repeated
// formats and seeking.
public void sampleWithScte35() throws Exception { public void sampleWithScte35() throws Exception {
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_scte35.ts"); ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_scte35.ts");
} }
@Test @Test
@Ignore
// TODO(internal: b/153539929) Re-enable when ExtractorAsserts is less strict around repeated
// formats and seeking.
public void sampleWithAit() throws Exception { public void sampleWithAit() throws Exception {
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_ait.ts"); ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_ait.ts");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment